Skip to content

Sized hierarchy: PointeeSized bounds aren't fully validated during HIR ty lowering #142718

Closed

Description

@fmease

The following code compiles successfully:

#![feature(sized_hierarchy)]
fn f<T: std::marker::PointeeSized<(), (), (), Undefined = ()>>() {}

but it should definitely not because PointeeSized doesn't have any generic params or assoc types.

This happens because of this check:

if self.should_skip_sizedness_bound(hir_bound) {
continue;
}

which leads to <dyn HirTyLowering<'_>>::lower_poly_trait_ref getting skipped which would've performed the necessary generic args validation.

Activity

  1. self-assigned this
    on Jun 19, 2025
  2. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Jun 19, 2025
  3. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 19, 2025
  4. fmease commented on Jun 19, 2025

    @fmease
    MemberAuthor
  5. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 19, 2025
  6. fmease commented on Jun 19, 2025

    @fmease
    MemberAuthor

    I'll be working on that as part of fixing a whole slew of preexisting bound lowering issues (in AST lowering and HIR ty lowering).

    See #142693, #135841 (review), #135229.

  7. fmease commented on Jun 19, 2025

    @fmease
    MemberAuthor

    It also leads to rustc accepting const PointeeSized and ~const PointeeSized despite it not being a #[const_trait] (which it will also never be):

    #![feature(sized_hierarchy, const_trait_impl)]
    
    fn f<T: const std::marker::PointeeSized>() {}
    const fn g<T: ~const std::marker::PointeeSized>() {}
  8. added a commit that references this issue on Jun 20, 2025
  9. added a commit that references this issue on Jun 28, 2025
  10. added 2 commits that reference this issue on Jul 18, 2025
  11. added a commit that references this issue on Jul 19, 2025
  12. added a commit that references this issue on Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-HIR-ty-loweringArea: HIR ty lowering (HIR → middle::ty IR)A-type-systemArea: Type systemC-bugCategory: This is a bug.F-sized_hierarchy`#![feature(sized_hierarchy)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions