diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs index 0b544b8ab415e..0957213bfed61 100644 --- a/compiler/rustc_incremental/src/persist/dirty_clean.rs +++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs @@ -37,15 +37,15 @@ const CFG: Symbol = sym::cfg; // Base and Extra labels to build up the labels /// For typedef, constants, and statics -const BASE_CONST: &[&str] = &[label_strs::type_of]; +const BASE_CONST: &[&str] = &[label_strs::try_type_of]; /// DepNodes for functions + methods const BASE_FN: &[&str] = &[ // Callers will depend on the signature of these items, so we better test - label_strs::fn_sig, + label_strs::try_fn_sig, label_strs::generics_of, label_strs::predicates_of, - label_strs::type_of, + label_strs::try_type_of, // And a big part of compilation (that we eventually want to cache) is type inference // information: label_strs::typeck, @@ -71,7 +71,7 @@ const BASE_MIR: &[&str] = &[label_strs::optimized_mir, label_strs::promoted_mir] /// Note that changing the type of a field does not change the type of the struct or enum, but /// adding/removing fields or changing a fields name or visibility does. const BASE_STRUCT: &[&str] = - &[label_strs::generics_of, label_strs::predicates_of, label_strs::type_of]; + &[label_strs::generics_of, label_strs::predicates_of, label_strs::try_type_of]; /// Trait definition `DepNode`s. const BASE_TRAIT_DEF: &[&str] = &[ diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 0f860d11dc21a..429d556f1b0df 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -90,7 +90,7 @@ impl IntoArgs for (CrateNum, DefId) { } provide! { <'tcx> tcx, def_id, other, cdata, - type_of => { cdata.get_type(def_id.index, tcx) } + try_type_of => { Ok(cdata.get_type(def_id.index, tcx)) } generics_of => { cdata.get_generics(def_id.index, tcx.sess) } explicit_predicates_of => { cdata.get_explicit_predicates(def_id.index, tcx) } inferred_outlives_of => { cdata.get_inferred_outlives(def_id.index, tcx) } @@ -123,7 +123,7 @@ provide! { <'tcx> tcx, def_id, other, cdata, mir_abstract_const => { cdata.get_mir_abstract_const(tcx, def_id.index) } unused_generic_params => { cdata.get_unused_generic_params(def_id.index) } mir_const_qualif => { cdata.mir_const_qualif(def_id.index) } - fn_sig => { cdata.fn_sig(def_id.index, tcx) } + try_fn_sig => { Ok(cdata.fn_sig(def_id.index, tcx)) } inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) } is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) } asyncness => { cdata.asyncness(def_id.index) } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 06f53bb9282eb..c371e72308f6a 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -836,6 +836,180 @@ fn should_encode_mir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> (bool, bool) { } } +fn should_encode_variances(def_kind: DefKind) -> bool { + match def_kind { + DefKind::Struct + | DefKind::Union + | DefKind::Enum + | DefKind::Variant + | DefKind::Fn + | DefKind::Ctor(..) + | DefKind::AssocFn => true, + DefKind::Mod + | DefKind::Field + | DefKind::AssocTy + | DefKind::AssocConst + | DefKind::TyParam + | DefKind::ConstParam + | DefKind::Static + | DefKind::Const + | DefKind::ForeignMod + | DefKind::TyAlias + | DefKind::OpaqueTy + | DefKind::Impl + | DefKind::Trait + | DefKind::TraitAlias + | DefKind::Macro(..) + | DefKind::ForeignTy + | DefKind::Use + | DefKind::LifetimeParam + | DefKind::AnonConst + | DefKind::GlobalAsm + | DefKind::Closure + | DefKind::Generator + | DefKind::ExternCrate => false, + } +} + +fn should_encode_generics(def_kind: DefKind) -> bool { + match def_kind { + DefKind::Struct + | DefKind::Union + | DefKind::Enum + | DefKind::Variant + | DefKind::Trait + | DefKind::TyAlias + | DefKind::ForeignTy + | DefKind::TraitAlias + | DefKind::AssocTy + | DefKind::Fn + | DefKind::Const + | DefKind::Static + | DefKind::Ctor(..) + | DefKind::AssocFn + | DefKind::AssocConst + | DefKind::AnonConst + | DefKind::OpaqueTy + | DefKind::Impl + | DefKind::Closure + | DefKind::Generator => true, + DefKind::Mod + | DefKind::Field + | DefKind::ForeignMod + | DefKind::TyParam + | DefKind::ConstParam + | DefKind::Macro(..) + | DefKind::Use + | DefKind::LifetimeParam + | DefKind::GlobalAsm + | DefKind::ExternCrate => false, + } +} + +fn should_encode_type(def_kind: DefKind) -> bool { + match def_kind { + DefKind::Struct + | DefKind::Union + | DefKind::Enum + | DefKind::Variant + | DefKind::TyAlias + | DefKind::ForeignTy + | DefKind::AssocTy + | DefKind::TyParam + | DefKind::Fn + | DefKind::Const + | DefKind::ConstParam + | DefKind::Static + | DefKind::Ctor(..) + | DefKind::AssocFn + | DefKind::AssocConst + | DefKind::AnonConst + | DefKind::OpaqueTy + | DefKind::Field + | DefKind::Impl + | DefKind::Closure + | DefKind::Generator => true, + DefKind::Mod + | DefKind::ForeignMod + | DefKind::Trait + | DefKind::TraitAlias + | DefKind::Macro(..) + | DefKind::Use + | DefKind::LifetimeParam + | DefKind::GlobalAsm + | DefKind::ExternCrate => false, + } +} + +fn should_encode_fn_sig(def_kind: DefKind) -> bool { + match def_kind { + DefKind::Variant + | DefKind::TraitAlias + | DefKind::Fn + | DefKind::Ctor(..) + | DefKind::AssocFn => true, + DefKind::Struct + | DefKind::Union + | DefKind::Enum + | DefKind::Trait + | DefKind::TyAlias + | DefKind::ForeignTy + | DefKind::AssocTy + | DefKind::Const + | DefKind::Static + | DefKind::AssocConst + | DefKind::AnonConst + | DefKind::OpaqueTy + | DefKind::Impl + | DefKind::Closure + | DefKind::Generator + | DefKind::Mod + | DefKind::Field + | DefKind::ForeignMod + | DefKind::TyParam + | DefKind::ConstParam + | DefKind::Macro(..) + | DefKind::Use + | DefKind::LifetimeParam + | DefKind::GlobalAsm + | DefKind::ExternCrate => false, + } +} + +fn should_encode_explicit_item_bounds(def_kind: DefKind) -> bool { + match def_kind { + DefKind::AssocTy | DefKind::OpaqueTy => true, + DefKind::Variant + | DefKind::TraitAlias + | DefKind::Fn + | DefKind::Ctor(..) + | DefKind::AssocFn + | DefKind::Struct + | DefKind::Union + | DefKind::Enum + | DefKind::Trait + | DefKind::TyAlias + | DefKind::ForeignTy + | DefKind::Const + | DefKind::Static + | DefKind::AssocConst + | DefKind::AnonConst + | DefKind::Impl + | DefKind::Closure + | DefKind::Generator + | DefKind::Mod + | DefKind::Field + | DefKind::ForeignMod + | DefKind::TyParam + | DefKind::ConstParam + | DefKind::Macro(..) + | DefKind::Use + | DefKind::LifetimeParam + | DefKind::GlobalAsm + | DefKind::ExternCrate => false, + } +} + impl EncodeContext<'a, 'tcx> { fn encode_def_ids(&mut self) { if self.is_proc_macro { @@ -864,6 +1038,38 @@ impl EncodeContext<'a, 'tcx> { self.encode_const_stability(def_id); self.encode_deprecation(def_id); } + if should_encode_variances(def_kind) { + let v = self.tcx.variances_of(def_id); + record!(self.tables.variances[def_id] <- v); + } + if should_encode_generics(def_kind) { + let g = tcx.generics_of(def_id); + record!(self.tables.generics[def_id] <- g); + record!(self.tables.explicit_predicates[def_id] <- self.tcx.explicit_predicates_of(def_id)); + let inferred_outlives = self.tcx.inferred_outlives_of(def_id); + if !inferred_outlives.is_empty() { + record!(self.tables.inferred_outlives[def_id] <- inferred_outlives); + } + } + if let DefKind::Trait | DefKind::TraitAlias = def_kind { + record!(self.tables.super_predicates[def_id] <- self.tcx.super_predicates_of(def_id)); + } + if should_encode_type(def_kind) { + if let Ok(ty) = self.tcx.try_type_of(def_id) { + record!(self.tables.ty[def_id] <- ty); + } + } + if should_encode_fn_sig(def_kind) { + if let Ok(sig) = tcx.try_fn_sig(def_id) { + record!(self.tables.fn_sig[def_id] <- sig); + } + } + if should_encode_explicit_item_bounds(def_kind) { + let bounds = self.tcx.explicit_item_bounds(def_id); + if !bounds.is_empty() { + record!(self.tables.explicit_item_bounds[def_id] <- bounds); + } + } } let inherent_impls = tcx.crate_inherent_impls(LOCAL_CRATE); for (def_id, implementations) in inherent_impls.inherent_impls.iter() { @@ -878,18 +1084,7 @@ impl EncodeContext<'a, 'tcx> { } } - fn encode_variances_of(&mut self, def_id: DefId) { - debug!("EncodeContext::encode_variances_of({:?})", def_id); - record!(self.tables.variances[def_id] <- self.tcx.variances_of(def_id)); - } - - fn encode_item_type(&mut self, def_id: DefId) { - debug!("EncodeContext::encode_item_type({:?})", def_id); - record!(self.tables.ty[def_id] <- self.tcx.type_of(def_id)); - } - fn encode_enum_variant_info(&mut self, def: &ty::AdtDef, index: VariantIdx) { - let tcx = self.tcx; let variant = &def.variants[index]; let def_id = variant.def_id; debug!("EncodeContext::encode_enum_variant_info({:?})", def_id); @@ -907,22 +1102,9 @@ impl EncodeContext<'a, 'tcx> { f.did.index })); self.encode_ident_span(def_id, variant.ident); - self.encode_item_type(def_id); - if variant.ctor_kind == CtorKind::Fn { - // FIXME(eddyb) encode signature only in `encode_enum_variant_ctor`. - if let Some(ctor_def_id) = variant.ctor_def_id { - record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(ctor_def_id)); - } - // FIXME(eddyb) is this ever used? - self.encode_variances_of(def_id); - } - self.encode_generics(def_id); - self.encode_explicit_predicates(def_id); - self.encode_inferred_outlives(def_id); } fn encode_enum_variant_ctor(&mut self, def: &ty::AdtDef, index: VariantIdx) { - let tcx = self.tcx; let variant = &def.variants[index]; let def_id = variant.ctor_def_id.unwrap(); debug!("EncodeContext::encode_enum_variant_ctor({:?})", def_id); @@ -936,14 +1118,6 @@ impl EncodeContext<'a, 'tcx> { }; record!(self.tables.kind[def_id] <- EntryKind::Variant(self.lazy(data))); - self.encode_item_type(def_id); - if variant.ctor_kind == CtorKind::Fn { - record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); - self.encode_variances_of(def_id); - } - self.encode_generics(def_id); - self.encode_explicit_predicates(def_id); - self.encode_inferred_outlives(def_id); } fn encode_info_for_mod(&mut self, local_def_id: LocalDefId, md: &hir::Mod<'_>) { @@ -1001,15 +1175,10 @@ impl EncodeContext<'a, 'tcx> { record!(self.tables.kind[def_id] <- EntryKind::Field); self.encode_ident_span(def_id, field.ident); - self.encode_item_type(def_id); - self.encode_generics(def_id); - self.encode_explicit_predicates(def_id); - self.encode_inferred_outlives(def_id); } fn encode_struct_ctor(&mut self, adt_def: &ty::AdtDef, def_id: DefId) { debug!("EncodeContext::encode_struct_ctor({:?})", def_id); - let tcx = self.tcx; let variant = adt_def.non_enum_variant(); let data = VariantData { @@ -1020,46 +1189,6 @@ impl EncodeContext<'a, 'tcx> { }; record!(self.tables.kind[def_id] <- EntryKind::Struct(self.lazy(data), adt_def.repr)); - self.encode_item_type(def_id); - if variant.ctor_kind == CtorKind::Fn { - record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); - self.encode_variances_of(def_id); - } - self.encode_generics(def_id); - self.encode_explicit_predicates(def_id); - self.encode_inferred_outlives(def_id); - } - - fn encode_generics(&mut self, def_id: DefId) { - debug!("EncodeContext::encode_generics({:?})", def_id); - record!(self.tables.generics[def_id] <- self.tcx.generics_of(def_id)); - } - - fn encode_explicit_predicates(&mut self, def_id: DefId) { - debug!("EncodeContext::encode_explicit_predicates({:?})", def_id); - record!(self.tables.explicit_predicates[def_id] <- - self.tcx.explicit_predicates_of(def_id)); - } - - fn encode_inferred_outlives(&mut self, def_id: DefId) { - debug!("EncodeContext::encode_inferred_outlives({:?})", def_id); - let inferred_outlives = self.tcx.inferred_outlives_of(def_id); - if !inferred_outlives.is_empty() { - record!(self.tables.inferred_outlives[def_id] <- inferred_outlives); - } - } - - fn encode_super_predicates(&mut self, def_id: DefId) { - debug!("EncodeContext::encode_super_predicates({:?})", def_id); - record!(self.tables.super_predicates[def_id] <- self.tcx.super_predicates_of(def_id)); - } - - fn encode_explicit_item_bounds(&mut self, def_id: DefId) { - debug!("EncodeContext::encode_explicit_item_bounds({:?})", def_id); - let bounds = self.tcx.explicit_item_bounds(def_id); - if !bounds.is_empty() { - record!(self.tables.explicit_item_bounds[def_id] <- bounds); - } } fn encode_info_for_trait_item(&mut self, def_id: DefId) { @@ -1111,34 +1240,14 @@ impl EncodeContext<'a, 'tcx> { }))); } ty::AssocKind::Type => { - self.encode_explicit_item_bounds(def_id); record!(self.tables.kind[def_id] <- EntryKind::AssocType(container)); } } self.encode_ident_span(def_id, ast_item.ident); - match trait_item.kind { - ty::AssocKind::Const | ty::AssocKind::Fn => { - self.encode_item_type(def_id); - } - ty::AssocKind::Type => { - if trait_item.defaultness.has_value() { - self.encode_item_type(def_id); - } - } - } - if trait_item.kind == ty::AssocKind::Fn { - record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); - self.encode_variances_of(def_id); - } - self.encode_generics(def_id); - self.encode_explicit_predicates(def_id); - self.encode_inferred_outlives(def_id); } fn encode_info_for_impl_item(&mut self, def_id: DefId) { debug!("EncodeContext::encode_info_for_impl_item({:?})", def_id); - let tcx = self.tcx; - let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); let ast_item = self.tcx.hir().expect_impl_item(hir_id); let impl_item = self.tcx.associated_item(def_id); @@ -1186,14 +1295,6 @@ impl EncodeContext<'a, 'tcx> { } } self.encode_ident_span(def_id, impl_item.ident); - self.encode_item_type(def_id); - if impl_item.kind == ty::AssocKind::Fn { - record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); - self.encode_variances_of(def_id); - } - self.encode_generics(def_id); - self.encode_explicit_predicates(def_id); - self.encode_inferred_outlives(def_id); } fn encode_fn_param_names_for_body(&mut self, body_id: hir::BodyId) -> Lazy<[Ident]> { @@ -1290,8 +1391,6 @@ impl EncodeContext<'a, 'tcx> { } fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) { - let tcx = self.tcx; - debug!("EncodeContext::encode_info_for_item({:?})", def_id); self.encode_ident_span(def_id, item.ident); @@ -1318,10 +1417,7 @@ impl EncodeContext<'a, 'tcx> { hir::ItemKind::ForeignMod { .. } => EntryKind::ForeignMod, hir::ItemKind::GlobalAsm(..) => EntryKind::GlobalAsm, hir::ItemKind::TyAlias(..) => EntryKind::Type, - hir::ItemKind::OpaqueTy(..) => { - self.encode_explicit_item_bounds(def_id); - EntryKind::OpaqueTy - } + hir::ItemKind::OpaqueTy(..) => EntryKind::OpaqueTy, hir::ItemKind::Enum(..) => EntryKind::Enum(self.tcx.adt_def(def_id).repr), hir::ItemKind::Struct(ref struct_def, _) => { let adt_def = self.tcx.adt_def(def_id); @@ -1438,57 +1534,11 @@ impl EncodeContext<'a, 'tcx> { } _ => {} } - match item.kind { - hir::ItemKind::Static(..) - | hir::ItemKind::Const(..) - | hir::ItemKind::Fn(..) - | hir::ItemKind::TyAlias(..) - | hir::ItemKind::OpaqueTy(..) - | hir::ItemKind::Enum(..) - | hir::ItemKind::Struct(..) - | hir::ItemKind::Union(..) - | hir::ItemKind::Impl { .. } => self.encode_item_type(def_id), - _ => {} - } - if let hir::ItemKind::Fn(..) = item.kind { - record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); - } if let hir::ItemKind::Impl { .. } = item.kind { if let Some(trait_ref) = self.tcx.impl_trait_ref(def_id) { record!(self.tables.impl_trait_ref[def_id] <- trait_ref); } } - match item.kind { - hir::ItemKind::Enum(..) - | hir::ItemKind::Struct(..) - | hir::ItemKind::Union(..) - | hir::ItemKind::Fn(..) => self.encode_variances_of(def_id), - _ => {} - } - match item.kind { - hir::ItemKind::Static(..) - | hir::ItemKind::Const(..) - | hir::ItemKind::Fn(..) - | hir::ItemKind::TyAlias(..) - | hir::ItemKind::Enum(..) - | hir::ItemKind::Struct(..) - | hir::ItemKind::Union(..) - | hir::ItemKind::Impl { .. } - | hir::ItemKind::OpaqueTy(..) - | hir::ItemKind::Trait(..) - | hir::ItemKind::TraitAlias(..) => { - self.encode_generics(def_id); - self.encode_explicit_predicates(def_id); - self.encode_inferred_outlives(def_id); - } - _ => {} - } - match item.kind { - hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) => { - self.encode_super_predicates(def_id); - } - _ => {} - } } /// Serialize the text of exported macros @@ -1498,11 +1548,8 @@ impl EncodeContext<'a, 'tcx> { self.encode_ident_span(def_id, macro_def.ident); } - fn encode_info_for_generic_param(&mut self, def_id: DefId, kind: EntryKind, encode_type: bool) { + fn encode_info_for_generic_param(&mut self, def_id: DefId, kind: EntryKind) { record!(self.tables.kind[def_id] <- kind); - if encode_type { - self.encode_item_type(def_id); - } } fn encode_info_for_closure(&mut self, def_id: LocalDefId) { @@ -1525,11 +1572,6 @@ impl EncodeContext<'a, 'tcx> { _ => bug!("closure that is neither generator nor closure"), } - self.encode_item_type(def_id.to_def_id()); - if let ty::Closure(def_id, substs) = *ty.kind() { - record!(self.tables.fn_sig[def_id] <- substs.as_closure().sig()); - } - self.encode_generics(def_id.to_def_id()); } fn encode_info_for_anon_const(&mut self, def_id: LocalDefId) { @@ -1540,10 +1582,6 @@ impl EncodeContext<'a, 'tcx> { let qualifs = self.tcx.mir_const_qualif(def_id); record!(self.tables.kind[def_id.to_def_id()] <- EntryKind::AnonConst(qualifs, const_data)); - self.encode_item_type(def_id.to_def_id()); - self.encode_generics(def_id.to_def_id()); - self.encode_explicit_predicates(def_id.to_def_id()); - self.encode_inferred_outlives(def_id.to_def_id()); } fn encode_native_libraries(&mut self) -> Lazy<[NativeLib]> { @@ -1791,8 +1829,6 @@ impl EncodeContext<'a, 'tcx> { } fn encode_info_for_foreign_item(&mut self, def_id: DefId, nitem: &hir::ForeignItem<'_>) { - let tcx = self.tcx; - debug!("EncodeContext::encode_info_for_foreign_item({:?})", def_id); match nitem.kind { @@ -1819,14 +1855,6 @@ impl EncodeContext<'a, 'tcx> { } } self.encode_ident_span(def_id, nitem.ident); - self.encode_item_type(def_id); - if let hir::ForeignItemKind::Fn(..) = nitem.kind { - record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); - self.encode_variances_of(def_id); - } - self.encode_generics(def_id); - self.encode_explicit_predicates(def_id); - self.encode_inferred_outlives(def_id); } } @@ -1881,19 +1909,11 @@ impl EncodeContext<'a, 'tcx> { let def_id = self.tcx.hir().local_def_id(param.hir_id); match param.kind { GenericParamKind::Lifetime { .. } => continue, - GenericParamKind::Type { default, .. } => { - self.encode_info_for_generic_param( - def_id.to_def_id(), - EntryKind::TypeParam, - default.is_some(), - ); + GenericParamKind::Type { .. } => { + self.encode_info_for_generic_param(def_id.to_def_id(), EntryKind::TypeParam); } GenericParamKind::Const { .. } => { - self.encode_info_for_generic_param( - def_id.to_def_id(), - EntryKind::ConstParam, - true, - ); + self.encode_info_for_generic_param(def_id.to_def_id(), EntryKind::ConstParam); // FIXME(const_generics_defaults) } } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index b03b26d64606c..b6e164b4825cd 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -94,7 +94,7 @@ rustc_queries! { } /// Records the type of every item. - query type_of(key: DefId) -> Ty<'tcx> { + query try_type_of(key: DefId) -> Result, String> { desc { |tcx| "computing type of `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } } @@ -600,7 +600,7 @@ rustc_queries! { } /// The signature of functions. - query fn_sig(key: DefId) -> ty::PolyFnSig<'tcx> { + query try_fn_sig(key: DefId) -> Result, String> { desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) } } diff --git a/compiler/rustc_middle/src/ty/query/mod.rs b/compiler/rustc_middle/src/ty/query/mod.rs index 51a214bc07bac..ec7106d6d6df7 100644 --- a/compiler/rustc_middle/src/ty/query/mod.rs +++ b/compiler/rustc_middle/src/ty/query/mod.rs @@ -307,17 +307,51 @@ mod sealed { use sealed::IntoQueryParam; impl TyCtxt<'tcx> { + #[inline] pub fn def_kind(self, def_id: impl IntoQueryParam) -> DefKind { let def_id = def_id.into_query_param(); self.opt_def_kind(def_id) .unwrap_or_else(|| bug!("def_kind: unsupported node: {:?}", def_id)) } + + #[inline] + pub fn fn_sig(self, def_id: impl IntoQueryParam) -> ty::PolyFnSig<'tcx> { + let def_id = def_id.into_query_param(); + self.try_fn_sig(def_id) + .unwrap_or_else(|s| span_bug!(self.def_span(def_id), "fn_sig: {}", s)) + } + + #[inline] + pub fn type_of(self, def_id: impl IntoQueryParam) -> Ty<'tcx> { + let def_id = def_id.into_query_param(); + self.try_type_of(def_id).unwrap_or_else(|msg| { + let hir_id = self.hir().local_def_id_to_hir_id(def_id.expect_local()); + span_bug!(self.def_span(def_id), "type_of: {}: {:?}", msg, self.hir().find(hir_id)); + }) + } } impl TyCtxtAt<'tcx> { + #[inline] pub fn def_kind(self, def_id: impl IntoQueryParam) -> DefKind { let def_id = def_id.into_query_param(); self.opt_def_kind(def_id) .unwrap_or_else(|| bug!("def_kind: unsupported node: {:?}", def_id)) } + + #[inline] + pub fn fn_sig(self, def_id: impl IntoQueryParam) -> ty::PolyFnSig<'tcx> { + let def_id = def_id.into_query_param(); + self.try_fn_sig(def_id) + .unwrap_or_else(|s| span_bug!(self.def_span(def_id), "fn_sig: {}", s)) + } + + #[inline] + pub fn type_of(self, def_id: impl IntoQueryParam) -> Ty<'tcx> { + let def_id = def_id.into_query_param(); + self.try_type_of(def_id).unwrap_or_else(|msg| { + let hir_id = self.hir().local_def_id_to_hir_id(def_id.expect_local()); + span_bug!(self.def_span(def_id), "type_of: {}: {:?}", msg, self.hir().find(hir_id)); + }) + } } diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index a175da3270638..03cba57e31ba3 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -69,7 +69,7 @@ fn collect_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { pub fn provide(providers: &mut Providers) { *providers = Providers { opt_const_param_of: type_of::opt_const_param_of, - type_of: type_of::type_of, + try_type_of: type_of::try_type_of, item_bounds: item_bounds::item_bounds, explicit_item_bounds: item_bounds::explicit_item_bounds, generics_of, @@ -83,7 +83,7 @@ pub fn provide(providers: &mut Providers) { type_param_predicates, trait_def, adt_def, - fn_sig, + try_fn_sig, impl_trait_ref, impl_polarity, is_foreign_item, @@ -251,12 +251,12 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { hir::GenericParamKind::Lifetime { .. } => {} hir::GenericParamKind::Type { default: Some(_), .. } => { let def_id = self.tcx.hir().local_def_id(param.hir_id); - self.tcx.ensure().type_of(def_id); + self.tcx.ensure().try_type_of(def_id); } hir::GenericParamKind::Type { .. } => {} hir::GenericParamKind::Const { .. } => { let def_id = self.tcx.hir().local_def_id(param.hir_id); - self.tcx.ensure().type_of(def_id); + self.tcx.ensure().try_type_of(def_id); // FIXME(const_generics_defaults) } } @@ -268,7 +268,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { if let hir::ExprKind::Closure(..) = expr.kind { let def_id = self.tcx.hir().local_def_id(expr.hir_id); self.tcx.ensure().generics_of(def_id); - self.tcx.ensure().type_of(def_id); + self.tcx.ensure().try_type_of(def_id); } intravisit::walk_expr(self, expr); } @@ -727,22 +727,22 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) { for item in items { let item = tcx.hir().foreign_item(item.id); tcx.ensure().generics_of(item.def_id); - tcx.ensure().type_of(item.def_id); + tcx.ensure().try_type_of(item.def_id); tcx.ensure().predicates_of(item.def_id); if let hir::ForeignItemKind::Fn(..) = item.kind { - tcx.ensure().fn_sig(item.def_id); + tcx.ensure().try_fn_sig(item.def_id); } } } hir::ItemKind::Enum(ref enum_definition, _) => { tcx.ensure().generics_of(def_id); - tcx.ensure().type_of(def_id); + tcx.ensure().try_type_of(def_id); tcx.ensure().predicates_of(def_id); convert_enum_variant_types(tcx, def_id.to_def_id(), &enum_definition.variants); } hir::ItemKind::Impl { .. } => { tcx.ensure().generics_of(def_id); - tcx.ensure().type_of(def_id); + tcx.ensure().try_type_of(def_id); tcx.ensure().impl_trait_ref(def_id); tcx.ensure().predicates_of(def_id); } @@ -759,13 +759,13 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) { } hir::ItemKind::Struct(ref struct_def, _) | hir::ItemKind::Union(ref struct_def, _) => { tcx.ensure().generics_of(def_id); - tcx.ensure().type_of(def_id); + tcx.ensure().try_type_of(def_id); tcx.ensure().predicates_of(def_id); for f in struct_def.fields() { let def_id = tcx.hir().local_def_id(f.hir_id); tcx.ensure().generics_of(def_id); - tcx.ensure().type_of(def_id); + tcx.ensure().try_type_of(def_id); tcx.ensure().predicates_of(def_id); } @@ -790,10 +790,10 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) { | hir::ItemKind::Const(..) | hir::ItemKind::Fn(..) => { tcx.ensure().generics_of(def_id); - tcx.ensure().type_of(def_id); + tcx.ensure().try_type_of(def_id); tcx.ensure().predicates_of(def_id); match it.kind { - hir::ItemKind::Fn(..) => tcx.ensure().fn_sig(def_id), + hir::ItemKind::Fn(..) => tcx.ensure().try_fn_sig(def_id), hir::ItemKind::OpaqueTy(..) => tcx.ensure().item_bounds(def_id), _ => (), } @@ -807,16 +807,16 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) { match trait_item.kind { hir::TraitItemKind::Fn(..) => { - tcx.ensure().type_of(trait_item_id.def_id); - tcx.ensure().fn_sig(trait_item_id.def_id); + tcx.ensure().try_type_of(trait_item_id.def_id); + tcx.ensure().try_fn_sig(trait_item_id.def_id); } hir::TraitItemKind::Const(.., Some(_)) => { - tcx.ensure().type_of(trait_item_id.def_id); + tcx.ensure().try_type_of(trait_item_id.def_id); } hir::TraitItemKind::Const(..) => { - tcx.ensure().type_of(trait_item_id.def_id); + tcx.ensure().try_type_of(trait_item_id.def_id); // Account for `const C: _;`. let mut visitor = PlaceholderHirTyCollector::default(); visitor.visit_trait_item(trait_item); @@ -825,7 +825,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) { hir::TraitItemKind::Type(_, Some(_)) => { tcx.ensure().item_bounds(trait_item_id.def_id); - tcx.ensure().type_of(trait_item_id.def_id); + tcx.ensure().try_type_of(trait_item_id.def_id); // Account for `type T = _;`. let mut visitor = PlaceholderHirTyCollector::default(); visitor.visit_trait_item(trait_item); @@ -849,12 +849,12 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) { fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::ImplItemId) { let def_id = impl_item_id.def_id; tcx.ensure().generics_of(def_id); - tcx.ensure().type_of(def_id); + tcx.ensure().try_type_of(def_id); tcx.ensure().predicates_of(def_id); let impl_item = tcx.hir().impl_item(impl_item_id); match impl_item.kind { hir::ImplItemKind::Fn(..) => { - tcx.ensure().fn_sig(def_id); + tcx.ensure().try_fn_sig(def_id); } hir::ImplItemKind::TyAlias(_) => { // Account for `type T = _;` @@ -870,7 +870,7 @@ fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::ImplItemId) { fn convert_variant_ctor(tcx: TyCtxt<'_>, ctor_id: hir::HirId) { let def_id = tcx.hir().local_def_id(ctor_id); tcx.ensure().generics_of(def_id); - tcx.ensure().type_of(def_id); + tcx.ensure().try_type_of(def_id); tcx.ensure().predicates_of(def_id); } @@ -908,7 +908,7 @@ fn convert_enum_variant_types(tcx: TyCtxt<'_>, def_id: DefId, variants: &[hir::V for f in variant.data.fields() { let def_id = tcx.hir().local_def_id(f.hir_id); tcx.ensure().generics_of(def_id); - tcx.ensure().type_of(def_id); + tcx.ensure().try_type_of(def_id); tcx.ensure().predicates_of(def_id); } @@ -1631,7 +1631,7 @@ pub fn get_infer_ret_ty(output: &'hir hir::FnRetTy<'hir>) -> Option<&'hir hir::T None } -fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { +fn try_fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> Result, String> { use rustc_hir::Node::*; use rustc_hir::*; @@ -1640,7 +1640,8 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { let icx = ItemCtxt::new(tcx, def_id.to_def_id()); - match tcx.hir().get(hir_id) { + let node = tcx.hir().find(hir_id).ok_or_else(|| "not found in HIR map".to_owned())?; + let sig = match node { TraitItem(hir::TraitItem { kind: TraitItemKind::Fn(sig, TraitFn::Provided(_)), ident, @@ -1749,15 +1750,17 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { // `sig` method on the `ClosureSubsts`: // // substs.as_closure().sig(def_id, tcx) - bug!( - "to get the signature of a closure, use `substs.as_closure().sig()` not `fn_sig()`", + return Err( + "to get the signature of a closure, use `substs.as_closure().sig()` not `fn_sig()`" + .to_owned(), ); } - x => { - bug!("unexpected sort of node in fn_sig(): {:?}", x); + _ => { + return Err(format!("unexpected sort of node in fn_sig()")); } - } + }; + Ok(sig) } fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option> { diff --git a/compiler/rustc_typeck/src/collect/item_bounds.rs b/compiler/rustc_typeck/src/collect/item_bounds.rs index fe18dc5ed0c69..e43ca0b030ab6 100644 --- a/compiler/rustc_typeck/src/collect/item_bounds.rs +++ b/compiler/rustc_typeck/src/collect/item_bounds.rs @@ -97,7 +97,7 @@ pub(super) fn explicit_item_bounds( span, .. }) => opaque_type_bounds(tcx, def_id, bounds, *span), - _ => bug!("item_bounds called on {:?}", def_id), + _ => &[], } } diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index 3f2f244e44fd2..3d4c5f3e3c875 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -250,7 +250,7 @@ fn get_path_containing_arg_in_pat<'hir>( arg_path } -pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { +pub(super) fn try_type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Result, String> { let def_id = def_id.expect_local(); use rustc_hir::*; @@ -258,7 +258,8 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { let icx = ItemCtxt::new(tcx, def_id.to_def_id()); - match tcx.hir().get(hir_id) { + let node = tcx.hir().find(hir_id).ok_or_else(|| format!("Not found in HIR: {:?}", hir_id))?; + let ty = match node { Node::TraitItem(item) => match item.kind { TraitItemKind::Fn(..) => { let substs = InternalSubsts::identity_for_item(tcx, def_id.to_def_id()); @@ -275,7 +276,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { .unwrap_or_else(|| icx.to_ty(ty)), TraitItemKind::Type(_, Some(ref ty)) => icx.to_ty(ty), TraitItemKind::Type(_, None) => { - span_bug!(item.span, "associated type missing default"); + return Err("associated type missing default".to_owned()); } }, @@ -368,11 +369,10 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { | ItemKind::GlobalAsm(..) | ItemKind::ExternCrate(..) | ItemKind::Use(..) => { - span_bug!( - item.span, + return Err(format!( "compute_type_of_item: unexpected item type: {:?}", item.kind - ); + )); } } } @@ -388,7 +388,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { Node::Ctor(&ref def) | Node::Variant(Variant { data: ref def, .. }) => match *def { VariantData::Unit(..) | VariantData::Struct(..) => { - tcx.type_of(tcx.hir().get_parent_did(hir_id).to_def_id()) + return tcx.try_type_of(tcx.hir().get_parent_did(hir_id).to_def_id()); } VariantData::Tuple(..) => { let substs = InternalSubsts::identity_for_item(tcx, def_id.to_def_id()); @@ -411,7 +411,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { if let Some(param) = tcx.opt_const_param_of(def_id) { // We defer to `type_of` of the corresponding parameter // for generic arguments. - return tcx.type_of(param); + return tcx.try_type_of(param); } let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id)); @@ -446,13 +446,14 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { Node::GenericParam(param) => match ¶m.kind { GenericParamKind::Type { default: Some(ty), .. } | GenericParamKind::Const { ty, .. } => icx.to_ty(ty), - x => bug!("unexpected non-type Node::GenericParam: {:?}", x), + x => return Err(format!("unexpected non-type Node::GenericParam: {:?}", x)), }, x => { - bug!("unexpected sort of node in type_of_def_id(): {:?}", x); + return Err(format!("unexpected sort of node in type_of_def_id(): {:?}", x)); } - } + }; + Ok(ty) } fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { diff --git a/src/test/incremental/hashes/consts.rs b/src/test/incremental/hashes/consts.rs index 6e0db6a49aae2..2458320440917 100644 --- a/src/test/incremental/hashes/consts.rs +++ b/src/test/incremental/hashes/consts.rs @@ -29,7 +29,7 @@ pub const CONST_VISIBILITY: u8 = 0; const CONST_CHANGE_TYPE_1: i32 = 0; #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] const CONST_CHANGE_TYPE_1: u32 = 0; @@ -39,7 +39,7 @@ const CONST_CHANGE_TYPE_1: u32 = 0; const CONST_CHANGE_TYPE_2: Option = None; #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] const CONST_CHANGE_TYPE_2: Option = None; @@ -99,11 +99,11 @@ mod const_change_type_indirectly { #[cfg(not(cfail1))] use super::ReferencedType2 as Type; - #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] + #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] const CONST_CHANGE_TYPE_INDIRECTLY_1: Type = Type; - #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] + #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] const CONST_CHANGE_TYPE_INDIRECTLY_2: Option = None; } diff --git a/src/test/incremental/hashes/enum_constructors.rs b/src/test/incremental/hashes/enum_constructors.rs index 26ff6b109dc32..c467224ea8da1 100644 --- a/src/test/incremental/hashes/enum_constructors.rs +++ b/src/test/incremental/hashes/enum_constructors.rs @@ -139,7 +139,7 @@ pub mod change_constructor_path_indirectly_struct_like { #[rustc_clean( cfg="cfail2", - except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\ + except="try_fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\ typeck" )] #[rustc_clean(cfg="cfail3")] @@ -232,7 +232,7 @@ pub mod change_constructor_path_indirectly_tuple_like { #[rustc_clean( cfg="cfail2", - except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\ + except="try_fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\ typeck" )] #[rustc_clean(cfg="cfail3")] @@ -309,7 +309,7 @@ pub mod change_constructor_path_indirectly_c_like { #[rustc_clean( cfg="cfail2", - except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\ + except="try_fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\ typeck" )] #[rustc_clean(cfg="cfail3")] diff --git a/src/test/incremental/hashes/enum_defs.rs b/src/test/incremental/hashes/enum_defs.rs index c73c03ca14e56..a39d7b41eee25 100644 --- a/src/test/incremental/hashes/enum_defs.rs +++ b/src/test/incremental/hashes/enum_defs.rs @@ -42,7 +42,7 @@ enum EnumChangeNameCStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumChangeNameCStyleVariant { Variant1, @@ -59,7 +59,7 @@ enum EnumChangeNameTupleStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumChangeNameTupleStyleVariant { Variant1, @@ -76,7 +76,7 @@ enum EnumChangeNameStructStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumChangeNameStructStyleVariant { Variant1, @@ -109,7 +109,7 @@ enum EnumChangeValueCStyleVariant1 { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumChangeValueCStyleVariant1 { Variant1, @@ -125,7 +125,7 @@ enum EnumAddCStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddCStyleVariant { Variant1, @@ -142,7 +142,7 @@ enum EnumRemoveCStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumRemoveCStyleVariant { Variant1, @@ -157,7 +157,7 @@ enum EnumAddTupleStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddTupleStyleVariant { Variant1, @@ -174,7 +174,7 @@ enum EnumRemoveTupleStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumRemoveTupleStyleVariant { Variant1, @@ -189,7 +189,7 @@ enum EnumAddStructStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddStructStyleVariant { Variant1, @@ -206,7 +206,7 @@ enum EnumRemoveStructStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumRemoveStructStyleVariant { Variant1, @@ -257,7 +257,7 @@ enum EnumChangeFieldNameStructStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumChangeFieldNameStructStyleVariant { Variant1 { a: u32, c: u32 }, @@ -289,7 +289,7 @@ enum EnumChangeFieldOrderStructStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumChangeFieldOrderStructStyleVariant { Variant1 { b: f32, a: u32 }, @@ -304,7 +304,7 @@ enum EnumAddFieldTupleStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddFieldTupleStyleVariant { Variant1(u32, u32, u32), @@ -319,7 +319,7 @@ enum EnumAddFieldStructStyleVariant { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddFieldStructStyleVariant { Variant1 { a: u32, b: u32, c: u32 }, @@ -353,7 +353,7 @@ enum EnumAddReprC { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="type_of")] +#[rustc_clean(cfg="cfail2", except="try_type_of")] #[rustc_clean(cfg="cfail3")] #[repr(C)] enum EnumAddReprC { @@ -435,7 +435,7 @@ enum EnumAddLifetimeParameterBound<'a, 'b> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2", except="generics_of,type_of")] +#[rustc_dirty(cfg="cfail2", except="generics_of,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddLifetimeParameterBound<'a, 'b: 'a> { Variant1(&'a u32), @@ -450,7 +450,7 @@ enum EnumAddLifetimeBoundToParameter<'a, T> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2", except="type_of")] +#[rustc_dirty(cfg="cfail2", except="try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddLifetimeBoundToParameter<'a, T: 'a> { Variant1(T), @@ -482,7 +482,7 @@ enum EnumAddLifetimeParameterBoundWhere<'a, 'b> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2", except="generics_of,type_of")] +#[rustc_dirty(cfg="cfail2", except="generics_of,try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddLifetimeParameterBoundWhere<'a, 'b> where 'b: 'a { Variant1(&'a u32), @@ -499,7 +499,7 @@ enum EnumAddLifetimeBoundToParameterWhere<'a, T> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2", except="type_of")] +#[rustc_dirty(cfg="cfail2", except="try_type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddLifetimeBoundToParameterWhere<'a, T> where T: 'a { Variant1(T), diff --git a/src/test/incremental/hashes/function_interfaces.rs b/src/test/incremental/hashes/function_interfaces.rs index ed67b2dcb0480..b20364527c111 100644 --- a/src/test/incremental/hashes/function_interfaces.rs +++ b/src/test/incremental/hashes/function_interfaces.rs @@ -22,7 +22,7 @@ pub fn add_parameter() {} #[cfg(not(cfail1))] #[rustc_clean( cfg = "cfail2", - except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig" + except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, try_fn_sig" )] #[rustc_clean(cfg = "cfail3")] pub fn add_parameter(p: i32) {} @@ -45,7 +45,7 @@ pub fn type_of_parameter(p: i32) {} #[cfg(not(cfail1))] #[rustc_clean( cfg = "cfail2", - except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig" + except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, try_fn_sig" )] #[rustc_clean(cfg = "cfail3")] pub fn type_of_parameter(p: i64) {} @@ -58,7 +58,7 @@ pub fn type_of_parameter_ref(p: &i32) {} #[cfg(not(cfail1))] #[rustc_clean( cfg = "cfail2", - except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig" + except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, try_fn_sig" )] #[rustc_clean(cfg = "cfail3")] pub fn type_of_parameter_ref(p: &mut i32) {} @@ -71,7 +71,7 @@ pub fn order_of_parameters(p1: i32, p2: i64) {} #[cfg(not(cfail1))] #[rustc_clean( cfg = "cfail2", - except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig" + except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, try_fn_sig" )] #[rustc_clean(cfg = "cfail3")] pub fn order_of_parameters(p2: i64, p1: i32) {} @@ -84,7 +84,7 @@ pub fn make_unsafe() {} #[cfg(not(cfail1))] #[rustc_clean( cfg = "cfail2", - except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig" + except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, try_fn_sig" )] #[rustc_clean(cfg = "cfail3")] pub unsafe fn make_unsafe() {} @@ -95,7 +95,7 @@ pub unsafe fn make_unsafe() {} pub fn make_extern() {} #[cfg(not(cfail1))] -#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")] +#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, try_fn_sig")] #[rustc_clean(cfg = "cfail3")] pub extern "C" fn make_extern() {} @@ -107,7 +107,7 @@ pub fn type_parameter() {} #[cfg(not(cfail1))] #[rustc_clean( cfg = "cfail2", - except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of" + except = "hir_owner, hir_owner_nodes, generics_of, try_type_of, predicates_of" )] #[rustc_clean(cfg = "cfail3")] pub fn type_parameter() {} @@ -150,7 +150,7 @@ pub fn lifetime_bound<'a, T>() {} #[cfg(not(cfail1))] #[rustc_clean( cfg = "cfail2", - except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of" + except = "hir_owner, hir_owner_nodes, generics_of, try_type_of, predicates_of" )] #[rustc_clean(cfg = "cfail3")] pub fn lifetime_bound<'a, T: 'a>() {} @@ -183,7 +183,7 @@ pub fn second_lifetime_bound<'a, 'b, T: 'a>() {} #[cfg(not(cfail1))] #[rustc_clean( cfg = "cfail2", - except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of" + except = "hir_owner, hir_owner_nodes, generics_of, try_type_of, predicates_of" )] #[rustc_clean(cfg = "cfail3")] pub fn second_lifetime_bound<'a, 'b, T: 'a + 'b>() {} @@ -241,7 +241,7 @@ pub fn return_impl_trait() -> i32 { } #[cfg(not(cfail1))] -#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")] +#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, try_fn_sig")] #[rustc_clean(cfg = "cfail3")] pub fn return_impl_trait() -> impl Clone { 0 @@ -274,7 +274,7 @@ pub mod change_return_type_indirectly { #[rustc_clean( cfg = "cfail2", - except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig" + except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, try_fn_sig" )] #[rustc_clean(cfg = "cfail3")] pub fn indirect_return_type() -> ReturnType { @@ -292,7 +292,7 @@ pub mod change_parameter_type_indirectly { #[rustc_clean( cfg = "cfail2", - except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig" + except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, try_fn_sig" )] #[rustc_clean(cfg = "cfail3")] pub fn indirect_parameter_type(p: ParameterType) {} diff --git a/src/test/incremental/hashes/inherent_impls.rs b/src/test/incremental/hashes/inherent_impls.rs index ae8f2ace217dc..e819ae858c97f 100644 --- a/src/test/incremental/hashes/inherent_impls.rs +++ b/src/test/incremental/hashes/inherent_impls.rs @@ -103,7 +103,7 @@ impl Foo { #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] #[rustc_clean(cfg="cfail3")] impl Foo { - #[rustc_dirty(cfg="cfail2", except="type_of,predicates_of,promoted_mir")] + #[rustc_dirty(cfg="cfail2", except="try_type_of,predicates_of,promoted_mir")] #[rustc_clean(cfg="cfail3")] pub fn method_selfness(&self) { } } @@ -120,7 +120,7 @@ impl Foo { impl Foo { #[rustc_clean( cfg="cfail2", - except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir" + except="hir_owner,hir_owner_nodes,try_fn_sig,typeck,optimized_mir" )] #[rustc_clean(cfg="cfail3")] pub fn method_selfmutness(&mut self) { } @@ -160,7 +160,7 @@ impl Foo { impl Foo { #[rustc_clean( cfg="cfail2", - except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir" + except="hir_owner,hir_owner_nodes,try_fn_sig,typeck,optimized_mir" )] #[rustc_clean(cfg="cfail3")] pub fn add_method_parameter(&self, _: i32) { } @@ -197,7 +197,7 @@ impl Foo { impl Foo { #[rustc_clean( cfg="cfail2", - except="hir_owner,hir_owner_nodes,fn_sig,optimized_mir,typeck")] + except="hir_owner,hir_owner_nodes,try_fn_sig,optimized_mir,typeck")] #[rustc_clean(cfg="cfail3")] pub fn change_method_return_type(&self) -> u8 { 0 } } @@ -251,7 +251,7 @@ impl Foo { impl Foo { #[rustc_clean( cfg="cfail2", - except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir" + except="hir_owner,hir_owner_nodes,try_fn_sig,typeck,optimized_mir" )] #[rustc_clean(cfg="cfail3")] pub unsafe fn make_method_unsafe(&self) { } @@ -269,7 +269,7 @@ impl Foo { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl Foo { - #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck")] + #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_fn_sig,typeck")] #[rustc_clean(cfg="cfail3")] pub extern "C" fn make_method_extern(&self) { } } @@ -286,7 +286,7 @@ impl Foo { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl Foo { - #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck")] + #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_fn_sig,typeck")] #[rustc_clean(cfg="cfail3")] pub extern "system" fn change_method_calling_convention(&self) { } } @@ -340,7 +340,7 @@ impl Foo { // appear dirty, that might be the cause. -nmatsakis #[rustc_clean( cfg="cfail2", - except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of", + except="hir_owner,hir_owner_nodes,generics_of,predicates_of,try_type_of", )] #[rustc_clean(cfg="cfail3")] pub fn add_type_parameter_to_method(&self) { } @@ -360,7 +360,7 @@ impl Foo { impl Foo { #[rustc_clean( cfg="cfail2", - except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of" + except="hir_owner,hir_owner_nodes,generics_of,predicates_of,try_type_of" )] #[rustc_clean(cfg="cfail3")] pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b: 'a>(&self) { } @@ -388,7 +388,7 @@ impl Foo { // body will be affected. So if you start to see `typeck` // appear dirty, that might be the cause. -nmatsakis #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,\ - type_of")] + try_type_of")] #[rustc_clean(cfg="cfail3")] pub fn add_lifetime_bound_to_type_param_of_method<'a, T: 'a>(&self) { } } @@ -453,7 +453,7 @@ impl Bar { impl Bar { #[rustc_clean( cfg="cfail2", - except="generics_of,fn_sig,typeck,type_of,optimized_mir" + except="generics_of,try_fn_sig,typeck,try_type_of,optimized_mir" )] #[rustc_clean(cfg="cfail3")] pub fn add_type_parameter_to_impl(&self) { } @@ -471,7 +471,7 @@ impl Bar { #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] #[rustc_clean(cfg="cfail3")] impl Bar { - #[rustc_clean(cfg="cfail2", except="fn_sig,optimized_mir,typeck")] + #[rustc_clean(cfg="cfail2", except="try_fn_sig,optimized_mir,typeck")] #[rustc_clean(cfg="cfail3")] pub fn change_impl_self_type(&self) { } } diff --git a/src/test/incremental/hashes/statics.rs b/src/test/incremental/hashes/statics.rs index 6f4089c60fe23..d121872ed78fd 100644 --- a/src/test/incremental/hashes/statics.rs +++ b/src/test/incremental/hashes/statics.rs @@ -74,7 +74,7 @@ static STATIC_THREAD_LOCAL: u8 = 0; static STATIC_CHANGE_TYPE_1: i16 = 0; #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] static STATIC_CHANGE_TYPE_1: u64 = 0; @@ -84,7 +84,7 @@ static STATIC_CHANGE_TYPE_1: u64 = 0; static STATIC_CHANGE_TYPE_2: Option = None; #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] static STATIC_CHANGE_TYPE_2: Option = None; @@ -144,11 +144,11 @@ mod static_change_type_indirectly { #[cfg(not(cfail1))] use super::ReferencedType2 as Type; - #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] + #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] static STATIC_CHANGE_TYPE_INDIRECTLY_1: Type = Type; - #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")] + #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,try_type_of")] #[rustc_clean(cfg="cfail3")] static STATIC_CHANGE_TYPE_INDIRECTLY_2: Option = None; } diff --git a/src/test/incremental/hashes/struct_constructors.rs b/src/test/incremental/hashes/struct_constructors.rs index edec03d4f057e..b1264c1d6e23d 100644 --- a/src/test/incremental/hashes/struct_constructors.rs +++ b/src/test/incremental/hashes/struct_constructors.rs @@ -173,7 +173,7 @@ pub mod change_constructor_path_indirectly_regular_struct { #[rustc_clean( cfg="cfail2", - except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck" + except="try_fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck" )] #[rustc_clean(cfg="cfail3")] pub fn function() -> Struct { @@ -230,7 +230,7 @@ pub mod change_constructor_path_indirectly_tuple_struct { #[rustc_clean( cfg="cfail2", - except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck" + except="try_fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck" )] #[rustc_clean(cfg="cfail3")] pub fn function() -> Struct { diff --git a/src/test/incremental/hashes/struct_defs.rs b/src/test/incremental/hashes/struct_defs.rs index 1339a1e5bf216..97f32b1437973 100644 --- a/src/test/incremental/hashes/struct_defs.rs +++ b/src/test/incremental/hashes/struct_defs.rs @@ -26,12 +26,12 @@ pub struct LayoutPacked; #[cfg(not(cfail1))] #[rustc_clean(label="hir_owner", cfg="cfail2")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] +#[rustc_dirty(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] #[repr(packed)] @@ -43,12 +43,12 @@ struct LayoutC; #[cfg(not(cfail1))] #[rustc_clean(label="hir_owner", cfg="cfail2")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] +#[rustc_dirty(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] #[repr(C)] @@ -63,12 +63,12 @@ struct TupleStructFieldType(i32); #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] +#[rustc_clean(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] // Note that changing the type of a field does not change the type of the struct or enum, but @@ -86,12 +86,12 @@ struct TupleStructAddField(i32); #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] +#[rustc_dirty(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct TupleStructAddField( @@ -108,12 +108,12 @@ struct TupleStructFieldVisibility(char); #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] +#[rustc_dirty(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct TupleStructFieldVisibility(pub char); @@ -127,12 +127,12 @@ struct RecordStructFieldType { x: f32 } #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] +#[rustc_clean(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] // Note that changing the type of a field does not change the type of the struct or enum, but @@ -150,12 +150,12 @@ struct RecordStructFieldName { x: f32 } #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] +#[rustc_dirty(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct RecordStructFieldName { y: f32 } @@ -169,12 +169,12 @@ struct RecordStructAddField { x: f32 } #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] +#[rustc_dirty(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct RecordStructAddField { @@ -190,12 +190,12 @@ struct RecordStructFieldVisibility { x: f32 } #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] +#[rustc_dirty(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct RecordStructFieldVisibility { @@ -211,12 +211,12 @@ struct AddLifetimeParameter<'a>(&'a f32, &'a f64); #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] +#[rustc_dirty(label="try_type_of", cfg="cfail2")] #[rustc_dirty(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct AddLifetimeParameter<'a, 'b>(&'a f32, &'b f64); @@ -230,12 +230,12 @@ struct AddLifetimeParameterBound<'a, 'b>(&'a f32, &'b f64); #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] +#[rustc_clean(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_dirty(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct AddLifetimeParameterBound<'a, 'b: 'a>( @@ -249,12 +249,12 @@ struct AddLifetimeParameterBoundWhereClause<'a, 'b>(&'a f32, &'b f64); #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] +#[rustc_clean(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_dirty(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct AddLifetimeParameterBoundWhereClause<'a, 'b>( @@ -271,12 +271,12 @@ struct AddTypeParameter(T1, T1); #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] +#[rustc_dirty(label="try_type_of", cfg="cfail2")] #[rustc_dirty(label="generics_of", cfg="cfail2")] #[rustc_dirty(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct AddTypeParameter( @@ -295,12 +295,12 @@ struct AddTypeParameterBound(T); #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] +#[rustc_clean(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_dirty(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct AddTypeParameterBound( @@ -314,12 +314,12 @@ struct AddTypeParameterBoundWhereClause(T); #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] +#[rustc_clean(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_dirty(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct AddTypeParameterBoundWhereClause( @@ -334,12 +334,12 @@ struct AddTypeParameterBoundWhereClause( // Note: there is no #[cfg(...)], so this is ALWAYS compiled #[rustc_clean(label="hir_owner", cfg="cfail2")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] +#[rustc_clean(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] pub struct EmptyStruct; @@ -353,12 +353,12 @@ struct Visibility; #[cfg(not(cfail1))] #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] +#[rustc_clean(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] +#[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] pub struct Visibility; @@ -375,12 +375,12 @@ mod tuple_struct_change_field_type_indirectly { #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="type_of", cfg="cfail2")] + #[rustc_clean(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] - #[rustc_clean(label="type_of", cfg="cfail3")] + #[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct TupleStruct( @@ -398,12 +398,12 @@ mod record_struct_change_field_type_indirectly { #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="type_of", cfg="cfail2")] + #[rustc_clean(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_clean(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] - #[rustc_clean(label="type_of", cfg="cfail3")] + #[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct RecordStruct { @@ -426,12 +426,12 @@ mod change_trait_bound_indirectly { #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="type_of", cfg="cfail2")] + #[rustc_clean(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_dirty(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] - #[rustc_clean(label="type_of", cfg="cfail3")] + #[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct Struct(T); @@ -446,12 +446,12 @@ mod change_trait_bound_indirectly_in_where_clause { #[rustc_dirty(label="hir_owner", cfg="cfail2")] #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="type_of", cfg="cfail2")] + #[rustc_clean(label="try_type_of", cfg="cfail2")] #[rustc_clean(label="generics_of", cfg="cfail2")] #[rustc_dirty(label="predicates_of", cfg="cfail2")] #[rustc_clean(label="hir_owner", cfg="cfail3")] #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] - #[rustc_clean(label="type_of", cfg="cfail3")] + #[rustc_clean(label="try_type_of", cfg="cfail3")] #[rustc_clean(label="generics_of", cfg="cfail3")] #[rustc_clean(label="predicates_of", cfg="cfail3")] struct Struct(T) where T : Trait; diff --git a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.rs b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.rs index b2edc1a1f66ca..6175b7df1107a 100644 --- a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.rs +++ b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.rs @@ -3,7 +3,6 @@ trait Foo> { //~^ ERROR cycle detected - //~| ERROR cycle detected } fn main() { } diff --git a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr index 58c458709a839..3450fa4f377c4 100644 --- a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr +++ b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr @@ -11,19 +11,6 @@ note: cycle used when collecting item types in top-level module LL | trait Foo> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0391]: cycle detected when computing type of `Foo::X` - --> $DIR/cycle-trait-default-type-trait.rs:4:23 - | -LL | trait Foo> { - | ^^^ - | - = note: ...which again requires computing type of `Foo::X`, completing the cycle -note: cycle used when collecting item types in top-level module - --> $DIR/cycle-trait-default-type-trait.rs:4:1 - | -LL | trait Foo> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/dep-graph/dep-graph-struct-signature.rs b/src/test/ui/dep-graph/dep-graph-struct-signature.rs index 7ef6fac48c3a6..ab40e917f84b2 100644 --- a/src/test/ui/dep-graph/dep-graph-struct-signature.rs +++ b/src/test/ui/dep-graph/dep-graph-struct-signature.rs @@ -24,63 +24,63 @@ struct WontChange { mod signatures { use WillChange; - #[rustc_then_this_would_need(type_of)] //~ ERROR no path + #[rustc_then_this_would_need(try_type_of)] //~ ERROR no path #[rustc_then_this_would_need(associated_item)] //~ ERROR no path #[rustc_then_this_would_need(trait_def)] //~ ERROR no path trait Bar { - #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK + #[rustc_then_this_would_need(try_fn_sig)] //~ ERROR OK fn do_something(x: WillChange); } - #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK + #[rustc_then_this_would_need(try_fn_sig)] //~ ERROR OK #[rustc_then_this_would_need(typeck)] //~ ERROR OK fn some_fn(x: WillChange) { } - #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK + #[rustc_then_this_would_need(try_fn_sig)] //~ ERROR OK #[rustc_then_this_would_need(typeck)] //~ ERROR OK fn new_foo(x: u32, y: u32) -> WillChange { WillChange { x: x, y: y } } - #[rustc_then_this_would_need(type_of)] //~ ERROR OK + #[rustc_then_this_would_need(try_type_of)] //~ ERROR OK impl WillChange { - #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK + #[rustc_then_this_would_need(try_fn_sig)] //~ ERROR OK #[rustc_then_this_would_need(typeck)] //~ ERROR OK fn new(x: u32, y: u32) -> WillChange { loop { } } } - #[rustc_then_this_would_need(type_of)] //~ ERROR OK + #[rustc_then_this_would_need(try_type_of)] //~ ERROR OK impl WillChange { - #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK + #[rustc_then_this_would_need(try_fn_sig)] //~ ERROR OK #[rustc_then_this_would_need(typeck)] //~ ERROR OK fn method(&self, x: u32) { } } struct WillChanges { - #[rustc_then_this_would_need(type_of)] //~ ERROR OK + #[rustc_then_this_would_need(try_type_of)] //~ ERROR OK x: WillChange, - #[rustc_then_this_would_need(type_of)] //~ ERROR OK + #[rustc_then_this_would_need(try_type_of)] //~ ERROR OK y: WillChange } // The fields change, not the type itself. - #[rustc_then_this_would_need(type_of)] //~ ERROR no path + #[rustc_then_this_would_need(try_type_of)] //~ ERROR no path fn indirect(x: WillChanges) { } } mod invalid_signatures { use WontChange; - #[rustc_then_this_would_need(type_of)] //~ ERROR no path + #[rustc_then_this_would_need(try_type_of)] //~ ERROR no path trait A { - #[rustc_then_this_would_need(fn_sig)] //~ ERROR no path + #[rustc_then_this_would_need(try_fn_sig)] //~ ERROR no path fn do_something_else_twice(x: WontChange); } - #[rustc_then_this_would_need(fn_sig)] //~ ERROR no path + #[rustc_then_this_would_need(try_fn_sig)] //~ ERROR no path fn b(x: WontChange) { } - #[rustc_then_this_would_need(fn_sig)] //~ ERROR no path from `WillChange` + #[rustc_then_this_would_need(try_fn_sig)] //~ ERROR no path from `WillChange` #[rustc_then_this_would_need(typeck)] //~ ERROR no path from `WillChange` fn c(x: u32) { } } diff --git a/src/test/ui/dep-graph/dep-graph-struct-signature.stderr b/src/test/ui/dep-graph/dep-graph-struct-signature.stderr index 9d1644a00d002..328d67d04e502 100644 --- a/src/test/ui/dep-graph/dep-graph-struct-signature.stderr +++ b/src/test/ui/dep-graph/dep-graph-struct-signature.stderr @@ -1,8 +1,8 @@ -error: no path from `WillChange` to `type_of` +error: no path from `WillChange` to `try_type_of` --> $DIR/dep-graph-struct-signature.rs:27:5 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `WillChange` to `associated_item` --> $DIR/dep-graph-struct-signature.rs:28:5 @@ -19,8 +19,8 @@ LL | #[rustc_then_this_would_need(trait_def)] error: OK --> $DIR/dep-graph-struct-signature.rs:35:5 | -LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_fn_sig)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-struct-signature.rs:36:5 @@ -31,8 +31,8 @@ LL | #[rustc_then_this_would_need(typeck)] error: OK --> $DIR/dep-graph-struct-signature.rs:39:5 | -LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_fn_sig)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-struct-signature.rs:40:5 @@ -43,50 +43,50 @@ LL | #[rustc_then_this_would_need(typeck)] error: OK --> $DIR/dep-graph-struct-signature.rs:45:5 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-struct-signature.rs:52:5 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-struct-signature.rs:60:9 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-struct-signature.rs:62:9 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `WillChange` to `type_of` +error: no path from `WillChange` to `try_type_of` --> $DIR/dep-graph-struct-signature.rs:67:5 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `WillChange` to `type_of` +error: no path from `WillChange` to `try_type_of` --> $DIR/dep-graph-struct-signature.rs:74:5 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `WillChange` to `fn_sig` +error: no path from `WillChange` to `try_fn_sig` --> $DIR/dep-graph-struct-signature.rs:80:5 | -LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_fn_sig)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `WillChange` to `fn_sig` +error: no path from `WillChange` to `try_fn_sig` --> $DIR/dep-graph-struct-signature.rs:83:5 | -LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_fn_sig)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `WillChange` to `typeck` --> $DIR/dep-graph-struct-signature.rs:84:5 @@ -97,20 +97,20 @@ LL | #[rustc_then_this_would_need(typeck)] error: OK --> $DIR/dep-graph-struct-signature.rs:31:9 | -LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_fn_sig)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `WillChange` to `fn_sig` +error: no path from `WillChange` to `try_fn_sig` --> $DIR/dep-graph-struct-signature.rs:76:9 | -LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_fn_sig)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-struct-signature.rs:47:9 | -LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_fn_sig)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-struct-signature.rs:48:9 @@ -121,8 +121,8 @@ LL | #[rustc_then_this_would_need(typeck)] error: OK --> $DIR/dep-graph-struct-signature.rs:54:9 | -LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_fn_sig)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-struct-signature.rs:55:9 diff --git a/src/test/ui/dep-graph/dep-graph-type-alias.rs b/src/test/ui/dep-graph/dep-graph-type-alias.rs index c9151ce79c5f6..376696e6e7072 100644 --- a/src/test/ui/dep-graph/dep-graph-type-alias.rs +++ b/src/test/ui/dep-graph/dep-graph-type-alias.rs @@ -14,41 +14,41 @@ type TypeAlias = u32; // The type alias directly affects the type of the field, // not the enclosing struct: -#[rustc_then_this_would_need(type_of)] //~ ERROR no path +#[rustc_then_this_would_need(try_type_of)] //~ ERROR no path struct Struct { - #[rustc_then_this_would_need(type_of)] //~ ERROR OK + #[rustc_then_this_would_need(try_type_of)] //~ ERROR OK x: TypeAlias, y: u32 } -#[rustc_then_this_would_need(type_of)] //~ ERROR no path +#[rustc_then_this_would_need(try_type_of)] //~ ERROR no path enum Enum { Variant1 { - #[rustc_then_this_would_need(type_of)] //~ ERROR OK + #[rustc_then_this_would_need(try_type_of)] //~ ERROR OK t: TypeAlias }, Variant2(i32) } -#[rustc_then_this_would_need(type_of)] //~ ERROR no path +#[rustc_then_this_would_need(try_type_of)] //~ ERROR no path trait Trait { - #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK + #[rustc_then_this_would_need(try_fn_sig)] //~ ERROR OK fn method(&self, _: TypeAlias); } struct SomeType; -#[rustc_then_this_would_need(type_of)] //~ ERROR no path +#[rustc_then_this_would_need(try_type_of)] //~ ERROR no path impl SomeType { - #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK + #[rustc_then_this_would_need(try_fn_sig)] //~ ERROR OK #[rustc_then_this_would_need(typeck)] //~ ERROR OK fn method(&self, _: TypeAlias) {} } -#[rustc_then_this_would_need(type_of)] //~ ERROR OK +#[rustc_then_this_would_need(try_type_of)] //~ ERROR OK type TypeAlias2 = TypeAlias; -#[rustc_then_this_would_need(fn_sig)] //~ ERROR OK +#[rustc_then_this_would_need(try_fn_sig)] //~ ERROR OK #[rustc_then_this_would_need(typeck)] //~ ERROR OK fn function(_: TypeAlias) { diff --git a/src/test/ui/dep-graph/dep-graph-type-alias.stderr b/src/test/ui/dep-graph/dep-graph-type-alias.stderr index 9baaf746fc210..1bd2f0c87ff77 100644 --- a/src/test/ui/dep-graph/dep-graph-type-alias.stderr +++ b/src/test/ui/dep-graph/dep-graph-type-alias.stderr @@ -1,50 +1,50 @@ -error: no path from `TypeAlias` to `type_of` +error: no path from `TypeAlias` to `try_type_of` --> $DIR/dep-graph-type-alias.rs:17:1 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-type-alias.rs:19:5 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `TypeAlias` to `type_of` +error: no path from `TypeAlias` to `try_type_of` --> $DIR/dep-graph-type-alias.rs:24:1 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-type-alias.rs:27:9 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `TypeAlias` to `type_of` +error: no path from `TypeAlias` to `try_type_of` --> $DIR/dep-graph-type-alias.rs:33:1 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `TypeAlias` to `type_of` +error: no path from `TypeAlias` to `try_type_of` --> $DIR/dep-graph-type-alias.rs:41:1 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-type-alias.rs:48:1 | -LL | #[rustc_then_this_would_need(type_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_type_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-type-alias.rs:51:1 | -LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_fn_sig)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-type-alias.rs:52:1 @@ -55,14 +55,14 @@ LL | #[rustc_then_this_would_need(typeck)] error: OK --> $DIR/dep-graph-type-alias.rs:35:5 | -LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_fn_sig)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-type-alias.rs:43:5 | -LL | #[rustc_then_this_would_need(fn_sig)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(try_fn_sig)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-type-alias.rs:44:5 diff --git a/src/test/ui/impl-trait/auto-trait-leak.rs b/src/test/ui/impl-trait/auto-trait-leak.rs index 087f4582b21c3..c2fbbf94fd666 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.rs +++ b/src/test/ui/impl-trait/auto-trait-leak.rs @@ -12,7 +12,6 @@ fn main() { fn cycle1() -> impl Clone { //~^ ERROR cycle detected send(cycle2().clone()); - //~^ ERROR cannot be sent between threads safely Rc::new(Cell::new(5)) } diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index e578c4b4f819e..3eb141cc2bb55 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -36,37 +36,37 @@ LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`... note: ...which requires computing type of `cycle2::{opaque#0}`... - --> $DIR/auto-trait-leak.rs:20:16 + --> $DIR/auto-trait-leak.rs:19:16 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^ note: ...which requires borrow-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 + --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires processing `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 + --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires processing MIR for `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 + --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires unsafety-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 + --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires building MIR for `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 + --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires type-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 + --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -84,22 +84,6 @@ LL | | Rc::new(String::from("foo")) LL | | } | |_^ -error[E0277]: `Rc` cannot be sent between threads safely - --> $DIR/auto-trait-leak.rs:14:5 - | -LL | fn send(_: T) {} - | ---- required by this bound in `send` -... -LL | send(cycle2().clone()); - | ^^^^ `Rc` cannot be sent between threads safely -... -LL | fn cycle2() -> impl Clone { - | ---------- within this `impl Clone` - | - = help: within `impl Clone`, the trait `Send` is not implemented for `Rc` - = note: required because it appears within the type `impl Clone` - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0277, E0391. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/resolve/resolve-self-in-impl.rs b/src/test/ui/resolve/resolve-self-in-impl.rs index 024fdc51ea318..7192633843814 100644 --- a/src/test/ui/resolve/resolve-self-in-impl.rs +++ b/src/test/ui/resolve/resolve-self-in-impl.rs @@ -12,9 +12,9 @@ impl Tr for S where S: Copy {} // OK impl Tr for S where Self::A: Copy {} // OK impl Tr for Self {} //~ ERROR cycle detected -impl Tr for S {} //~ ERROR cycle detected -impl Self {} //~ ERROR cycle detected -impl S {} //~ ERROR cycle detected -impl Tr for S {} //~ ERROR cycle detected +impl Tr for S {} +impl Self {} +impl S {} +impl Tr for S {} fn main() {} diff --git a/src/test/ui/resolve/resolve-self-in-impl.stderr b/src/test/ui/resolve/resolve-self-in-impl.stderr index 5b5c1834cad19..2026f179e6d42 100644 --- a/src/test/ui/resolve/resolve-self-in-impl.stderr +++ b/src/test/ui/resolve/resolve-self-in-impl.stderr @@ -17,82 +17,6 @@ LL | | LL | | fn main() {} | |____________^ -error[E0391]: cycle detected when computing type of `` - --> $DIR/resolve-self-in-impl.rs:15:15 - | -LL | impl Tr for S {} - | ^^^^ - | - = note: ...which again requires computing type of ``, completing the cycle -note: cycle used when collecting item types in top-level module - --> $DIR/resolve-self-in-impl.rs:1:1 - | -LL | / #![feature(associated_type_defaults)] -LL | | -LL | | struct S(T); -LL | | trait Tr { -... | -LL | | -LL | | fn main() {} - | |____________^ - -error[E0391]: cycle detected when computing type of `` - --> $DIR/resolve-self-in-impl.rs:16:6 - | -LL | impl Self {} - | ^^^^ - | - = note: ...which again requires computing type of ``, completing the cycle -note: cycle used when collecting item types in top-level module - --> $DIR/resolve-self-in-impl.rs:1:1 - | -LL | / #![feature(associated_type_defaults)] -LL | | -LL | | struct S(T); -LL | | trait Tr { -... | -LL | | -LL | | fn main() {} - | |____________^ - -error[E0391]: cycle detected when computing type of `` - --> $DIR/resolve-self-in-impl.rs:17:8 - | -LL | impl S {} - | ^^^^ - | - = note: ...which again requires computing type of ``, completing the cycle -note: cycle used when collecting item types in top-level module - --> $DIR/resolve-self-in-impl.rs:1:1 - | -LL | / #![feature(associated_type_defaults)] -LL | | -LL | | struct S(T); -LL | | trait Tr { -... | -LL | | -LL | | fn main() {} - | |____________^ - -error[E0391]: cycle detected when computing trait implemented by `` - --> $DIR/resolve-self-in-impl.rs:18:1 - | -LL | impl Tr for S {} - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: ...which again requires computing trait implemented by ``, completing the cycle -note: cycle used when collecting item types in top-level module - --> $DIR/resolve-self-in-impl.rs:1:1 - | -LL | / #![feature(associated_type_defaults)] -LL | | -LL | | struct S(T); -LL | | trait Tr { -... | -LL | | -LL | | fn main() {} - | |____________^ - -error: aborting due to 5 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0391`.