-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move const trait bounds checks to MIR constck #109557
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
struct X<const N: usize = { | ||
(||1usize)() | ||
//~^ ERROR cannot call non-const closure | ||
//~| ERROR the trait bound | ||
}>; | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,30 @@ | ||
error[E0277]: can't drop `UnconstDrop` in const contexts | ||
--> $DIR/const-block-const-bound.rs:20:11 | ||
--> $DIR/const-block-const-bound.rs:20:9 | ||
| | ||
LL | f(UnconstDrop); | ||
| - ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `UnconstDrop` | ||
| | | ||
| required by a bound introduced by this call | ||
| ^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `UnconstDrop` | ||
| | ||
= note: the trait bound `UnconstDrop: ~const Destruct` is not satisfied | ||
note: required by a bound in `f` | ||
--> $DIR/const-block-const-bound.rs:6:15 | ||
| | ||
LL | const fn f<T: ~const Destruct>(x: T) {} | ||
| ^^^^^^^^^^^^^^^ required by this bound in `f` | ||
help: consider borrowing here | ||
| | ||
LL | f(&UnconstDrop); | ||
| + | ||
LL | f(&mut UnconstDrop); | ||
| ++++ | ||
LL | &f(UnconstDrop); | ||
| + | ||
LL | &mut f(UnconstDrop); | ||
| ++++ | ||
Comment on lines
-17
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a regression that has something to do with the spans and how trait selection is different in typeck and constck. I will look into this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the span of the |
||
|
||
error[E0277]: can't drop `NonDrop` in const contexts | ||
--> $DIR/const-block-const-bound.rs:22:11 | ||
--> $DIR/const-block-const-bound.rs:22:9 | ||
| | ||
LL | f(NonDrop); | ||
| - ^^^^^^^ the trait `~const Destruct` is not implemented for `NonDrop` | ||
| | | ||
| required by a bound introduced by this call | ||
| ^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonDrop` | ||
| | ||
= note: the trait bound `NonDrop: ~const Destruct` is not satisfied | ||
note: required by a bound in `f` | ||
--> $DIR/const-block-const-bound.rs:6:15 | ||
| | ||
LL | const fn f<T: ~const Destruct>(x: T) {} | ||
| ^^^^^^^^^^^^^^^ required by this bound in `f` | ||
help: consider borrowing here | ||
| | ||
LL | f(&NonDrop); | ||
| + | ||
LL | f(&mut NonDrop); | ||
| ++++ | ||
LL | &f(NonDrop); | ||
| + | ||
LL | &mut f(NonDrop); | ||
| ++++ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
const X: u8 = | ||
|| -> u8 { 5 }() | ||
//~^ ERROR cannot call non-const closure | ||
//~| ERROR the trait bound | ||
; | ||
|
||
fn main() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the message say that we expect a
const
bound here too?