Skip to content
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

Fix outdated comment #67482

Merged
merged 1 commit into from
Dec 29, 2019
Merged

Fix outdated comment #67482

merged 1 commit into from
Dec 29, 2019

Conversation

ldm0
Copy link
Contributor

@ldm0 ldm0 commented Dec 21, 2019

Logics in libsyntax/ext/expand.rs:MacroExpander::expand() have been moved to libsyntax_expand/expand.rs:MacroExpander::fully_expand_fragment()
This pull request fixs the dangling file path.

Old

let derive_allowed = match item {
Annotatable::Item(ref item) => match item.node {
ast::ItemKind::Struct(..) |
ast::ItemKind::Enum(..) |
ast::ItemKind::Union(..) => true,
_ => false,
},
_ => false,
};
if !derive_allowed {
let span = item.attrs().iter()
.find(|attr| attr.check_name("derive"))
.expect("`derive` attribute should exist").span;
self.cx.span_err(span,
"`derive` may only be applied to structs, enums \
and unions");
}

New

if !item.derive_allowed() {
let attr = attr::find_by_name(item.attrs(), sym::derive)
.expect("`derive` attribute should exist");
let span = attr.span;
let mut err = self.cx.struct_span_err(span,
"`derive` may only be applied to structs, enums and unions");
if let ast::AttrStyle::Inner = attr.style {
let trait_list = derives.iter()
.map(|t| pprust::path_to_string(t))
.collect::<Vec<_>>();
let suggestion = format!("#[derive({})]", trait_list.join(", "));
err.span_suggestion(
span, "try an outer attribute", suggestion,
// We don't 𝑘𝑛𝑜𝑤 that the following item is an ADT
Applicability::MaybeIncorrect
);
}
err.emit();
}

pub fn derive_allowed(&self) -> bool {
match *self {
Annotatable::Item(ref item) => match item.kind {
ast::ItemKind::Struct(..) |
ast::ItemKind::Enum(..) |
ast::ItemKind::Union(..) => true,
_ => false,
},
_ => false,
}
}

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 21, 2019
@Centril
Copy link
Contributor

Centril commented Dec 21, 2019

r? @petrochenkov

@Dylan-DPC-zz
Copy link

@ldm0 please do not merge changes, rather rebase over master. Thanks

Logics in libsyntax/ext/expand.rs:MacroExpander::expand() have moved to libsyntax_expand/expand.rs:MacroExpander::fully_expand_fragment()
@ldm0
Copy link
Contributor Author

ldm0 commented Dec 22, 2019

@Dylan-DPC Sorry, fixed

@petrochenkov
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Dec 28, 2019

📌 Commit decb959 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 28, 2019
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Dec 29, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
bors added a commit that referenced this pull request Dec 29, 2019
Rollup of 3 pull requests

Successful merges:

 - #67482 (Fix outdated comment)
 - #67673 (Update .mailmap)
 - #67679 (Change "be returning" to "return")

Failed merges:

r? @ghost
@bors bors merged commit decb959 into rust-lang:master Dec 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants