Skip to content

Self as default type isnt typechecked #61631

Closed
@DutchGhost

Description

@DutchGhost

The following code compiles:

struct B<P: Sized = [Self]>(P);

but shouldn't, because [Self] is NOT Sized.

If we change [Self] with a [u8], like this:

struct B<P: Sized = [u8]>(P);

it fails to compile, because [u8] isnt sized.

Also note that if we would write impl B {} in the case of P being of default type [Self], we get an ICE:

Related to #59956 (comment)

Metadata

Metadata

Labels

C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions