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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::ops::ControlFlow;

use rustc_errors::FatalError;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_hir::{self as hir, LangItem, find_attr};
use rustc_middle::query::Providers;
Expand Down Expand Up @@ -833,8 +834,10 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IllegalSelfTypeVisitor<'tcx> {
match ct.kind() {
ty::ConstKind::Unevaluated(proj) if self.tcx.features().min_generic_const_args() => {
match self.allow_self_projections {
AllowSelfProjections::Yes => {
let trait_def_id = self.tcx.parent(proj.def);
AllowSelfProjections::Yes
if let trait_def_id = self.tcx.parent(proj.def)
&& self.tcx.def_kind(trait_def_id) == DefKind::Trait =>
{
let trait_ref = ty::TraitRef::from_assoc(self.tcx, trait_def_id, proj.args);

// Only walk contained consts if the parent trait is not a supertrait.
Expand All @@ -844,7 +847,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IllegalSelfTypeVisitor<'tcx> {
ct.super_visit_with(self)
}
}
AllowSelfProjections::No => ct.super_visit_with(self),
_ => ct.super_visit_with(self),
}
}
_ => ct.super_visit_with(self),
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/const-generics/mgca/type-const-used-in-trait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ check-pass

#![feature(min_generic_const_args)]
#![expect(incomplete_features)]

#[type_const]
const N: usize = 2;

trait CollectArray<A> {
fn inner_array(&mut self) -> [A; N];
}

fn main() {}
Loading