-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Do not ICE on AnonConst
s in diagnostic_hir_wf_check
#124219
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,21 @@ | ||
// Regression test for ICE #122989 | ||
trait Foo<const N: Bar<2>> { | ||
//~^ WARN trait objects without an explicit `dyn` are deprecated | ||
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! | ||
//~| ERROR cycle detected when computing type of `Foo::N` | ||
//~| ERROR cycle detected when computing type of `Foo::N` | ||
//~| ERROR the trait `Foo` cannot be made into an object | ||
//~| ERROR the trait `Foo` cannot be made into an object | ||
//~| ERROR the trait `Foo` cannot be made into an object | ||
//~| ERROR `(dyn Bar<2> + 'static)` is forbidden as the type of a const generic parameter | ||
fn func() { | ||
} | ||
} | ||
|
||
trait Bar<const M: Foo<2>> {} | ||
//~^ WARN trait objects without an explicit `dyn` are deprecated | ||
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! | ||
//~| ERROR the trait `Foo` cannot be made into an object | ||
//~| ERROR `(dyn Foo<2> + 'static)` is forbidden as the type of a const generic parameter | ||
|
||
fn main() {} |
179 changes: 179 additions & 0 deletions
179
tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr
This file contains hidden or 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,179 @@ | ||
warning: trait objects without an explicit `dyn` are deprecated | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:20 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| ^^^^^^ | ||
| | ||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! | ||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> | ||
= note: `#[warn(bare_trait_objects)]` on by default | ||
help: if this is an object-safe trait, use `dyn` | ||
| | ||
LL | trait Foo<const N: dyn Bar<2>> { | ||
| +++ | ||
|
||
warning: trait objects without an explicit `dyn` are deprecated | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:15:20 | ||
| | ||
LL | trait Bar<const M: Foo<2>> {} | ||
| ^^^^^^ | ||
| | ||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! | ||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> | ||
help: if this is an object-safe trait, use `dyn` | ||
| | ||
LL | trait Bar<const M: dyn Foo<2>> {} | ||
| +++ | ||
|
||
error[E0391]: cycle detected when computing type of `Foo::N` | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:11 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
note: ...which requires computing type of `Bar::M`... | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:15:11 | ||
| | ||
LL | trait Bar<const M: Foo<2>> {} | ||
| ^^^^^^^^^^^^^^^ | ||
= note: ...which again requires computing type of `Foo::N`, completing the cycle | ||
note: cycle used when computing explicit predicates of trait `Foo` | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:1 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information | ||
|
||
error[E0391]: cycle detected when computing type of `Foo::N` | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:11 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
note: ...which requires computing type of `Bar::M`... | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:15:11 | ||
| | ||
LL | trait Bar<const M: Foo<2>> {} | ||
| ^^^^^^^^^^^^^^^ | ||
= note: ...which again requires computing type of `Foo::N`, completing the cycle | ||
note: cycle used when computing explicit predicates of trait `Foo` | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:1 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error[E0038]: the trait `Foo` cannot be made into an object | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:24 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| ^ `Foo` cannot be made into an object | ||
| | ||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:8 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| --- this trait cannot be made into an object... | ||
... | ||
LL | fn func() { | ||
| ^^^^ ...because associated function `func` has no `self` parameter | ||
help: consider turning `func` into a method by giving it a `&self` argument | ||
| | ||
LL | fn func(&self) { | ||
| +++++ | ||
help: alternatively, consider constraining `func` so it does not apply to trait objects | ||
| | ||
LL | fn func() where Self: Sized { | ||
| +++++++++++++++++ | ||
|
||
error[E0038]: the trait `Foo` cannot be made into an object | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:11 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| ^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | ||
| | ||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:8 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| --- this trait cannot be made into an object... | ||
... | ||
LL | fn func() { | ||
| ^^^^ ...because associated function `func` has no `self` parameter | ||
help: consider turning `func` into a method by giving it a `&self` argument | ||
| | ||
LL | fn func(&self) { | ||
| +++++ | ||
help: alternatively, consider constraining `func` so it does not apply to trait objects | ||
| | ||
LL | fn func() where Self: Sized { | ||
| +++++++++++++++++ | ||
|
||
error: `(dyn Bar<2> + 'static)` is forbidden as the type of a const generic parameter | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:20 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| ^^^^^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
|
||
error[E0038]: the trait `Foo` cannot be made into an object | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:15:11 | ||
| | ||
LL | trait Bar<const M: Foo<2>> {} | ||
| ^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | ||
| | ||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:8 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| --- this trait cannot be made into an object... | ||
... | ||
LL | fn func() { | ||
| ^^^^ ...because associated function `func` has no `self` parameter | ||
help: consider turning `func` into a method by giving it a `&self` argument | ||
| | ||
LL | fn func(&self) { | ||
| +++++ | ||
help: alternatively, consider constraining `func` so it does not apply to trait objects | ||
| | ||
LL | fn func() where Self: Sized { | ||
| +++++++++++++++++ | ||
|
||
error: `(dyn Foo<2> + 'static)` is forbidden as the type of a const generic parameter | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:15:20 | ||
| | ||
LL | trait Bar<const M: Foo<2>> {} | ||
| ^^^^^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
|
||
error[E0038]: the trait `Foo` cannot be made into an object | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:11 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| ^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | ||
| | ||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> | ||
--> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:8 | ||
| | ||
LL | trait Foo<const N: Bar<2>> { | ||
| --- this trait cannot be made into an object... | ||
... | ||
LL | fn func() { | ||
| ^^^^ ...because associated function `func` has no `self` parameter | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
help: consider turning `func` into a method by giving it a `&self` argument | ||
| | ||
LL | fn func(&self) { | ||
| +++++ | ||
help: alternatively, consider constraining `func` so it does not apply to trait objects | ||
| | ||
LL | fn func() where Self: Sized { | ||
| +++++++++++++++++ | ||
|
||
error: aborting due to 8 previous errors; 2 warnings emitted | ||
|
||
Some errors have detailed explanations: E0038, E0391. | ||
For more information about an error, try `rustc --explain E0038`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.