Skip to content

Conversation

lukas-code
Copy link
Member

follow-up to #69675.

This pull request allows lint attributes on blocks like this:

fn main() {
    let _ = {
        #![allow(unused_variables)]
        let x = ();
    };
}

I think this should be fine, because attributes are already allowed on blocks, if they are the tail expression of another block:

// this compiles on stable
fn main() {
    let _ = {{
        #![allow(unused_variables)]
        let x = ();
    }};
}

This pull request does not allow outer attributes on blocks or inner attributes that are not lint attributes:

fn main() {
    let _ = #[allow(unused_variables)] {}; // error

    let _ = {
        #![cfg(TRUE)] // error
    };
}

@rust-highfive
Copy link
Contributor

r? @varkor

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 4, 2020
@Centril Centril added A-attributes Area: Attributes (`#[…]`, `#![…]`) needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. T-lang Relevant to the language team A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Mar 11, 2020
@Centril
Copy link
Contributor

Centril commented Mar 11, 2020

Thank you for your contribution. However, I don't think we should be special casing one type of attribute in terms of stability and this does not seem strongly motivated to me (as there are workarounds). Once we feel comfortable stabilizing stmt_expr_attributes this will also be allowed, but without the special case.

cc @petrochenkov

@petrochenkov
Copy link
Contributor

I agree with the previous comment.

@lukas-code lukas-code closed this Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-lang Relevant to the language team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants