Skip to content

Commit 4289514

Browse files
authored
Unrolled build for #152309
Rollup merge of #152309 - rynewang:fix/ice-152158-rtn-trait-alias, r=fmease Fix bound var resolution for trait aliases Fixes #152158 Fixes #152244
2 parents 286fbe5 + 7c5ea7f commit 4289514

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
16951695
| DefKind::Union
16961696
| DefKind::Enum
16971697
| DefKind::TyAlias
1698-
| DefKind::Trait,
1698+
| DefKind::Trait
1699+
| DefKind::TraitAlias,
16991700
def_id,
17001701
) if depth == 0 => Some(def_id),
17011702
_ => None,
@@ -1865,7 +1866,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
18651866
if constraint.gen_args.parenthesized == hir::GenericArgsParentheses::ReturnTypeNotation
18661867
{
18671868
let bound_vars = if let Some(type_def_id) = type_def_id
1868-
&& self.tcx.def_kind(type_def_id) == DefKind::Trait
1869+
&& let DefKind::Trait | DefKind::TraitAlias = self.tcx.def_kind(type_def_id)
18691870
&& let Some((mut bound_vars, assoc_fn)) = BoundVarContext::supertrait_hrtb_vars(
18701871
self.tcx,
18711872
type_def_id,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/152158>.
2+
//@ check-pass
3+
#![feature(return_type_notation, trait_alias)]
4+
5+
trait Tr {
6+
fn f() -> impl Sized;
7+
}
8+
9+
trait Al = Tr;
10+
11+
fn f<T: Al<f(..): Copy>>() {}
12+
13+
fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Check that we're successfully collecting bound vars behind trait aliases.
2+
// Regression test for <https://github.com/rust-lang/rust/issues/152244>.
3+
//@ check-pass
4+
//@ needs-rustc-debug-assertions
5+
#![feature(trait_alias)]
6+
7+
trait A<'a> { type X; }
8+
trait B: for<'a> A<'a> {}
9+
trait C = B;
10+
11+
fn f<T>() where T: C<X: Copy> {}
12+
fn g<T>() where T: C<X: for<'r> A<'r>> {}
13+
14+
fn main() {}

0 commit comments

Comments
 (0)