Skip to content

[E0271] needless repetitions #45805

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
mqudsi opened this issue Nov 6, 2017 · 2 comments
Closed

[E0271] needless repetitions #45805

mqudsi opened this issue Nov 6, 2017 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@mqudsi
Copy link
Contributor

mqudsi commented Nov 6, 2017

I have this code fragment:

fn start() -> Result<()> {
    let addr = "0.0.0.0:3000".parse().unwrap();
    let server = Http::new().bind(&addr, || Server::new())?;

    server.run()?;
    Ok(())
}

When compiled it returns the following:

~> cargo build
   Compiling messagebridge v0.1.0 (file:///Users/mqudsi/Projects/messagebridge)
warning: unused import: `std::env`
 --> src/imessage/db.rs:4:5
  |
4 | use std::env;
  |     ^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: unused import: `std::error`
 --> src/imessage/db.rs:5:5
  |
5 | use std::error;
  |     ^^^^^^^^^^

warning: unused import: `errors::*;`
 --> src/incoming.rs:2:5
  |
2 | use errors::*;
  |     ^^^^^^^^^^

error[E0271]: type mismatch resolving `<[closure@src/main.rs:75:42: 75:58] as std::ops::FnOnce<()>>::Output == std::result::Result<_, std::io::Error>`
  --> src/main.rs:75:30
   |
75 |     let server = Http::new().bind(&addr, || Server::new())?;
   |                              ^^^^ expected struct `Server`, found enum `std::result::Result`
   |
   = note: expected type `Server`
              found type `std::result::Result<_, std::io::Error>`
   = note: required because of the requirements on the impl of `hyper::server::NewService` for `[closure@src/main.rs:75:42: 75:58]`

error[E0271]: type mismatch resolving `<[closure@src/main.rs:75:42: 75:58] as std::ops::FnOnce<()>>::Output == std::result::Result<_, std::io::Error>`
  --> src/main.rs:75:30
   |
75 |     let server = Http::new().bind(&addr, || Server::new())?;
   |                              ^^^^ expected struct `Server`, found enum `std::result::Result`
   |
   = note: expected type `Server`
              found type `std::result::Result<_, std::io::Error>`
   = note: required because of the requirements on the impl of `hyper::server::NewService` for `[closure@src/main.rs:75:42: 75:58]`

error[E0271]: type mismatch resolving `<[closure@src/main.rs:75:42: 75:58] as std::ops::FnOnce<()>>::Output == std::result::Result<_, std::io::Error>`
  --> src/main.rs:75:30
   |
75 |     let server = Http::new().bind(&addr, || Server::new())?;
   |                              ^^^^ expected struct `Server`, found enum `std::result::Result`
   |
   = note: expected type `Server`
              found type `std::result::Result<_, std::io::Error>`
   = note: required because of the requirements on the impl of `hyper::server::NewService` for `[closure@src/main.rs:75:42: 75:58]`

error[E0271]: type mismatch resolving `<[closure@src/main.rs:75:42: 75:58] as std::ops::FnOnce<()>>::Output == std::result::Result<_, std::io::Error>`
  --> src/main.rs:75:30
   |
75 |     let server = Http::new().bind(&addr, || Server::new())?;
   |                              ^^^^ expected struct `Server`, found enum `std::result::Result`
   |
   = note: expected type `Server`
              found type `std::result::Result<_, std::io::Error>`
   = note: required because of the requirements on the impl of `hyper::server::NewService` for `[closure@src/main.rs:75:42: 75:58]`

error[E0599]: no method named `run` found for type `hyper::Server<[closure@src/main.rs:75:42: 75:58], _>` in the current scope
  --> src/main.rs:77:12
   |
77 |     server.run()?;
   |            ^^^
   |
   = note: the method `run` exists but the following trait bounds were not satisfied:
           `[closure@src/main.rs:75:42: 75:58] : hyper::server::NewService`

error: aborting due to 5 previous errors

error: Could not compile `messagebridge`.

To learn more, run the command again with --verbose.

This is under rustc 1.21.0 (3b72af97e 2017-10-09)

@estebank
Copy link
Contributor

estebank commented Nov 6, 2017

Very similar to #33941.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Nov 6, 2017
zackmdavis added a commit to zackmdavis/rust that referenced this issue Nov 13, 2017
The `ErrorId` variant takes a u16 so that `DiagnosticMessageId` can retain
its `Copy` status (the present author's first choice having been the "EXXX"
code as a string).

The duplicated "type mismatch resolving `{}`" literal is unfortunate, but
the `struct_span_err!` macro (which we want to mark that error code as
used) is fussy about taking a literal, and the one-time-diagnostics set
needs an owned string.

This is concerning rust-lang#33941 and probably rust-lang#45805!
kennytm added a commit to kennytm/rust that referenced this issue Nov 13, 2017
…stebank

deduplicate projection error (E0271) messages

The `ErrorId` variant takes a u16 so that `DiagnosticMessageId` can retain
its `Copy` status (the present author's first choice having been the "EXXX"
code as a string).

The duplicated "type mismatch resolving `{}`" literal is unfortunate, but
the `struct_span_err!` macro (which we want to mark that error code as
used) is fussy about taking a literal, and the one-time-diagnostics set
needs an owned string.

This is concerning rust-lang#33941 and probably rust-lang#45805!

r? @estebank
@estebank
Copy link
Contributor

estebank commented Dec 7, 2017

@mqudsi could you try your code with latest nightly, or provide a full repro case? I believe this can be closed after #45952.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

2 participants