Auto merge of #72539 - RalfJung:rollup-8yfidi8, r=RalfJung
Rollup of 5 pull requests Successful merges: - #72402 (Remove all uses of `NodeId` in `ResolverOutputs`) - #72527 (bootstrap: propagate test-args to miri and clippy test suites) - #72530 (Clean up E0602 explanation) - #72532 (Use `dyn` trait syntax in more comments and docs) - #72535 (Use sort_unstable_by in its own docs) Failed merges: r? @ghost
This commit is contained in:
commit
46e85b4328
8 changed files with 130 additions and 67 deletions
|
@ -439,6 +439,8 @@ impl Step for Miri {
|
||||||
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
|
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
|
||||||
cargo.env("MIRI_PATH", miri);
|
cargo.env("MIRI_PATH", miri);
|
||||||
|
|
||||||
|
cargo.arg("--").args(builder.config.cmd.test_args());
|
||||||
|
|
||||||
builder.add_rustc_lib_path(compiler, &mut cargo);
|
builder.add_rustc_lib_path(compiler, &mut cargo);
|
||||||
|
|
||||||
if !try_run(builder, &mut cargo.into()) {
|
if !try_run(builder, &mut cargo.into()) {
|
||||||
|
@ -545,6 +547,8 @@ impl Step for Clippy {
|
||||||
// clippy tests need to find the driver
|
// clippy tests need to find the driver
|
||||||
cargo.env("CLIPPY_DRIVER_PATH", clippy);
|
cargo.env("CLIPPY_DRIVER_PATH", clippy);
|
||||||
|
|
||||||
|
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());
|
try_run(builder, &mut cargo.into());
|
||||||
|
|
|
@ -9,15 +9,15 @@
|
||||||
//! Their definition should always match the ABI defined in
|
//! Their definition should always match the ABI defined in
|
||||||
//! `rustc_middle::ty::layout`.
|
//! `rustc_middle::ty::layout`.
|
||||||
|
|
||||||
/// The representation of a trait object like `&SomeTrait`.
|
/// The representation of a trait object like `&dyn SomeTrait`.
|
||||||
///
|
///
|
||||||
/// This struct has the same layout as types like `&SomeTrait` and
|
/// This struct has the same layout as types like `&dyn SomeTrait` and
|
||||||
/// `Box<dyn AnotherTrait>`.
|
/// `Box<dyn AnotherTrait>`.
|
||||||
///
|
///
|
||||||
/// `TraitObject` is guaranteed to match layouts, but it is not the
|
/// `TraitObject` is guaranteed to match layouts, but it is not the
|
||||||
/// type of trait objects (e.g., the fields are not directly accessible
|
/// type of trait objects (e.g., the fields are not directly accessible
|
||||||
/// on a `&SomeTrait`) nor does it control that layout (changing the
|
/// on a `&dyn SomeTrait`) nor does it control that layout (changing the
|
||||||
/// definition will not change the layout of a `&SomeTrait`). It is
|
/// definition will not change the layout of a `&dyn SomeTrait`). It is
|
||||||
/// only designed to be used by unsafe code that needs to manipulate
|
/// only designed to be used by unsafe code that needs to manipulate
|
||||||
/// the low-level details.
|
/// the low-level details.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1654,7 +1654,7 @@ impl<T> [T] {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// let mut floats = [5f64, 4.0, 1.0, 3.0, 2.0];
|
/// let mut floats = [5f64, 4.0, 1.0, 3.0, 2.0];
|
||||||
/// floats.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
/// floats.sort_unstable_by(|a, b| a.partial_cmp(b).unwrap());
|
||||||
/// assert_eq!(floats, [1.0, 2.0, 3.0, 4.0, 5.0]);
|
/// assert_eq!(floats, [1.0, 2.0, 3.0, 4.0, 5.0]);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
An unknown lint was used on the command line.
|
An unknown lint was used on the command line.
|
||||||
|
|
||||||
Erroneous example:
|
Erroneous code example:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
rustc -D bogus omse_file.rs
|
rustc -D bogus rust_file.rs
|
||||||
```
|
```
|
||||||
|
|
||||||
Maybe you just misspelled the lint name or the lint doesn't exist anymore.
|
Maybe you just misspelled the lint name or the lint doesn't exist anymore.
|
||||||
|
|
|
@ -327,7 +327,9 @@ impl Definitions {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn local_def_id(&self, node: ast::NodeId) -> LocalDefId {
|
pub fn local_def_id(&self, node: ast::NodeId) -> LocalDefId {
|
||||||
self.opt_local_def_id(node).unwrap()
|
self.opt_local_def_id(node).unwrap_or_else(|| {
|
||||||
|
panic!("no entry for node id: `{:?}` / `{:?}`", node, self.opt_node_id_to_hir_id(node))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -35,7 +35,6 @@ use crate::ty::{InferTy, ParamTy, PolyFnSig, ProjectionTy};
|
||||||
use crate::ty::{List, TyKind, TyS};
|
use crate::ty::{List, TyKind, TyS};
|
||||||
use rustc_ast::ast;
|
use rustc_ast::ast;
|
||||||
use rustc_ast::expand::allocator::AllocatorKind;
|
use rustc_ast::expand::allocator::AllocatorKind;
|
||||||
use rustc_ast::node_id::NodeMap;
|
|
||||||
use rustc_attr as attr;
|
use rustc_attr as attr;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_data_structures::profiling::SelfProfilerRef;
|
use rustc_data_structures::profiling::SelfProfilerRef;
|
||||||
|
@ -926,7 +925,7 @@ pub struct GlobalCtxt<'tcx> {
|
||||||
pub consts: CommonConsts<'tcx>,
|
pub consts: CommonConsts<'tcx>,
|
||||||
|
|
||||||
/// Resolutions of `extern crate` items produced by resolver.
|
/// Resolutions of `extern crate` items produced by resolver.
|
||||||
extern_crate_map: NodeMap<CrateNum>,
|
extern_crate_map: FxHashMap<DefId, CrateNum>,
|
||||||
|
|
||||||
/// Map indicating what traits are in scope for places where this
|
/// Map indicating what traits are in scope for places where this
|
||||||
/// is relevant; generated by resolve.
|
/// is relevant; generated by resolve.
|
||||||
|
@ -1116,13 +1115,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default();
|
let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default();
|
||||||
for (k, v) in resolutions.trait_map {
|
for (hir_id, v) in resolutions.trait_map.into_iter() {
|
||||||
let hir_id = definitions.node_id_to_hir_id(k);
|
|
||||||
let map = trait_map.entry(hir_id.owner).or_default();
|
let map = trait_map.entry(hir_id.owner).or_default();
|
||||||
let v = v
|
|
||||||
.into_iter()
|
|
||||||
.map(|tc| tc.map_import_ids(|id| definitions.node_id_to_hir_id(id)))
|
|
||||||
.collect();
|
|
||||||
map.insert(hir_id.local_id, StableVec::new(v));
|
map.insert(hir_id.local_id, StableVec::new(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1139,32 +1133,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
consts: common_consts,
|
consts: common_consts,
|
||||||
extern_crate_map: resolutions.extern_crate_map,
|
extern_crate_map: resolutions.extern_crate_map,
|
||||||
trait_map,
|
trait_map,
|
||||||
export_map: resolutions
|
export_map: resolutions.export_map,
|
||||||
.export_map
|
maybe_unused_trait_imports: resolutions.maybe_unused_trait_imports,
|
||||||
.into_iter()
|
maybe_unused_extern_crates: resolutions.maybe_unused_extern_crates,
|
||||||
.map(|(k, v)| {
|
glob_map: resolutions.glob_map,
|
||||||
let exports: Vec<_> = v
|
|
||||||
.into_iter()
|
|
||||||
.map(|e| e.map_id(|id| definitions.node_id_to_hir_id(id)))
|
|
||||||
.collect();
|
|
||||||
(k, exports)
|
|
||||||
})
|
|
||||||
.collect(),
|
|
||||||
maybe_unused_trait_imports: resolutions
|
|
||||||
.maybe_unused_trait_imports
|
|
||||||
.into_iter()
|
|
||||||
.map(|id| definitions.local_def_id(id))
|
|
||||||
.collect(),
|
|
||||||
maybe_unused_extern_crates: resolutions
|
|
||||||
.maybe_unused_extern_crates
|
|
||||||
.into_iter()
|
|
||||||
.map(|(id, sp)| (definitions.local_def_id(id).to_def_id(), sp))
|
|
||||||
.collect(),
|
|
||||||
glob_map: resolutions
|
|
||||||
.glob_map
|
|
||||||
.into_iter()
|
|
||||||
.map(|(id, names)| (definitions.local_def_id(id), names))
|
|
||||||
.collect(),
|
|
||||||
extern_prelude: resolutions.extern_prelude,
|
extern_prelude: resolutions.extern_prelude,
|
||||||
untracked_crate: krate,
|
untracked_crate: krate,
|
||||||
definitions,
|
definitions,
|
||||||
|
@ -2729,10 +2701,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
|
||||||
let id = tcx.hir().local_def_id_to_hir_id(id.expect_local());
|
let id = tcx.hir().local_def_id_to_hir_id(id.expect_local());
|
||||||
tcx.stability().local_deprecation_entry(id)
|
tcx.stability().local_deprecation_entry(id)
|
||||||
};
|
};
|
||||||
providers.extern_mod_stmt_cnum = |tcx, id| {
|
providers.extern_mod_stmt_cnum = |tcx, id| tcx.extern_crate_map.get(&id).cloned();
|
||||||
let id = tcx.hir().as_local_node_id(id).unwrap();
|
|
||||||
tcx.extern_crate_map.get(&id).cloned()
|
|
||||||
};
|
|
||||||
providers.all_crate_nums = |tcx, cnum| {
|
providers.all_crate_nums = |tcx, cnum| {
|
||||||
assert_eq!(cnum, LOCAL_CRATE);
|
assert_eq!(cnum, LOCAL_CRATE);
|
||||||
tcx.arena.alloc_slice(&tcx.cstore.crates_untracked())
|
tcx.arena.alloc_slice(&tcx.cstore.crates_untracked())
|
||||||
|
|
|
@ -17,11 +17,11 @@ use crate::ty;
|
||||||
use crate::ty::subst::{InternalSubsts, Subst, SubstsRef};
|
use crate::ty::subst::{InternalSubsts, Subst, SubstsRef};
|
||||||
use crate::ty::util::{Discr, IntTypeExt};
|
use crate::ty::util::{Discr, IntTypeExt};
|
||||||
use rustc_ast::ast;
|
use rustc_ast::ast;
|
||||||
use rustc_ast::node_id::{NodeId, NodeMap, NodeSet};
|
|
||||||
use rustc_attr as attr;
|
use rustc_attr as attr;
|
||||||
use rustc_data_structures::captures::Captures;
|
use rustc_data_structures::captures::Captures;
|
||||||
use rustc_data_structures::fingerprint::Fingerprint;
|
use rustc_data_structures::fingerprint::Fingerprint;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_data_structures::sorted_map::SortedIndexMultiMap;
|
use rustc_data_structures::sorted_map::SortedIndexMultiMap;
|
||||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||||
|
@ -31,7 +31,7 @@ use rustc_hir as hir;
|
||||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Namespace, Res};
|
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Namespace, Res};
|
||||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX};
|
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX};
|
||||||
use rustc_hir::lang_items::{FnMutTraitLangItem, FnOnceTraitLangItem, FnTraitLangItem};
|
use rustc_hir::lang_items::{FnMutTraitLangItem, FnOnceTraitLangItem, FnTraitLangItem};
|
||||||
use rustc_hir::{Constness, GlobMap, Node, TraitMap};
|
use rustc_hir::{Constness, Node};
|
||||||
use rustc_index::vec::{Idx, IndexVec};
|
use rustc_index::vec::{Idx, IndexVec};
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use rustc_serialize::{self, Encodable, Encoder};
|
use rustc_serialize::{self, Encodable, Encoder};
|
||||||
|
@ -120,12 +120,12 @@ mod sty;
|
||||||
pub struct ResolverOutputs {
|
pub struct ResolverOutputs {
|
||||||
pub definitions: rustc_hir::definitions::Definitions,
|
pub definitions: rustc_hir::definitions::Definitions,
|
||||||
pub cstore: Box<CrateStoreDyn>,
|
pub cstore: Box<CrateStoreDyn>,
|
||||||
pub extern_crate_map: NodeMap<CrateNum>,
|
pub extern_crate_map: FxHashMap<DefId, CrateNum>,
|
||||||
pub trait_map: TraitMap<NodeId>,
|
pub trait_map: FxHashMap<hir::HirId, Vec<hir::TraitCandidate<hir::HirId>>>,
|
||||||
pub maybe_unused_trait_imports: NodeSet,
|
pub maybe_unused_trait_imports: FxHashSet<LocalDefId>,
|
||||||
pub maybe_unused_extern_crates: Vec<(NodeId, Span)>,
|
pub maybe_unused_extern_crates: Vec<(DefId, Span)>,
|
||||||
pub export_map: ExportMap<NodeId>,
|
pub export_map: ExportMap<hir::HirId>,
|
||||||
pub glob_map: GlobMap,
|
pub glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>,
|
||||||
/// Extern prelude entries. The value is `true` if the entry was introduced
|
/// Extern prelude entries. The value is `true` if the entry was introduced
|
||||||
/// via `extern crate` item and not `--extern` option or compiler built-in.
|
/// via `extern crate` item and not `--extern` option or compiler built-in.
|
||||||
pub extern_prelude: FxHashMap<Symbol, bool>,
|
pub extern_prelude: FxHashMap<Symbol, bool>,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// ignore-tidy-filelength
|
||||||
|
|
||||||
//! This crate is responsible for the part of name resolution that doesn't require type checker.
|
//! This crate is responsible for the part of name resolution that doesn't require type checker.
|
||||||
//!
|
//!
|
||||||
//! Module structure of the crate is built here.
|
//! Module structure of the crate is built here.
|
||||||
|
@ -1266,15 +1268,60 @@ impl<'a> Resolver<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_outputs(self) -> ResolverOutputs {
|
pub fn into_outputs(self) -> ResolverOutputs {
|
||||||
|
let definitions = self.definitions;
|
||||||
|
let extern_crate_map = self
|
||||||
|
.extern_crate_map
|
||||||
|
.into_iter()
|
||||||
|
.map(|(k, v)| (definitions.local_def_id(k).to_def_id(), v))
|
||||||
|
.collect();
|
||||||
|
let export_map = self
|
||||||
|
.export_map
|
||||||
|
.into_iter()
|
||||||
|
.map(|(k, v)| {
|
||||||
|
(
|
||||||
|
k,
|
||||||
|
v.into_iter()
|
||||||
|
.map(|e| e.map_id(|id| definitions.node_id_to_hir_id(id)))
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
let trait_map = self
|
||||||
|
.trait_map
|
||||||
|
.into_iter()
|
||||||
|
.map(|(k, v)| {
|
||||||
|
(
|
||||||
|
definitions.node_id_to_hir_id(k),
|
||||||
|
v.into_iter()
|
||||||
|
.map(|tc| tc.map_import_ids(|id| definitions.node_id_to_hir_id(id)))
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
let maybe_unused_trait_imports = self
|
||||||
|
.maybe_unused_trait_imports
|
||||||
|
.into_iter()
|
||||||
|
.map(|id| definitions.local_def_id(id))
|
||||||
|
.collect();
|
||||||
|
let maybe_unused_extern_crates = self
|
||||||
|
.maybe_unused_extern_crates
|
||||||
|
.into_iter()
|
||||||
|
.map(|(id, sp)| (definitions.local_def_id(id).to_def_id(), sp))
|
||||||
|
.collect();
|
||||||
|
let glob_map = self
|
||||||
|
.glob_map
|
||||||
|
.into_iter()
|
||||||
|
.map(|(id, names)| (definitions.local_def_id(id), names))
|
||||||
|
.collect();
|
||||||
ResolverOutputs {
|
ResolverOutputs {
|
||||||
definitions: self.definitions,
|
definitions: definitions,
|
||||||
cstore: Box::new(self.crate_loader.into_cstore()),
|
cstore: Box::new(self.crate_loader.into_cstore()),
|
||||||
extern_crate_map: self.extern_crate_map,
|
extern_crate_map,
|
||||||
export_map: self.export_map,
|
export_map,
|
||||||
trait_map: self.trait_map,
|
trait_map,
|
||||||
glob_map: self.glob_map,
|
glob_map,
|
||||||
maybe_unused_trait_imports: self.maybe_unused_trait_imports,
|
maybe_unused_trait_imports,
|
||||||
maybe_unused_extern_crates: self.maybe_unused_extern_crates,
|
maybe_unused_extern_crates,
|
||||||
extern_prelude: self
|
extern_prelude: self
|
||||||
.extern_prelude
|
.extern_prelude
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -1287,12 +1334,53 @@ impl<'a> Resolver<'a> {
|
||||||
ResolverOutputs {
|
ResolverOutputs {
|
||||||
definitions: self.definitions.clone(),
|
definitions: self.definitions.clone(),
|
||||||
cstore: Box::new(self.cstore().clone()),
|
cstore: Box::new(self.cstore().clone()),
|
||||||
extern_crate_map: self.extern_crate_map.clone(),
|
extern_crate_map: self
|
||||||
export_map: self.export_map.clone(),
|
.extern_crate_map
|
||||||
trait_map: self.trait_map.clone(),
|
.iter()
|
||||||
glob_map: self.glob_map.clone(),
|
.map(|(&k, &v)| (self.definitions.local_def_id(k).to_def_id(), v))
|
||||||
maybe_unused_trait_imports: self.maybe_unused_trait_imports.clone(),
|
.collect(),
|
||||||
maybe_unused_extern_crates: self.maybe_unused_extern_crates.clone(),
|
export_map: self
|
||||||
|
.export_map
|
||||||
|
.iter()
|
||||||
|
.map(|(&k, v)| {
|
||||||
|
(
|
||||||
|
k,
|
||||||
|
v.iter()
|
||||||
|
.map(|e| e.map_id(|id| self.definitions.node_id_to_hir_id(id)))
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
trait_map: self
|
||||||
|
.trait_map
|
||||||
|
.iter()
|
||||||
|
.map(|(&k, v)| {
|
||||||
|
(
|
||||||
|
self.definitions.node_id_to_hir_id(k),
|
||||||
|
v.iter()
|
||||||
|
.cloned()
|
||||||
|
.map(|tc| {
|
||||||
|
tc.map_import_ids(|id| self.definitions.node_id_to_hir_id(id))
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
glob_map: self
|
||||||
|
.glob_map
|
||||||
|
.iter()
|
||||||
|
.map(|(&id, names)| (self.definitions.local_def_id(id), names.clone()))
|
||||||
|
.collect(),
|
||||||
|
maybe_unused_trait_imports: self
|
||||||
|
.maybe_unused_trait_imports
|
||||||
|
.iter()
|
||||||
|
.map(|&id| self.definitions.local_def_id(id))
|
||||||
|
.collect(),
|
||||||
|
maybe_unused_extern_crates: self
|
||||||
|
.maybe_unused_extern_crates
|
||||||
|
.iter()
|
||||||
|
.map(|&(id, sp)| (self.definitions.local_def_id(id).to_def_id(), sp))
|
||||||
|
.collect(),
|
||||||
extern_prelude: self
|
extern_prelude: self
|
||||||
.extern_prelude
|
.extern_prelude
|
||||||
.iter()
|
.iter()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue