-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Avoid stack overflow when printing unevaluated const #72341
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
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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #![feature(const_generics)] | ||
|
|
||
| pub struct Num<const N: usize>; | ||
|
|
||
| // Braces around const expression causes crash | ||
| impl Num<{5}> { | ||
|
Comment on lines
+5
to
+6
Member
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. The braces shouldn't matter, I wonder if this is a bug (cc @varkor).
Contributor
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. We currently don't look into blocks for literals, It seems like we only do it for params at the moment
Contributor
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. Will get a PR ready which cleans this up. edit: we may not actually want this for now, as being more aggressive here may mask some otherwise found issues with
Contributor
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. We shouldn't need braces here: arbitrary expressions should work, and
Contributor
Author
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. The braces are needed to trigger the original ICE, so I included them in the test |
||
| pub fn five(&self) { | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // aux-build:impl-const.rs | ||
| // run-pass | ||
|
|
||
| #![feature(const_generics)] | ||
| #![allow(incomplete_features)] | ||
|
|
||
| extern crate impl_const; | ||
|
|
||
| use impl_const::*; | ||
|
|
||
| pub fn main() { | ||
| let n = Num::<5>; | ||
| n.five(); | ||
| } |
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.
Can you try
with_forced_impl_filename_lineinstead? It should also work since I believe the problem here is the pretty-printing ofimplpaths.Wait. Hang on. Why would this ever print paths?!
The bug is probably in metadata encoding/decoding.
AnonConsts shouldn't turn intoDefKind::Const.