-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Associated const references using UFCS can bypass check_static_recursion
#24949
Labels
A-associated-items
Area: Associated items (types, constants & functions)
A-type-system
Area: Type system
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
Comments
steveklabnik
added
A-type-system
Area: Type system
A-associated-items
Area: Associated items (types, constants & functions)
labels
Apr 30, 2015
A simpler example of this:
compiles. |
Triage: @gankro 's example still compiles. |
E-needstest. |
Mark-Simulacrum
added
the
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
label
May 18, 2017
trait Foo {
const FOO: Self;
}
impl Foo for u8 {
const FOO: u8 = u8::FOO;
} fails to compile, but adding: fn main() {} makes it compile without an error. |
@rustbot claim |
Daniel-Worrall
added a commit
to Daniel-Worrall/rust
that referenced
this issue
Apr 29, 2020
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Apr 29, 2020
Rollup of 5 pull requests Successful merges: - rust-lang#71217 (Suggest `;` or assignment to drop borrows in tail exprs) - rust-lang#71286 (Add regression test for rust-lang#69654) - rust-lang#71296 (Change wording on read_vectored docs) - rust-lang#71654 (Update link to unstable book for llvm_asm macro) - rust-lang#71657 (Add rust-lang#24949 assoc constant static recursion test) Failed merges: r? @ghost
This isn't fixed. The example in this comment still compiles. |
Dylan-DPC-zz
removed
the
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
label
Apr 29, 2020
Noratrieb
added
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
labels
Apr 5, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-associated-items
Area: Associated items (types, constants & functions)
A-type-system
Area: Type system
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
Currently,
check_static_recursion
is run afterresolve
, but beforetypeck
. This made sense before, because afterresolve
it was possible to determine which constants referenced one another, and running beforetypeck
ensured that we don't fall into an infinite loop during type checking. However, when referencing an associated constant with some UFCS forms, we can't resolve the constant untiltypeck
, meaning thatcheck_static_recursion
can't always tell when a recursive definition is present. On top of that, this check is not currently working right even for inherent impls, where it should be possible to discover a problem ahead oftypeck
running.A set of test cases:
The above cases should all fail in the recursion check, but they all compile successfully! If any of the constants are actually used in a context that requires the compiler to evaluate them, there will be an ICE (specifically, the compiler enters an infinite loop that ends up blowing the stack).
Update
playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=76e9edaf2827806e18a557f37bc930ea
This issue has been assigned to @Daniel-Worrall via this comment.
The text was updated successfully, but these errors were encountered: