mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 04:55:22 +03:00
Fix ICE
This commit is contained in:
@@ -570,6 +570,8 @@ pub fn to_dep_node(self, tcx: TyCtxt, kind: DepKind) -> DepNode {
|
||||
[] MissingExternCrateItem(CrateNum),
|
||||
[] UsedCrateSource(CrateNum),
|
||||
[] PostorderCnums,
|
||||
[] HasCloneClosures(CrateNum),
|
||||
[] HasCopyClosures(CrateNum),
|
||||
|
||||
[] Freevars(DefId),
|
||||
[] MaybeUnusedTraitImport(DefId),
|
||||
|
||||
@@ -2087,10 +2087,10 @@ fn copy_clone_conditions(&mut self, obligation: &TraitObligation<'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 @@ fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
|
||||
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 @@
|
||||
[] 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 @@ pub fn is_no_builtins(&self) -> bool {
|
||||
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 @@ fn into_args(self) -> (DefId, DefId) { (self.0.as_def_id(), self.1) }
|
||||
}
|
||||
|
||||
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> {
|
||||
|
||||
Reference in New Issue
Block a user