mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Rollup merge of #69896 - petrochenkov:reqname2, r=Centril
parse: Tweak the function parameter edition check Follow-up to https://github.com/rust-lang/rust/pull/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
This commit is contained in:
commit
6a8683fcd0
@ -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);
|
||||
|
10
src/test/ui/anon-params/anon-params-edition-hygiene.rs
Normal file
10
src/test/ui/anon-params/anon-params-edition-hygiene.rs
Normal file
@ -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() {}
|
@ -0,0 +1,12 @@
|
||||
// edition:2015
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! generate_trait_2015 {
|
||||
($Type: ident) => {
|
||||
trait Trait {
|
||||
fn method($Type) {}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user