-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #127711 - BoxyUwU:add_effects_test, r=fee1-dead
Add regression test for a gce + effects ICE Fixes #125770 I'm not *exactly* sure why this stopped ICEing, I assume its something to do with the fact that there used to be a generic parameter on `Add` for the host generic and we have mismatched args here, which #125608 made no longer later cause issues. But now the desugaring is also different so? 🤷♀️ r? `@fee1-dead`
- Loading branch information
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
tests/ui/rfcs/rfc-2632-const-trait-impl/effects/mismatched_generic_args.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![feature(generic_const_exprs)] | ||
//~^ WARN: the feature `generic_const_exprs` is incomplete | ||
|
||
// Regression test for #125770 which would ICE under the old effects desugaring that | ||
// created a const generic parameter for constness on `Add`. | ||
|
||
use std::ops::Add; | ||
|
||
pub struct Dimension; | ||
|
||
pub struct Quantity<S, const D: Dimension>(S); | ||
//~^ ERROR: `Dimension` is forbidden as the type of a const generic parameter | ||
|
||
impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {} | ||
//~^ ERROR: trait takes at most 1 generic argument | ||
//~| ERROR: `Dimension` is forbidden as the type of a const generic parameter | ||
|
||
pub fn add<const U: Dimension>(x: Quantity<f32, U>) -> Quantity<f32, U> { | ||
//~^ ERROR: `Dimension` is forbidden as the type of a const generic parameter | ||
x + y | ||
//~^ ERROR: cannot find value `y` in this scope | ||
} | ||
|
||
fn main() {} |
64 changes: 64 additions & 0 deletions
64
tests/ui/rfcs/rfc-2632-const-trait-impl/effects/mismatched_generic_args.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
error[E0425]: cannot find value `y` in this scope | ||
--> $DIR/mismatched_generic_args.rs:20:9 | ||
| | ||
LL | pub fn add<const U: Dimension>(x: Quantity<f32, U>) -> Quantity<f32, U> { | ||
| - similarly named const parameter `U` defined here | ||
LL | | ||
LL | x + y | ||
| ^ help: a const parameter with a similar name exists: `U` | ||
|
||
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/mismatched_generic_args.rs:1:12 | ||
| | ||
LL | #![feature(generic_const_exprs)] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error: `Dimension` is forbidden as the type of a const generic parameter | ||
--> $DIR/mismatched_generic_args.rs:11:33 | ||
| | ||
LL | pub struct Quantity<S, const D: Dimension>(S); | ||
| ^^^^^^^^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | ||
| | ||
LL + #![feature(adt_const_params)] | ||
| | ||
|
||
error[E0107]: trait takes at most 1 generic argument but 2 generic arguments were supplied | ||
--> $DIR/mismatched_generic_args.rs:14:36 | ||
| | ||
LL | impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {} | ||
| ^^^ expected at most 1 generic argument | ||
|
||
error: `Dimension` is forbidden as the type of a const generic parameter | ||
--> $DIR/mismatched_generic_args.rs:14:15 | ||
| | ||
LL | impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {} | ||
| ^^^^^^^^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | ||
| | ||
LL + #![feature(adt_const_params)] | ||
| | ||
|
||
error: `Dimension` is forbidden as the type of a const generic parameter | ||
--> $DIR/mismatched_generic_args.rs:18:21 | ||
| | ||
LL | pub fn add<const U: Dimension>(x: Quantity<f32, U>) -> Quantity<f32, U> { | ||
| ^^^^^^^^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | ||
| | ||
LL + #![feature(adt_const_params)] | ||
| | ||
|
||
error: aborting due to 5 previous errors; 1 warning emitted | ||
|
||
Some errors have detailed explanations: E0107, E0425. | ||
For more information about an error, try `rustc --explain E0107`. |