Closed
Description
Following code seems to lead to overly long diagnostics: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20main()%20%7B%0A%20%20%20%200u8.as_ref()%0A%7D
fn main() {
0u8.as_ref()
}
The current output is:
error[E0599]: no method named `as_ref` found for type `u8` in the current scope
--> b.rs:2:9
|
2 | 0u8.as_ref()
| ^^^^^^ method not found in `u8`
|
::: ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:159:8
|
159 | fn as_ref(&self) -> &T;
| ------
| |
| the method is available for `Box<u8>` here
| the method is available for `Arc<u8>` here
| the method is available for `Rc<u8>` here
| the method is available for `Box<&mut u8>` here
| the method is available for `Arc<&mut u8>` here
| the method is available for `Rc<&mut u8>` here
| the method is available for `Box<&u8>` here
| the method is available for `Arc<&u8>` here
| the method is available for `Rc<&u8>` here
|
::: ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/pin.rs:584:12
|
584 | pub fn as_ref(&self) -> Pin<&P::Target> {
| ------
| |
| the method is available for `Pin<&mut u8>` here
| the method is available for `Pin<&u8>` here
|
help: consider wrapping the receiver expression with the appropriate type
|
2 | Box::new(0u8).as_ref()
| ^^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
2 | Arc::new(0u8).as_ref()
| ^^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
2 | Rc::new(0u8).as_ref()
| ^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
2 | Box::new(&mut 0u8).as_ref()
| ^^^^^^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
2 | Pin::new(&mut 0u8).as_ref()
| ^^^^^^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
2 | Arc::new(&mut 0u8).as_ref()
| ^^^^^^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
2 | Rc::new(&mut 0u8).as_ref()
| ^^^^^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
2 | Box::new(&0u8).as_ref()
| ^^^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
2 | Pin::new(&0u8).as_ref()
| ^^^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
2 | Arc::new(&0u8).as_ref()
| ^^^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
2 | Rc::new(&0u8).as_ref()
| ^^^^^^^^^ ^
Note that this happens not just with 0u8 but with most types not implementing AsRef as far as I can see.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: A structured suggestion resulting in incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Relevant to the compiler team, which will review and decide on the PR/issue.