Auto merge of #93854 - matthiaskrgr:rollup-bh2a85j, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #92670 (add kernel target for RustyHermit) - #93756 (Support custom options for LLVM build) - #93802 (fix oversight in the `min_const_generics` checks) - #93808 (Remove first headings indent) - #93824 (Stabilize cfg_target_has_atomic) - #93830 (Refactor sidebar printing code) - #93843 (kmc-solid: Fix wait queue manipulation errors in the `Condvar` implementation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
502d6aa47b
34 changed files with 445 additions and 599 deletions
|
@ -2281,8 +2281,27 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
assert_eq!(opt_self_ty, None);
|
||||
self.prohibit_generics(path.segments);
|
||||
// Try to evaluate any array length constants.
|
||||
let normalized_ty = self.normalize_ty(span, tcx.at(span).type_of(def_id));
|
||||
if forbid_generic && normalized_ty.needs_subst() {
|
||||
let ty = tcx.at(span).type_of(def_id);
|
||||
// HACK(min_const_generics): Forbid generic `Self` types
|
||||
// here as we can't easily do that during nameres.
|
||||
//
|
||||
// We do this before normalization as we otherwise allow
|
||||
// ```rust
|
||||
// trait AlwaysApplicable { type Assoc; }
|
||||
// impl<T: ?Sized> AlwaysApplicable for T { type Assoc = usize; }
|
||||
//
|
||||
// trait BindsParam<T> {
|
||||
// type ArrayTy;
|
||||
// }
|
||||
// impl<T> BindsParam<T> for <T as AlwaysApplicable>::Assoc {
|
||||
// type ArrayTy = [u8; Self::MAX];
|
||||
// }
|
||||
// ```
|
||||
// Note that the normalization happens in the param env of
|
||||
// the anon const, which is empty. This is why the
|
||||
// `AlwaysApplicable` impl needs a `T: ?Sized` bound for
|
||||
// this to compile if we were to normalize here.
|
||||
if forbid_generic && ty.needs_subst() {
|
||||
let mut err = tcx.sess.struct_span_err(
|
||||
path.span,
|
||||
"generic `Self` types are currently not permitted in anonymous constants",
|
||||
|
@ -2297,7 +2316,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
err.emit();
|
||||
tcx.ty_error()
|
||||
} else {
|
||||
normalized_ty
|
||||
self.normalize_ty(span, ty)
|
||||
}
|
||||
}
|
||||
Res::Def(DefKind::AssocTy, def_id) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue