Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 42780f0

Browse files
authored
Merge pull request rust-lang#3142 from topecongiro/issue-3139
Do not remove path disambiugator inside macro
2 parents 8fb1b17 + 5ca90ed commit 42780f0

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/types.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ fn rewrite_segment(
229229
.chain(data.bindings.iter().map(|x| SegmentParam::Binding(&*x)))
230230
.collect::<Vec<_>>();
231231

232-
let separator = if path_context == PathContext::Expr {
232+
let force_separator =
233+
context.inside_macro() && context.snippet(data.span).starts_with("::");
234+
let separator = if path_context == PathContext::Expr || force_separator {
233235
"::"
234236
} else {
235237
""

tests/source/type.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,11 @@ fn issue3117() {
121121
}
122122
}
123123
}
124+
125+
// #3139
126+
fn issue3139() {
127+
assert_eq!(
128+
to_json_value(&None :: <i32>).unwrap(),
129+
json!( { "test": None :: <i32> } )
130+
);
131+
}

tests/target/type.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,11 @@ fn issue3117() {
120120
}
121121
}
122122
}
123+
124+
// #3139
125+
fn issue3139() {
126+
assert_eq!(
127+
to_json_value(&None::<i32>).unwrap(),
128+
json!({ "test": None::<i32> })
129+
);
130+
}

0 commit comments

Comments
 (0)