-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 Type parameter I/#1
(I/1) out of range when substituting
#59956
Comments
Update: struct Bug<B = Self>;
impl Bug {} |
I got hit by the same thing and was excited that Rust now supported The ICE was introduced in 1.32.0: $ cat bug.rs
struct Bug<B = Self>;
impl Bug {}
$ rustc +1.31.1 bug.rs
error[E0411]: cannot find type `Self` in this scope
--> bug.rs:1:16
|
1 | struct Bug<B = Self>;
| ^^^^ `Self` is only available in traits and impls
error[E0601]: `main` function not found in crate `bug`
|
= note: consider adding a `main` function to `bug.rs`
error[E0392]: parameter `B` is never used
--> bug.rs:1:12
|
1 | struct Bug<B = Self>;
| ^ unused type parameter
|
= help: consider removing `B` or using a marker such as `std::marker::PhantomData`
error: aborting due to 3 previous errors
Some errors occurred: E0392, E0411, E0601.
For more information about an error, try `rustc --explain E0392`.
$ rustc +1.32.0 bug.rs
error[E0601]: `main` function not found in crate `bug`
|
= note: consider adding a `main` function to `bug.rs`
error: internal compiler error: src/librustc/ty/subst.rs:491: Type parameter `B/#0` (B/0) out of range when substituting (root type=Some(Bug<B>)) substs=[]
--> bug.rs:3:6
|
3 | impl Bug {}
| ^^^
thread 'main' panicked at 'Box<Any>', src/librustc_errors/lib.rs:538:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0601`.
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.32.0 (9fda7c223 2019-01-16) running on x86_64-unknown-linux-gnu As long as the #[allow(dead_code)]
struct Bug<B = Self>(Option<B>);
impl Bug<u32> {} As an aside, is there any plan or interest for supporting Self default type parameters in structs? In the following, I would expect the types struct A<T, U = Self>(T, Option<Box<U>>);
struct B<T>(T, Option<Box<B<T>>>); (Yes I am aware of at least some potential issues related to recursive types and multiple default arguments, but they should be solvable with the appropriate restrictions I believe) |
This was fixed by #64842, including a similar test |
The following code ICE's on stable, beta and nightly, on both editions:
Backtrace:
The text was updated successfully, but these errors were encountered: