Skip to content

Conversation

@reddevilmidzy
Copy link
Contributor

@reddevilmidzy reddevilmidzy commented Dec 2, 2025

resolve: #149511

@rustbot rustbot added 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 Dec 2, 2025
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] tracing_tree test:false 0.482
   Compiling rustc_borrowck v0.0.0 (/checkout/compiler/rustc_borrowck)
[RUSTC-TIMING] rustc_passes test:false 12.605
   Compiling rustc_resolve v0.0.0 (/checkout/compiler/rustc_resolve)
error[E0615]: attempted to take value of method `is_empty` on type `&[rustc_hir::GenericParam<'_>]`
    --> compiler/rustc_lint/src/builtin.rs:1002:40
     |
1002 |                     && generics.params.is_empty
     |                                        ^^^^^^^^ method, not a field
     |

{
// account for "pub const" (#45562)
let start = cx
.tcx
Copy link
Member

@fmease fmease Dec 2, 2025

Choose a reason for hiding this comment

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

(unrelated) This cx.tcx.sess.source_map().span_to_snippet(it.span).map(|snippet| snippet.find("const").unwrap_or(0)).unwrap_or(0) as u32; let suggestion = it.span.with_hi(BytePos(it.span.lo().0 + start + 5)); can probably be made more robust (accounting for source code comments for example) & simplified by changing it to let suggestion = item.vis_span.to(ident.span); (at least I think that's what it's computing).

}
}
hir::ItemKind::Const(..) => {
if find_attr!(attrs, AttributeKind::NoMangle(..)) {
Copy link
Member

Choose a reason for hiding this comment

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

We still want to emit the lint, we just want to suppress the suggestion. So make the suggestion in BuiltinConstNoMangle Optional and set it to None if there are params or a where-clause.

@rustbot
Copy link
Collaborator

rustbot commented Dec 2, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@fmease fmease self-assigned this Dec 2, 2025
@@ -0,0 +1,16 @@
//! Test that nonsense bounds prevent consts from being evaluated at all.
Copy link
Member

@bjorn3 bjorn3 Dec 2, 2025

Choose a reason for hiding this comment

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

This is not what this test file tests. Also please give the test a better name and location.

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

Labels

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.

no_mangle_const_items: const -> pub static suggestion causes syntax error

5 participants