Rollup merge of #152309 - rynewang:fix/ice-152158-rtn-trait-alias, r=fmease
Fix bound var resolution for trait aliases Fixes rust-lang/rust#152158 Fixes rust-lang/rust#152244
This commit is contained in:
commit
6521fcf018
3 changed files with 30 additions and 2 deletions
|
|
@ -1695,7 +1695,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
| DefKind::Union
|
||||
| DefKind::Enum
|
||||
| DefKind::TyAlias
|
||||
| DefKind::Trait,
|
||||
| DefKind::Trait
|
||||
| DefKind::TraitAlias,
|
||||
def_id,
|
||||
) if depth == 0 => Some(def_id),
|
||||
_ => None,
|
||||
|
|
@ -1865,7 +1866,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
if constraint.gen_args.parenthesized == hir::GenericArgsParentheses::ReturnTypeNotation
|
||||
{
|
||||
let bound_vars = if let Some(type_def_id) = type_def_id
|
||||
&& self.tcx.def_kind(type_def_id) == DefKind::Trait
|
||||
&& let DefKind::Trait | DefKind::TraitAlias = self.tcx.def_kind(type_def_id)
|
||||
&& let Some((mut bound_vars, assoc_fn)) = BoundVarContext::supertrait_hrtb_vars(
|
||||
self.tcx,
|
||||
type_def_id,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
// Regression test for <https://github.com/rust-lang/rust/issues/152158>.
|
||||
//@ check-pass
|
||||
#![feature(return_type_notation, trait_alias)]
|
||||
|
||||
trait Tr {
|
||||
fn f() -> impl Sized;
|
||||
}
|
||||
|
||||
trait Al = Tr;
|
||||
|
||||
fn f<T: Al<f(..): Copy>>() {}
|
||||
|
||||
fn main() {}
|
||||
14
tests/ui/associated-type-bounds/trait-alias-bound-vars.rs
Normal file
14
tests/ui/associated-type-bounds/trait-alias-bound-vars.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Check that we're successfully collecting bound vars behind trait aliases.
|
||||
// Regression test for <https://github.com/rust-lang/rust/issues/152244>.
|
||||
//@ check-pass
|
||||
//@ needs-rustc-debug-assertions
|
||||
#![feature(trait_alias)]
|
||||
|
||||
trait A<'a> { type X; }
|
||||
trait B: for<'a> A<'a> {}
|
||||
trait C = B;
|
||||
|
||||
fn f<T>() where T: C<X: Copy> {}
|
||||
fn g<T>() where T: C<X: for<'r> A<'r>> {}
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue