Skip to content

Commit aa9714b

Browse files
committed
compiler: report error when trait object type param reference self
Fixes rust-lang#139082. Bug: rust-lang#139082 Signed-off-by: xtex <xtexchooser@duck.com>
1 parent 8989165 commit aa9714b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs

+11
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,17 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
352352
b.projection_term = replace_dummy_self_with_error(tcx, b.projection_term, guar);
353353
}
354354

355+
if let Some(term_ty) = &b.term.as_type() {
356+
let references_self = term_ty.walk().any(|arg| arg == dummy_self.into());
357+
if references_self {
358+
let guar = tcx.dcx().span_delayed_bug(
359+
span,
360+
"trait object projection bounds reference `Self`",
361+
);
362+
b.term = replace_dummy_self_with_error(tcx, b.term, guar);
363+
}
364+
}
365+
355366
ty::ExistentialPredicate::Projection(ty::ExistentialProjection::erase_self_ty(
356367
tcx, b,
357368
))

0 commit comments

Comments
 (0)