Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions crates/hir-ty/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ impl<'db, 'a> TyLoweringContext<'db, 'a> {
bound: &'b TypeBound,
self_ty: Ty<'db>,
ignore_bindings: bool,
) -> impl Iterator<Item = (Clause<'db>, GenericPredicateSource)> + use<'b, 'a, 'db> {
) -> impl Iterator<Item = (Clause<'db>, GenericPredicateSource)> + use<'db> {
let interner = self.interner;
let meta_sized = self.lang_items.MetaSized;
let pointee_sized = self.lang_items.PointeeSized;
Expand Down Expand Up @@ -1030,7 +1030,17 @@ impl<'db, 'a> TyLoweringContext<'db, 'a> {

for b in bounds {
let db = self.db;
self.lower_type_bound(b, dummy_self_ty, false).for_each(|(b, _)| {
match b {
TypeBound::Path(_, TraitBoundModifier::None) => {

@Wilfred Wilfred Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm understanding #22927 correctly, I think this can change to TypeBound::Path(None, _, TraitBoundModifier::None) => if that PR merges first. I think the PRs are strictly complementary.

View changes since the review

// `dyn Trait<'a>` is an existential predicate that introduces a binder.
self.with_shifted_in(&[], |ctx| {
ctx.lower_type_bound(b, dummy_self_ty, false)
})
.0
}
_ => self.lower_type_bound(b, dummy_self_ty, false),
}
.for_each(|(b, _)| {
match b.kind().skip_binder() {
rustc_type_ir::ClauseKind::Trait(t) => {
let id = t.def_id();
Expand Down
10 changes: 10 additions & 0 deletions crates/hir-ty/src/tests/regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3138,3 +3138,13 @@ fn main() {
"#,
);
}

#[test]
fn dyn_trait_binder_inside_fn_ptr() {
check_no_mismatches(
r#"
trait Trait<'a> {}
fn f<'a>(_: fn() -> &'a dyn Trait<'a>) {}
"#,
);
}