From 131f11a6e55cbd942a49ebdec3305ba53edaf333 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Sat, 27 Oct 2018 11:22:18 +0900 Subject: [PATCH 1/2] Add a test for #3139 --- tests/source/type.rs | 8 ++++++++ tests/target/type.rs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/tests/source/type.rs b/tests/source/type.rs index 2c2c32e7602c..208a30e634e5 100644 --- a/tests/source/type.rs +++ b/tests/source/type.rs @@ -121,3 +121,11 @@ fn issue3117() { } } } + +// #3139 +fn issue3139() { + assert_eq!( + to_json_value(&None :: ).unwrap(), + json!( { "test": None :: } ) + ); +} diff --git a/tests/target/type.rs b/tests/target/type.rs index d0d1543e10a0..b8f41218f417 100644 --- a/tests/target/type.rs +++ b/tests/target/type.rs @@ -120,3 +120,11 @@ fn issue3117() { } } } + +// #3139 +fn issue3139() { + assert_eq!( + to_json_value(&None::).unwrap(), + json!({ "test": None:: }) + ); +} From 5ca90edc5bdba1d0e8c280581ee05c7517683622 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Sat, 27 Oct 2018 11:22:40 +0900 Subject: [PATCH 2/2] Do not remove path disambiugator inside macro --- src/types.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/types.rs b/src/types.rs index 20828429cb1f..f1d89ab9aedd 100644 --- a/src/types.rs +++ b/src/types.rs @@ -229,7 +229,9 @@ fn rewrite_segment( .chain(data.bindings.iter().map(|x| SegmentParam::Binding(&*x))) .collect::>(); - let separator = if path_context == PathContext::Expr { + let force_separator = + context.inside_macro() && context.snippet(data.span).starts_with("::"); + let separator = if path_context == PathContext::Expr || force_separator { "::" } else { ""