Skip to content

_ in associated types causes nightly and beta compiler to panic #69204

Closed
@Jess3Jane

Description

@Jess3Jane

Code

trait IAmATrait {
    type Item;
    fn function(&self) -> Self::Item;
}

struct IAmAnObject(usize);

impl IAmATrait for IAmAnObject {
    type Item = _;
    fn function(&self) -> Self::Item {
        self.0
    }
}

fn main() {}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018

Meta

rustc --version --verbose:

rustc 1.43.0-nightly (61d9231ff 2020-02-15)
binary: rustc
commit-hash: 61d9231ff2604a0467987042d9ebf9ff9ea739b5
commit-date: 2020-02-15
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0

Error output

error: internal compiler error: bad placeholder type
 --> test.rs:9:17
  |
9 |     type Item = _;
  |                 ^

error: internal compiler error: cat_expr Errd
  --> test.rs:10:38
   |
10 |       fn function(&self) -> Self::Item {
   |  ______________________________________^
11 | |         self.0
12 | |     }
   | |_____^

error: internal compiler error: PromoteTemps: MIR had errors
  --> test.rs:10:5
   |
10 | /     fn function(&self) -> Self::Item {
11 | |         self.0
12 | |     }
   | |_____^

error: internal compiler error: broken MIR in DefId(0:11 ~ test[317d]::{{impl}}[0]::function[0]) ("return type"): bad type [type error]
  --> test.rs:10:5
   |
10 | /     fn function(&self) -> Self::Item {
11 | |         self.0
12 | |     }
   | |_____^

error: internal compiler error: broken MIR in DefId(0:11 ~ test[317d]::{{impl}}[0]::function[0]) (LocalDecl { mutability: Mut, local_info: Other, internal: false, is_block_tail: None, ty: [type error], user_ty: UserTypeProjections { contents: [] }, source_info: SourceInfo { span: test.rs:10:5: 12:6, scope: scope[0] } }): bad type [type error]
  --> test.rs:10:5
   |
10 | /     fn function(&self) -> Self::Item {
11 | |         self.0
12 | |     }
   | |_____^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:355:17
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1052
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1428
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
  12: std::panicking::begin_panic
  13: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
  14: core::ptr::drop_in_place
  15: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
  16: core::ptr::drop_in_place
  17: rustc_interface::interface::run_compiler_in_existing_thread_pool
  18: scoped_tls::ScopedKey<T>::set
  19: syntax::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

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.43.0-nightly (61d9231ff 2020-02-15) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

Metadata

Metadata

Assignees

Labels

A-associated-itemsArea: Associated items (types, constants & functions)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions