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

BUG:src/hir_typeck/common.cpp:751: Impl parameters were not expected (got T/*I:0*/) #322

Open
iamanonymouscs opened this issue Oct 10, 2023 · 5 comments

Comments

@iamanonymouscs
Copy link

iamanonymouscs commented Oct 10, 2023

Code

$ cat small.rs

#![crate_type = "lib"]
struct Assert<const COND: bool>;
trait IsTrue {}
impl IsTrue for Assert<true> {}
trait IsNotZst {}
impl<T> IsNotZst for T
where
    Assert<{ std::mem::size_of::<T>() > 0 }>: IsTrue,
{}
fn assert_not_zero_sized<T: IsNotZst>(_: T) {}
fn main() {
    assert_not_zero_sized(vec![]);
}

Version

mrustc --version

rustc 1.29.100 (mrustc v0.10.0 master:4c7e8171)
release: 1.29.100
- Build time: Tue, 26 Sep 2023 07:36:21 +0000
- Commit: 4c7e81716493678df9fe9cac86ea9beedc57db44

Command

mrustc -L output-1.54.0 small.rs

Output

The error message I received is: ":0:0 BUG: src/hir_typeck/common.cpp:751: Impl parameters were not expected (got T/I:0/)".

I found that when I remove the first line, the compiler could output the correct error message🤣

Setup: V V V
(0.00 s) Setup: DONE
Target Load: V V V
(0.00 s) Target Load: DONE
Parse: V V V
(0.00 s) Parse: DONE
LoadCrates: V V V
(0.39 s) LoadCrates: DONE
Expand: V V V
(0.00 s) Expand: DONE
- main: params.outfile = lib3.rlib
Implicit Crates: V V V
(0.00 s) Implicit Crates: DONE
Resolve Use: V V V
(0.00 s) Resolve Use: DONE
Resolve Index: V V V
(0.00 s) Resolve Index: DONE
Resolve Absolute: V V V
(0.00 s) Resolve Absolute: DONE
HIR Lower: V V V
(0.00 s) HIR Lower: DONE
Lifetime Elision: V V V
(0.00 s) Lifetime Elision: DONE
Resolve Type Aliases: V V V
(0.00 s) Resolve Type Aliases: DONE
Resolve Bind: V V V
(0.10 s) Resolve Bind: DONE
Resolve UFCS Outer: V V V
(0.00 s) Resolve UFCS Outer: DONE
Resolve HIR Self Type: V V V
(0.00 s) Resolve HIR Self Type: DONE
Resolve HIR Markings: V V V
(0.00 s) Resolve HIR Markings: DONE
Sort Impls: V V V
(0.01 s) Sort Impls: DONE
Resolve UFCS paths: V V V
(0.00 s) Resolve UFCS paths: DONE
Constant Evaluate: V V V
:0:0 BUG:src/hir_typeck/common.cpp:751: Impl parameters were not expected (got T/*I:0*/)
Aborted (core dumped)

If remove the first line of the code:

Implicit Crates: V V V
:0:0 warn:0:Multiple panic_runtime crates loaded - panic_abort-0_0_0 and panic_unwind-0_0_0
:0:0 error:0:Unable to locate crate 'alloc_system' in search directories
Aborted (core dumped)
@thepowersgang
Copy link
Owner

Removing the first line just causes it to fail to compile earlier.

@thepowersgang
Copy link
Owner

The std::mem::size_of::<T>() > 0 is the cause of the issue, constant evaluation isn't correctly propagating the generic parameter through to the expansion/evaluation of that expression.

@iamanonymouscs
Copy link
Author

The std::mem::size_of::<T>() > 0 is the cause of the issue, constant evaluation isn't correctly propagating the generic parameter through to the expansion/evaluation of that expression.

Will this issue be fixed in the future? 🤣It seems that the compiler did not successfully output the error message and instead caused an internal error in the compiler😶‍🌫️

@thepowersgang
Copy link
Owner

It's an ICE because the generic type was copied to a scope with no generics.
I'll address the issue when I get time.

@iamanonymouscs
Copy link
Author

It's an ICE because the generic type was copied to a scope with no generics. I'll address the issue when I get time.

Thank you for your dedication and responsiveness. I look forward to seeing the issue resolved soon~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants