Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #61105

Merged
merged 41 commits into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1e3302d
Suggest dereferencing on assignment to mutable borrow
estebank May 22, 2019
f44b264
fix dangling reference in Vec::append
RalfJung May 23, 2019
3cbf586
tweak discriminant on non-nullary enum diagnostic
euclio May 22, 2019
6116f19
Box::into_unique: do the reborrow-to-raw *after* destroying the Box
RalfJung May 23, 2019
8d4e7fd
adjust comment
RalfJung May 23, 2019
4ba144d
Update associated_item_def_ids
Zoxc Nov 30, 2018
8c936e4
Update inherent_impls
Zoxc Nov 30, 2018
99f6221
Update borrowck
Zoxc Nov 30, 2018
95dfd82
Update upstream_monomorphizations and upstream_monomorphizations_for
Zoxc Nov 30, 2018
093940d
Update implementations_of_trait and all_trait_implementations
Zoxc Nov 30, 2018
529aed8
Update resolve_lifetimes, named_region_map, is_late_bound_map and obj…
Zoxc Nov 30, 2018
b1398a0
Update item_children
Zoxc Nov 30, 2018
28482db
Update used_trait_imports
Zoxc Nov 30, 2018
ba5d9c0
Optimize alloc_from_iter
Zoxc Apr 23, 2019
ae8975c
Update GenericPredicates queries
Zoxc Dec 1, 2018
e77096b
Remove subtle Default impl for Value
Zoxc Apr 5, 2019
4214565
Add a comment for arena_types!
Zoxc May 19, 2019
ad2b35b
Make ArenaField private
Zoxc May 19, 2019
5bcc80b
Update Cargo.lock
Zoxc May 19, 2019
9dcc60b
Update lint_levels
Zoxc Nov 30, 2018
10ef70b
Update stability_index, all_crate_nums and features_query
Zoxc Nov 30, 2018
5751fcc
Update all_traits
Zoxc Nov 30, 2018
fb57879
Update privacy_access_levels
Zoxc Dec 1, 2018
5f808f6
Update in_scope_traits_map
Zoxc Dec 1, 2018
9b648f7
Update upvars and module_exports
Zoxc Dec 1, 2018
46f2511
Update wasm_import_module_map and target_features_whitelist
Zoxc Dec 1, 2018
3f87975
Update get_lib_features, defined_lib_features, get_lang_items, define…
Zoxc Dec 1, 2018
2f74d90
Update visible_parent_map
Zoxc Dec 1, 2018
469831f
Update foreign_modules and dllimport_foreign_items
Zoxc Dec 1, 2018
a58999c
Update dylib_dependency_formats, extern_crate and reachable_non_generics
Zoxc Dec 1, 2018
d46e732
Update crate_variances and inferred_outlives_crate
Zoxc May 20, 2019
7fbbcfa
Add regression test for negative case
estebank May 23, 2019
49f01d8
Fix missing overflowing literal lint in for loop
varkor May 23, 2019
3e4cefe
Update unreachable loop patterns test
varkor May 23, 2019
12de24c
Add test for denying overflowing literal in loop
varkor May 23, 2019
e0e9c86
Rollup merge of #59545 - Zoxc:the-arena-3, r=eddyb,michaelwoerister
Centril May 23, 2019
b9459e7
Rollup merge of #61054 - estebank:mut-ref-reassign, r=zackmdavis
Centril May 23, 2019
26f3528
Rollup merge of #61056 - euclio:custom-discriminant-error, r=estebank
Centril May 23, 2019
ee97210
Rollup merge of #61082 - RalfJung:vec, r=alexcrichton
Centril May 23, 2019
3388028
Rollup merge of #61086 - RalfJung:box, r=alexcrichton
Centril May 23, 2019
92fda92
Rollup merge of #61098 - varkor:fix-overflowing-literal-in-loop, r=es…
Centril May 23, 2019
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
Update inherent_impls
  • Loading branch information
