Skip to content

rustc suggests removing all trait bounds leaving stray impl #127441

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

fn foo(_: impl ?Sized + ?Sized) {}
fn main() {}

Current output

error[E0203]: type parameter has more than one relaxed default bound, only one is supported
 --> a.rs:1:16
  |
1 | fn foo(_: impl ?Sized + ?Sized) {}
  |                ^^^^^^   ^^^^^^

error[E0277]: the size for values of type `impl ?Sized + ?Sized` cannot be known at compilation time
 --> a.rs:1:8
  |
1 | fn foo(_: impl ?Sized + ?Sized) {}
  |        ^  -------------------- this type parameter needs to be `Sized`
  |        |
  |        doesn't have a size known at compile-time
  |
  = help: unsized fn params are gated as an unstable feature
help: consider restricting type parameters
  |
1 - fn foo(_: impl ?Sized + ?Sized) {}
1 + fn foo(_: impl ) {}
  |
help: function arguments must have a statically known size, borrowed types always have a known size
  |
1 | fn foo(_: &impl ?Sized + ?Sized) {}
  |           +

error: aborting due to 2 previous

Desired output

No response

Rationale and extra context

No response

Other cases

No response

Rust Version

51917e2e69702e5752bce6a4f3bfd285d0f4ae39

Anything else?

I found the fn foo(_: impl ) {} suggestion slightly amusing :)

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions