-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Open
Open
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.F-generic_const_items`#![feature(generic_const_items)]``#![feature(generic_const_items)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Using the following flags
--force-warn no_mangle_const_items
this code:
//! Test that nonsense bounds prevent consts from being evaluated at all.
//@ check-pass
#![feature(generic_const_items)]
#![allow(incomplete_features)]
trait Trait {
const ASSOC: u32;
}
// rustfmt eats the where bound
#[unsafe(no_mangle)]
const ASSOC: u32 = <&'static ()>::ASSOC where for<'a> &'a (): Trait;
fn main() {}caused the following diagnostics:
Checking _23d74b92f51a14cefeb40f5cad7a397b39971b5d v0.1.0 (/tmp/icemaker_global_tempdir.fzTw1TOrsbiL/icemaker_clippyfix_tempdir.xP3b20GgdVBR/_23d74b92f51a14cefeb40f5cad7a397b39971b5d)
warning: const items should never be `#[no_mangle]`
--> src/main.rs:12:1
|
12 | const ASSOC: u32 = <&'static ()>::ASSOC where for<'a> &'a (): Trait;
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| help: try a static value: `pub static`
|
= note: requested on the command line with `--force-warn no-mangle-const-items`
warning: `_23d74b92f51a14cefeb40f5cad7a397b39971b5d` (bin "_23d74b92f51a14cefeb40f5cad7a397b39971b5d") generated 1 warning (run `cargo clippy --fix --bin "_23d74b92f51a14cefeb40f5cad7a397b39971b5d" -p _23d74b92f51a14cefeb40f5cad7a397b39971b5d` to apply 1 suggestion)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.21s
However after applying these diagnostics, the resulting code:
//! Test that nonsense bounds prevent consts from being evaluated at all.
//@ check-pass
#![feature(generic_const_items)]
#![allow(incomplete_features)]
trait Trait {
const ASSOC: u32;
}
// rustfmt eats the where bound
#[unsafe(no_mangle)]
pub static ASSOC: u32 = <&'static ()>::ASSOC where for<'a> &'a (): Trait;
fn main() {}no longer compiled:
Checking _23d74b92f51a14cefeb40f5cad7a397b39971b5d v0.1.0 (/tmp/icemaker_global_tempdir.fzTw1TOrsbiL/icemaker_clippyfix_tempdir.xP3b20GgdVBR/_23d74b92f51a14cefeb40f5cad7a397b39971b5d)
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found keyword `where`
--> src/main.rs:12:46
|
12 | pub static ASSOC: u32 = <&'static ()>::ASSOC where for<'a> &'a (): Trait;
| ^^^^^ expected one of 7 possible tokens
error: could not compile `_23d74b92f51a14cefeb40f5cad7a397b39971b5d` (bin "_23d74b92f51a14cefeb40f5cad7a397b39971b5d") due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `_23d74b92f51a14cefeb40f5cad7a397b39971b5d` (bin "_23d74b92f51a14cefeb40f5cad7a397b39971b5d" test) due to 1 previous error
Version:
rustc 1.93.0-nightly (f40a70d2b 2025-11-30)
binary: rustc
commit-hash: f40a70d2bcd830a4f1f8c7ca1a7f93f1d9d703d6
commit-date: 2025-11-30
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.F-generic_const_items`#![feature(generic_const_items)]``#![feature(generic_const_items)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Status
Can Do