From 6b27e8d2a631183babfb25c5aac008b263ba4978 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 10 Mar 2020 21:02:15 +0300 Subject: [PATCH] parse: Tweak the function parameter edition check Move anon-params tests to ui/anon-params. --- src/librustc_parse/parser/item.rs | 4 +--- .../ui/{ => anon-params}/anon-params-denied-2018.rs | 0 .../{ => anon-params}/anon-params-denied-2018.stderr | 0 .../{ => anon-params}/anon-params-deprecated.fixed | 0 .../ui/{ => anon-params}/anon-params-deprecated.rs | 0 .../{ => anon-params}/anon-params-deprecated.stderr | 0 .../ui/anon-params/anon-params-edition-hygiene.rs | 10 ++++++++++ .../auxiliary/anon-params-edition-hygiene.rs | 12 ++++++++++++ 8 files changed, 23 insertions(+), 3 deletions(-) rename src/test/ui/{ => anon-params}/anon-params-denied-2018.rs (100%) rename src/test/ui/{ => anon-params}/anon-params-denied-2018.stderr (100%) rename src/test/ui/{ => anon-params}/anon-params-deprecated.fixed (100%) rename src/test/ui/{ => anon-params}/anon-params-deprecated.rs (100%) rename src/test/ui/{ => anon-params}/anon-params-deprecated.stderr (100%) create mode 100644 src/test/ui/anon-params/anon-params-edition-hygiene.rs create mode 100644 src/test/ui/anon-params/auxiliary/anon-params-edition-hygiene.rs diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index 126686c8defbf..a9c4de04c0a2e 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -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); diff --git a/src/test/ui/anon-params-denied-2018.rs b/src/test/ui/anon-params/anon-params-denied-2018.rs similarity index 100% rename from src/test/ui/anon-params-denied-2018.rs rename to src/test/ui/anon-params/anon-params-denied-2018.rs diff --git a/src/test/ui/anon-params-denied-2018.stderr b/src/test/ui/anon-params/anon-params-denied-2018.stderr similarity index 100% rename from src/test/ui/anon-params-denied-2018.stderr rename to src/test/ui/anon-params/anon-params-denied-2018.stderr diff --git a/src/test/ui/anon-params-deprecated.fixed b/src/test/ui/anon-params/anon-params-deprecated.fixed similarity index 100% rename from src/test/ui/anon-params-deprecated.fixed rename to src/test/ui/anon-params/anon-params-deprecated.fixed diff --git a/src/test/ui/anon-params-deprecated.rs b/src/test/ui/anon-params/anon-params-deprecated.rs similarity index 100% rename from src/test/ui/anon-params-deprecated.rs rename to src/test/ui/anon-params/anon-params-deprecated.rs diff --git a/src/test/ui/anon-params-deprecated.stderr b/src/test/ui/anon-params/anon-params-deprecated.stderr similarity index 100% rename from src/test/ui/anon-params-deprecated.stderr rename to src/test/ui/anon-params/anon-params-deprecated.stderr diff --git a/src/test/ui/anon-params/anon-params-edition-hygiene.rs b/src/test/ui/anon-params/anon-params-edition-hygiene.rs new file mode 100644 index 0000000000000..14e11c5696f4a --- /dev/null +++ b/src/test/ui/anon-params/anon-params-edition-hygiene.rs @@ -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() {} diff --git a/src/test/ui/anon-params/auxiliary/anon-params-edition-hygiene.rs b/src/test/ui/anon-params/auxiliary/anon-params-edition-hygiene.rs new file mode 100644 index 0000000000000..aa4221becc24f --- /dev/null +++ b/src/test/ui/anon-params/auxiliary/anon-params-edition-hygiene.rs @@ -0,0 +1,12 @@ +// edition:2015 + +#[macro_export] +macro_rules! generate_trait_2015 { + ($Type: ident) => { + trait Trait { + fn method($Type) {} + } + }; +} + +fn main() {}