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

ICE when using "Generic Associated Types" feature with references for impl block #80433

Closed
rxcompile opened this issue Dec 28, 2020 · 4 comments · Fixed by #79554
Closed

ICE when using "Generic Associated Types" feature with references for impl block #80433

rxcompile opened this issue Dec 28, 2020 · 4 comments · Fixed by #79554
Labels
A-GATs Area: Generic associated types (GATs) C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@rxcompile
Copy link

Code

#![allow(incomplete_features)]
#![feature(generic_associated_types)]

#[derive(Default)]
struct E<T> {
    data: T,
}

trait TestMut {
    type Output<'a>;
    fn test_mut<'a>(&'a mut self) -> Self::Output<'a>;
}

impl<T> TestMut for E<T>
where
    T: 'static,
{
    type Output<'a> = &'a mut T;
    fn test_mut<'a>(&'a mut self) -> Self::Output<'a> {
        &mut self.data
    }
}

fn test_simpler<'a>(dst: &'a mut impl TestMut<Output = &'a mut f32>)
{
    for n in 0i16..100 {
        *dst.test_mut() = n.into();
    }
}

fn main() {
    let mut t1: E<f32> = Default::default();
    test_simpler(&mut t1);
}

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (bb178237c 2020-12-25)
binary: rustc
commit-hash: bb178237c5539c75e1b85ab78a8ab902b1f333d5
commit-date: 2020-12-25
host: x86_64-apple-darwin
release: 1.50.0-nightly

Error output

error: internal compiler error: impl item and trait item have different parameter counts
  --> src/main.rs:33:5
   |
33 |     test_simpler(&mut t1);
   |     ^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/project.rs:1418:23

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at /rustc/bb178237c5539c75e1b85ab78a8ab902b1f333d5/compiler/rustc_middle/src/ty/relate.rs:347:59

error: internal compiler error: impl item and trait item have different parameter counts
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/project.rs:1418:23

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:974:13
Backtrace

   0:        0x1107200dc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha6f5ddd5259d3e16
   1:        0x110784c8d - core::fmt::write::hefe95a44532fe6ed
   2:        0x110711e86 - std::io::Write::write_fmt::hf513c99961415bff
   3:        0x110723d89 - std::panicking::default_hook::{{closure}}::h70a3a940826edea5
   4:        0x110723910 - std::panicking::default_hook::h9520f36dd50be056
   5:        0x108cb1458 - rustc_driver::report_ice::h64178aa7cd01307c
   6:        0x11072456e - std::panicking::rust_panic_with_hook::h102f8bee4e0ef4c7
   7:        0x110724075 - std::panicking::begin_panic_handler::{{closure}}::hb72eee9aad2e147c
   8:        0x110720598 - std::sys_common::backtrace::__rust_end_short_backtrace::h372ff87ecb2667f3
   9:        0x110723fda - _rust_begin_unwind
  10:        0x1107ab27b - std::panicking::begin_panic_fmt::hf0e714fa3e981e6e
  11:        0x10d3472a6 - rustc_errors::HandlerInner::flush_delayed::he9da53448a9bd660
  12:        0x10d3434eb - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::h44af1dc5df0a1fa4
  13:        0x108ccba5a - core::ptr::drop_in_place::hd03156b954b70984
  14:        0x108ccefb8 - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::hd4c9eabf652375d9
  15:        0x108cc8112 - core::ptr::drop_in_place::h83698f86dd7e4a49
  16:        0x108cb3ab1 - rustc_span::with_source_map::hb3cfcc431ed11000
  17:        0x108ce7694 - rustc_interface::interface::create_compiler_and_run::he8e7b2281c1964ad
  18:        0x108cbff94 - std::sys_common::backtrace::__rust_begin_short_backtrace::h9bf0a320b59d4a76
  19:        0x108c56799 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hb43737fa064e4b63
  20:        0x11073150d - std::sys::unix::thread::Thread::new::thread_start::h93dd3097fa4fa219
  21:     0x7fff20358950 - __pthread_start

@rxcompile rxcompile 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 Dec 28, 2020
@rxcompile rxcompile changed the title ICE when using "Generic Assotiated Types" feature with mutable borrows ICE when using "Generic Assotiated Types" feature with mutable references Dec 28, 2020
@rxcompile rxcompile changed the title ICE when using "Generic Assotiated Types" feature with mutable references ICE when using "Generic Associated Types" feature with mutable references Dec 28, 2020
@rxcompile rxcompile changed the title ICE when using "Generic Associated Types" feature with mutable references ICE when using "Generic Associated Types" feature with references for impl block Dec 28, 2020
@fanninpm
Copy link

fanninpm added a commit to fanninpm/glacier that referenced this issue Dec 29, 2020
@jyn514
Copy link
Member

jyn514 commented Dec 29, 2020

Slightly smaller:

#![allow(incomplete_features)]
#![feature(generic_associated_types)]

struct E {}

trait TestMut {
    type Output<'a>;
    fn test_mut(&mut self) -> Self::Output<'static>;
}

impl TestMut for E {
    type Output<'a> = usize;
    fn test_mut(&mut self) -> Self::Output<'static> {
        todo!()
    }
}

fn test_simpler(_: impl TestMut<Output = usize>) {}

fn main() {
    test_simpler(E {});
}

Playground

@jyn514 jyn514 added F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs requires-nightly This issue requires a nightly compiler in some way. labels Dec 29, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 31, 2020
@b-naber
Copy link
Contributor

b-naber commented Jan 10, 2021

This should work once #79554 lands using fn test_simpler<'a>(dst: &'a mut impl TestMut<Output<'a> = &'a mut f32>)

@b-naber
Copy link
Contributor

b-naber commented Feb 3, 2021

There's another error in @rxcompile 's code, you mutably borrow in the loop, you might be able to fix this if you re-borrow.

m-ou-se added a commit to m-ou-se/rust that referenced this issue Feb 5, 2021
…-trait-paths, r=jackh726

Generic associated types in trait paths

This is the second part of rust-lang#78978

This should fix:

Fixes rust-lang#67510
Fixes rust-lang#68648
Fixes rust-lang#68649
Fixes rust-lang#68650
Fixes rust-lang#68652
Fixes rust-lang#74684
Fixes rust-lang#76535
Fixes rust-lang#79422
Fixes rust-lang#80433

and implement the remaining functionality needed for rust-lang#44265

r? `@matthewjasper`
@bors bors closed this as completed in deec6a9 Feb 5, 2021
@fmease fmease added the A-GATs Area: Generic associated types (GATs) label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-GATs Area: Generic associated types (GATs) C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants