-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Add coherency check for query cycle breaking #153953
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
base: main
Are you sure you want to change the base?
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,7 +14,7 @@ use rustc_data_structures::sync::Lock; | |||||
| use rustc_macros::{Decodable, Encodable, HashStable_Generic, symbols}; | ||||||
|
|
||||||
| use crate::edit_distance::find_best_match_for_name; | ||||||
| use crate::{DUMMY_SP, Edition, Span, with_session_globals}; | ||||||
| use crate::{DUMMY_SP, Edition, Span, are_session_globals_set, with_session_globals}; | ||||||
|
|
||||||
| #[cfg(test)] | ||||||
| mod tests; | ||||||
|
|
@@ -2545,6 +2545,10 @@ impl Symbol { | |||||
| }) | ||||||
| } | ||||||
|
|
||||||
| pub fn opt_as_str(&self) -> Option<&str> { | ||||||
| are_session_globals_set().then(|| self.as_str()) | ||||||
| } | ||||||
|
|
||||||
| pub fn as_u32(self) -> u32 { | ||||||
| self.0.as_u32() | ||||||
| } | ||||||
|
|
@@ -2586,13 +2590,21 @@ impl Symbol { | |||||
|
|
||||||
| impl fmt::Debug for Symbol { | ||||||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||||||
| fmt::Debug::fmt(self.as_str(), f) | ||||||
| if let Some(s) = self.opt_as_str() { | ||||||
|
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.
Suggested change
Together with a comment #153953 (comment) explaining why it's acceptable. |
||||||
| fmt::Debug::fmt(s, f) | ||||||
| } else { | ||||||
| fmt::Debug::fmt(&self.0, f) | ||||||
|
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. This will just print a number, e.g.
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. Symbols should never be used in contexts in which this path can be triggered, it's better to continue panicking here.
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.
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.
That thread doesn't have anything answering my question.
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. This context is the cycle detection thread
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. Could you add a comment explaining this use? |
||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| impl fmt::Display for Symbol { | ||||||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||||||
| fmt::Display::fmt(self.as_str(), f) | ||||||
| if let Some(s) = self.opt_as_str() { | ||||||
| fmt::Display::fmt(s, f) | ||||||
| } else { | ||||||
| fmt::Debug::fmt(&self.0, f) | ||||||
|
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. Same here. |
||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
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.
There are no added comments in this commit. An explanatory comment here would be useful. Something like "compare the single-threaded cycle detection against the multi-threaded cycle detection".