Add test
This commit is contained in:
parent
a5f2b16366
commit
1635d22a35
1 changed files with 40 additions and 0 deletions
|
@ -338,6 +338,46 @@ pub fn baz() -> usize { 31usize }
|
||||||
assert_eq!("(i32, usize)", type_at_pos(&db, pos));
|
assert_eq!("(i32, usize)", type_at_pos(&db, pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn infer_macro_with_dollar_crate_is_correct_in_trait_associate_type() {
|
||||||
|
let (db, pos) = TestDB::with_position(
|
||||||
|
r#"
|
||||||
|
//- /main.rs crate:main deps:foo
|
||||||
|
use foo::Trait;
|
||||||
|
|
||||||
|
fn test() {
|
||||||
|
let msg = foo::Message(foo::MessageRef);
|
||||||
|
let r = msg.deref();
|
||||||
|
r<|>;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- /lib.rs crate:foo
|
||||||
|
pub struct MessageRef;
|
||||||
|
pub struct Message(MessageRef);
|
||||||
|
|
||||||
|
pub trait Trait {
|
||||||
|
type Target;
|
||||||
|
fn deref(&self) -> &Self::Target;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! expand {
|
||||||
|
() => {
|
||||||
|
impl Trait for Message {
|
||||||
|
type Target = $crate::MessageRef;
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expand!();
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
assert_eq!("&MessageRef", type_at_pos(&db, pos));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn infer_type_value_non_legacy_macro_use_as() {
|
fn infer_type_value_non_legacy_macro_use_as() {
|
||||||
assert_snapshot!(
|
assert_snapshot!(
|
||||||
|
|
Loading…
Reference in a new issue