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

All relaxed bounds are assumed to be ?Sized #87199

Closed
ibraheemdev opened this issue Jul 16, 2021 · 0 comments · Fixed by #87250
Closed

All relaxed bounds are assumed to be ?Sized #87199

ibraheemdev opened this issue Jul 16, 2021 · 0 comments · Fixed by #87250
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-trait-system Area: Trait system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ibraheemdev
Copy link
Member

ibraheemdev commented Jul 16, 2021

fn foo() -> impl Iterator<Item = u8> + ?Send {
    "".to_string().into_bytes().into_iter()
}

fn main() {
    let x = foo();
}
// This warning is correct
warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported
 --> src/main.rs:1:13
  |
1 | fn foo() -> impl Iterator<Item = u8> + ?Send {
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

// These errors aren't
error[E0277]: the size for values of type `impl Iterator+?Sized` cannot be known at compilation time
 --> src/main.rs:1:13
  |
1 | fn foo() -> impl Iterator<Item = u8> + ?Send {
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `impl Iterator+?Sized`
  = note: the return type of a function must have a statically known size

error[E0277]: the size for values of type `impl Iterator+?Sized` cannot be known at compilation time
 --> src/main.rs:6:9
  |
6 |     let x = foo();
  |         ^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `impl Iterator+?Sized`
  = note: all local variables must have a statically known size
  = help: unsized locals are gated as an unstable feature

error[E0277]: the size for values of type `impl Iterator+?Sized` cannot be known at compilation time
 --> src/main.rs:6:13
  |
6 |     let x = foo();
  |             ^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `impl Iterator+?Sized`
  = note: the return type of a function must have a statically known size

error: aborting due to 3 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground`

To learn more, run the command again with --verbose.
@ibraheemdev ibraheemdev added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 16, 2021
@ibraheemdev ibraheemdev changed the title Invalid relaxed bounds are assumed to be ?Sized All relaxed bounds are assumed to be ?Sized Jul 16, 2021
@jonas-schievink jonas-schievink added C-bug Category: This is a bug. A-trait-system Area: Trait system labels Jul 16, 2021
@bors bors closed this as completed in 7db08ee Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-trait-system Area: Trait system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants