Skip to content

Hang: type_alias_impl_trait #132797

Open
Open
@wxie7

Description

@wxie7

I tried this code:

rustc file.rs
#![feature(type_alias_impl_trait)]
trait Id {
    type Assoc;
}
impl<T> *const u8 {
    type Assoc = T;
}
type Ty
where
    Ty: Id<Assoc = Ty>,
= impl Sized;
fn define() -> Ty {}
fn main() {}

This file causes rustc to hang and is derived from mutant #109387. #109387 can terminate successfully.

Meta

rustc --version --verbose:

rustc 1.84.0-nightly (b91a3a056 2024-11-07)
binary: rustc
commit-hash: b91a3a05609a46f73d23e0995ae7ebb4a4f429a5
commit-date: 2024-11-07
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3
Compiler Output (before the hang)
error[E0658]: inherent associated types are unstable
 --> file.rs:6:5
  |
6 |     type Assoc = T;
  |     ^^^^^^^^^^^^^^^
  |
  = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information
  = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable
  = note: this compiler was built on 2024-11-04; consider upgrading it if it is out of date

error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
 --> file.rs:5:6
  |
5 | impl<T> *const u8 {
  |      ^ unconstrained type parameter

error[E0277]: the trait bound `Ty: Id` is not satisfied
  --> file.rs:8:1
   |
8  | type Ty
   | ^^^^^^^ the trait `Id` is not implemented for `Ty`
   |
help: this trait has no implementations, consider adding one
  --> file.rs:2:1
   |
2  | trait Id {
   | ^^^^^^^^
note: required by a bound on the type alias `Ty`
  --> file.rs:10:9
   |
10 |     Ty: Id<Assoc = Ty>,
   |         ^^^^^^^^^^^^^^ required by this bound

error[E0277]: the trait bound `Ty: Id` is not satisfied
  --> file.rs:10:5
   |
10 |     Ty: Id<Assoc = Ty>,
   |     ^^^^^^^^^^^^^^^^^^ the trait `Id` is not implemented for `Ty`
   |
help: this trait has no implementations, consider adding one
  --> file.rs:2:1
   |
2  | trait Id {
   | ^^^^^^^^
   = help: see issue #48214
help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
   |
2  + #![feature(trivial_bounds)]
   |

error[E0277]: the trait bound `Ty: Id` is not satisfied
  --> file.rs:11:3
   |
11 | = impl Sized;
   |   ^^^^^^^^^^ the trait `Id` is not implemented for `Ty`
   |
help: this trait has no implementations, consider adding one
  --> file.rs:2:1
   |
2  | trait Id {
   | ^^^^^^^^
note: required by a bound on the type alias `Ty`
  --> file.rs:10:9
   |
10 |     Ty: Id<Assoc = Ty>,
   |         ^^^^^^^^^^^^^^ required by this bound

error[E0277]: the trait bound `Ty: Id` is not satisfied
  --> file.rs:12:16
   |
12 | fn define() -> Ty {}
   |                ^^ the trait `Id` is not implemented for `Ty`
   |
help: this trait has no implementations, consider adding one
  --> file.rs:2:1
   |
2  | trait Id {
   | ^^^^^^^^
note: required by a bound on the type alias `Ty`
  --> file.rs:10:9
   |
10 |     Ty: Id<Assoc = Ty>,
   |         ^^^^^^^^^^^^^^ required by this bound

error[E0277]: the trait bound `Ty: Id` is not satisfied
  --> file.rs:12:19
   |
12 | fn define() -> Ty {}
   |                   ^^ the trait `Id` is not implemented for `Ty`
   |
help: this trait has no implementations, consider adding one
  --> file.rs:2:1
   |
2  | trait Id {
   | ^^^^^^^^
note: required by a bound on the type alias `Ty`
  --> file.rs:10:9
   |
10 |     Ty: Id<Assoc = Ty>,
   |         ^^^^^^^^^^^^^^ required by this bound

error[E0390]: cannot define inherent `impl` for primitive types
 --> file.rs:5:1
  |
5 | impl<T> *const u8 {
  | ^^^^^^^^^^^^^^^^^
  |
  = help: consider using an extension trait instead

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`I-compilememIssue: Problems and improvements with respect to memory usage during compilation.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions