-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Tweak diagnostic for use
suggestion to blank text surrounding span.
#90941
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,63 @@ | ||||||||||||||||||
// aux-build:amputate-span.rs | ||||||||||||||||||
|
// FIXME: UsePlacementFinder is broken because active attributes are | |
// removed, and thus the `derive` attribute here is not in the AST. | |
// An inert attribute should work, though. | |
// #[derive(Debug)] | |
use std::path::Path; | |
#[allow(warnings)] | |
pub struct Foo; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0433]: failed to resolve: use of undeclared type `Command` | ||
--> $DIR/amputate-span.rs:48:5 | ||
| | ||
LL | Command::new("git"); | ||
| ^^^^^^^ not found in this scope | ||
| | ||
help: consider importing this struct | ||
| | ||
LL | use std::process::Command; | ||
| | ||
|
||
error[E0433]: failed to resolve: use of undeclared type `Command` | ||
--> $DIR/amputate-span.rs:61:2 | ||
| | ||
LL | Command::new("git"); | ||
| ^^^^^^^ not found in this scope | ||
| | ||
help: consider importing this struct | ||
| | ||
LL | use std::process::Command; | ||
| | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0433`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// force-host | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::TokenStream; | ||
|
||
#[proc_macro_attribute] | ||
pub fn drop_first_token(attr: TokenStream, input: TokenStream) -> TokenStream { | ||
assert!(attr.is_empty()); | ||
input.into_iter().skip(1).collect() | ||
} |
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.
If the goal is to preserve indentation, I think removing any non-whitespace characters may be better? For example, in the
async fn
case, you probably wantuse
aligned withasync
, not indented to thefn
.Uh oh!
There was an error while loading. Please reload this page.
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.
Well, then trailing
... */
comments (which would likewise get removed under your suggestion) end up messing up the indentation?And I guess if the item is on the same line as its containing module, we might likewise have a problem:
But I freely admit, both of these cases sound much more rare than
#[tokio::main]
. :)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.
(I think I'm gradually talking myself into going back and looking at deriving the span from the span of the containing mod/crate again, despite my earlier frustrations with that approach.)