9 lines
21 KiB
Text
9 lines
21 KiB
Text
|
{"message":"unused import: `reqwest::*`","code":{"code":"unused_imports","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":4,"byte_end":14,"line_start":1,"line_end":1,"column_start":5,"column_end":15,"is_primary":true,"text":[{"text":"use reqwest::*;","highlight_start":5,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_imports)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove the whole `use` item","code":null,"level":"help","spans":[{"file_name":"src/main.rs","byte_start":0,"byte_end":15,"line_start":1,"line_end":1,"column_start":1,"column_end":16,"is_primary":true,"text":[{"text":"use reqwest::*;","highlight_start":1,"highlight_end":16}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: unused import: `reqwest::*`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:1:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m1\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0muse reqwest::*;\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33m^^^^^^^^^^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: `#[warn(unused_imports)]` on by default\u001b[0m\n\n"}
|
||
|
{"message":"`await` is only allowed inside `async` functions and blocks","code":{"code":"E0728","explanation":"[`await`] has been used outside [`async`] function or [`async`] block.\n\nErroneous code example:\n\n```edition2018,compile_fail,E0728\n# use std::pin::Pin;\n# use std::future::Future;\n# use std::task::{Context, Poll};\n#\n# struct WakeOnceThenComplete(bool);\n#\n# fn wake_and_yield_once() -> WakeOnceThenComplete {\n# WakeOnceThenComplete(false)\n# }\n#\n# impl Future for WakeOnceThenComplete {\n# type Output = ();\n# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {\n# if self.0 {\n# Poll::Ready(())\n# } else {\n# cx.waker().wake_by_ref();\n# self.0 = true;\n# Poll::Pending\n# }\n# }\n# }\n#\nfn foo() {\n wake_and_yield_once().await // `await` is used outside `async` context\n}\n```\n\n[`await`] is used to suspend the current computation until the given\nfuture is ready to produce a value. So it is legal only within\nan [`async`] context, like an `async` function or an `async` block.\n\n```edition2018\n# use std::pin::Pin;\n# use std::future::Future;\n# use std::task::{Context, Poll};\n#\n# struct WakeOnceThenComplete(bool);\n#\n# fn wake_and_yield_once() -> WakeOnceThenComplete {\n# WakeOnceThenComplete(false)\n# }\n#\n# impl Future for WakeOnceThenComplete {\n# type Output = ();\n# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {\n# if self.0 {\n# Poll::Ready(())\n# } else {\n# cx.waker().wake_by_ref();\n# self.0 = true;\n# Poll::Pending\n# }\n# }\n# }\n#\nasync fn foo() {\n wake_and_yield_once().await // `await` is used within `async` function\n}\n\nfn bar(x: u8) -> impl Future<Output = u8> {\n async move {\n wake_and_yield_once().await; // `await` is used within `async` block\n x\n }\n}\n```\n\n[`async`]: https://doc.rust-lang.org/std/keyword.async.html\n[`await`]: https://doc.rust-lang.org/std/keyword.await.html\n"},"level":"error","spans":[{"file_name":"src/main.rs","byte_start":134,"byte_end":139,"line_start":7,"line_end":7,"column_start":10,"column_end":15,"is_primary":true,"text":[{"text":" .await?;","highlight_start":10,"highlight_end":15}],"label":"only allowed inside `async` functions and blocks","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/main.rs","byte_start":20,"byte_end":24,"line_start":3,"line_end":3,"column_start":4,"column_end":8,"is_primary":false,"text":[{"text":"fn main() {","highlight_start":4,"highlight_end":8}],"label":"this is not `async`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0728]\u001b[0m\u001b[0m\u001b[1m: `await` is only allowed inside `async` functions and blocks\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:7:10\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m3\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0mfn main() {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m----\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mthis is not `async`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m...\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m7\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m .await?;\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9monly allowed inside `async` functions and blocks\u001b[0m\n\n"}
|
||
|
{"message":"`await` is only allowed inside `async` functions and blocks","code":{"code":"E0728","explanation":"[`await`] has been used outside [`async`] function or [`async`] block.\n\nErroneous code example:\n\n```edition2018,compile_fail,E0728\n# use std::pin::Pin;\n# use std::future::Future;\n# use std::task::{Context, Poll};\n#\n# struct WakeOnceThenComplete(bool);\n#\n# fn wake_and_yield_once() -> WakeOnceThenComplete {\n# WakeOnceThenComplete(false)\n# }\n#\n# impl Future for WakeOnceThenComplete {\n# type Output = ();\n# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {\n# if self.0 {\n# Poll::Ready(())\n# } else {\n# cx.waker().wake_by_ref();\n# self.0 = true;\n# Poll::Pending\n# }\n# }\n# }\n#\nfn foo() {\n wake_and_yield_once().await // `await` is used outside `async` context\n}\n```\n\n[`await`] is used to suspend the current computation until the given\nfuture is ready to produce a value. So it is legal only within\nan [`async`] context, like an `async` function or an `async` block.\n\n```edition2018\n# use std::pin::Pin;\n# use std::future::Future;\n# use std::task::{Context, Poll};\n#\n# struct WakeOnceThenComplete(bool);\n#\n# fn wake_and_yield_once() -> WakeOnceThenComplete {\n# WakeOnceThenComplete(false)\n# }\n#\n# impl Future for WakeOnceThenComplete {\n# type Output = ();\n# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {\n# if self.0 {\n# Poll::Ready(())\n# } else {\n# cx.waker().wake_by_ref();\n# self.0 = true;\n# Poll::Pending\n# }\n# }\n# }\n#\nasync fn foo() {\n wake_and_yield_once().await // `await` is used within `async` function\n}\n\nfn bar(x: u8) -> impl Future<Output = u8> {\n async move {\n wake_and_yield_once().await; // `await` is used within `async` block\n x\n }\n}\n```\n\n[`async`]: https://doc.rust-lang.org/std/keyword.async.html\n[`await`]: https://doc.rust-lang.org/std/keyword.await.html\n"},"level":"error","spans":[{"file_name":"src/main.rs","byte_start":102,"byte_end":107,"line_start":5,"line_end":5,"column_start":10,"column_end":15,"is_primary":true,"text":[{"text":" .await?","highlight_start":10,"highlight_end":15}],"label":"only allowed inside `async` functions and blocks","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/main.rs","byte_start":20,"byte_end":24,"line_start":3,"line_end":3,"column_start":4,"column_end":8,"is_primary":false,"text":[{"text":"fn main() {","highlight_start":4,"highlight_end":8}],"label":"this is not `async`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0728]\u001b[0m\u001b[0m\u001b[1m: `await` is only allowed inside `async` functions and blocks\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:5:10\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m3\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0mfn main() {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m----\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mthis is not `async`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m4\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m let body = reqwest::get(\"https://dennis.doordesk.net/home\")\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m5\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m .await?\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9monly allowed inside `async` functio
|
||
|
{"message":"the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)","code":{"code":"E0277","explanation":"You tried to use a type which doesn't implement some trait in a place which\nexpected that trait.\n\nErroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n foo.bar();\n}\n\nfn main() {\n // we now call the method with the i32 type, which doesn't implement\n // the Foo trait\n some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you're using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n fn bar(&self);\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n fn bar(&self) {}\n}\n\nfn some_func<T: Foo>(foo: T) {\n foo.bar(); // we can now use this method since i32 implements the\n // Foo trait\n}\n\nfn main() {\n some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n // implemented for the type `T`\n}\n\nfn main() {\n // We now call the method with the i32 type,\n // which *does* implement the Debug trait.\n some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function. Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function. It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we're\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n println!(\"{:?}\", foo);\n}\n\nfn main() {\n // Calling the method is still fine, as i32 implements Debug.\n some_func(5i32);\n\n // This would fail to compile now:\n // struct WithoutDebug;\n // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"},"level":"error","spans":[{"file_name":"src/main.rs","byte_start":107,"byte_end":108,"line_start":5,"line_end":5,"column_start":15,"column_end":16,"is_primary":true,"text":[{"text":" .await?","highlight_start":15,"highlight_end":16}],"label":"cannot use the `?` operator in a function that returns `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"src/main.rs","byte_start":107,"byte_end":108,"line_start":5,"line_end":5,"column_start":15,"column_end":16,"is_primary":false,"text":[{"text":" .await?","highlight_start":15,"highlight_end":16}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of operator `?`","def_site_span":{"file_name":"src/main.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"src/main.rs","byte_start":17,"byte_end":26,"line_start":3,"line_end":3,"column_start":1,"column_end":10,"is_primary":false,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":10}],"label":"this function should return `Result` or `Option` to accept `?`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"the trait `FromResidual<Result<Infallible, reqwest::Error>>` is not implemented for `()`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0277]\u001b[0m\u001b[0m\u001b[1m: the `?` operator can only
|
||
|
{"message":"the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)","code":{"code":"E0277","explanation":"You tried to use a type which doesn't implement some trait in a place which\nexpected that trait.\n\nErroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n foo.bar();\n}\n\nfn main() {\n // we now call the method with the i32 type, which doesn't implement\n // the Foo trait\n some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you're using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n fn bar(&self);\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n fn bar(&self) {}\n}\n\nfn some_func<T: Foo>(foo: T) {\n foo.bar(); // we can now use this method since i32 implements the\n // Foo trait\n}\n\nfn main() {\n some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n // implemented for the type `T`\n}\n\nfn main() {\n // We now call the method with the i32 type,\n // which *does* implement the Debug trait.\n some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function. Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function. It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we're\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n println!(\"{:?}\", foo);\n}\n\nfn main() {\n // Calling the method is still fine, as i32 implements Debug.\n some_func(5i32);\n\n // This would fail to compile now:\n // struct WithoutDebug;\n // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"},"level":"error","spans":[{"file_name":"src/main.rs","byte_start":139,"byte_end":140,"line_start":7,"line_end":7,"column_start":15,"column_end":16,"is_primary":true,"text":[{"text":" .await?;","highlight_start":15,"highlight_end":16}],"label":"cannot use the `?` operator in a function that returns `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"src/main.rs","byte_start":139,"byte_end":140,"line_start":7,"line_end":7,"column_start":15,"column_end":16,"is_primary":false,"text":[{"text":" .await?;","highlight_start":15,"highlight_end":16}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of operator `?`","def_site_span":{"file_name":"src/main.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"src/main.rs","byte_start":17,"byte_end":26,"line_start":3,"line_end":3,"column_start":1,"column_end":10,"is_primary":false,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":10}],"label":"this function should return `Result` or `Option` to accept `?`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"the trait `FromResidual<Result<Infallible, reqwest::Error>>` is not implemented for `()`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0277]\u001b[0m\u001b[0m\u001b[1m: the `?` operator can onl
|
||
|
{"message":"aborting due to 4 previous errors; 1 warning emitted","code":null,"level":"error","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: aborting due to 4 previous errors; 1 warning emitted\u001b[0m\n\n"}
|
||
|
{"message":"Some errors have detailed explanations: E0277, E0728.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1mSome errors have detailed explanations: E0277, E0728.\u001b[0m\n"}
|
||
|
{"message":"For more information about an error, try `rustc --explain E0277`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1mFor more information about an error, try `rustc --explain E0277`.\u001b[0m\n"}
|