diff options
| author | Cameron Steffen <cam.steffen94@gmail.com> | 2025-08-13 14:36:13 -0500 |
|---|---|---|
| committer | Cameron Steffen <cam.steffen94@gmail.com> | 2025-09-12 15:14:15 -0500 |
| commit | b995a55cafcbcafec51aba6c567b32161fa9c2f1 (patch) | |
| tree | 853fd2e3bc6faedf1af0f98797144eaba922dfa7 /compiler/rustc_middle/src | |
| parent | 9615ec7d108399501d7d48f4aeac46561ef31fc8 (diff) | |
| download | rust-b995a55cafcbcafec51aba6c567b32161fa9c2f1.tar.gz rust-b995a55cafcbcafec51aba6c567b32161fa9c2f1.zip | |
Don't store defaultness for inherent impl items
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/query/mod.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/assoc.rs | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 2aa32dfa0d8..0e645a3aae4 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -1881,6 +1881,7 @@ rustc_queries! { } /// Returns whether the impl or associated function has the `default` keyword. + /// Note: This will ICE on inherent impl items. Consider using `AssocItem::defaultness`. query defaultness(def_id: DefId) -> hir::Defaultness { desc { |tcx| "looking up whether `{}` has `default`", tcx.def_path_str(def_id) } separate_provide_extern diff --git a/compiler/rustc_middle/src/ty/assoc.rs b/compiler/rustc_middle/src/ty/assoc.rs index 60181783f9b..768646c7630 100644 --- a/compiler/rustc_middle/src/ty/assoc.rs +++ b/compiler/rustc_middle/src/ty/assoc.rs @@ -53,7 +53,10 @@ impl AssocItem { /// /// [`type_of`]: crate::ty::TyCtxt::type_of pub fn defaultness(&self, tcx: TyCtxt<'_>) -> hir::Defaultness { - tcx.defaultness(self.def_id) + match self.container { + AssocContainer::InherentImpl => hir::Defaultness::Final, + AssocContainer::Trait | AssocContainer::TraitImpl(_) => tcx.defaultness(self.def_id), + } } pub fn expect_trait_impl(&self) -> Result<DefId, ErrorGuaranteed> { |
