Description
Hello! I'm reporting an apparent compiler error stemming from a typo.
Version
$ rustc --version --verbose
rustc 1.4.0-nightly (7bf626a68 2015-09-07)
binary: rustc
commit-hash: 7bf626a68045be1d1a4fac9a635113bb7775b6bb
commit-date: 2015-09-07
host: x86_64-apple-darwin
release: 1.4.0-nightly
Repro
It suffices to attempt compilation of the following:
Ex. 1
use std::ops::BitXor;
fn f() {
let x: u8 = BitXor::bitor(0 as u8, 0 as u8);
}
The above does compile if the obvious typo is fixed. I tried to find an even smaller example which failed similarly. A smaller example which does not compile if the typo is fixed, but as is, also fails with an error similar to Ex. 1:
Ex. 2
use std::ops::BitXor;
fn f() {
let g = BitXor::bitor;
}
My build invocation was cargo build
.
Expected behavior
For Ex 1., I would expect to see some sort of name resolution error. That example compiles if bitor
is replaced with bitxor
. For Ex. 2, I have a less certain expectation, but would still expect some sort of name resolution error.
Observed behavior
Both snippets fail to compile with the following error message:
error: internal compiler error: Type parameter `Self/SelfSpace.0` (Self/SelfSpace/0) out of range when substituting (root type=Some(Self)) substs=Substs[types=[[];[];[]], regions=[[];[];[]]]
Backtraces follow below.
Ex. 1
$ RUST_BACKTRACE=1 cargo build
Compiling bugreport v0.1.0 (file:///Users/joe/devel/bugreport)
src/lib.rs:4:17: 4:30 error: internal compiler error: Type parameter `Self/SelfSpace.0` (Self/SelfSpace/0) out of range when substituting (root type=Some(Self)) substs=Substs[types=[[];[];[]], regions=[[];[];[]]]
src/lib.rs:4 let x: u8 = BitXor::bitor(0 as u8, 0 as u8);
^~~~~~~~~~~~~
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
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/diagnostic.rs:176
stack backtrace:
1: 0x111eab820 - sys::backtrace::tracing::imp::write::h8eb606f0676b1c68Sqs
2: 0x111eb263b - panicking::on_panic::h439344cab6a0722eKXw
3: 0x111e74362 - rt::unwind::begin_unwind_inner::h208ecd91d43787c9Msw
4: 0x10f71977a - rt::unwind::begin_unwind::h544928616495927122
5: 0x10f719742 - diagnostic::SpanHandler::span_bug::hd65799bd4f0c505a6NA
6: 0x10eb9bcfe - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_ty::h93ff7eb3e9afebb7TYQ
7: 0x10e5c1df0 - check::FnCtxt<'a, 'tcx>.AstConv<'tcx>::ty_infer::hb0bb190e00a198c90Cq
8: 0x10e63f435 - iter::Map<I, F>.Iterator::next::h1142259025829094402
9: 0x10e63e41e - astconv::create_substs_for_ast_path::hd4dfccf714bc74f4q2v
10: 0x10e6466e9 - astconv::create_substs_for_ast_trait_ref::h4368114ff2eab34dfrw
11: 0x10e64431c - astconv::ast_path_to_poly_trait_ref::h29bb903d881cbabdAow
12: 0x10e63455c - astconv::finish_resolving_def_to_ty::habd24143c000f312Phx
13: 0x10e532532 - check::resolve_ty_and_def_ufcs::h94d5f667283b3292wVt
14: 0x10e62e174 - check::check_expr_with_unifier::h17434517167852192102
15: 0x10e5c3877 - check::callee::check_call::heb2226e51ebba80aGUm
16: 0x10e618052 - check::check_expr_with_unifier::h7638636721109620462
17: 0x10e636fd5 - check::check_decl_initializer::h60197528b46dd3ddB2t
18: 0x10e637083 - check::check_decl_local::hada2f84316d1a260P3t
19: 0x10e6374a7 - check::check_stmt::ha7821baa526c3cf6I5t
20: 0x10e5edd77 - check::check_block_with_expected::h008ebf27f3d681a9F9t
21: 0x10e5c3010 - check::check_fn::h73e2f75c353c138drJp
22: 0x10e5e4bac - check::check_bare_fn::h9d4937e09659b1ff0yp
23: 0x10e5e2903 - check::check_item_body::hbee3397a0255ef56k0p
24: 0x10e69d3e1 - check_crate::hfc612f2e81e3f3ec1BE
25: 0x10de1d74a - driver::phase_3_run_analysis_passes::closure.21870
26: 0x10ddff38a - middle::ty::ctxt<'tcx>::create_and_enter::h10730255013514676807
27: 0x10ddfab95 - driver::phase_3_run_analysis_passes::h3370851894325132430
28: 0x10dddb585 - driver::compile_input::h88f9e5d56c3193e90ba
29: 0x10df40250 - run_compiler::h0bd793d9ea569018qqc
30: 0x10df3db49 - boxed::F.FnBox<A>::call_box::h4277668881798780915
31: 0x10df3d542 - rt::unwind::try::try_fn::h17584184833201088243
32: 0x111eb21f8 - __rust_try
33: 0x111e9e400 - rt::unwind::try::inner_try::h1851ddf9ecd93c2fFow
34: 0x10df3d6f2 - boxed::F.FnBox<A>::call_box::h5084478766513466170
35: 0x111eb156d - sys::thread::Thread::new::thread_start::hc131c4deb753ff20oNv
36: 0x7fff8de30267 - _pthread_body
37: 0x7fff8de301e4 - _pthread_start
Could not compile `bugreport`.
Ex. 2
$ RUST_BACKTRACE=1 cargo build
Compiling bugreport v0.1.0 (file:///Users/joe/devel/bugreport)
src/lib.rs:9:13: 9:26 error: internal compiler error: Type parameter `Self/SelfSpace.0` (Self/SelfSpace/0) out of range when substituting (root type=Some(Self)) substs=Substs[types=[[];[];[]], regions=[[];[];[]]]
src/lib.rs:9 let g = BitXor::bitor;
^~~~~~~~~~~~~
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
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/diagnostic.rs:176
stack backtrace:
1: 0x1081f2820 - sys::backtrace::tracing::imp::write::h8eb606f0676b1c68Sqs
2: 0x1081f963b - panicking::on_panic::h439344cab6a0722eKXw
3: 0x1081bb362 - rt::unwind::begin_unwind_inner::h208ecd91d43787c9Msw
4: 0x105a7177a - rt::unwind::begin_unwind::h544928616495927122
5: 0x105a71742 - diagnostic::SpanHandler::span_bug::hd65799bd4f0c505a6NA
6: 0x104efbcfe - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_ty::h93ff7eb3e9afebb7TYQ
7: 0x104922df0 - check::FnCtxt<'a, 'tcx>.AstConv<'tcx>::ty_infer::hb0bb190e00a198c90Cq
8: 0x1049a0435 - iter::Map<I, F>.Iterator::next::h1142259025829094402
9: 0x10499f41e - astconv::create_substs_for_ast_path::hd4dfccf714bc74f4q2v
10: 0x1049a76e9 - astconv::create_substs_for_ast_trait_ref::h4368114ff2eab34dfrw
11: 0x1049a531c - astconv::ast_path_to_poly_trait_ref::h29bb903d881cbabdAow
12: 0x10499555c - astconv::finish_resolving_def_to_ty::habd24143c000f312Phx
13: 0x104893532 - check::resolve_ty_and_def_ufcs::h94d5f667283b3292wVt
14: 0x10497c667 - check::check_expr_with_unifier::h7638636721109620462
15: 0x104997fd5 - check::check_decl_initializer::h60197528b46dd3ddB2t
16: 0x104998083 - check::check_decl_local::hada2f84316d1a260P3t
17: 0x1049984a7 - check::check_stmt::ha7821baa526c3cf6I5t
18: 0x10494ed77 - check::check_block_with_expected::h008ebf27f3d681a9F9t
19: 0x104924010 - check::check_fn::h73e2f75c353c138drJp
20: 0x104945bac - check::check_bare_fn::h9d4937e09659b1ff0yp
21: 0x104943903 - check::check_item_body::hbee3397a0255ef56k0p
22: 0x1049fe3e1 - check_crate::hfc612f2e81e3f3ec1BE
23: 0x10417974a - driver::phase_3_run_analysis_passes::closure.21870
24: 0x10415b38a - middle::ty::ctxt<'tcx>::create_and_enter::h10730255013514676807
25: 0x104156b95 - driver::phase_3_run_analysis_passes::h3370851894325132430
26: 0x104137585 - driver::compile_input::h88f9e5d56c3193e90ba
27: 0x10429c250 - run_compiler::h0bd793d9ea569018qqc
28: 0x104299b49 - boxed::F.FnBox<A>::call_box::h4277668881798780915
29: 0x104299542 - rt::unwind::try::try_fn::h17584184833201088243
30: 0x1081f91f8 - __rust_try
31: 0x1081e5400 - rt::unwind::try::inner_try::h1851ddf9ecd93c2fFow
32: 0x1042996f2 - boxed::F.FnBox<A>::call_box::h5084478766513466170
33: 0x1081f856d - sys::thread::Thread::new::thread_start::hc131c4deb753ff20oNv
34: 0x7fff8de30267 - _pthread_body
35: 0x7fff8de301e4 - _pthread_start
Could not compile `bugreport`.
Notes
Similar errors can be elicited with other imports (e.g. using BitOr
instead of BitXor
) or when the qualified identifier will definitely not be found elsewhere (e.g. referring to BitXor::nonexistent_name
instead of BitXor::bitor
).