Zoxc committed May 23, 2019
commit 8c936e422f0cbd5a90adf73f6b680736551bf9db
1 change: 1 addition & 0 deletions src/librustc/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ macro_rules! arena_types {
rustc::infer::canonical::Canonical<'tcx,
rustc::infer::canonical::QueryResponse<'tcx, rustc::ty::Ty<'tcx>>
>,
[few] crate_inherent_impls: rustc::ty::CrateInherentImpls,
], $tcx);
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ rustc_queries! {
/// Maps a `DefId` of a type to a list of its inherent impls.
/// Contains implementations of methods that are inherent to a type.
/// Methods in these implementations don't need to be exported.
query inherent_impls(_: DefId) -> Lrc<Vec<DefId>> {
query inherent_impls(_: DefId) -> &'tcx [DefId] {
eval_always
}
}
Expand Down Expand Up @@ -383,7 +383,7 @@ rustc_queries! {
/// Not meant to be used directly outside of coherence.
/// (Defined only for `LOCAL_CRATE`.)
query crate_inherent_impls(k: CrateNum)
-> Lrc<CrateInherentImpls> {
-> &'tcx CrateInherentImpls {
eval_always
desc { "all inherent impls defined in crate `{:?}`", k }
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3389,7 +3389,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
/// (constructing this map requires touching the entire crate).
#[derive(Clone, Debug, Default, HashStable)]
pub struct CrateInherentImpls {
pub inherent_impls: DefIdMap<Lrc<Vec<DefId>>>,
pub inherent_impls: DefIdMap<Vec<DefId>>,
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
(cdata.mir_const_qualif(def_id.index), tcx.arena.alloc(BitSet::new_empty(0)))
}
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
inherent_impls => { Lrc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) }
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
static_mutability => { cdata.static_mutability(def_id.index) }
Expand Down
15 changes: 9 additions & 6 deletions src/librustc_metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,12 +1013,15 @@ impl<'a, 'tcx> CrateMetadata {
None
}

pub fn get_inherent_implementations_for_type(&self, id: DefIndex) -> Vec<DefId> {
self.entry(id)
.inherent_impls
.decode(self)
.map(|index| self.local_def_id(index))
.collect()
pub fn get_inherent_implementations_for_type(
&self,
tcx: TyCtxt<'_, 'tcx, '_>,
id: DefIndex
) -> &'tcx [DefId] {
tcx.arena.alloc_from_iter(self.entry(id)
.inherent_impls
.decode(self)
.map(|index| self.local_def_id(index)))
}

pub fn get_implementations_for_trait(&self,
Expand Down
24 changes: 7 additions & 17 deletions src/librustc_typeck/coherence/inherent_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ use rustc::hir;
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::ty::{self, CrateInherentImpls, TyCtxt};

use rustc_data_structures::sync::Lrc;
use syntax::ast;
use syntax_pos::Span;

/// On-demand query: yields a map containing all types mapped to their inherent impls.
pub fn crate_inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
crate_num: CrateNum)
-> Lrc<CrateInherentImpls> {
-> &'tcx CrateInherentImpls {
assert_eq!(crate_num, LOCAL_CRATE);

let krate = tcx.hir().krate();
Expand All @@ -29,13 +28,13 @@ pub fn crate_inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impls_map: Default::default(),
};
krate.visit_all_item_likes(&mut collect);
Lrc::new(collect.impls_map)
tcx.arena.alloc(collect.impls_map)
}

/// On-demand query: yields a vector of the inherent impls for a specific type.
pub fn inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
ty_def_id: DefId)
-> Lrc<Vec<DefId>> {
-> &'tcx [DefId] {
assert!(ty_def_id.is_local());

// NB. Until we adopt the red-green dep-tracking algorithm (see
Expand All @@ -53,15 +52,11 @@ pub fn inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
//
// [the plan]: https://github.com/rust-lang/rust-roadmap/issues/4

thread_local! {
static EMPTY_DEF_ID_VEC: Lrc<Vec<DefId>> = Lrc::new(vec![])
}

let result = tcx.dep_graph.with_ignore(|| {
let crate_map = tcx.crate_inherent_impls(ty_def_id.krate);
match crate_map.inherent_impls.get(&ty_def_id) {
Some(v) => v.clone(),
None => EMPTY_DEF_ID_VEC.with(|v| v.clone())
Some(v) => &v[..],
None => &[],
}
});

Expand Down Expand Up @@ -289,13 +284,8 @@ impl<'a, 'tcx> InherentCollect<'a, 'tcx> {
// type def ID, if there is a base type for this implementation and
// the implementation does not have any associated traits.
let impl_def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let mut rc_vec = self.impls_map.inherent_impls
.entry(def_id)
.or_default();

// At this point, there should not be any clones of the
// `Lrc`, so we can still safely push into it in place:
Lrc::get_mut(&mut rc_vec).unwrap().push(impl_def_id);
let vec = self.impls_map.inherent_impls.entry(def_id).or_default();
vec.push(impl_def_id);
} else {
struct_span_err!(self.tcx.sess,
item.span,
Expand Down