You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect warning: type alias is never used #54234
With the following code, I'm getting an incorrect warning:
cargo run
Compiling hellors v0.1.0 (file:///home/ngupta/temp/hellors)
warning: type alias is never used: `Result`
--> src/main.rs:3:1
|
3 | type Result<T> = ::std::result::Result<(T, usize), usize>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default
Finished dev [unoptimized + debuginfo] target(s) in 0.44s
Running `target/debug/hellors`
Code
// On success, return what was parsed and where to start parsing from next.
// On failure, return where the parsing failed.
type Result<T> = ::std::result::Result<(T, usize), usize>;
fn parse_until(terminator: &'static str) -> impl Fn(&str, usize) -> Result<&str> {
move |s, location| {
let s = &s[location..];
match s.find(terminator) {
Some(pos) => {
let head = &s[..pos];
Ok((head, location + pos + terminator.len()))
},
None => {
Err(location)
}
}
}
}
fn main() {
let input = "hello\nworld";
assert_eq!(Ok(("hello", 6)), parse_until("\n")(input, 0));
assert_eq!(Err(6), parse_until("\n")(input, 6));
}
Activity
Centril commentedon Sep 14, 2018
minimized to:
RalfJung commentedon Oct 16, 2018
Potentially related: #47131
sanxiyn commentedon Mar 12, 2019
I just confirmed that this is fixed by #59129. #47131 is unrelated as it is about impl header, not impl Trait.
sanxiyn commentedon Mar 13, 2019
Fixed by #59129.