Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
591584e
Add tests for 'impl Default for [T; N]'
MikailBag May 26, 2020
3313bf6
Skip leak test on targets without panic=unwind
MikailBag May 28, 2020
5837518
`-Zunpretty=everybody_loops` only works after expansion
ecstatic-morse Jun 7, 2020
d684855
Helper method for whether `ast::Ty` contains `impl Trait`
ecstatic-morse Jun 7, 2020
b5fdbbe
Use correct names for things in `ReplaceBodyWithLoops`
ecstatic-morse Jun 7, 2020
d8c99f3
Preserve expressions that get a `DefId`
ecstatic-morse Jun 7, 2020
1a30042
Remove unnecessary `opt_local_def_id_to_hir_id`
ecstatic-morse Jun 7, 2020
e319f20
Add `rustdoc` tests from #72088
ecstatic-morse Jun 7, 2020
bbb3321
Ensure std benchmarks get tested.
ehuss Jun 8, 2020
0687b78
Speed up bootstrap a little.
ehuss Jun 13, 2020
561107c
Ignore overflow when finding auto-trait impls in Rustdoc
Aaron1011 Jun 14, 2020
4004bf1
Don't run generator transform when there's a TyErr
jonas-schievink Jun 14, 2020
607e851
Switch bootstrap metadata to --no-deps.
ehuss Jun 14, 2020
c2b920f
Show suite paths (`src/test/ui/...`) in help output.
ehuss Jun 14, 2020
f17fd7b
Add some doc comments regarding PathSet.
ehuss Jun 15, 2020
c0c3327
Check for overflow in DroplessArena and return aligned pointer
tmiasko Jun 11, 2020
1f08951
Avoid forming references to an uninitialized memory in DroplessArena
tmiasko Jun 14, 2020
f62903b
Export `#[inline] #[no_mangle]` fns in cdylibs and staticlibs
cofibrant Jun 5, 2020
6b7cacb
Export all fns with extern indicator
cofibrant Jun 8, 2020
d23bedd
Fix whitespace
cofibrant Jun 8, 2020
ee810a7
Fix exports with `#[inline(always)]`
cofibrant Jun 9, 2020
11b56fb
Fix whitespace
cofibrant Jun 9, 2020
babda94
Fix sanitizer test
cofibrant Jun 15, 2020
e8e0a0e
Update sanitizer test
cofibrant Jun 15, 2020
64a6de2
Join mutiple lines if it is more readable
tesuji Jun 15, 2020
9e51008
Complete the std::time documentation to warn about the inconsistencie…
poliorcetics Jun 15, 2020
b67bdb5
Re-order correctly the sections in the sidebar
GuillaumeGomez Jun 15, 2020
fe7456c
Use track caller for bug! macro
tesuji Jun 15, 2020
e857696
Tweak "non-primitive cast" error
estebank Jun 15, 2020
81c9094
Suggest substituting `'static` lifetime in impl/dyn `Trait + 'static`…
estebank May 29, 2020
4e90f17
When `'static` is explicit, suggest constraining argument with it
estebank May 30, 2020
921f35f
Reduce verbosity of suggestion message and mention lifetime in label
estebank May 30, 2020
e755889
Move overlapping span to a note
estebank May 30, 2020
bc15790
Tweak output for overlapping required/captured spans
estebank May 30, 2020
539e978
Tweak wording and add error code
estebank May 30, 2020
31ea589
review comments: wording
estebank Jun 1, 2020
10d9bf1
Use note for requirement source span
estebank Jun 2, 2020
34d8692
Register new eror code
estebank Jun 2, 2020
e31367d
small tweaks
estebank Jun 2, 2020
f7a1f97
Change E0758 to E0759 to avoid conflict with #72912
estebank Jun 3, 2020
bfe1434
fix rebase
estebank Jun 15, 2020
a4337cc
Use `LocalDefId` for import IDs in trait map
petrochenkov Jun 14, 2020
fc13fd0
typeck: Use `LocalDefId`s for the unused trait import set
petrochenkov Jun 15, 2020
9b18bbf
Rollup merge of #72628 - MikailBag:array-default-tests, r=shepmaster
Manishearth Jun 16, 2020
0521cf9
Rollup merge of #72804 - estebank:opaque-missing-lts-in-fn-2, r=nikom…
Manishearth Jun 16, 2020
809dd8e
Rollup merge of #72836 - poliorcetics:std-time-os-specificities, r=sh…
Manishearth Jun 16, 2020
3bbc4fd
Rollup merge of #73034 - doctorn:nomangle-inline-linkage, r=matthewja…
Manishearth Jun 16, 2020
be623f5
Rollup merge of #73103 - ecstatic-morse:replace-body-with-loop, r=pnk…
Manishearth Jun 16, 2020
d5dc79d
Rollup merge of #73142 - ehuss:std-benches, r=dtolnay
Manishearth Jun 16, 2020
6e5d03e
Rollup merge of #73237 - tmiasko:arena, r=nnethercote
Manishearth Jun 16, 2020
88a3b0e
Rollup merge of #73335 - Aaron1011:fix/rustdoc-overflow, r=estebank
Manishearth Jun 16, 2020
e1af5cb
Rollup merge of #73339 - jonas-schievink:unbug, r=estebank
Manishearth Jun 16, 2020
54c762f
Rollup merge of #73352 - ehuss:bootstrap-metadata, r=Mark-Simulacrum
Manishearth Jun 16, 2020
aa70ddd
Rollup merge of #73357 - petrochenkov:tmap, r=davidtwco
Manishearth Jun 16, 2020
f77b58b
Rollup merge of #73361 - estebank:non-primitive-cast, r=davidtwco
Manishearth Jun 16, 2020
6d14efc
Rollup merge of #73372 - GuillaumeGomez:re-order-sidebar-sections, r=…
Manishearth Jun 16, 2020
2973b63
Rollup merge of #73373 - lzutao:bug-trackcaller, r=Amanieu
Manishearth Jun 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use LocalDefId for import IDs in trait map
  • Loading branch information
