-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
struct Type {
option: Option<Vec<u8>>
}
impl Type {
fn method(&self) -> Option<Vec<u8>> {
self.option..as_ref().map(|x| x)
}
}
fn main() {
let _ = Type { option: None }.method();
}
error[E0425]: cannot find function `as_ref` in this scope
--> src/main.rs:7:22
|
7 | self.option..as_ref().map(|x| x)
| ^^^^^^ not found in this scope
error[E0308]: mismatched types
--> src/main.rs:7:9
|
6 | fn method(&self) -> Option<Vec<u8>> {
| --------------- expected `std::option::Option<std::vec::Vec<u8>>` because of return type
7 | self.option..as_ref().map(|x| x)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found struct `std::ops::Range`
|
= note: expected type `std::option::Option<_>`
found type `std::ops::Range<std::option::Option<_>>`
has a typo where two dots where written where one for method access was meant. It is not made clear enough in the output due to complaining about finding Range
but not pointing at the two dots that caused the range to be there.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.