Skip to content

Outer attribute after inner attribute error should give more information #61218

Closed
@estebank

Description

@estebank

Given the following

#[feature(lang_items)]
#![recursion_limit="100"] //~ ERROR an inner attribute is not permitted following an outer attribute
fn main() {}

we currently emit

error: an inner attribute is not permitted following an outer attribute
--> $DIR/inner-attr.rs:3:3
|
LL | #![recursion_limit="100"]
| ^
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.

We should emit at least the following

error: an inner attribute is not permitted following an outer attribute
  --> $DIR/inner-attr.rs:3:3
   |
LL | #[feature(lang_items)]
   | ---------------------- previous outer attribute
LL | 
LL | #![recursion_limit="100"]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^ not permited following an outer attibute
   |
   = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.

We might also want to provide suggestions when it makes sense (like turning the feature attr into an outer attr).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.P-lowLow priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions