File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
crates/ra_hir_ty/src/tests Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -338,6 +338,46 @@ pub fn baz() -> usize { 31usize }
338338 assert_eq ! ( "(i32, usize)" , type_at_pos( & db, pos) ) ;
339339}
340340
341+ #[ test]
342+ fn infer_macro_with_dollar_crate_is_correct_in_trait_associate_type ( ) {
343+ let ( db, pos) = TestDB :: with_position (
344+ r#"
345+ //- /main.rs crate:main deps:foo
346+ use foo::Trait;
347+
348+ fn test() {
349+ let msg = foo::Message(foo::MessageRef);
350+ let r = msg.deref();
351+ r<|>;
352+ }
353+
354+ //- /lib.rs crate:foo
355+ pub struct MessageRef;
356+ pub struct Message(MessageRef);
357+
358+ pub trait Trait {
359+ type Target;
360+ fn deref(&self) -> &Self::Target;
361+ }
362+
363+ #[macro_export]
364+ macro_rules! expand {
365+ () => {
366+ impl Trait for Message {
367+ type Target = $crate::MessageRef;
368+ fn deref(&self) -> &Self::Target {
369+ &self.0
370+ }
371+ }
372+ }
373+ }
374+
375+ expand!();
376+ "# ,
377+ ) ;
378+ assert_eq ! ( "&MessageRef" , type_at_pos( & db, pos) ) ;
379+ }
380+
341381#[ test]
342382fn infer_type_value_non_legacy_macro_use_as ( ) {
343383 assert_snapshot ! (
You can’t perform that action at this time.
0 commit comments