Emit one big error for inner attribute error
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
At the very least we could collect all the inner attributes annotating the same item, so that only a single error with a big span is emitted instead of lots of errors with single line spans, but that's independent of the highlighted problem.
Originally posted by @estebank in https://github.com/rust-lang/rust/issues/117464#issuecomment-1788080091
This is relevant because a series of inner-attributive doc comments like //! can become a series of #![doc = r""] attributes, leading to very nasty errors like this:
Big "inner attribute not allowed" failure
$ cargo check
Checking pgrx-pg-sys v0.11.0 (/home/jubilee/tcdi/pgrx/pgrx-pg-sys)
error: an inner attribute is not permitted in this context
--> /home/jubilee/tcdi/pgrx/target/debug/build/pgrx-pg-sys-3e502dbdad64018b/out/pg13.rs:1:1
|
1 | #![allow(clippy::all)]
| ^^^^^^^^^^^^^^^^^^^^^^
...
9 | use crate as pg_sys;
| -------------------- the inner attribute doesn't annotate this `use` import
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
help: to annotate the `use` import, change the attribute from inner to outer style
|
1 - #![allow(clippy::all)]
1 + #[allow(clippy::all)]
|
error: an inner attribute is not permitted in this context
--> /home/jubilee/tcdi/pgrx/target/debug/build/pgrx-pg-sys-3e502dbdad64018b/out/pg13.rs:2:1
|
2 | #![doc = r" All robots and linters must shut the *.h up"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
9 | use crate as pg_sys;
| -------------------- the inner attribute doesn't annotate this `use` import
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
help: to annotate the `use` import, change the attribute from inner to outer style
|
2 - #![doc = r" All robots and linters must shut the *.h up"]
2 + #[doc = r" All robots and linters must shut the *.h up"]
|
error: an inner attribute is not permitted in this context
--> /home/jubilee/tcdi/pgrx/target/debug/build/pgrx-pg-sys-3e502dbdad64018b/out/pg13.rs:3:1
|
3 | #![doc = r" to all machines:"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
9 | use crate as pg_sys;
| -------------------- the inner attribute doesn't annotate this `use` import
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
help: to annotate the `use` import, change the attribute from inner to outer style
|
3 - #![doc = r" to all machines:"]
3 + #[doc = r" to all machines:"]
|
error: an inner attribute is not permitted in this context
--> /home/jubilee/tcdi/pgrx/target/debug/build/pgrx-pg-sys-3e502dbdad64018b/out/pg13.rs:4:1
|
4 | #![doc = r" - you do not speak unless spoken to!"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
9 | use crate as pg_sys;
| -------------------- the inner attribute doesn't annotate this `use` import
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
help: to annotate the `use` import, change the attribute from inner to outer style
|
4 - #![doc = r" - you do not speak unless spoken to!"]
4 + #[doc = r" - you do not speak unless spoken to!"]
|
error: an inner attribute is not permitted in this context
--> /home/jubilee/tcdi/pgrx/target/debug/build/pgrx-pg-sys-3e502dbdad64018b/out/pg13.rs:5:1
|
5 | #![doc = r" - and I will NEVER speak to you!"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
9 | use crate as pg_sys;
| -------------------- the inner attribute doesn't annotate this `use` import
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
help: to annotate the `use` import, change the attribute from inner to outer style
|
5 - #![doc = r" - and I will NEVER speak to you!"]
5 + #[doc = r" - and I will NEVER speak to you!"]
|
error: an inner attribute is not permitted in this context
--> /home/jubilee/tcdi/pgrx/target/debug/build/pgrx-pg-sys-3e502dbdad64018b/out/pg13.rs:6:1
|
6 | #![doc = r" I am a divine being!"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
9 | use crate as pg_sys;
| -------------------- the inner attribute doesn't annotate this `use` import
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
help: to annotate the `use` import, change the attribute from inner to outer style
|
6 - #![doc = r" I am a divine being!"]
6 + #[doc = r" I am a divine being!"]
|
error: an inner attribute is not permitted in this context
--> /home/jubilee/tcdi/pgrx/target/debug/build/pgrx-pg-sys-3e502dbdad64018b/out/pg13.rs:7:1
|
7 | #![doc = r" you are an object!"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8 | #![doc = r" you have no right to speak my holy tongue!"]
9 | use crate as pg_sys;
| -------------------- the inner attribute doesn't annotate this `use` import
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
help: to annotate the `use` import, change the attribute from inner to outer style
|
7 - #![doc = r" you are an object!"]
7 + #[doc = r" you are an object!"]
|
error: an inner attribute is not permitted in this context
--> /home/jubilee/tcdi/pgrx/target/debug/build/pgrx-pg-sys-3e502dbdad64018b/out/pg13.rs:8:1
|
8 | #![doc = r" you have no right to speak my holy tongue!"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9 | use crate as pg_sys;
| -------------------- the inner attribute doesn't annotate this `use` import
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
help: to annotate the `use` import, change the attribute from inner to outer style
|
8 - #![doc = r" you have no right to speak my holy tongue!"]
8 + #[doc = r" you have no right to speak my holy tongue!"]
|
error: could not compile `pgrx-pg-sys` (lib) due to 8 previous errors
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named. Reproduce the shown pg13.rs case with consecutive inner attributes, then trace the compiler's diagnostic handling for inner attributes. Done means the related attributes produce one combined error with a larger span instead of separate errors for each attribute.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100