Skip to content

Spurious "bounds [...] not enforced in type aliases" when using TAIT #108617

Closed
@Patryk27

Description

@Patryk27

Code

#![feature(type_alias_impl_trait)]

use std::fmt::Debug;

type Foo<T: Debug> = (impl Debug, usize);

fn foo<U: Debug>() -> Foo<U> {
    (Vec::<U>::new(), 1234)
}

Current output

warning: bounds on generic parameters are not enforced in type aliases
 --> src/main.rs:5:13
  |
5 | type Foo<T: Debug> = (impl Debug, usize);
  |             ^^^^^
  |
  = note: `#[warn(type_alias_bounds)]` on by default
help: the bound will not be checked when the type alias is used, and should be removed
  |
5 - type Foo<T: Debug> = (impl Debug, usize);
5 + type Foo<T> = (impl Debug, usize);
  |

Desired output

No warning at all, I think, since the bound is actually checked; applying the suggestion yields code that does not compile.

Rationale and extra context

No response

Other cases

No response

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-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