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

parse: Tweak the function parameter edition check #69896

Merged
merged 1 commit into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/librustc_parse/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1544,9 +1544,7 @@ impl<'a> Parser<'a> {

let is_name_required = match self.token.kind {
token::DotDotDot => false,
// FIXME: Consider using interpolated token for this edition check,
// it should match the intent of edition hygiene better.
_ => req_name(self.token.uninterpolate().span.edition()),
_ => req_name(self.token.span.edition()),
};
let (pat, ty) = if is_name_required || self.is_named_param() {
debug!("parse_param_general parse_pat (is_name_required:{})", is_name_required);
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/anon-params/anon-params-edition-hygiene.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// check-pass
// edition:2018
// aux-build:anon-params-edition-hygiene.rs

#[macro_use]
extern crate anon_params_edition_hygiene;

generate_trait_2015!(u8);

fn main() {}
12 changes: 12 additions & 0 deletions src/test/ui/anon-params/auxiliary/anon-params-edition-hygiene.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// edition:2015

#[macro_export]
macro_rules! generate_trait_2015 {
($Type: ident) => {
trait Trait {
fn method($Type) {}
}
};
}

fn main() {}