Skip to content

Commit af64662

Browse files
committed
Auto merge of rust-lang#12916 - Veykril:nits, r=Veykril
minor: Properly cfg the `max` field of Limit
2 parents e0ff4be + 3b2ecf4 commit af64662

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

crates/hir-def/src/nameres/collector.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ impl DefCollector<'_> {
10551055
};
10561056
let mut res = ReachedFixedPoint::Yes;
10571057
macros.retain(|directive| {
1058-
let resolver2 = |path| {
1058+
let resolver = |path| {
10591059
let resolved_res = self.def_map.resolve_path_fp_with_macro(
10601060
self.db,
10611061
ResolveMode::Other,
@@ -1068,7 +1068,7 @@ impl DefCollector<'_> {
10681068
.take_macros()
10691069
.map(|it| (it, macro_id_to_def_id(self.db, it)))
10701070
};
1071-
let resolver = |path| resolver2(path).map(|(_, it)| it);
1071+
let resolver_def_id = |path| resolver(path).map(|(_, it)| it);
10721072

10731073
match &directive.kind {
10741074
MacroDirectiveKind::FnLike { ast_id, expand_to } => {
@@ -1077,7 +1077,7 @@ impl DefCollector<'_> {
10771077
ast_id,
10781078
*expand_to,
10791079
self.def_map.krate,
1080-
&resolver,
1080+
&resolver_def_id,
10811081
&mut |_err| (),
10821082
);
10831083
if let Ok(Ok(call_id)) = call_id {
@@ -1093,7 +1093,7 @@ impl DefCollector<'_> {
10931093
*derive_attr,
10941094
*derive_pos as u32,
10951095
self.def_map.krate,
1096-
&resolver2,
1096+
&resolver,
10971097
);
10981098

10991099
if let Ok((macro_id, def_id, call_id)) = id {
@@ -1158,7 +1158,7 @@ impl DefCollector<'_> {
11581158
}
11591159
}
11601160

1161-
let def = match resolver(path.clone()) {
1161+
let def = match resolver_def_id(path.clone()) {
11621162
Some(def) if def.is_attribute() => def,
11631163
_ => return true,
11641164
};
@@ -1292,7 +1292,8 @@ impl DefCollector<'_> {
12921292
true
12931293
});
12941294
// Attribute resolution can add unresolved macro invocations, so concatenate the lists.
1295-
self.unresolved_macros.extend(macros);
1295+
macros.extend(mem::take(&mut self.unresolved_macros));
1296+
self.unresolved_macros = macros;
12961297

12971298
for (module_id, depth, container, macro_call_id) in resolved {
12981299
self.collect_macro_expansion(module_id, macro_call_id, depth, container);

crates/limit/src/lib.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,36 @@
22
33
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
44

5+
#[cfg(feature = "tracking")]
56
use std::sync::atomic::AtomicUsize;
67

78
/// Represents a struct used to enforce a numerical limit.
89
pub struct Limit {
910
upper_bound: usize,
10-
#[allow(unused)]
11+
#[cfg(feature = "tracking")]
1112
max: AtomicUsize,
1213
}
1314

1415
impl Limit {
1516
/// Creates a new limit.
1617
#[inline]
1718
pub const fn new(upper_bound: usize) -> Self {
18-
Self { upper_bound, max: AtomicUsize::new(0) }
19+
Self {
20+
upper_bound,
21+
#[cfg(feature = "tracking")]
22+
max: AtomicUsize::new(0),
23+
}
1924
}
2025

2126
/// Creates a new limit.
2227
#[inline]
2328
#[cfg(feature = "tracking")]
2429
pub const fn new_tracking(upper_bound: usize) -> Self {
25-
Self { upper_bound, max: AtomicUsize::new(1) }
30+
Self {
31+
upper_bound,
32+
#[cfg(feature = "tracking")]
33+
max: AtomicUsize::new(1),
34+
}
2635
}
2736

2837
/// Gets the underlying numeric limit.

0 commit comments

Comments
 (0)