Skip to content

Conversation

JonathanBrouwer
Copy link
Contributor

Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 21, 2025
| ^^^^^---^
| | |
| | expected a valid identifier here
| help: must be of the form: `#![cfg(predicate)]`
Copy link
Contributor Author

@JonathanBrouwer JonathanBrouwer Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This help message is suggesting attribute related things, which is awful. Will fix in a separate PR that will go before this one (which is why this is in draft)

@rust-log-analyzer

This comment has been minimized.

Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
@JonathanBrouwer JonathanBrouwer added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Oct 21, 2025
&CFG_ATTR_TEMPLATE,
)
.ok_or_else(|| {
.map_err(|_err: ErrorGuaranteed| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the delayed bug below necessary? Having an error guaranteed here effectively proves error emission already

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is in a Parser run, we need to produce PResult, which is Result<T, Diag>. This was my hack to create a Diag, I was still gonna see if there was a better way to do this

cfg!(); //~ ERROR macro requires a cfg-pattern
cfg!(123); //~ ERROR literal in `cfg` predicate value must be a boolean
cfg!(foo = 123); //~ ERROR literal in `cfg` predicate value must be a string
cfg!(123); //~ ERROR malformed `cfg` attribute input
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I like these diagnostics, it's not an attribute!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a discussion open for this, that's why it's a draft :)


Erroneous code example:

```compile_fail,E0536
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this old error code was correct

Copy link
Contributor Author

@JonathanBrouwer JonathanBrouwer Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old error code (E0536) is no longer emitted by anything, except cfg in the doc attribute. This example now emits the new error code.
I may change the example to use the doc attribute for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) S-blocked Status: Blocked on something else such as an RFC or other implementation work. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants