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

Maybe-bounds in associated type bounds don't get rejected #135229

Open
fmease opened this issue Jan 8, 2025 · 1 comment
Open

Maybe-bounds in associated type bounds don't get rejected #135229

fmease opened this issue Jan 8, 2025 · 1 comment
Assignees
Labels
C-bug Category: This is a bug. F-associated_type_bounds `#![feature(associated_type_bounds)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented Jan 8, 2025

The following code gets erroneously accepted:

fn f<T>() where T: Trait<Ty: ?Sized> {}
//                           ^^^^^^ not good

trait Trait { type Ty/*: ?Sized*/; }

Maybe-bounds / unbounds are only meant to be put on type parameters and associated types "declared in the immediate vicinity" which isn't the case here. This is supported by the fact that Trait<Ty:> (sic!) doesn't elaborate to Trait<Ty: Sized>.

Compare this to the snippet below which gets rightfully rejected:

fn f<T>() where T: Trait, T::Ty: ?Sized {}
//                               ^^^^^^
//~^^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
trait Trait { type Ty/*: ?Sized*/; }

Obviously a fix would be a breaking change. However I doubt anyone is writing such code (unless macro generated). In any case, we should run crater on the future PR.

@fmease fmease added C-bug Category: This is a bug. F-associated_type_bounds `#![feature(associated_type_bounds)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 8, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 8, 2025
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 8, 2025
@compiler-errors
Copy link
Member

😭

@fmease fmease changed the title Maybe-bounds on associated type bounds don't get rejected Maybe-bounds in associated type bounds don't get rejected Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-associated_type_bounds `#![feature(associated_type_bounds)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants