Skip to content

Commit

Permalink
Auto merge of rust-lang#72716 - Dylan-DPC:rollup-wdj97ab, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 12 pull requests

Successful merges:

 - rust-lang#72239 (Implement PartialOrd and Ord for SocketAddr*)
 - rust-lang#72466 (Stabilize str_strip feature)
 - rust-lang#72605 (Add working example for E0617 explanation)
 - rust-lang#72636 (Cleanup `Resolver::<clone|into>_outputs` methods)
 - rust-lang#72645 (Add myself to .mailmap)
 - rust-lang#72667 (expand unaligned_references test)
 - rust-lang#72670 (Fix incorrect comment in generator test)
 - rust-lang#72674 (Clippy should always build)
 - rust-lang#72682 (Add test for rust-lang#66930)
 - rust-lang#72695 (update data layout for illumos x86)
 - rust-lang#72697 (Remove rustc-ux-guidelines)
 - rust-lang#72702 (rustc_lint: Remove `unused_crate_dependencies` from the `unused` group)

Failed merges:

r? @ghost
  • Loading branch information
bors committed May 29, 2020
2 parents 4512721 + 049b6dd commit 255c033
Show file tree
Hide file tree
Showing 25 changed files with 248 additions and 225 deletions.
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ David Manescu <david.manescu@gmail.com> <dman2626@uni.sydney.edu.au>
David Ross <daboross@daboross.net>
Derek Chiang <derekchiang93@gmail.com> Derek Chiang (Enchi Jiang) <derekchiang93@gmail.com>
Diggory Hardy <diggory.hardy@gmail.com> Diggory Hardy <github@dhardy.name>
Donough Liu <ldm2993593805@163.com> <donoughliu@gmail.com>
Donough Liu <ldm2993593805@163.com> DingMing Liu <liudingming@bupt.edu.cn>
Dustin Bensing <dustin.bensing@googlemail.com>
Dylan Braithwaite <dylanbraithwaite1@gmail.com> <mail@dylanb.me>
Dzmitry Malyshau <kvarkus@gmail.com>
Expand Down
60 changes: 26 additions & 34 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,45 +516,37 @@ impl Step for Clippy {
let host = self.host;
let compiler = builder.compiler(stage, host);

let clippy = builder.ensure(tool::Clippy {
let clippy = builder
.ensure(tool::Clippy { compiler, target: self.host, extra_features: Vec::new() })
.expect("in-tree tool");
let mut cargo = tool::prepare_tool_cargo(
builder,
compiler,
target: self.host,
extra_features: Vec::new(),
});
if let Some(clippy) = clippy {
let mut cargo = tool::prepare_tool_cargo(
builder,
compiler,
Mode::ToolRustc,
host,
"test",
"src/tools/clippy",
SourceType::InTree,
&[],
);
Mode::ToolRustc,
host,
"test",
"src/tools/clippy",
SourceType::InTree,
&[],
);

// clippy tests need to know about the stage sysroot
cargo.env("SYSROOT", builder.sysroot(compiler));
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
let target_libs = builder
.stage_out(compiler, Mode::ToolRustc)
.join(&self.host)
.join(builder.cargo_dir());
cargo.env("HOST_LIBS", host_libs);
cargo.env("TARGET_LIBS", target_libs);
// clippy tests need to find the driver
cargo.env("CLIPPY_DRIVER_PATH", clippy);
// clippy tests need to know about the stage sysroot
cargo.env("SYSROOT", builder.sysroot(compiler));
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
let target_libs =
builder.stage_out(compiler, Mode::ToolRustc).join(&self.host).join(builder.cargo_dir());
cargo.env("HOST_LIBS", host_libs);
cargo.env("TARGET_LIBS", target_libs);
// clippy tests need to find the driver
cargo.env("CLIPPY_DRIVER_PATH", clippy);

cargo.arg("--").args(builder.config.cmd.test_args());
cargo.arg("--").args(builder.config.cmd.test_args());

builder.add_rustc_lib_path(compiler, &mut cargo);
builder.add_rustc_lib_path(compiler, &mut cargo);

try_run(builder, &mut cargo.into());
} else {
eprintln!("failed to test clippy: could not build");
}
try_run(builder, &mut cargo.into());
}
}

Expand Down
90 changes: 0 additions & 90 deletions src/doc/rustc-ux-guidelines.md

This file was deleted.

