Skip to content

Commit a54dbbf

Browse files
committed
add_effects_test
1 parent 00167ab commit a54dbbf

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![feature(generic_const_exprs)]
2+
//~^ WARN: the feature `generic_const_exprs` is incomplete
3+
4+
// Regression test for #125770 which would ICE under the old effects desugaring that
5+
// created a const generic parameter for constness on `Add`.
6+
7+
use std::ops::Add;
8+
9+
pub struct Dimension;
10+
11+
pub struct Quantity<S, const D: Dimension>(S);
12+
//~^ ERROR: `Dimension` is forbidden as the type of a const generic parameter
13+
14+
impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {}
15+
//~^ ERROR: trait takes at most 1 generic argument
16+
//~| ERROR: `Dimension` is forbidden as the type of a const generic parameter
17+
18+
pub fn add<const U: Dimension>(x: Quantity<f32, U>) -> Quantity<f32, U> {
19+
//~^ ERROR: `Dimension` is forbidden as the type of a const generic parameter
20+
x + y
21+
//~^ ERROR: cannot find value `y` in this scope
22+
}
23+
24+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
error[E0425]: cannot find value `y` in this scope
2+
--> $DIR/mismatched_generic_args.rs:20:9
3+
|
4+
LL | pub fn add<const U: Dimension>(x: Quantity<f32, U>) -> Quantity<f32, U> {
5+
| - similarly named const parameter `U` defined here
6+
LL |
7+
LL | x + y
8+
| ^ help: a const parameter with a similar name exists: `U`
9+
10+
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
11+
--> $DIR/mismatched_generic_args.rs:1:12
12+
|
13+
LL | #![feature(generic_const_exprs)]
14+
| ^^^^^^^^^^^^^^^^^^^
15+
|
16+
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
17+
= note: `#[warn(incomplete_features)]` on by default
18+
19+
error: `Dimension` is forbidden as the type of a const generic parameter
20+
--> $DIR/mismatched_generic_args.rs:11:33
21+
|
22+
LL | pub struct Quantity<S, const D: Dimension>(S);
23+
| ^^^^^^^^^
24+
|
25+
= note: the only supported types are integers, `bool` and `char`
26+
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
27+
|
28+
LL + #![feature(adt_const_params)]
29+
|
30+
31+
error[E0107]: trait takes at most 1 generic argument but 2 generic arguments were supplied
32+
--> $DIR/mismatched_generic_args.rs:14:36
33+
|
34+
LL | impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {}
35+
| ^^^ expected at most 1 generic argument
36+
37+
error: `Dimension` is forbidden as the type of a const generic parameter
38+
--> $DIR/mismatched_generic_args.rs:14:15
39+
|
40+
LL | impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {}
41+
| ^^^^^^^^^
42+
|
43+
= note: the only supported types are integers, `bool` and `char`
44+
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
45+
|
46+
LL + #![feature(adt_const_params)]
47+
|
48+
49+
error: `Dimension` is forbidden as the type of a const generic parameter
50+
--> $DIR/mismatched_generic_args.rs:18:21
51+
|
52+
LL | pub fn add<const U: Dimension>(x: Quantity<f32, U>) -> Quantity<f32, U> {
53+
| ^^^^^^^^^
54+
|
55+
= note: the only supported types are integers, `bool` and `char`
56+
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
57+
|
58+
LL + #![feature(adt_const_params)]
59+
|
60+
61+
error: aborting due to 5 previous errors; 1 warning emitted
62+
63+
Some errors have detailed explanations: E0107, E0425.
64+
For more information about an error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)