Skip to content

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

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

Closed
Jess3Jane opened this issue Feb 16, 2020 · 4 comments
Closed

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

Jess3Jane opened this issue Feb 16, 2020 · 4 comments
Assignees
Labels
A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Jess3Jane
Copy link

Jess3Jane commented Feb 16, 2020

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.heygears.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.heygears.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
@Jess3Jane Jess3Jane added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 16, 2020
@jonas-schievink jonas-schievink added A-associated-items Area: Associated items (types, constants & functions) I-nominated regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Feb 16, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Feb 16, 2020
@hellow554
Copy link
Contributor

The function isn't needed for the ICE to happen:

trait IAmATrait {
    type Item;
}

impl IAmATrait for () {
    type Item = _;
}

fn main() {}

@estebank
Copy link
Contributor

Will be fixed by #69148.

@pnkfelix
Copy link
Member

triage: P-high. Has PR. Removing nomination tag.

@pnkfelix pnkfelix added P-high High priority and removed I-nominated labels Feb 20, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Feb 28, 2020
Account for bounds and asociated items when denying `_`

Fix rust-lang#68801, rust-lang#69204. Follow up to rust-lang#67597 and rust-lang#68071.

Output for the original ICE report:

```
    Checking vinoteca v5.0.0 (/Users/ekuber/workspace/vinoteca)
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
  --> src/producers.rs:43:70
   |
43 | pub fn top<Table: diesel::Table + diesel::query_dsl::InternalJoinDsl<_, diesel::query_source::joins::Inner, _>>(table: Table, limit: usize, connection: DbConn) -> RestResult<Vec<TopWineType>> {
   |                                                                      ^ not allowed in type signatures       ^ not allowed in type signatures

error: aborting due to previous error
```
bors added a commit that referenced this issue Feb 28, 2020
Account for bounds and asociated items when denying `_`

Fix #68801, #69204. Follow up to #67597 and #68071.

Output for the original ICE report:

```
    Checking vinoteca v5.0.0 (/Users/ekuber/workspace/vinoteca)
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
  --> src/producers.rs:43:70
   |
43 | pub fn top<Table: diesel::Table + diesel::query_dsl::InternalJoinDsl<_, diesel::query_source::joins::Inner, _>>(table: Table, limit: usize, connection: DbConn) -> RestResult<Vec<TopWineType>> {
   |                                                                      ^ not allowed in type signatures       ^ not allowed in type signatures

error: aborting due to previous error
```
@JohnTitor
Copy link
Member

Fixed by #69324 directly and the actual fix (#69148) has landed, closing.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants