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

Expression attribute duplication #3313

Closed
ghost opened this issue Feb 2, 2019 · 1 comment
Closed

Expression attribute duplication #3313

ghost opened this issue Feb 2, 2019 · 1 comment
Labels
blocked Blocked on rustc, an RFC, etc. bug Panic, non-idempotency, invalid code, etc.

Comments

@ghost
Copy link

ghost commented Feb 2, 2019

input

Playground

#![feature(stmt_expr_attributes)]

fn main() {
    let foo;
    #[must_use]
    foo = false;
}

output

#![feature(stmt_expr_attributes)]

fn main() {
    let foo;
    #[must_use]
    #[must_use]
    foo = false;
}
@scampi scampi added the bug Panic, non-idempotency, invalid code, etc. label Feb 2, 2019
@topecongiro
Copy link
Contributor

The problem is that the span of assignment (foo = false) does not include the attribute, so rustfmt incorrectly adds it as 'missing'.

@topecongiro topecongiro added the blocked Blocked on rustc, an RFC, etc. label Feb 3, 2019
kennytm added a commit to kennytm/rust that referenced this issue Feb 5, 2019
…r=petrochenkov

Include the span of attributes of the lhs to the span of the assignment expression

This PR adds the span of attributes of the lhs to the span of the assignment expression. Currently with the following code, `#[attr]` is not included to the span of the assignment (`foo = true`).

```rust
#[attr]
foo = true;
```
The rational behind this change is that as libsyntax user I expect the span of the parent node includes every span of child nodes.

cc rust-lang/rustfmt#3313, rust-lang#15701.
topecongiro added a commit to topecongiro/rustfmt that referenced this issue Feb 6, 2019
topecongiro added a commit to topecongiro/rustfmt that referenced this issue Feb 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked on rustc, an RFC, etc. bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

No branches or pull requests

2 participants