-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix incorrect cfg
structured suggestion and make suggestion verbose
#137773
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
Open
estebank
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
estebank:attr-span
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+205
−83
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,7 +219,7 @@ impl Attribute { | |
/// Extracts the MetaItem from inside this Attribute. | ||
pub fn meta(&self) -> Option<MetaItem> { | ||
match &self.kind { | ||
AttrKind::Normal(normal) => normal.item.meta(self.span), | ||
AttrKind::Normal(normal) => normal.item.meta(), | ||
AttrKind::DocComment(..) => None, | ||
} | ||
} | ||
|
@@ -285,12 +285,12 @@ impl AttrItem { | |
} | ||
} | ||
|
||
pub fn meta(&self, span: Span) -> Option<MetaItem> { | ||
pub fn meta(&self) -> Option<MetaItem> { | ||
Some(MetaItem { | ||
unsafety: Safety::Default, | ||
path: self.path.clone(), | ||
kind: self.meta_kind()?, | ||
span, | ||
span: self.span(), | ||
}) | ||
} | ||
|
||
|
@@ -406,7 +406,7 @@ impl MetaItem { | |
Path { span, segments, tokens: None } | ||
} | ||
Some(TokenTree::Token(Token { kind: token::Interpolated(nt), .. }, _)) => match &**nt { | ||
token::Nonterminal::NtMeta(item) => return item.meta(item.path.span), | ||
token::Nonterminal::NtMeta(item) => return item.meta(), | ||
token::Nonterminal::NtPath(path) => (**path).clone(), | ||
_ => return None, | ||
}, | ||
|
@@ -620,8 +620,15 @@ pub fn mk_attr( | |
path: Path, | ||
args: AttrArgs, | ||
span: Span, | ||
inner_span: Span, | ||
) -> Attribute { | ||
mk_attr_from_item(g, AttrItem { unsafety, path, args, tokens: None }, None, style, span) | ||
mk_attr_from_item( | ||
g, | ||
AttrItem { unsafety, path, args, tokens: None, span: inner_span }, | ||
None, | ||
style, | ||
span, | ||
) | ||
} | ||
|
||
pub fn mk_attr_from_item( | ||
|
@@ -645,10 +652,11 @@ pub fn mk_attr_word( | |
unsafety: Safety, | ||
name: Symbol, | ||
span: Span, | ||
inner_span: Span, | ||
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 no caller needs this to be different as there are no args |
||
) -> Attribute { | ||
let path = Path::from_ident(Ident::new(name, span)); | ||
let args = AttrArgs::Empty; | ||
mk_attr(g, style, unsafety, path, args, span) | ||
mk_attr(g, style, unsafety, path, args, span, inner_span) | ||
} | ||
|
||
pub fn mk_attr_nested_word( | ||
|
@@ -658,6 +666,7 @@ pub fn mk_attr_nested_word( | |
outer: Symbol, | ||
inner: Symbol, | ||
span: Span, | ||
inner_span: Span, | ||
) -> Attribute { | ||
let inner_tokens = TokenStream::new(vec![TokenTree::Token( | ||
Token::from_ast_ident(Ident::new(inner, span)), | ||
|
@@ -670,7 +679,7 @@ pub fn mk_attr_nested_word( | |
delim: Delimiter::Parenthesis, | ||
tokens: inner_tokens, | ||
}); | ||
mk_attr(g, style, unsafety, path, attr_args, span) | ||
mk_attr(g, style, unsafety, path, attr_args, span, inner_span) | ||
} | ||
|
||
pub fn mk_attr_name_value_str( | ||
|
@@ -680,6 +689,7 @@ pub fn mk_attr_name_value_str( | |
name: Symbol, | ||
val: Symbol, | ||
span: Span, | ||
inner_span: Span, | ||
) -> Attribute { | ||
let lit = token::Lit::new(token::Str, escape_string_symbol(val), None); | ||
let expr = P(Expr { | ||
|
@@ -691,7 +701,7 @@ pub fn mk_attr_name_value_str( | |
}); | ||
let path = Path::from_ident(Ident::new(name, span)); | ||
let args = AttrArgs::Eq { eq_span: span, expr }; | ||
mk_attr(g, style, unsafety, path, args, span) | ||
mk_attr(g, style, unsafety, path, args, span, inner_span) | ||
} | ||
|
||
pub fn filter_by_name<A: AttributeExt>(attrs: &[A], name: Symbol) -> impl Iterator<Item = &A> { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Pls add docs with examples what it refers to