Closed
Description
I have been able to reproduce #64282.
If an fn
inside an impl
has a param attr on the first parameter, no matter how many, they are not visible in the TokenStream
.
Repro repo: https://github.com/bbqsrc/params-attribute-example
Source:
#[rename_params(send_help)]
fn hello(#[angery(true)] a: i32, #[a2] b: i32, #[what = "how"] c: u32) {}
#[rename_params(send_help)]
impl Foo {
fn hello(#[angery(true)] a: i32, #[a2] b: i32, #[what = "how"] c: u32) {}
fn hello2(#[a1] #[a2] a: i32, #[what = "how"] b: i32, #[angery(true)] c: u32) {}
fn hello_self(#[a1] #[a2] &self, #[a1] #[a2] a: i32, #[what = "how"] b: i32, #[angery(true)] c: u32) {}
}
Printed output:
fn hello(#[angery(true)] a: i32, #[a2] b: i32, #[what = "how"] c: u32) { }
impl Foo {
fn hello(a: i32, #[a2] b: i32, #[what = "how"] c: u32) { }
fn hello2(a: i32, #[what = "how"] b: i32, #[angery(true)] c: u32) { }
fn hello_self(#[a1] #[a2] &self, #[a1] #[a2] a: i32,
#[what = "how"] b: i32, #[angery(true)] c: u32) {
}
}
As you can see, hello
and hello2
are missing their attrs on the a
param. The addition of self
however gives both self
and the a
param their attrs. Weird.
$ rustc --version
rustc 1.39.0-nightly (ed8b708c1 2019-09-21)
Activity
bbqsrc commentedon Sep 22, 2019
Ping @Centril
bbqsrc commentedon Sep 22, 2019
Also pinging @c410-f3r due to impact on #64010.
c410-f3r commentedon Sep 25, 2019
I'm rather busy this week and I can only take a look into it in this weekend
pnkfelix commentedon Sep 26, 2019
triage: P-high. Leaving nominated in hopes to find someone to look into it, since @c410-f3r won't have time for next few days.
pnkfelix commentedon Sep 26, 2019
assigning to @Centril
Centril commentedon Sep 29, 2019
Investigation thus far: I don't think the problem is in pretty printing but somewhere else.
results in:
However: the problem is not in the parser:results in:
on stable.
But the problem does appear at least in AST validation:
Actually, it turns out the problem is in the parser, and we have a bug that allows:
10 remaining items