Skip to content

Commit afd11f1

Browse files
committed
Avoid "const uses param" error
1 parent 965192f commit afd11f1

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
@@ -3250,7 +3250,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
32503250
obligation: &PredicateObligation<'tcx>,
32513251
span: Span,
32523252
) -> Result<Diag<'a>, ErrorGuaranteed> {
3253-
if !self.tcx.features().generic_const_exprs() {
3253+
if !self.tcx.features().generic_const_exprs()
3254+
&& !self.tcx.features().min_generic_const_args()
3255+
{
32543256
let guar = self
32553257
.dcx()
32563258
.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)