diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-04-17 05:44:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-17 05:44:53 +0200 |
| commit | 90af17ddcbd39ff80ee4264e908eda2e2c57de98 (patch) | |
| tree | 7420aa12af8259bfdb38dd10429f547d9ee5a490 /compiler/rustc_hir_analysis/src | |
| parent | 8229a34102540924347b8a0fd81cba895f623473 (diff) | |
| parent | 6288a721f5ea59a59b4304a7b70c92d7755e8aa8 (diff) | |
| download | rust-90af17ddcbd39ff80ee4264e908eda2e2c57de98.tar.gz rust-90af17ddcbd39ff80ee4264e908eda2e2c57de98.zip | |
Rollup merge of #123997 - compiler-errors:self-res, r=fmease
Delay span bug when `Self` kw resolves to `DefKind::{Mod,Trait}`
Catch the case where `kw::Self` is recovered in the parser and causes us to subsequently resolve `&self`'s implicit type to something that's not a type.
This check could be made more accurate, though I'm not sure how hard we have to try here.
Fixes #123988
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 0fe02856a62..0d5a295ca96 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -1866,6 +1866,17 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { self.set_tainted_by_errors(e); Ty::new_error(self.tcx(), e) } + Res::Def(..) => { + assert_eq!( + path.segments.get(0).map(|seg| seg.ident.name), + Some(kw::SelfUpper), + "only expected incorrect resolution for `Self`" + ); + Ty::new_error( + self.tcx(), + self.tcx().dcx().span_delayed_bug(span, "incorrect resolution for `Self`"), + ) + } _ => span_bug!(span, "unexpected resolution: {:?}", path.res), } } |
