Attempting to include!
inner attributes leads to incorrect and confusing diagnostics
#94340
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-bug
Category: This is a bug.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
First of all, trying to
include!
inner attributes should be an error, I think, reading between the lines ofstd::include
's documentation and the Reference on modules. Correct me if I am wrong. I initially did not know this butstd::include
may only include expressions and items (according to the documentation) and inner attributes are not items (according to the Reference).Now, given the following code in file
it.rs
:And the code below in file
attrs.rs
:The current output of
rustc it.rs --crate-type=lib
is:note
saying that they can't beinclude!
d#![no_std]
, annotate the item enclosing them, and are usually found at the beginning of source files andnote: outer attributes, like
#[test]
, annotate the item following themattrs.rs
this confusing/incorrect: those are inner attributes, no item needs to followThis diagnostic is fine, I just read it the wrong way. It just means that an item was expected but not found and along the way, some (outer or inner) attributes were found. It doesn't necessarily mean that those attributes need an item / need to be ascribed to an item<eof>
which in this case should be allowedrustc 1.60.0-nightly (5d8767c 2022-02-12)
@rustbot modify labels: +C-bug +D-incorrect +D-confusing
The text was updated successfully, but these errors were encountered: