- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
#![feature(type_alias_impl_trait)]
type Alias<T: Send> = (impl Send,);
pub fn foo<T: Send>(x: T) -> Alias<T> {
    (x,)
}Compiling this code (Playground) produces the following diagnostics:
warning: bounds on generic parameters are not enforced in type aliases
 --> src/lib.rs:3:15
  |
3 | type Alias<T: Send> = (impl Send,);
  |               ^^^^
  |
  = 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
  |
3 - type Alias<T: Send> = (impl Send,);
3 + type Alias<T> = (impl Send,);
  | 
I expected to see this happen: The compiler should not have suggested removing : Send from the type alias.
Instead, this happened: Removing : Send as per the compiler's suggestion breaks the code.
error[E0277]: `T` cannot be sent between threads safely
 --> src/lib.rs:3:18
  |
3 | type Alias<T> = (impl Send,);
  |                  ^^^^^^^^^ `T` cannot be sent between threads safely
  |
help: consider restricting type parameter `T`
  |
3 | type Alias<T: std::marker::Send> = (impl Send,);
  |             +++++++++++++++++++
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` due to previous error
Meta
rustc --version --verbose:
rustc 1.61.0-nightly (532d3cda9 2022-02-23)
binary: rustc
commit-hash: 532d3cda90b8a729cd982548649d32803d265052
commit-date: 2022-02-23
host: aarch64-apple-darwin
release: 1.61.0-nightly
LLVM version: 14.0.0
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.