7 changes: 2 additions & 5 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4052,15 +4052,13 @@ impl str {
/// # Examples
///
/// ```
/// #![feature(str_strip)]
///
/// assert_eq!("foo:bar".strip_prefix("foo:"), Some("bar"));
/// assert_eq!("foo:bar".strip_prefix("bar"), None);
/// assert_eq!("foofoo".strip_prefix("foo"), Some("foo"));
/// ```
#[must_use = "this returns the remaining substring as a new slice, \
without modifying the original"]
#[unstable(feature = "str_strip", reason = "newly added", issue = "67302")]
#[stable(feature = "str_strip", since = "1.45.0")]
pub fn strip_prefix<'a, P: Pattern<'a>>(&'a self, prefix: P) -> Option<&'a str> {
prefix.strip_prefix_of(self)
}
Expand All @@ -4082,14 +4080,13 @@ impl str {
/// # Examples
///
/// ```
/// #![feature(str_strip)]
/// assert_eq!("bar:foo".strip_suffix(":foo"), Some("bar"));
/// assert_eq!("bar:foo".strip_suffix("bar"), None);
/// assert_eq!("foofoo".strip_suffix("foo"), Some("foo"));
/// ```
#[must_use = "this returns the remaining substring as a new slice, \
without modifying the original"]
#[unstable(feature = "str_strip", reason = "newly added", issue = "67302")]
#[stable(feature = "str_strip", since = "1.45.0")]
pub fn strip_suffix<'a, P>(&'a self, suffix: P) -> Option<&'a str>
where
P: Pattern<'a>,
Expand Down
11 changes: 11 additions & 0 deletions src/librustc_error_codes/error_codes/E0617.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,14 @@ Certain Rust types must be cast before passing them to a variadic function,
because of arcane ABI rules dictated by the C standard. To fix the error,
cast the value to the type specified by the error message (which you may need
to import from `std::os::raw`).

In this case, `c_double` has the same size as `f64` so we can use it directly:

```no_run
# extern {
# fn printf(c: *const i8, ...);
# }
unsafe {
printf(::std::ptr::null(), 0f64); // ok!
}
```
5 changes: 0 additions & 5 deletions src/librustc_hir/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub use rustc_ast::ast::{CaptureBy, Movability, Mutability};
use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_ast::node_id::NodeMap;
use rustc_ast::util::parser::ExprPrecedence;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
use rustc_macros::HashStable_Generic;
use rustc_span::source_map::{SourceMap, Spanned};
Expand Down Expand Up @@ -2664,10 +2663,6 @@ impl<ID> TraitCandidate<ID> {
// Trait method resolution
pub type TraitMap<ID = HirId> = NodeMap<Vec<TraitCandidate<ID>>>;

// Map from the NodeId of a glob import to a list of items which are actually
// imported.
pub type GlobMap = NodeMap<FxHashSet<Symbol>>;

#[derive(Copy, Clone, Debug, HashStable_Generic)]
pub enum Node<'hir> {
Param(&'hir Param<'hir>),
Expand Down
1 change: 0 additions & 1 deletion src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
UNUSED_ALLOCATION,
UNUSED_DOC_COMMENTS,
UNUSED_EXTERN_CRATES,
UNUSED_CRATE_DEPENDENCIES,
UNUSED_FEATURES,
UNUSED_LABELS,
UNUSED_PARENS,
Expand Down
6 changes: 0 additions & 6 deletions src/librustc_middle/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ impl<'hir> Map<'hir> {
})
}

// FIXME(eddyb) this function can and should return `LocalDefId`.
#[inline]
pub fn local_def_id(&self, hir_id: HirId) -> LocalDefId {
self.opt_local_def_id(hir_id).unwrap_or_else(|| {
Expand All @@ -192,11 +191,6 @@ impl<'hir> Map<'hir> {
self.tcx.definitions.opt_local_def_id(node)
}

#[inline]
pub fn as_local_node_id(&self, def_id: DefId) -> Option<NodeId> {
self.tcx.definitions.as_local_node_id(def_id)
}

#[inline]
pub fn as_local_hir_id(&self, def_id: LocalDefId) -> HirId {
self.tcx.definitions.as_local_hir_id(def_id)
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_middle/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,9 @@ rustc_queries! {
desc { "fetching what a crate is named" }
}
query item_children(_: DefId) -> &'tcx [Export<hir::HirId>] {}
query extern_mod_stmt_cnum(_: DefId) -> Option<CrateNum> {}
query extern_mod_stmt_cnum(_: LocalDefId) -> Option<CrateNum> {
desc { "fetching extern module statement" }
}

query get_lib_features(_: CrateNum) -> LibFeatures {
storage(ArenaCacheSelector<'tcx>)
Expand Down Expand Up @@ -1040,7 +1042,7 @@ rustc_queries! {
desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) }
}
query maybe_unused_extern_crates(_: CrateNum)
-> &'tcx [(DefId, Span)] {
-> &'tcx [(LocalDefId, Span)] {
eval_always
desc { "looking up all possibly unused extern crates" }
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_middle/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ pub struct GlobalCtxt<'tcx> {
pub consts: CommonConsts<'tcx>,

/// Resolutions of `extern crate` items produced by resolver.
extern_crate_map: FxHashMap<DefId, CrateNum>,
extern_crate_map: FxHashMap<LocalDefId, CrateNum>,

/// Map indicating what traits are in scope for places where this
/// is relevant; generated by resolve.
Expand All @@ -944,7 +944,7 @@ pub struct GlobalCtxt<'tcx> {
pub queries: query::Queries<'tcx>,

maybe_unused_trait_imports: FxHashSet<LocalDefId>,
maybe_unused_extern_crates: Vec<(DefId, Span)>,
maybe_unused_extern_crates: Vec<(LocalDefId, Span)>,
/// A map of glob use to a set of names it actually imports. Currently only
/// used in save-analysis.
glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_middle/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ mod sty;
pub struct ResolverOutputs {
pub definitions: rustc_hir::definitions::Definitions,
pub cstore: Box<CrateStoreDyn>,
pub extern_crate_map: FxHashMap<DefId, CrateNum>,
pub extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
pub trait_map: FxHashMap<hir::HirId, Vec<hir::TraitCandidate<hir::HirId>>>,
pub maybe_unused_trait_imports: FxHashSet<LocalDefId>,
pub maybe_unused_extern_crates: Vec<(DefId, Span)>,
pub maybe_unused_extern_crates: Vec<(LocalDefId, Span)>,
pub export_map: ExportMap<hir::HirId>,
pub glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>,
/// Extern prelude entries. The value is `true` if the entry was introduced
Expand Down
13 changes: 7 additions & 6 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<'a> Resolver<'a> {
Some(def_id) => def_id,
None => return self.ast_transform_scopes.get(&expn_id).unwrap_or(&self.graph_root),
};
if let Some(id) = self.definitions.as_local_node_id(def_id) {
if let Some(id) = def_id.as_local() {
self.local_macro_def_scopes[&id]
} else {
let module_def_id = ty::DefIdTree::parent(&*self, def_id).unwrap();
Expand Down Expand Up @@ -640,9 +640,10 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
} else if orig_name == Some(kw::SelfLower) {
self.r.graph_root
} else {
let def_id = self.r.definitions.local_def_id(item.id);
let crate_id =
self.r.crate_loader.process_extern_crate(item, &self.r.definitions);
self.r.extern_crate_map.insert(item.id, crate_id);
self.r.extern_crate_map.insert(def_id, crate_id);
self.r.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX })
};

Expand Down Expand Up @@ -1173,10 +1174,10 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
_ => unreachable!(),
};

let def_id = self.r.definitions.local_def_id(item.id).to_def_id();
let res = Res::Def(DefKind::Macro(ext.macro_kind()), def_id);
self.r.macro_map.insert(def_id, ext);
self.r.local_macro_def_scopes.insert(item.id, parent_scope.module);
let def_id = self.r.definitions.local_def_id(item.id);
let res = Res::Def(DefKind::Macro(ext.macro_kind()), def_id.to_def_id());
self.r.macro_map.insert(def_id.to_def_id(), ext);
self.r.local_macro_def_scopes.insert(def_id, parent_scope.module);

if macro_rules {
let ident = ident.normalize_to_macros_2_0();
Expand Down
8 changes: 5 additions & 3 deletions src/librustc_resolve/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ impl<'a, 'b> UnusedImportCheckVisitor<'a, 'b> {
fn check_import(&mut self, id: ast::NodeId) {
let mut used = false;
self.r.per_ns(|this, ns| used |= this.used_imports.contains(&(id, ns)));
let def_id = self.r.definitions.local_def_id(id);
if !used {
if self.r.maybe_unused_trait_imports.contains(&id) {
if self.r.maybe_unused_trait_imports.contains(&def_id) {
// Check later.
return;
}
self.unused_import(self.base_id).add(id);
} else {
// This trait import is definitely used, in a way other than
// method resolution.
self.r.maybe_unused_trait_imports.remove(&id);
self.r.maybe_unused_trait_imports.remove(&def_id);
if let Some(i) = self.unused_imports.get_mut(&self.base_id) {
i.unused.remove(&id);
}
Expand Down Expand Up @@ -245,7 +246,8 @@ impl Resolver<'_> {
}
}
ImportKind::ExternCrate { .. } => {
self.maybe_unused_extern_crates.push((import.id, import.span));
let def_id = self.definitions.local_def_id(import.id);
self.maybe_unused_extern_crates.push((def_id, import.span));
}
ImportKind::MacroUse => {
let msg = "unused `#[macro_use]` import";
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_resolve/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,8 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
) -> SmallVec<[NodeId; 1]> {
let mut import_ids = smallvec![];
while let NameBindingKind::Import { import, binding, .. } = kind {
self.r.maybe_unused_trait_imports.insert(import.id);
let id = self.r.definitions.local_def_id(import.id);
self.r.maybe_unused_trait_imports.insert(id);
self.r.add_to_glob_map(&import, trait_name);
import_ids.push(import.id);
kind = &binding.kind;
Expand Down
Loading

0 comments on commit 255c033

Please sign in to comment.