petrochenkov committed Jun 15, 2020
commit a4337ccc10db07f72566ad06f62662ab9b27e3bd
19 changes: 3 additions & 16 deletions src/librustc_hir/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use rustc_ast::node_id::NodeMap;
use rustc_ast::util::parser::ExprPrecedence;
use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
use rustc_macros::HashStable_Generic;
use rustc_span::def_id::LocalDefId;
use rustc_span::source_map::{SourceMap, Spanned};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{MultiSpan, Span, DUMMY_SP};
Expand Down Expand Up @@ -2651,25 +2652,11 @@ pub type CaptureModeMap = NodeMap<CaptureBy>;
// has length > 0 if the trait is found through an chain of imports, starting with the
// import/use statement in the scope where the trait is used.
#[derive(Clone, Debug)]
pub struct TraitCandidate<ID = HirId> {
pub struct TraitCandidate {
pub def_id: DefId,
pub import_ids: SmallVec<[ID; 1]>,
pub import_ids: SmallVec<[LocalDefId; 1]>,
}

impl<ID> TraitCandidate<ID> {
pub fn map_import_ids<F, T>(self, f: F) -> TraitCandidate<T>
where
F: Fn(ID) -> T,
{
let TraitCandidate { def_id, import_ids } = self;
let import_ids = import_ids.into_iter().map(f).collect();
TraitCandidate { def_id, import_ids }
}
}

// Trait method resolution
pub type TraitMap<ID = HirId> = NodeMap<Vec<TraitCandidate<ID>>>;

#[derive(Copy, Clone, Debug, HashStable_Generic)]
pub enum Node<'hir> {
Param(&'hir Param<'hir>),
Expand Down
11 changes: 5 additions & 6 deletions src/librustc_middle/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,15 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitCandidate {
}

impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::TraitCandidate {
type KeyType = (DefPathHash, SmallVec<[(DefPathHash, hir::ItemLocalId); 1]>);
type KeyType = (DefPathHash, SmallVec<[DefPathHash; 1]>);

fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> Self::KeyType {
let hir::TraitCandidate { def_id, import_ids } = self;

let import_keys = import_ids
.iter()
.map(|hir_id| (hcx.local_def_path_hash(hir_id.owner), hir_id.local_id))
.collect();
(hcx.def_path_hash(*def_id), import_keys)
(
hcx.def_path_hash(*def_id),
import_ids.iter().map(|def_id| hcx.local_def_path_hash(*def_id)).collect(),
)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub struct ResolverOutputs {
pub definitions: rustc_hir::definitions::Definitions,
pub cstore: Box<CrateStoreDyn>,
pub extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
pub trait_map: FxHashMap<hir::HirId, Vec<hir::TraitCandidate<hir::HirId>>>,
pub trait_map: FxHashMap<hir::HirId, Vec<hir::TraitCandidate>>,
pub maybe_unused_trait_imports: FxHashSet<LocalDefId>,
pub maybe_unused_extern_crates: Vec<(LocalDefId, Span)>,
pub export_map: ExportMap<LocalDefId>,
Expand Down
9 changes: 5 additions & 4 deletions src/librustc_resolve/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX};
use rustc_hir::TraitCandidate;
use rustc_middle::{bug, span_bug};
use rustc_session::lint;
use rustc_span::def_id::LocalDefId;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::Span;
use smallvec::{smallvec, SmallVec};
Expand Down Expand Up @@ -2188,7 +2189,7 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
&mut self,
mut ident: Ident,
ns: Namespace,
) -> Vec<TraitCandidate<NodeId>> {
) -> Vec<TraitCandidate> {
debug!("(getting traits containing item) looking for '{}'", ident.name);

let mut found_traits = Vec::new();
Expand Down Expand Up @@ -2233,7 +2234,7 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
ident: Ident,
ns: Namespace,
module: Module<'a>,
found_traits: &mut Vec<TraitCandidate<NodeId>>,
found_traits: &mut Vec<TraitCandidate>,
) {
assert!(ns == TypeNS || ns == ValueNS);
let mut traits = module.traits.borrow_mut();
Expand Down Expand Up @@ -2292,13 +2293,13 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
&mut self,
mut kind: &NameBindingKind<'_>,
trait_name: Ident,
) -> SmallVec<[NodeId; 1]> {
) -> SmallVec<[LocalDefId; 1]> {
let mut import_ids = smallvec![];
while let NameBindingKind::Import { import, binding, .. } = kind {
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);
import_ids.push(id);
kind = &binding.kind;
}
import_ids
Expand Down
25 changes: 4 additions & 21 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX};
use rustc_hir::definitions::{DefKey, Definitions};
use rustc_hir::PrimTy::{self, Bool, Char, Float, Int, Str, Uint};
use rustc_hir::TraitMap;
use rustc_hir::TraitCandidate;
use rustc_metadata::creader::{CStore, CrateLoader};
use rustc_middle::hir::exports::ExportMap;
use rustc_middle::middle::cstore::{CrateStore, MetadataLoaderDyn};
Expand Down Expand Up @@ -879,7 +879,7 @@ pub struct Resolver<'a> {
/// `CrateNum` resolutions of `extern crate` items.
extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
export_map: ExportMap<LocalDefId>,
trait_map: TraitMap<NodeId>,
trait_map: NodeMap<Vec<TraitCandidate>>,

/// A map from nodes to anonymous modules.
/// Anonymous modules are pseudo-modules that are implicitly created around items
Expand Down Expand Up @@ -1285,14 +1285,7 @@ impl<'a> Resolver<'a> {
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(),
)
})
.map(|(k, v)| (definitions.node_id_to_hir_id(k), v))
.collect();
let maybe_unused_trait_imports = self.maybe_unused_trait_imports;
let maybe_unused_extern_crates = self.maybe_unused_extern_crates;
Expand Down Expand Up @@ -1323,17 +1316,7 @@ impl<'a> Resolver<'a> {
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(),
)
})
.map(|(&k, v)| (self.definitions.node_id_to_hir_id(k), v.clone()))
.collect(),
glob_map: self.glob_map.clone(),
maybe_unused_trait_imports: self.maybe_unused_trait_imports.clone(),
Expand Down
10 changes: 4 additions & 6 deletions src/librustc_typeck/check/method/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.lookup_probe(span, segment.ident, self_ty, call_expr, ProbeScope::TraitsInScope)?;

