-
Notifications
You must be signed in to change notification settings - Fork 13.4k
called Option::unwrap()
on a None
value in compiler/rustc_hir_analysis/src/delegation.rs
#128810
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
A-HIR
Area: The high-level intermediate representation (HIR)
C-bug
Category: This is a bug.
F-fn_delegation
`#![feature(fn_delegation)]`
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
S-bug-has-test
Status: This bug is tracked inside the repo by a `known-bug` test.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
Adding more methods in trait creates more ICE 👀 #![feature(fn_delegation)]
use std::marker::PhantomData;
pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);
impl<'a> InvariantRef<'a, ()> {
pub const NEW: Self = InvariantRef::new(&());
}
trait Trait {
fn foo(&self) -> u8 { 0 }
fn bar(&self) -> u8 { 1 }
fn meh(&self) -> u8 { 2 }
}
struct Z(u8);
impl Trait for Z {
reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
}
fn main() { } Backtrace
|
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Aug 16, 2024
…r=compiler-errors Return correct HirId when finding body owner in diagnostics Fixes rust-lang#129145 Fixes rust-lang#128810 r? `@compiler-errors` ```rust fn generic<const N: u32>() {} trait Collate<const A: u32> { type Pass; fn collate(self) -> Self::Pass; } impl<const B: u32> Collate<B> for i32 { type Pass = (); fn collate(self) -> Self::Pass { generic::<{ true }>() //~^ ERROR: mismatched types } } ``` When type checking the `{ true }` anon const we would error with a type mismatch. This then results in diagnostics code attempting to check whether its due to a type mismatch with the return type. That logic was implemented by walking up the hir until we reached the body owner, except instead of using the `enclosing_body_owner` function it special cased various hir nodes incorrectly resulting in us walking out of the anon const and stopping at `fn collate` instead. This then resulted in diagnostics logic inside of the anon consts `ParamEnv` attempting to do trait solving involving the `<i32 as Collate<B>>::Pass` type which ICEs because it is in the wrong environment. I have rewritten this function to just walk up until it hits the `enclosing_body_owner` and made some other changes since I found this pretty hard to read/understand. Hopefully it's easier to understand now, it also makes it more obvious that this is not implemented in a very principled way and is definitely missing cases :)
tgross35
added a commit
to tgross35/rust
that referenced
this issue
Aug 17, 2024
…r=compiler-errors Return correct HirId when finding body owner in diagnostics Fixes rust-lang#129145 Fixes rust-lang#128810 r? ``@compiler-errors`` ```rust fn generic<const N: u32>() {} trait Collate<const A: u32> { type Pass; fn collate(self) -> Self::Pass; } impl<const B: u32> Collate<B> for i32 { type Pass = (); fn collate(self) -> Self::Pass { generic::<{ true }>() //~^ ERROR: mismatched types } } ``` When type checking the `{ true }` anon const we would error with a type mismatch. This then results in diagnostics code attempting to check whether its due to a type mismatch with the return type. That logic was implemented by walking up the hir until we reached the body owner, except instead of using the `enclosing_body_owner` function it special cased various hir nodes incorrectly resulting in us walking out of the anon const and stopping at `fn collate` instead. This then resulted in diagnostics logic inside of the anon consts `ParamEnv` attempting to do trait solving involving the `<i32 as Collate<B>>::Pass` type which ICEs because it is in the wrong environment. I have rewritten this function to just walk up until it hits the `enclosing_body_owner` and made some other changes since I found this pretty hard to read/understand. Hopefully it's easier to understand now, it also makes it more obvious that this is not implemented in a very principled way and is definitely missing cases :)
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Aug 17, 2024
Rollup merge of rust-lang#129168 - BoxyUwU:mismatched_ty_correct_id, r=compiler-errors Return correct HirId when finding body owner in diagnostics Fixes rust-lang#129145 Fixes rust-lang#128810 r? ```@compiler-errors``` ```rust fn generic<const N: u32>() {} trait Collate<const A: u32> { type Pass; fn collate(self) -> Self::Pass; } impl<const B: u32> Collate<B> for i32 { type Pass = (); fn collate(self) -> Self::Pass { generic::<{ true }>() //~^ ERROR: mismatched types } } ``` When type checking the `{ true }` anon const we would error with a type mismatch. This then results in diagnostics code attempting to check whether its due to a type mismatch with the return type. That logic was implemented by walking up the hir until we reached the body owner, except instead of using the `enclosing_body_owner` function it special cased various hir nodes incorrectly resulting in us walking out of the anon const and stopping at `fn collate` instead. This then resulted in diagnostics logic inside of the anon consts `ParamEnv` attempting to do trait solving involving the `<i32 as Collate<B>>::Pass` type which ICEs because it is in the wrong environment. I have rewritten this function to just walk up until it hits the `enclosing_body_owner` and made some other changes since I found this pretty hard to read/understand. Hopefully it's easier to understand now, it also makes it more obvious that this is not implemented in a very principled way and is definitely missing cases :)
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
A-HIR
Area: The high-level intermediate representation (HIR)
C-bug
Category: This is a bug.
F-fn_delegation
`#![feature(fn_delegation)]`
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
S-bug-has-test
Status: This bug is tracked inside the repo by a `known-bug` test.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Meta
rustc --version --verbose
:Error output
Backtrace
Note
ICE location
rust/compiler/rustc_hir_analysis/src/delegation.rs
Lines 241 to 251 in 60d1465
@rustbot label +F-fn_delegation
The text was updated successfully, but these errors were encountered: