Skip to content

Commit ef9b72b

Browse files
committed
wip: remove accidental constraining pattern
1 parent 9962c99 commit ef9b72b

File tree

9 files changed

+47
-60
lines changed

9 files changed

+47
-60
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2381,10 +2381,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23812381
// FIXME(min_generic_const_args): for now we only lower params to ConstArgKind::Path
23822382
if let Some(res) = maybe_res
23832383
&& let ExprKind::Path(qself, path) = &expr.kind
2384-
&& let Res::Def(DefKind::ConstParam, _) = res
23852384
// FIXME(min_generic_const_args): only allow one-segment const paths for now
23862385
&& let Res::Def(
2387-
DefKind::ConstParam | DefKind::Const | DefKind::Ctor(_, CtorKind::Const),
2386+
DefKind::ConstParam
2387+
| DefKind::Const
2388+
| DefKind::Ctor(_, CtorKind::Const),
23882389
_,
23892390
) = res
23902391
&& path.is_potential_trivial_const_arg()

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::sync::atomic::Ordering::Relaxed;
22

33
use either::{Left, Right};
4-
use rustc_hir::def::DefKind;
4+
use rustc_hir::def::{CtorKind, DefKind};
55
use rustc_middle::bug;
66
use rustc_middle::mir::interpret::{AllocId, ErrorHandled, InterpErrorInfo};
77
use rustc_middle::mir::{self, ConstAlloc, ConstValue};
@@ -43,6 +43,7 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
4343
| DefKind::AnonConst
4444
| DefKind::InlineConst
4545
| DefKind::AssocConst
46+
| DefKind::Ctor(_, CtorKind::Const)
4647
),
4748
"Unexpected DefKind: {:?}",
4849
ecx.tcx.def_kind(cid.instance.def_id())
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/bad-generic-in-copy-impl.rs:3:13
1+
error: the constant `1` is not of type `usize`
2+
--> $DIR/bad-generic-in-copy-impl.rs:3:8
33
|
44
LL | x: [u8; SIZE],
5-
| ^^^^ expected `usize`, found `u32`
5+
| ^^^^^^^^^^ expected `usize`, found `u32`
66

