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 { "" 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:: }) + ); +}