Skip to content

Commit 36bec37

Browse files
Merge pull request google#431 from google:use_in_macro
PiperOrigin-RevId: 654088521
2 parents f99635d + 6e7ffc4 commit 36bec37

File tree

7 files changed

+94
-96
lines changed

7 files changed

+94
-96
lines changed

googletest/src/assertions.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
macro_rules! verify_that {
123123
($actual:expr, [$($expecteds:expr),+ $(,)?]) => {
124124
{
125-
use $crate::assertions::internal::Subject;
125+
use $crate::assertions::internal::Subject as _;
126126
$actual.check(
127127
$crate::matchers::elements_are![$($expecteds),+],
128128
stringify!($actual),
@@ -131,7 +131,7 @@ macro_rules! verify_that {
131131
};
132132
($actual:expr, {$($expecteds:expr),+ $(,)?}) => {
133133
{
134-
use $crate::assertions::internal::Subject;
134+
use $crate::assertions::internal::Subject as _;
135135
$actual.check(
136136
$crate::matchers::unordered_elements_are![$($expecteds),+],
137137
stringify!($actual),
@@ -140,7 +140,7 @@ macro_rules! verify_that {
140140
};
141141
($actual:expr, $expected:expr $(,)?) => {
142142
{
143-
use $crate::assertions::internal::Subject;
143+
use $crate::assertions::internal::Subject as _;
144144
$actual.check(
145145
$expected,
146146
stringify!($actual),
@@ -358,7 +358,7 @@ macro_rules! succeed {
358358
#[macro_export]
359359
macro_rules! add_failure {
360360
($($message:expr),+ $(,)?) => {{
361-
use $crate::GoogleTestSupport;
361+
use $crate::GoogleTestSupport as _;
362362
$crate::assertions::internal::create_fail_result(
363363
format!($($message),*),
364364
).and_log_failure();
@@ -406,7 +406,7 @@ macro_rules! add_failure {
406406
#[macro_export]
407407
macro_rules! add_failure_at {
408408
($file:expr, $line:expr, $column:expr, $($message:expr),+ $(,)?) => {{
409-
use $crate::GoogleTestSupport;
409+
use $crate::GoogleTestSupport as _;
410410
$crate::assertions::internal::create_fail_result(
411411
format!($($message),*),
412412
).map_err(|e| e.with_fake_location($file, $line, $column)).and_log_failure();
@@ -444,7 +444,7 @@ macro_rules! add_failure_at {
444444
#[macro_export]
445445
macro_rules! verify_true {
446446
($condition:expr) => {{
447-
use $crate::assertions::internal::Subject;
447+
use $crate::assertions::internal::Subject as _;
448448
($condition).check($crate::matchers::eq(true), stringify!($condition))
449449
}};
450450
}
@@ -472,7 +472,7 @@ macro_rules! verify_true {
472472
#[macro_export]
473473
macro_rules! expect_true {
474474
($condition:expr) => {{
475-
use $crate::GoogleTestSupport;
475+
use $crate::GoogleTestSupport as _;
476476
verify_true!($condition).and_log_failure()
477477
}};
478478
}
@@ -504,7 +504,7 @@ macro_rules! expect_true {
504504
#[macro_export]
505505
macro_rules! verify_false {
506506
($condition:expr) => {{
507-
use $crate::assertions::internal::Subject;
507+
use $crate::assertions::internal::Subject as _;
508508
($condition).check($crate::matchers::eq(false), stringify!($condition))
509509
}};
510510
}
@@ -532,7 +532,7 @@ macro_rules! verify_false {
532532
#[macro_export]
533533
macro_rules! expect_false {
534534
($condition:expr) => {{
535-
use $crate::GoogleTestSupport;
535+
use $crate::GoogleTestSupport as _;
536536
verify_false!($condition).and_log_failure()
537537
}};
538538
}
@@ -622,31 +622,31 @@ macro_rules! verify_eq {
622622
#[macro_export]
623623
macro_rules! expect_eq {
624624
($actual:expr, [$($expected:expr),+ $(,)?] $(,)?) => {{
625-
use $crate::GoogleTestSupport;
625+
use $crate::GoogleTestSupport as _;
626626
verify_eq!($actual, [$($expected),*]).and_log_failure();
627627
}};
628628
($actual:expr, [$($expected:expr),+ $(,)?], $($format_args:expr),* $(,)?) => {{
629-
use $crate::GoogleTestSupport;
629+
use $crate::GoogleTestSupport as _;
630630
verify_eq!($actual, [$($expected),*])
631631
.with_failure_message(|| format!($($format_args),*))
632632
.and_log_failure();
633633
}};
634634
($actual:expr, {$($expected:expr),+ $(,)?} $(,)?) => {{
635-
use $crate::GoogleTestSupport;
635+
use $crate::GoogleTestSupport as _;
636636
verify_eq!($actual, {$($expected),*}).and_log_failure();
637637
}};
638638
($actual:expr, {$($expected:expr),+ $(,)?}, $($format_args:expr),* $(,)?) => {{
639-
use $crate::GoogleTestSupport;
639+
use $crate::GoogleTestSupport as _;
640640
verify_eq!($actual, {$($expected),*})
641641
.with_failure_message(|| format!($($format_args),*))
642642
.and_log_failure();
643643
}};
644644
($actual:expr, $expected:expr $(,)?) => {{
645-
use $crate::GoogleTestSupport;
645+
use $crate::GoogleTestSupport as _;
646646
verify_eq!($actual, $expected).and_log_failure();
647647
}};
648648
($actual:expr, $expected:expr, $($format_args:expr),* $(,)?) => {{
649-
use $crate::GoogleTestSupport;
649+
use $crate::GoogleTestSupport as _;
650650
verify_eq!($actual, $expected)
651651
.with_failure_message(|| format!($($format_args),*))
652652
.and_log_failure();
@@ -720,13 +720,13 @@ macro_rules! verify_ne {
720720
#[macro_export]
721721
macro_rules! expect_ne {
722722
($actual:expr, $expected:expr, $($format_args:expr),+ $(,)?) => {{
723-
use $crate::GoogleTestSupport;
723+
use $crate::GoogleTestSupport as _;
724724
verify_ne!($actual, $expected)
725725
.with_failure_message(|| format!($($format_args),*))
726726
.and_log_failure();
727727
}};
728728
($actual:expr, $expected:expr $(,)?) => {{
729-
use $crate::GoogleTestSupport;
729+
use $crate::GoogleTestSupport as _;
730730
verify_ne!($actual, $expected).and_log_failure();
731731
}};
732732
}
@@ -798,13 +798,13 @@ macro_rules! verify_lt {
798798
#[macro_export]
799799
macro_rules! expect_lt {
800800
($actual:expr, $expected:expr, $($format_args:expr),+ $(,)?) => {{
801-
use $crate::GoogleTestSupport;
801+
use $crate::GoogleTestSupport as _;
802802
verify_lt!($actual, $expected)
803803
.with_failure_message(|| format!($($format_args),*))
804804
.and_log_failure();
805805
}};
806806
($actual:expr, $expected:expr $(,)?) => {{
807-
use $crate::GoogleTestSupport;
807+
use $crate::GoogleTestSupport as _;
808808
verify_lt!($actual, $expected).and_log_failure();
809809
}};
810810
}
@@ -877,13 +877,13 @@ macro_rules! verify_le {
877877
#[macro_export]
878878
macro_rules! expect_le {
879879
($actual:expr, $expected:expr, $($format_args:expr),+ $(,)?) => {{
880-
use $crate::GoogleTestSupport;
880+
use $crate::GoogleTestSupport as _;
881881
verify_le!($actual, $expected)
882882
.with_failure_message(|| format!($($format_args),*))
883883
.and_log_failure();
884884
}};
885885
($actual:expr, $expected:expr $(,)?) => {{
886-
use $crate::GoogleTestSupport;
886+
use $crate::GoogleTestSupport as _;
887887
verify_le!($actual, $expected).and_log_failure();
888888
}};
889889
}
@@ -955,13 +955,13 @@ macro_rules! verify_gt {
955955
#[macro_export]
956956
macro_rules! expect_gt {
957957
($actual:expr, $expected:expr, $($format_args:expr),+ $(,)?) => {{
958-
use $crate::GoogleTestSupport;
958+
use $crate::GoogleTestSupport as _;
959959
verify_gt!($actual, $expected)
960960
.with_failure_message(|| format!($($format_args),*))
961961
.and_log_failure();
962962
}};
963963
($actual:expr, $expected:expr $(,)?) => {{
964-
use $crate::GoogleTestSupport;
964+
use $crate::GoogleTestSupport as _;
965965
verify_gt!($actual, $expected).and_log_failure();
966966
}};
967967
}
@@ -1035,13 +1035,13 @@ macro_rules! verify_ge {
10351035
#[macro_export]
10361036
macro_rules! expect_ge {
10371037
($actual:expr, $expected:expr, $($format_args:expr),+ $(,)?) => {{
1038-
use $crate::GoogleTestSupport;
1038+
use $crate::GoogleTestSupport as _;
10391039
verify_ge!($actual, $expected)
10401040
.with_failure_message(|| format!($($format_args),*))
10411041
.and_log_failure();
10421042
}};
10431043
($actual:expr, $expected:expr $(,)?) => {{
1044-
use $crate::GoogleTestSupport;
1044+
use $crate::GoogleTestSupport as _;
10451045
verify_ge!($actual, $expected).and_log_failure();
10461046
}};
10471047
}
@@ -1130,13 +1130,13 @@ macro_rules! verify_float_eq {
11301130
#[macro_export]
11311131
macro_rules! expect_float_eq {
11321132
($actual:expr, $expected:expr, $($format_args:expr),+ $(,)?) => {{
1133-
use $crate::GoogleTestSupport;
1133+
use $crate::GoogleTestSupport as _;
11341134
verify_float_eq!($actual, $expected)
11351135
.with_failure_message(|| format!($($format_args),*))
11361136
.and_log_failure();
11371137
}};
11381138
($actual:expr, $expected:expr $(,)?) => {{
1139-
use $crate::GoogleTestSupport;
1139+
use $crate::GoogleTestSupport as _;
11401140
verify_float_eq!($actual, $expected).and_log_failure();
11411141
}};
11421142
}
@@ -1211,13 +1211,13 @@ macro_rules! verify_near {
12111211
#[macro_export]
12121212
macro_rules! expect_near {
12131213
($actual:expr, $expected:expr, $max_abs_error:expr, $($format_args:expr),+ $(,)?) => {{
1214-
use $crate::GoogleTestSupport;
1214+
use $crate::GoogleTestSupport as _;
12151215
verify_near!($actual, $expected, $max_abs_error)
12161216
.with_failure_message(|| format!($($format_args),*))
12171217
.and_log_failure();
12181218
}};
12191219
($actual:expr, $expected:expr, $max_abs_error:expr $(,)?) => {{
1220-
use $crate::GoogleTestSupport;
1220+
use $crate::GoogleTestSupport as _;
12211221
verify_near!($actual, $expected, $max_abs_error).and_log_failure();
12221222
}};
12231223
}
@@ -1359,7 +1359,7 @@ macro_rules! assert_pred {
13591359
#[macro_export]
13601360
macro_rules! expect_that {
13611361
($actual:expr, $expected:expr $(,)?) => {{
1362-
use $crate::GoogleTestSupport;
1362+
use $crate::GoogleTestSupport as _;
13631363
$crate::verify_that!($actual, $expected).and_log_failure();
13641364
}};
13651365

@@ -1389,7 +1389,7 @@ macro_rules! expect_that {
13891389
#[macro_export]
13901390
macro_rules! expect_pred {
13911391
($($content:tt)*) => {{
1392-
use $crate::GoogleTestSupport;
1392+
use $crate::GoogleTestSupport as _;
13931393
$crate::verify_pred!($($content)*).and_log_failure();
13941394
}};
13951395
}

googletest/src/matcher_support/auto_eq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
macro_rules! __auto_eq {
2828
($e:expr) => {{
2929
#[allow(unused_imports)]
30-
use $crate::matcher_support::__internal_unstable_do_not_depend_on_these::ExpectedKind;
30+
use $crate::matcher_support::__internal_unstable_do_not_depend_on_these::ExpectedKind as _;
3131
match $e {
3232
expected => {
3333
$crate::matcher_support::__internal_unstable_do_not_depend_on_these::Wrapper(

googletest/src/matchers/elements_are_matcher.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@
8787
#[doc(hidden)]
8888
macro_rules! __elements_are {
8989
($($matcher:expr),* $(,)?) => {{
90-
use $crate::matchers::__internal_unstable_do_not_depend_on_these::ElementsAre;
91-
use $crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq;
92-
ElementsAre::new(vec![$(Box::new(auto_eq!($matcher))),*])
90+
$crate::matchers::__internal_unstable_do_not_depend_on_these::ElementsAre::new(
91+
vec![$(Box::new(
92+
$crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq!(
93+
$matcher
94+
)
95+
)),*])
9396
}}
9497
}
9598

googletest/src/matchers/field_matcher.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,7 @@ macro_rules! __field {
197197
#[macro_export]
198198
macro_rules! field_internal {
199199
(&$($t:ident)::+.$field:tt, ref $m:expr) => {{
200-
use $crate::matchers::__internal_unstable_do_not_depend_on_these::field_matcher;
201-
use $crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq;
202-
field_matcher(
200+
$crate::matchers::__internal_unstable_do_not_depend_on_these::field_matcher(
203201
|o: &_| {
204202
match o {
205203
&$($t)::* {$field: ref value, .. } => Some(value),
@@ -211,12 +209,10 @@ macro_rules! field_internal {
211209
}
212210
},
213211
&stringify!($field),
214-
auto_eq!($m))
212+
$crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq!($m))
215213
}};
216214
(&$($t:ident)::+.$field:tt, $m:expr) => {{
217-
use $crate::matchers::__internal_unstable_do_not_depend_on_these::field_matcher;
218-
use $crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq;
219-
field_matcher(
215+
$crate::matchers::__internal_unstable_do_not_depend_on_these::field_matcher(
220216
|o: &&_| {
221217
match o {
222218
&$($t)::* {$field: value, .. } => Some(value),
@@ -228,12 +224,10 @@ macro_rules! field_internal {
228224
}
229225
},
230226
&stringify!($field),
231-
auto_eq!($m))
227+
$crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq!($m))
232228
}};
233229
($($t:ident)::+.$field:tt, $m:expr) => {{
234-
use $crate::matchers::__internal_unstable_do_not_depend_on_these::field_matcher;
235-
use $crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq;
236-
field_matcher(
230+
$crate::matchers::__internal_unstable_do_not_depend_on_these::field_matcher(
237231
|o: &_| {
238232
match o {
239233
$($t)::* {$field: value, .. } => Some(value),
@@ -245,7 +239,7 @@ macro_rules! field_internal {
245239
}
246240
},
247241
&stringify!($field),
248-
auto_eq!($m))
242+
$crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq!($m))
249243
}};
250244
}
251245

googletest/src/matchers/pointwise_matcher.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@
114114
#[doc(hidden)]
115115
macro_rules! __pointwise {
116116
($matcher:expr, $container:expr) => {{
117-
use $crate::matchers::__internal_unstable_do_not_depend_on_these::PointwiseMatcher;
118-
PointwiseMatcher::new($container.into_iter().map($matcher).collect())
117+
$crate::matchers::__internal_unstable_do_not_depend_on_these::PointwiseMatcher::new(
118+
$container.into_iter().map($matcher).collect(),
119+
)
119120
}};
120121

121122
($matcher:expr, $left_container:expr, $right_container:expr) => {{
122-
use $crate::matchers::__internal_unstable_do_not_depend_on_these::PointwiseMatcher;
123-
PointwiseMatcher::new(
123+
$crate::matchers::__internal_unstable_do_not_depend_on_these::PointwiseMatcher::new(
124124
$left_container
125125
.into_iter()
126126
.zip($right_container.into_iter())
@@ -130,8 +130,7 @@ macro_rules! __pointwise {
130130
}};
131131

132132
($matcher:expr, $left_container:expr, $middle_container:expr, $right_container:expr) => {{
133-
use $crate::matchers::__internal_unstable_do_not_depend_on_these::PointwiseMatcher;
134-
PointwiseMatcher::new(
133+
$crate::matchers::__internal_unstable_do_not_depend_on_these::PointwiseMatcher::new(
135134
$left_container
136135
.into_iter()
137136
.zip($right_container.into_iter().zip($middle_container.into_iter()))

googletest/src/matchers/property_matcher.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,36 +178,28 @@ macro_rules! __property {
178178
macro_rules! property_internal {
179179

180180
(&$($t:ident)::+.$method:tt($($argument:tt),* $(,)?), ref $m:expr) => {{
181-
use $crate::matchers::__internal_unstable_do_not_depend_on_these::property_ref_matcher;
182-
use $crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq;
183-
property_ref_matcher(
181+
$crate::matchers::__internal_unstable_do_not_depend_on_these::property_ref_matcher(
184182
|o: &$($t)::+| $($t)::+::$method(o, $($argument),*),
185183
&stringify!($method($($argument),*)),
186-
auto_eq!($m))
184+
$crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq!($m))
187185
}};
188186
($($t:ident)::+.$method:tt($($argument:tt),* $(,)?), ref $m:expr) => {{
189-
use $crate::matchers::__internal_unstable_do_not_depend_on_these::property_ref_matcher;
190-
use $crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq;
191-
property_ref_matcher(
187+
$crate::matchers::__internal_unstable_do_not_depend_on_these::property_ref_matcher(
192188
|o: $($t)::+| $($t)::+::$method(o, $($argument),*),
193189
&stringify!($method($($argument),*)),
194-
auto_eq!($m))
190+
$crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq!($m))
195191
}};
196192
(& $($t:ident)::+.$method:tt($($argument:tt),* $(,)?), $m:expr) => {{
197-
use $crate::matchers::__internal_unstable_do_not_depend_on_these::property_matcher;
198-
use $crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq;
199-
property_matcher(
193+
$crate::matchers::__internal_unstable_do_not_depend_on_these::property_matcher(
200194
|o: &&$($t)::+| o.$method($($argument),*),
201195
&stringify!($method($($argument),*)),
202-
auto_eq!($m))
196+
$crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq!($m))
203197
}};
204198
($($t:ident)::+.$method:tt($($argument:tt),* $(,)?), $m:expr) => {{
205-
use $crate::matchers::__internal_unstable_do_not_depend_on_these::property_matcher;
206-
use $crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq;
207-
property_matcher(
199+
$crate::matchers::__internal_unstable_do_not_depend_on_these::property_matcher(
208200
|o: &$($t)::+| o.$method($($argument),*),
209201
&stringify!($method($($argument),*)),
210-
auto_eq!($m))
202+
$crate::matcher_support::__internal_unstable_do_not_depend_on_these::auto_eq!($m))
211203
}};
212204
}
213205

0 commit comments

Comments
 (0)