Skip to content

Commit afda88d

Browse files
committed
Avoid "const uses param" error
1 parent ef6597f commit afda88d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3125,7 +3125,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
31253125
obligation: &PredicateObligation<'tcx>,
31263126
span: Span,
31273127
) -> Result<Diag<'a>, ErrorGuaranteed> {
3128-
if !self.tcx.features().generic_const_exprs() {
3128+
if !self.tcx.features().generic_const_exprs()
3129+
&& !self.tcx.features().min_generic_const_args()
3130+
{
31293131
let guar = self
31303132
.dcx()
31313133
.struct_span_err(span, "constant expression depends on a generic parameter")
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ check-pass
2+
3+
#![feature(min_generic_const_args)]
4+
#![allow(incomplete_features)]
5+
6+
pub trait Tr {
7+
const SIZE: usize;
8+
}
9+
10+
fn mk_array<T: Tr>(_x: T) -> [(); T::SIZE] {
11+
[(); T::SIZE]
12+
}
13+
14+
fn main() {}
15+

0 commit comments

Comments
 (0)