Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug assertion ice: bad spans: -Wunused-lifetimes #108248

Open
matthiaskrgr opened this issue Feb 19, 2023 · 4 comments
Open

debug assertion ice: bad spans: -Wunused-lifetimes #108248

matthiaskrgr opened this issue Feb 19, 2023 · 4 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ L-unused_lifetimes Lint: unused_lifetimes requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Feb 19, 2023

Code

fn main() {
    let _: extern fn<'a: 'static>();
}

The problem is this first garbage span:

warning: lifetime parameter `'a` never used
 --> recover-fn-ptr-with-generics.rs:2:22
  |
2 |     let _: extern fn<'a: 'static>();
  |            -         ^^
  |            |
  |            help: elide the unused lifetime
  |
  = note: requested on the command line with `-W unused-lifetimes`

Meta

rustc --version --verbose:

eebdfb55fce148676c24555505aebf648123b2de

Error output

<output>

unused_lifetime.txt

@matthiaskrgr matthiaskrgr added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way labels Feb 19, 2023
@KittyBorgX
Copy link
Member

KittyBorgX commented Feb 20, 2023

@matthiaskrgr I think I can take this up.
Before I do, just some questions:

  • What's the expected output which I can use to verify?
  • I can't reproduce the help: elide the unused lifetime part:
    image
    and there's no ICE for me.

rustc --version --verbose for me:

rustc 1.69.0-nightly (7aa413d59 2023-02-19)
binary: rustc
commit-hash: 7aa413d59206fd511137728df3d9e0fd377429bd
commit-date: 2023-02-19
host: aarch64-apple-darwin
release: 1.69.0-nightly
LLVM version: 15.0.7

Edit : I'm on the latest nightly

@clubby789
Copy link
Contributor

clubby789 commented Feb 20, 2023

You need to build with debug assertions, and invoke with -Wunused-lifetimes. I believe the bad span is created around

let span = ty.span.shrink_to_lo().to(bare_fn.decl_span.shrink_to_lo());

I tried modifying that span to instead contain the generics, which fixes this case but regresses a few other cases

@layerkugou
Copy link

very good

@jieyouxu jieyouxu added L-unconditional_recursion Lint: unconditional_recursion L-unused_lifetimes Lint: unused_lifetimes and removed L-unconditional_recursion Lint: unconditional_recursion labels May 13, 2024
fmease added a commit to fmease/rust that referenced this issue Jan 27, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 27, 2025
Rollup merge of rust-lang#136072 - cyrgani:old-crash-tests, r=WaffleLapkin

add two old crash tests

This is for rust-lang#108248 and rust-lang#132826.
@cyrgani
Copy link
Contributor

cyrgani commented Jan 27, 2025

@rustbot label S-bug-has-test

@rustbot rustbot added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ L-unused_lifetimes Lint: unused_lifetimes requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants