This commit is contained in:
Edwin Cheng 2020-04-30 18:12:52 +08:00
parent a5f2b16366
commit 1635d22a35

View file

@ -338,6 +338,46 @@ pub fn baz() -> usize { 31usize }
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]
fn infer_type_value_non_legacy_macro_use_as() {
assert_snapshot!(