Skip to content

Commit bd6caad

Browse files
committed
Avoid "const uses param" error
1 parent ee58f0c commit bd6caad

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -3115,7 +3115,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
31153115
obligation: &PredicateObligation<'tcx>,
31163116
span: Span,
31173117
) -> Result<Diag<'a>, ErrorGuaranteed> {
3118-
if !self.tcx.features().generic_const_exprs() {
3118+
if !self.tcx.features().generic_const_exprs()
3119+
&& !self.tcx.features().min_generic_const_args()
3120+
{
31193121
let guar = self
31203122
.dcx()
31213123
.struct_span_err(span, "constant expression depends on a generic parameter")
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)