forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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 rust-lang#71657 - Daniel-Worrall:24949, r=estebank
Add rust-lang#24949 assoc constant static recursion test Closes rust-lang#24949 Forced tidy fixes
- Loading branch information
Showing
6 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.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,15 @@ | ||
// Check for recursion involving references to impl-associated const. | ||
|
||
trait Foo { | ||
const BAR: u32; | ||
} | ||
|
||
const IMPL_REF_BAR: u32 = GlobalImplRef::BAR; //~ ERROR E0391 | ||
|
||
struct GlobalImplRef; | ||
|
||
impl GlobalImplRef { | ||
const BAR: u32 = IMPL_REF_BAR; | ||
} | ||
|
||
fn main() {} |
44 changes: 44 additions & 0 deletions
44
src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.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,44 @@ | ||
error[E0391]: cycle detected when const-evaluating + checking `IMPL_REF_BAR` | ||
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1 | ||
| | ||
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: ...which requires const-evaluating + checking `IMPL_REF_BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1 | ||
| | ||
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...which requires const-evaluating `IMPL_REF_BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1 | ||
| | ||
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: ...which requires normalizing `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`... | ||
note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5 | ||
| | ||
LL | const BAR: u32 = IMPL_REF_BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5 | ||
| | ||
LL | const BAR: u32 = IMPL_REF_BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...which requires const-evaluating `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5 | ||
| | ||
LL | const BAR: u32 = IMPL_REF_BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...which requires processing `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5 | ||
| | ||
LL | const BAR: u32 = IMPL_REF_BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: ...which requires normalizing `IMPL_REF_BAR`... | ||
= note: ...which again requires const-evaluating + checking `IMPL_REF_BAR`, completing the cycle | ||
= note: cycle used when running analysis passes on this crate | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0391`. |
17 changes: 17 additions & 0 deletions
17
src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.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,17 @@ | ||
// Check for recursion involving references to trait-associated const default. | ||
|
||
trait Foo { | ||
const BAR: u32; | ||
} | ||
|
||
trait FooDefault { | ||
const BAR: u32 = DEFAULT_REF_BAR; | ||
} | ||
|
||
const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR; //~ ERROR E0391 | ||
|
||
struct GlobalDefaultRef; | ||
|
||
impl FooDefault for GlobalDefaultRef {} | ||
|
||
fn main() {} |
44 changes: 44 additions & 0 deletions
44
src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.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,44 @@ | ||
error[E0391]: cycle detected when const-evaluating + checking `DEFAULT_REF_BAR` | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1 | ||
| | ||
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1 | ||
| | ||
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...which requires const-evaluating `DEFAULT_REF_BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1 | ||
| | ||
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: ...which requires normalizing `<GlobalDefaultRef as FooDefault>::BAR`... | ||
note: ...which requires const-evaluating + checking `FooDefault::BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5 | ||
| | ||
LL | const BAR: u32 = DEFAULT_REF_BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...which requires const-evaluating + checking `FooDefault::BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5 | ||
| | ||
LL | const BAR: u32 = DEFAULT_REF_BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...which requires const-evaluating `FooDefault::BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5 | ||
| | ||
LL | const BAR: u32 = DEFAULT_REF_BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...which requires processing `FooDefault::BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5 | ||
| | ||
LL | const BAR: u32 = DEFAULT_REF_BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: ...which requires normalizing `DEFAULT_REF_BAR`... | ||
= note: ...which again requires const-evaluating + checking `DEFAULT_REF_BAR`, completing the cycle | ||
= note: cycle used when running analysis passes on this crate | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0391`. |
15 changes: 15 additions & 0 deletions
15
src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.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,15 @@ | ||
// Check for recursion involving references to trait-associated const. | ||
|
||
trait Foo { | ||
const BAR: u32; | ||
} | ||
|
||
const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR; //~ ERROR E0391 | ||
|
||
struct GlobalTraitRef; | ||
|
||
impl Foo for GlobalTraitRef { | ||
const BAR: u32 = TRAIT_REF_BAR; | ||
} | ||
|
||
fn main() {} |
44 changes: 44 additions & 0 deletions
44
src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.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,44 @@ | ||
error[E0391]: cycle detected when const-evaluating + checking `TRAIT_REF_BAR` | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1 | ||
| | ||
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1 | ||
| | ||
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...which requires const-evaluating `TRAIT_REF_BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1 | ||
| | ||
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: ...which requires normalizing `<GlobalTraitRef as Foo>::BAR`... | ||
note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5 | ||
| | ||
LL | const BAR: u32 = TRAIT_REF_BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5 | ||
| | ||
LL | const BAR: u32 = TRAIT_REF_BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...which requires const-evaluating `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5 | ||
| | ||
LL | const BAR: u32 = TRAIT_REF_BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
note: ...which requires processing `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`... | ||
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5 | ||
| | ||
LL | const BAR: u32 = TRAIT_REF_BAR; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: ...which requires normalizing `TRAIT_REF_BAR`... | ||
= note: ...which again requires const-evaluating + checking `TRAIT_REF_BAR`, completing the cycle | ||
= note: cycle used when running analysis passes on this crate | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0391`. |