Skip to content

Conversation

@Aditya-PS-05
Copy link
Contributor

@Aditya-PS-05 Aditya-PS-05 commented Dec 19, 2025

Fixes #149438

The compiler incorrectly accepted nested RPITs with ?Sized bounds when used in associated type positions that have implicit Sized bounds. See this playgound

The fix is to only skip validation when the nested RPIT does NOT have an explicit ?Sized bound.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 19, 2025

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@fmease fmease assigned lcnr and unassigned fee1-dead Dec 19, 2025
@Aditya-PS-05
Copy link
Contributor Author

@lcnr , please review it.

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't quite feel right, it results in the following behavior, does it not?

trait Bound {}
trait Trait {
    type Assoc: ?Sized + Bound;
}
impl Bound for () {}
impl Trait for () {
    type Assoc = ();
}

fn foo() -> impl Trait<Assoc = impl ?Sized + PartialEq> {} 
// ^ now lints that `Bound` is not implemented?

I feel like what we'd want to do is sth like this:

  • check whether item bounds involve Sized
  • check whether we explicitly opt out of Sized
  • lint in that case

View changes since this review

@Aditya-PS-05
Copy link
Contributor Author

This doesn't quite feel right, it results in the following behavior, does it not?

trait Bound {}
trait Trait {
    type Assoc: ?Sized + Bound;
}
impl Bound for () {}
impl Trait for () {
    type Assoc = ();
}

fn foo() -> impl Trait<Assoc = impl ?Sized + PartialEq> {} 
// ^ now lints that `Bound` is not implemented?

I feel like what we'd want to do is sth like this:

* check whether item bounds involve `Sized`

* check whether we explicitly opt out of `Sized`

* lint in that case

View changes since this review

Yeah, my fix is too broad.
I will update it.

@Aditya-PS-05 Aditya-PS-05 requested a review from lcnr December 23, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maybe-sized RPIT type is unexpectedly allowed in async fn

4 participants