Skip to content

Fix the span for discriminators in non-C-like enums - #17415

Merged
bors merged 1 commit into
masterfrom
unknown repository
Sep 21, 2014
Merged

Fix the span for discriminators in non-C-like enums#17415
bors merged 1 commit into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Sep 20, 2014

Copy link
Copy Markdown

Fixes #17383.

Comment thread src/test/compile-fail/issue-17383.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you modify the test to make the b'a' token on its own line? Something like:

enum X {
    A =
        b'a' //~ ERROR: ...
    ,
    B(int)
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Definitely! Done.

bors added a commit that referenced this pull request Sep 21, 2014
@bors bors closed this Sep 21, 2014
@bors
bors merged commit 3514737 into rust-lang:master Sep 21, 2014
@ghost
ghost deleted the issue-17383 branch October 2, 2014 20:24
lnicola pushed a commit to lnicola/rust that referenced this pull request Jun 23, 2024
…eykril

fix: Only show unlinked-file diagnostic on first line during startup

This partially reverts rust-lang#17350, based on the feedback in rust-lang#17397.

If we don't have an autofix, it's more annoying to highlight the whole file. This autofix heuristic fixes the diagnostic being overwhelming during startup.
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jul 23, 2026
…lizers (rust-lang#17415)

Fixes rust-lang/rust-clippy#13910.

`ref_as_ptr` can suggest `std::ptr::from_ref`/`std::ptr::from_mut` for
nested reference-to-raw-pointer casts inside `const` and `static`
initializers. The suggested replacement then fails during const
evaluation.

The existing guard only checks the immediate expression use site, which
misses nested cast expressions. Extend it to also check whether the
expression is inside an always-const context using
`is_inside_always_const_context`.

### Testing

- Added a regression test reproducing the reported nested `static mut`
case.
- Ran the `ref_as_ptr` UI tests.

changelog: [`ref_as_ptr`]: avoid invalid suggestions in const/static
initializers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"discriminator values can only be used with a c-like enum" wrong span

3 participants