Closed
Description
Environment
rust 1.56.1
rust-analyzer 2021-11-01
edition 2021
Steps to reproduce
pub struct GreaterThanZero(i32);
impl TryFrom<i32> for GreaterThanZero {
type Error = &'static str;
fn try_from(value: i32) -> Result<Self, Self::Error> {
Ok(GreaterThanZero(value))
}
}
pub trait MyTrait {
// This has the same name as `TryInto::try_into`
fn try_into(&self, addition: i32) -> Result<GreaterThanZero, ()>;
}
impl MyTrait for i32 {
fn try_into(&self, addition: i32) -> Result<GreaterThanZero, ()> {
Ok(GreaterThanZero(*self + addition))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn internal() {
let a: &dyn MyTrait = &2;
let v: GreaterThanZero = (&*a).try_into(1).unwrap();
assert_eq!(3, v.0);
}
}
- Expected: No error.
try_into
ininternal()
resolves toMyTrait::try_into
- What happened: cargo compiles fine but RA reports
mismatched-arg-count
.try_into
ininternal()
resolves toTryInto::try_into
from the prelude.
Courtesy of minstrel1977@rustcc