for import_id in &pick.import_ids {
let import_def_id = self.tcx.hir().local_def_id(*import_id);
debug!("used_trait_import: {:?}", import_def_id);
debug!("used_trait_import: {:?}", import_id);
Lrc::get_mut(&mut self.tables.borrow_mut().used_trait_imports)
.unwrap()
.insert(import_def_id.to_def_id());
.insert(import_id.to_def_id());
}

self.tcx.check_stability(pick.item.def_id, Some(call_expr.hir_id), span);
Expand Down Expand Up @@ -461,9 +460,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut tables = self.tables.borrow_mut();
let used_trait_imports = Lrc::get_mut(&mut tables.used_trait_imports).unwrap();
for import_id in pick.import_ids {
let import_def_id = tcx.hir().local_def_id(import_id);
debug!("resolve_ufcs: used_trait_import: {:?}", import_def_id);
used_trait_imports.insert(import_def_id.to_def_id());
debug!("resolve_ufcs: used_trait_import: {:?}", import_id);
used_trait_imports.insert(import_id.to_def_id());
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/librustc_typeck/check/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use rustc_middle::ty::{
};
use rustc_session::config::nightly_options;
use rustc_session::lint;
use rustc_span::def_id::LocalDefId;
use rustc_span::{symbol::Ident, Span, Symbol, DUMMY_SP};
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
use rustc_trait_selection::traits::query::method_autoderef::MethodAutoderefBadTy;
Expand Down Expand Up @@ -129,7 +130,7 @@ struct Candidate<'tcx> {
xform_ret_ty: Option<Ty<'tcx>>,
item: ty::AssocItem,
kind: CandidateKind<'tcx>,
import_ids: SmallVec<[hir::HirId; 1]>,
import_ids: SmallVec<[LocalDefId; 1]>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -158,7 +159,7 @@ enum ProbeResult {
pub struct Pick<'tcx> {
pub item: ty::AssocItem,
pub kind: PickKind<'tcx>,
pub import_ids: SmallVec<[hir::HirId; 1]>,
pub import_ids: SmallVec<[LocalDefId; 1]>,

// Indicates that the source expression should be autoderef'd N times
//
Expand Down Expand Up @@ -930,7 +931,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {

fn assemble_extension_candidates_for_trait(
&mut self,
import_ids: &SmallVec<[hir::HirId; 1]>,
import_ids: &SmallVec<[LocalDefId; 1]>,
trait_def_id: DefId,
) -> Result<(), MethodError<'tcx>> {
debug!("assemble_extension_candidates_for_trait(trait_def_id={:?})", trait_def_id);
Expand Down