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

Clippy breaks when a struct was renamed in definition only. #8147

Closed
codybloemhard opened this issue Dec 19, 2021 · 3 comments
Closed

Clippy breaks when a struct was renamed in definition only. #8147

codybloemhard opened this issue Dec 19, 2021 · 3 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@codybloemhard
Copy link

Summary

I wanted to rename a struct so I started by the definition and compiled, which in my case is always cargo clippy --all-features. It crashed after giving the errors. It does not crash with cargo check. I don't have time to reduce all the code but trying a very simple case does not crash so it's something more complicated than this:

struct NotOof{
    a: f32,
    b: u32,
}

impl Oof{
    pub fn new() -> Self{
        Self{ a: 0.0, b: 2 }
    }
}

fn main() {
    println!("Hello, world!");
    let oof = Oof::new();
}

I left a branch on my public repo that has the code on it that crashes for me:
https://github.com/ocdy1001/clrays/tree/clippy-ice
Point of interest is at src/kernels.rs at line 96.

Version

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0

Error output

Backtrace

 λ  clrays   clippy-ice  📦 v0.1.0  ⚙ 11s cargo clippy --all-features
  Checking clrays-rs v0.1.0 (/home/cody/git/clrays)
error[E0433]: failed to resolve: use of undeclared type `TraceKernelReal`
--> src/trace_processor.rs:30:32
 |
30 | ...   let kernel = unpackdb!(TraceKernelReal::new("raytracing", (width, height), &program, &queue, sce
 |                              ^^^^^^^^^^^^^^^ use of undeclared type `TraceKernelReal`

error[E0412]: cannot find type `TraceKernelReal` in this scope
 --> src/kernels.rs:107:6
  |
107 | impl TraceKernelReal{
  |      ^^^^^^^^^^^^^^^ help: a struct with a similar name exists: `TraceKernelAa`
...
199 | pub struct TraceKernelAa{
  | ------------------------ similarly named struct `TraceKernelAa` defined here

error[E0412]: cannot find type `TraceKernelReal` in this scope
 --> src/kernels.rs:177:26
  |
177 | impl VoidKernel<u32> for TraceKernelReal{
  |                          ^^^^^^^^^^^^^^^ help: a struct with a similar name exists: `TraceKernelAa`
...
199 | pub struct TraceKernelAa{
  | ------------------------ similarly named struct `TraceKernelAa` defined here

error[E0412]: cannot find type `TraceKernelReal` in this scope
 --> src/kernels.rs:189:28
  |
189 | impl ResultKernel<u32> for TraceKernelReal{
  |                            ^^^^^^^^^^^^^^^ help: a struct with a similar name exists: `TraceKernelAa`
...
199 | pub struct TraceKernelAa{
  | ------------------------ similarly named struct `TraceKernelAa` defined here

error[E0412]: cannot find type `TraceKernelReal` in this scope
 --> src/trace_processor.rs:20:17
  |
20  |     kernel: Box<TraceKernelReal>,
  |                 ^^^^^^^^^^^^^^^
  |
   ::: src/kernels.rs:199:1
  |
199 | pub struct TraceKernelAa{
  | ------------------------ similarly named struct `TraceKernelAa` defined here
  |
help: a struct with a similar name exists
  |
20  |     kernel: Box<TraceKernelAa>,
  |                 ~~~~~~~~~~~~~
help: you might be missing a type parameter
  |
19  | pub struct RealTracer<TraceKernelReal>{
  |                      +++++++++++++++++

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/f1edd0429582dd29cccacaf50f
stack backtrace:
 0: rust_begin_unwind
           at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:517:5
 1: core::panicking::panic_fmt
           at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
 2: core::panicking::panic
           at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:50:5
 3: <rustc_query_impl::on_disk_cache::OnDiskCache as rustc_middle::ty::context::OnDiskCache>::def_path_ha
 4: rustc_middle::dep_graph::dep_node::<impl rustc_query_system::dep_graph::dep_node::DepNodeParams<rustc
 5: rustc_query_impl::query_callbacks::hir_owner::force_from_dep_node
 6: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
 7: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
 8: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
 9: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
10: rustc_query_system::query::plumbing::ensure_must_run
11: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::coherent_trait
12: rustc_session::session::Session::track_errors
13: rustc_typeck::check_crate
14: rustc_interface::passes::analysis
15: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
16: rustc_data_structures::stack::ensure_sufficient_stack
17: rustc_query_system::query::plumbing::try_execute_query
18: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
19: rustc_interface::passes::QueryContext::enter
20: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
21: rustc_span::with_source_map
22: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new

note: Clippy version: clippy 0.1.57 (f1edd04 2021-11-29)

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
Some errors have detailed explanations: E0412, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `clrays-rs` due to 5 previous errors

@codybloemhard codybloemhard added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Dec 19, 2021
@codybloemhard
Copy link
Author

So, the struct was named TraceKernelReal and I wanted to name it TraceKernelWhitted. As described in the comment at src/kernels.rs at line 96, when I name it back to that it works again. I went back and forth to check it multiple times to check. But now that I went on with my work and renamed it TraceKernelWhitted and resolved the errors, it still crashes. cargo check compiles fine and the program runs. Error and backtrace looks the same as can be found above in the initial comment of this issue.

@giraffate
Copy link
Contributor

It seems to be duplicate of rust-lang/rust#91511.

@xFrednet
Copy link
Member

Hey, this is triage. It's likely that this was an incremental compilation issue in rustc as linked above. I'll close this issue for now, since the linked issue has been resolved. If this happens again, please open a new issue. Thank you for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants