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

ICE in clippy::borrow_interior_mutable_const #12979

Open
saethlin opened this issue Jun 22, 2024 · 1 comment · May be fixed by #13207
Open

ICE in clippy::borrow_interior_mutable_const #12979

saethlin opened this issue Jun 22, 2024 · 1 comment · May be fixed by #13207
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@saethlin
Copy link
Member

saethlin commented Jun 22, 2024

Summary

#![deny(clippy::borrow_interior_mutable_const)]

use std::cell::UnsafeCell;

const ATOMIC_TUPLE: (Vec<UnsafeCell<u8>>, u8) = (Vec::new(), 42);

fn main() {
    let _x = &ATOMIC_TUPLE.0;
}

reports:

error: internal compiler error: /home/ben/rust/compiler/rustc_middle/src/ty/consts/valtree.rs:55:18: expected branch, got Leaf(0x0000000000000000)

thread 'rustc' panicked at /home/ben/rust/compiler/rustc_middle/src/ty/consts/valtree.rs:55:18:

The problem is this unwrap_branch:

ty::Adt(def, args) => val
.unwrap_branch()

Version

rustc 1.81.0-nightly (c1b336cb6 2024-06-21)
binary: rustc
commit-hash: c1b336cb6b491b3be02cd821774f03af4992f413
commit-date: 2024-06-21
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Figuring out what's broken here is blocking rust-lang/rust#126793

@saethlin saethlin added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jun 22, 2024
@y21
Copy link
Member

y21 commented Jun 23, 2024

Looks like the lint calls is_value_unfrozen_expr with the type of ATOMIC_TUPLE.0 (Vec<UnsafeCell<i32>>), but it is passing the valtree of the whole const (a tuple), so the type does not match the valtree, however they need to match each other so that the function can correctly traverse the valtree.
Otherwise we run into this ICE here where the function thinks it's looking at struct Cap(usize); and expecting a branch but it's already at the usize which is a leaf.

That specific repro seems to only ICE in nightly, probably because of #12691 where the lint was made stronger, but the root cause has existed for longer it seems. Smaller repro that also ICEs on stable:

use std::cell::Cell;

const C: ((i32, Cell<i32>), i32) = ((0, Cell::new(1)), 2);

fn main() {
  let _x = &C.0;
}

bors added a commit to rust-lang-ci/rust that referenced this issue Jul 14, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 14, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 14, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 14, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 15, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 15, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 30, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
@Jarcho Jarcho linked a pull request Aug 3, 2024 that will close this issue
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 3, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 9, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 10, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 10, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.

try-job: x86_64-msvc
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 10, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.

try-job: x86_64-msvc
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 11, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.

try-job: x86_64-msvc
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 11, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.

try-job: x86_64-msvc
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 12, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
RalfJung pushed a commit to RalfJung/miri that referenced this issue Aug 12, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Aug 13, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
Jarcho pushed a commit to Jarcho/rust-clippy that referenced this issue Aug 24, 2024
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered rust-lang#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
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

Successfully merging a pull request may close this issue.

2 participants