7-
error[E0308]: mismatched types
8-
--> $DIR/bad-generic-in-copy-impl.rs:3:13
7+
error[E0204]: the trait `Copy` cannot be implemented for this type
8+
--> $DIR/bad-generic-in-copy-impl.rs:1:10
99
|
10+
LL | #[derive(Copy, Clone)]
11+
| ^^^^
12+
LL | pub struct Foo {
1013
LL | x: [u8; SIZE],
11-
| ^^^^ expected `usize`, found `u32`
14+
| ------------- this field does not implement `Copy`
1215
|
13-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
16+
note: the `Copy` impl for `[u8; 1]` requires that `the constant `1` has type `usize``
17+
--> $DIR/bad-generic-in-copy-impl.rs:3:8
18+
|
19+
LL | x: [u8; SIZE],
20+
| ^^^^^^^^^^
21+
= note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
22+
23+
error: the constant `1` is not of type `usize`
24+
--> $DIR/bad-generic-in-copy-impl.rs:3:5
25+
|
26+
LL | #[derive(Copy, Clone)]
27+
| ----- in this derive macro expansion
28+
LL | pub struct Foo {
29+
LL | x: [u8; SIZE],
30+
| ^^^^^^^^^^^^^ expected `usize`, found `u32`
31+
|
32+
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
1433

15-
error: aborting due to 2 previous errors
34+
error: aborting due to 3 previous errors
1635

17-
For more information about this error, try `rustc --explain E0308`.
36+
For more information about this error, try `rustc --explain E0204`.
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
error[E0275]: overflow evaluating the requirement `S<{ U }> well-formed`
2-
--> $DIR/adt_wf_hang.rs:11:5
1+
error[E0741]: `U` must implement `ConstParamTy` to be used as the type of a const generic parameter
2+
--> $DIR/adt_wf_hang.rs:9:19
33
|
4-
LL | S<{ U }>:;
5-
| ^^^^^^^^
4+
LL | struct S<const N: U>()
5+
| ^
66
|
7-
note: required by a bound in `S`
8-
--> $DIR/adt_wf_hang.rs:11:5
7+
help: add `#[derive(ConstParamTy)]` to the struct
8+
|
9+
LL + #[derive(ConstParamTy)]
10+
LL | struct U;
911
|
10-
LL | struct S<const N: U>()
11-
| - required by a bound in this struct
12-
LL | where
13-
LL | S<{ U }>:;
14-
| ^^^^^^^^ required by this bound in `S`
1512

1613
error: aborting due to 1 previous error
1714

18-
For more information about this error, try `rustc --explain E0275`.
15+
For more information about this error, try `rustc --explain E0741`.

tests/ui/const-generics/generic_const_exprs/type-alias-bounds.neg.stderr

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
error[E0277]: the trait bound `String: Copy` is not satisfied
2-
--> $DIR/type-alias-bounds.rs:23:12
3-
|
4-
LL | let _: AliasConstUnused<String>;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
6-
|
7-
note: required by a bound in `ct_unused_0::AliasConstUnused`
8-
--> $DIR/type-alias-bounds.rs:20:30
9-
|
10-
LL | type AliasConstUnused<T: Copy> = (T, I32<{ DATA }>);
11-
| ^^^^ required by this bound in `AliasConstUnused`
12-
131
error[E0277]: the trait bound `String: Copy` is not satisfied
142
--> $DIR/type-alias-bounds.rs:31:12
153
|
@@ -58,6 +46,6 @@ note: required by a bound in `AliasFnUsed`
5846
LL | type AliasFnUsed<T: Trait + Copy> = I32<{ code::<T>() }>;
5947
| ^^^^ required by this bound in `AliasFnUsed`
6048

61-
error: aborting due to 5 previous errors
49+
error: aborting due to 4 previous errors
6250

6351
For more information about this error, try `rustc --explain E0277`.

tests/ui/consts/const-len-underflow-separate-spans.next.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ error[E0080]: evaluation of constant value failed
44
LL | const LEN: usize = ONE - TWO;
55
| ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow
66

7-
note: erroneous constant encountered
8-
--> $DIR/const-len-underflow-separate-spans.rs:14:17
9-
|
10-
LL | let a: [i8; LEN] = unimplemented!();
11-
| ^^^
12-
137
error: aborting due to 1 previous error
148

159
For more information about this error, try `rustc --explain E0080`.

tests/ui/consts/const-len-underflow-separate-spans.old.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ error[E0080]: evaluation of constant value failed
44
LL | const LEN: usize = ONE - TWO;
55
| ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow
66

7-
note: erroneous constant encountered
8-
--> $DIR/const-len-underflow-separate-spans.rs:14:17
9-
|
10-
LL | let a: [i8; LEN] = unimplemented!();
11-
| ^^^
12-
137
error: aborting due to 1 previous error
148

159
For more information about this error, try `rustc --explain E0080`.

tests/ui/consts/issue-39974.stderr

+1-7
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ help: use a float literal
99
LL | const LENGTH: f64 = 2.0;
1010
| ++
1111

12-
error[E0308]: mismatched types
13-
--> $DIR/issue-39974.rs:5:19
14-
|
15-
LL | f: [[f64; 2]; LENGTH],
16-
| ^^^^^^ expected `usize`, found `f64`
17-
18-
error: aborting due to 2 previous errors
12+
error: aborting due to 1 previous error
1913

2014
For more information about this error, try `rustc --explain E0308`.

tests/ui/issues/issue-27008.stderr

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/issue-27008.rs:4:17
1+
error: the constant `S` is not of type `usize`
2+
--> $DIR/issue-27008.rs:4:13
33
|
44
LL | let b = [0; S];
5-
| ^ expected `usize`, found `S`
5+
| ^^^^^^ expected `usize`, found `S`
66

77
error: aborting due to 1 previous error
88

9-
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)