Skip to content

Commit 6a8683f

Browse files
authored
Rollup merge of #69896 - petrochenkov:reqname2, r=Centril
parse: Tweak the function parameter edition check Follow-up to #69801. Edition of a code fragment is inferred from "the place where the code is written". For individual tokens like edition-specific keywords it may be the span of the token itself ("uninterpolated" span), but for larger code fragments it's probably not, in the test example the trait method is obviously written in "2015 edition code". r? @Centril
2 parents a05bab5 + 6b27e8d commit 6a8683f

8 files changed

+23
-3
lines changed

src/librustc_parse/parser/item.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1544,9 +1544,7 @@ impl<'a> Parser<'a> {
15441544

15451545
let is_name_required = match self.token.kind {
15461546
token::DotDotDot => false,
1547-
// FIXME: Consider using interpolated token for this edition check,
1548-
// it should match the intent of edition hygiene better.
1549-
_ => req_name(self.token.uninterpolate().span.edition()),
1547+
_ => req_name(self.token.span.edition()),
15501548
};
15511549
let (pat, ty) = if is_name_required || self.is_named_param() {
15521550
debug!("parse_param_general parse_pat (is_name_required:{})", is_name_required);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
// edition:2018
3+
// aux-build:anon-params-edition-hygiene.rs
4+
5+
#[macro_use]
6+
extern crate anon_params_edition_hygiene;
7+
8+
generate_trait_2015!(u8);
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// edition:2015
2+
3+
#[macro_export]
4+
macro_rules! generate_trait_2015 {
5+
($Type: ident) => {
6+
trait Trait {
7+
fn method($Type) {}
8+
}
9+
};
10+
}
11+
12+
fn main() {}

0 commit comments

Comments
 (0)