Skip to content

Commit

Permalink
Rollup merge of #120956 - compiler-errors:clean-type-alias, r=Guillau…
Browse files Browse the repository at this point in the history
…meGomez

Clean inlined type alias with correct param-env

We were cleaning the `hir::Ty` of a type alias item in the param-env of the item that *references* the type alias, and not the alias's own param-env.

Fixes #120954
  • Loading branch information
matthiaskrgr authored Feb 12, 2024
2 parents 8ec144d + fc7693d commit a0156e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,9 @@ fn maybe_expand_private_type_alias<'tcx>(
}
}

Some(cx.enter_alias(args, def_id.to_def_id(), |cx| clean_ty(&ty, cx)))
Some(cx.enter_alias(args, def_id.to_def_id(), |cx| {
cx.with_param_env(def_id.to_def_id(), |cx| clean_ty(&ty, cx))
}))
}

pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type {
Expand Down
14 changes: 14 additions & 0 deletions tests/rustdoc-ui/normalize-in-inlined-type-alias.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// check-pass
// compile-flags: -Znormalize-docs

trait Woo<T> {
type Assoc;
}

impl<T> Woo<T> for () {
type Assoc = ();
}

type Alias<P> = <() as Woo<P>>::Assoc;

pub fn hello<S>() -> Alias<S> {}

0 comments on commit a0156e5

Please sign in to comment.