Skip to content

Misspelling a macro/function name causes a cascade of unrelated errors #85131

Closed
@Frederik-Baetens

Description

@Frederik-Baetens

Given the following code:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=0299184600f08daea9aa44c52348717f

use futures::stream::{self, StreamExt};

#[tokio::main]
async fn main() {
    let key1: String = "/helloa".to_string();

    dbg!(&key1);

    let futlist = stream::iter(0..10);
    let _stringvec: Vec<String> = futlist.map(|_| {
        async {
            key1.clone()
        }
    }).buffer_unordered(10).collect::<Vec<String>>().await;
    printn!("hi");
}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: cannot find macro `printn` in this scope
  --> src/main.rs:15:5
   |
15 |       printn!("hi");
   |       ^^^^^^ help: a macro with a similar name exists: `print`

error[E0698]: type inside `async` block must be known in this context
  --> src/main.rs:9:9
   |
9  |     let futlist = stream::iter(0..10);
   |         ^^^^^^^ cannot infer type for type `{integer}`
   |
note: the type is part of the `async` block because of this `await`
  --> src/main.rs:10:35
   |
10 |       let _stringvec: Vec<String> = futlist.map(|_| {
   |  ___________________________________^
11 | |         async {
12 | |             key1.clone()
13 | |         }
14 | |     }).buffer_unordered(10).collect::<Vec<String>>().await;
   | |__________________________________________________________^

error[E0698]: type inside `async` block must be known in this context
  --> src/main.rs:10:35
   |
10 |     let _stringvec: Vec<String> = futlist.map(|_| {
   |                                   ^^^^^^^ cannot infer type for type `{integer}`
   |
note: the type is part of the `async` block because of this `await`
  --> src/main.rs:10:35
   |
10 |       let _stringvec: Vec<String> = futlist.map(|_| {
   |  ___________________________________^
11 | |         async {
12 | |             key1.clone()
13 | |         }
14 | |     }).buffer_unordered(10).collect::<Vec<String>>().await;
   | |__________________________________________________________^

error[E0698]: type inside `async` block must be known in this context
  --> src/main.rs:10:47
   |
10 |       let _stringvec: Vec<String> = futlist.map(|_| {
   |  _______________________________________________^
11 | |         async {
12 | |             key1.clone()
13 | |         }
14 | |     }).buffer_unordered(10).collect::<Vec<String>>().await;
   | |_____^ cannot infer type for type `{integer}`
   |
note: the type is part of the `async` block because of this `await`
  --> src/main.rs:10:35
   |
10 |       let _stringvec: Vec<String> = futlist.map(|_| {
   |  ___________________________________^
11 | |         async {
12 | |             key1.clone()
13 | |         }
14 | |     }).buffer_unordered(10).collect::<Vec<String>>().await;
   | |__________________________________________________________^

error[E0698]: type inside `async` block must be known in this context
  --> src/main.rs:10:35
   |
10 |       let _stringvec: Vec<String> = futlist.map(|_| {
   |  ___________________________________^
11 | |         async {
12 | |             key1.clone()
13 | |         }
14 | |     }).buffer_unordered(10).collect::<Vec<String>>().await;
   | |______^ cannot infer type for type `{integer}`
   |
note: the type is part of the `async` block because of this `await`
  --> src/main.rs:10:35
   |
10 |       let _stringvec: Vec<String> = futlist.map(|_| {
   |  ___________________________________^
11 | |         async {
12 | |             key1.clone()
13 | |         }
14 | |     }).buffer_unordered(10).collect::<Vec<String>>().await;
   | |__________________________________________________________^

error[E0698]: type inside `async` block must be known in this context
  --> src/main.rs:10:35
   |
10 |       let _stringvec: Vec<String> = futlist.map(|_| {
   |  ___________________________________^
11 | |         async {
12 | |             key1.clone()
13 | |         }
14 | |     }).buffer_unordered(10).collect::<Vec<String>>().await;
   | |___________________________^ cannot infer type for type `{integer}`
   |
note: the type is part of the `async` block because of this `await`
  --> src/main.rs:10:35
   |
10 |       let _stringvec: Vec<String> = futlist.map(|_| {
   |  ___________________________________^
11 | |         async {
12 | |             key1.clone()
13 | |         }
14 | |     }).buffer_unordered(10).collect::<Vec<String>>().await;
   | |__________________________________________________________^

error[E0698]: type inside `async` block must be known in this context
  --> src/main.rs:10:35
   |
10 |       let _stringvec: Vec<String> = futlist.map(|_| {
   |  ___________________________________^
11 | |         async {
12 | |             key1.clone()
13 | |         }
14 | |     }).buffer_unordered(10).collect::<Vec<String>>().await;
   | |____________________________________________________^ cannot infer type for type `{integer}`
   |
note: the type is part of the `async` block because of this `await`
  --> src/main.rs:10:35
   |
10 |       let _stringvec: Vec<String> = futlist.map(|_| {
   |  ___________________________________^
11 | |         async {
12 | |             key1.clone()
13 | |         }
14 | |     }).buffer_unordered(10).collect::<Vec<String>>().await;
   | |__________________________________________________________^

error[E0698]: type inside `async` block must be known in this context
  --> src/main.rs:10:35
   |
10 |       let _stringvec: Vec<String> = futlist.map(|_| {
   |  ___________________________________^
11 | |         async {
12 | |             key1.clone()
13 | |         }
14 | |     }).buffer_unordered(10).collect::<Vec<String>>().await;
   | |__________________________________________________________^ cannot infer type for type `{integer}`
   |
note: the type is part of the `async` block because of this `await`
  --> src/main.rs:10:35
   |
10 |       let _stringvec: Vec<String> = futlist.map(|_| {
   |  ___________________________________^
11 | |         async {
12 | |             key1.clone()
13 | |         }
14 | |     }).buffer_unordered(10).collect::<Vec<String>>().await;
   | |__________________________________________________________^

error: aborting due to 8 previous errors

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

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

Ideally the output should look like:

Only the first error should be shown

   Compiling playground v0.0.1 (/playground)
error: cannot find macro `printn` in this scope
  --> src/main.rs:15:5
   |
15 |       printn!("hi");
   |       ^^^^^^ help: a macro with a similar name exists: `print`

Metadata

Metadata

Assignees

No one assigned

    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