Skip to content

associated type missing default #6882

Closed
@XiangpengHao

Description

@XiangpengHao

Code example from #6792,
the pr (#6812) doesn't seem to fix it

Code

struct Test {}
trait SomeTrait {
  type Outer;

  fn broken() -> Self::Outer;
}

struct Inner {}
impl SomeTrait for Inner {
  type Outer = Test;

  fn broken() -> Self::Outer {
    Self::Outer{}
  }
}

fn main() {}

Meta

  • cargo clippy -V: clippy 0.1.52 (3a5d45f 2021-03-09)
  • rustc -Vv:
rustc 1.52.0-nightly (3a5d45f68 2021-03-09)
binary: rustc
commit-hash: 3a5d45f68cadc8fff4fbb557780f92b403b19c19
commit-date: 2021-03-09
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 12.0.0

Error output

error: internal compiler error: compiler/rustc_typeck/src/collect/type_of.rs:278:17: associated type missing default
  --> src/main.rs:22:3
   |
22 |   type Outer;
   |   ^^^^^^^^^^^

thread 'rustc' panicked at 'Box<Any>', /rustc/3a5d45f68cadc8fff4fbb557780f92b403b19c19/library/std/src/panic.rs:59:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new

note: Clippy version: clippy 0.1.52 (3a5d45f 2021-03-09)

query stack during panic:
#0 [type_of] computing type of `SomeTrait::Outer`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `rust_test`

To learn more, run the command again with --verbose.
Backtrace

<backtrace>

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions