Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions compiler/rustc_trait_selection/src/traits/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,23 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
},
));
}
ty::Array(elem_ty, _len) => {
let elem_vals = val.to_branch();
let cause = self.cause(ObligationCauseCode::WellFormed(None));

self.out.extend(elem_vals.iter().map(|&elem_val| {
let predicate = ty::PredicateKind::Clause(
ty::ClauseKind::ConstArgHasType(elem_val, *elem_ty),
);
traits::Obligation::with_depth(
tcx,
cause.clone(),
self.recursion_depth,
self.param_env,
predicate,
)
}));
}
_ => {}
}
}
Expand Down
15 changes: 15 additions & 0 deletions tests/ui/const-generics/array-const-arg-type-mismatch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![feature(adt_const_params, min_generic_const_args)]
//~^ WARN feature `min_generic_const_args` is incomplete
Copy link
Copy Markdown
Contributor

@asder8215 asder8215 Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also do #![expect(incomplete_features)] instead of the warning here. I personally would go for that route because I don't think the warning should be mentioned in the .stderr file.

use std::marker::ConstParamTy;

#[derive(Eq, PartialEq, ConstParamTy)]
struct Foo;

struct Bar;

fn test<const N: [Foo; 1]>() {}

fn main() {
test::<{ [Bar] }>();
//~^ ERROR constant `Bar` is not of type `Foo`
}
17 changes: 17 additions & 0 deletions tests/ui/const-generics/array-const-arg-type-mismatch.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/array-const-arg-type-mismatch.rs:1:30
|
LL | #![feature(adt_const_params, min_generic_const_args)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
= note: `#[warn(incomplete_features)]` on by default

error: the constant `Bar` is not of type `Foo`
--> $DIR/array-const-arg-type-mismatch.rs:13:14
|
LL | test::<{ [Bar] }>();
| ^^^^^ expected `Foo`, found `Bar`

error: aborting due to 1 previous error; 1 warning emitted

Loading