Fix ICE
This commit is contained in:
parent
f7964aebe5
commit
3fa3fe01b6
8 changed files with 54 additions and 2 deletions
|
|
@ -570,6 +570,8 @@ define_dep_nodes!( <'tcx>
|
|||
[] MissingExternCrateItem(CrateNum),
|
||||
[] UsedCrateSource(CrateNum),
|
||||
[] PostorderCnums,
|
||||
[] HasCloneClosures(CrateNum),
|
||||
[] HasCopyClosures(CrateNum),
|
||||
|
||||
[] Freevars(DefId),
|
||||
[] MaybeUnusedTraitImport(DefId),
|
||||
|
|
|
|||
|
|
@ -2087,10 +2087,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
let trait_id = obligation.predicate.def_id();
|
||||
let copy_closures =
|
||||
Some(trait_id) == self.tcx().lang_items().copy_trait() &&
|
||||
self.tcx().sess.features.borrow().copy_closures;
|
||||
self.tcx().has_copy_closures(def_id.krate);
|
||||
let clone_closures =
|
||||
Some(trait_id) == self.tcx().lang_items().clone_trait() &&
|
||||
self.tcx().sess.features.borrow().clone_closures;
|
||||
self.tcx().has_clone_closures(def_id.krate);
|
||||
|
||||
if copy_closures || clone_closures {
|
||||
Where(ty::Binder(substs.upvar_tys(def_id, self.tcx()).collect()))
|
||||
|
|
|
|||
|
|
@ -2247,4 +2247,12 @@ pub fn provide(providers: &mut ty::maps::Providers) {
|
|||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.output_filenames.clone()
|
||||
};
|
||||
providers.has_copy_closures = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.sess.features.borrow().copy_closures
|
||||
};
|
||||
providers.has_clone_closures = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.sess.features.borrow().clone_closures
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -490,3 +490,15 @@ impl<'tcx> QueryDescription for queries::output_filenames<'tcx> {
|
|||
format!("output_filenames")
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::has_clone_closures<'tcx> {
|
||||
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
|
||||
format!("seeing if the crate has enabled `Clone` closures")
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::has_copy_closures<'tcx> {
|
||||
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
|
||||
format!("seeing if the crate has enabled `Copy` closures")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -326,6 +326,9 @@ define_maps! { <'tcx>
|
|||
[] fn compile_codegen_unit: CompileCodegenUnit(InternedString) -> Stats,
|
||||
[] fn output_filenames: output_filenames_node(CrateNum)
|
||||
-> Arc<OutputFilenames>,
|
||||
|
||||
[] fn has_copy_closures: HasCopyClosures(CrateNum) -> bool,
|
||||
[] fn has_clone_closures: HasCloneClosures(CrateNum) -> bool,
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -218,6 +218,16 @@ impl CrateMetadata {
|
|||
attr::contains_name(&attrs, "no_builtins")
|
||||
}
|
||||
|
||||
pub fn has_copy_closures(&self) -> bool {
|
||||
let attrs = self.get_item_attrs(CRATE_DEF_INDEX);
|
||||
attr::contains_feature_attr(&attrs, "copy_closures")
|
||||
}
|
||||
|
||||
pub fn has_clone_closures(&self) -> bool {
|
||||
let attrs = self.get_item_attrs(CRATE_DEF_INDEX);
|
||||
attr::contains_feature_attr(&attrs, "clone_closures")
|
||||
}
|
||||
|
||||
pub fn panic_strategy(&self) -> PanicStrategy {
|
||||
self.root.panic_strategy.clone()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,6 +231,9 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
|||
}
|
||||
|
||||
used_crate_source => { Rc::new(cdata.source.clone()) }
|
||||
|
||||
has_copy_closures => { cdata.has_copy_closures() }
|
||||
has_clone_closures => { cdata.has_clone_closures() }
|
||||
}
|
||||
|
||||
pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
|
||||
|
|
|
|||
|
|
@ -500,6 +500,20 @@ pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: &str) -> Option<S
|
|||
.and_then(|at| at.value_str())
|
||||
}
|
||||
|
||||
/// Check if `attrs` contains an attribute like `#![feature(feature_name)]`.
|
||||
/// This will not perform any "sanity checks" on the form of the attributes.
|
||||
pub fn contains_feature_attr(attrs: &[Attribute], feature_name: &str) -> bool {
|
||||
attrs.iter().any(|item| {
|
||||
item.check_name("feature") &&
|
||||
item.meta_item_list().map(|list| {
|
||||
list.iter().any(|mi| {
|
||||
mi.word().map(|w| w.name() == feature_name)
|
||||
.unwrap_or(false)
|
||||
})
|
||||
}).unwrap_or(false)
|
||||
})
|
||||
}
|
||||
|
||||
/* Higher-level applications */
|
||||
|
||||
pub fn find_crate_name(attrs: &[Attribute]) -> Option<Symbol> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue