-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix clippy *errors* in current build #7108
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
f9e6a25
f6aead4
b43b337
9b7455d
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 |
---|---|---|
|
@@ -77,7 +77,10 @@ impl FromStr for TokenStream { | |
/// with `Delimiter::None` delimiters and negative numeric literals. | ||
impl fmt::Display for TokenStream { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.write_str(&self.to_string()) | ||
// NOTE(kinnison) | ||
// This differs from the "upstream" because we cannot use the ToString | ||
// impl commented out above. | ||
f.write_str(&self.0.to_string()) | ||
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. I recommend that do not changes this file as it is almost straight copy from rustc such that it is quite hard to trace if they changed something relevant. 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. I understand, however without this change, afaict the Display impls are recursive because the blanket ToString impl calls the Display impl a'la https://doc.rust-lang.org/stable/src/alloc/string.rs.html#2194-2207 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. Yes, but these won't be called in normal situation and these implementation are just dummy for make the ABI happy. Anyway, I think it is okay to change it for functionality 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. My fear is that if they're there for ABI compatibility then it implies they could be called at which point they'd break. If on the other hand they can't be called then removing them (commenting them out?) might be a better bet since it'd be clearer what was going on. I'm not clear about how that might affect compatibility though, you're the expert here :D 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. Okay, Agreed. Maybe add a comment to indicate it is a complicated case :)
I wish I were the expert. :( I even don't understand why the original rustc allow duplication implementation of the 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. I think that when the real code is built, specialisation is possible. I'll consider a suitable comment to add |
||
} | ||
} | ||
|
||
|
@@ -428,7 +431,15 @@ impl From<Literal> for TokenTree { | |
/// with `Delimiter::None` delimiters and negative numeric literals. | ||
impl fmt::Display for TokenTree { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.write_str(&self.to_string()) | ||
// NOTE(kinnison) | ||
// This differs from the "upstream" because we cannot use the ToString | ||
// impl commented out above. | ||
f.write_str(&match self { | ||
TokenTree::Group(g) => g.to_string(), | ||
TokenTree::Ident(i) => i.to_string(), | ||
TokenTree::Punct(p) => p.to_string(), | ||
TokenTree::Literal(l) => l.to_string(), | ||
}) | ||
} | ||
} | ||
|
||
|
@@ -533,7 +544,11 @@ impl Group { | |
/// with `Delimiter::None` delimiters. | ||
impl fmt::Display for Group { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.write_str(&self.to_string()) | ||
// NOTE(kinnison) | ||
// This differs from the "upstream" because we cannot use the ToString | ||
// impl commented out above. | ||
let stream = TokenStream::from(TokenTree::from(self.clone())); | ||
f.write_str(&stream.to_string()) | ||
} | ||
} | ||
|
||
|
@@ -612,7 +627,11 @@ impl Punct { | |
/// back into the same character. | ||
impl fmt::Display for Punct { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.write_str(&self.to_string()) | ||
// NOTE(kinnison) | ||
// This differs from the "upstream" because we cannot use the ToString | ||
// impl commented out above. | ||
let stream = TokenStream::from(TokenTree::from(self.clone())); | ||
f.write_str(&stream.to_string()) | ||
} | ||
} | ||
|
||
|
@@ -683,7 +702,11 @@ impl Ident { | |
/// back into the same identifier. | ||
impl fmt::Display for Ident { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.write_str(&self.to_string()) | ||
// NOTE(kinnison) | ||
// This differs from the "upstream" because we cannot use the ToString | ||
// impl commented out above. | ||
let stream = TokenStream::from(TokenTree::from(self.clone())); | ||
f.write_str(&stream.to_string()) | ||
} | ||
} | ||
|
||
|
@@ -914,7 +937,11 @@ impl Literal { | |
/// back into the same literal (except for possible rounding for floating point literals). | ||
impl fmt::Display for Literal { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.write_str(&self.to_string()) | ||
// NOTE(kinnison) | ||
// This differs from the "upstream" because we cannot use the ToString | ||
// impl commented out above. | ||
let stream = TokenStream::from(TokenTree::from(self.clone())); | ||
f.write_str(&stream.to_string()) | ||
} | ||
} | ||
|
||
|
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.
oh dear... rust-lang/rust#80505
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's a lot of nasty in pointer comparisons here I guess, though once you start transmuting stuff I think I tap out on knowing what's sane 😬
Do you mean, by this comment, that you want this particular change dropped, annotated that at some point it might be revertable, or do you just mean to mention the horror 😁 ?