Skip to content

Commit bcb4dda

Browse files
committed
avoid non-defining uses in defining scope
1 parent f0038a7 commit bcb4dda

File tree

2 files changed

+51
-40
lines changed

2 files changed

+51
-40
lines changed

compiler/rustc_data_structures/src/obligation_forest/mod.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,25 @@ pub enum ProcessResult<O, E> {
146146
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
147147
struct ObligationTreeId(usize);
148148

149-
type ObligationTreeIdGenerator = impl Iterator<Item = ObligationTreeId>;
149+
use uwu::*;
150+
151+
mod uwu {
152+
use super::*;
153+
pub type ObligationTreeIdGenerator = impl Iterator<Item = ObligationTreeId>;
154+
155+
impl<O: ForestObligation> ObligationForest<O> {
156+
pub fn new() -> ObligationForest<O> {
157+
ObligationForest {
158+
nodes: vec![],
159+
done_cache: Default::default(),
160+
active_cache: Default::default(),
161+
reused_node_vec: vec![],
162+
obligation_tree_id_generator: (0..).map(ObligationTreeId),
163+
error_cache: Default::default(),
164+
}
165+
}
166+
}
167+
}
150168

151169
pub struct ObligationForest<O: ForestObligation> {
152170
/// The list of obligations. In between calls to [Self::process_obligations],
@@ -311,17 +329,6 @@ pub struct Error<O, E> {
311329
}
312330

313331
impl<O: ForestObligation> ObligationForest<O> {
314-
pub fn new() -> ObligationForest<O> {
315-
ObligationForest {
316-
nodes: vec![],
317-
done_cache: Default::default(),
318-
active_cache: Default::default(),
319-
reused_node_vec: vec![],
320-
obligation_tree_id_generator: (0..).map(ObligationTreeId),
321-
error_cache: Default::default(),
322-
}
323-
}
324-
325332
/// Returns the total number of nodes in the forest that have not
326333
/// yet been fully resolved.
327334
pub fn len(&self) -> usize {

library/std/src/backtrace.rs

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -428,37 +428,41 @@ impl fmt::Display for Backtrace {
428428
}
429429
}
430430

431-
type LazyResolve = impl (FnOnce() -> Capture) + Send + Sync + UnwindSafe;
432-
433-
fn lazy_resolve(mut capture: Capture) -> LazyResolve {
434-
move || {
435-
// Use the global backtrace lock to synchronize this as it's a
436-
// requirement of the `backtrace` crate, and then actually resolve
437-
// everything.
438-
let _lock = lock();
439-
for frame in capture.frames.iter_mut() {
440-
let symbols = &mut frame.symbols;
441-
let frame = match &frame.frame {
442-
RawFrame::Actual(frame) => frame,
443-
#[cfg(test)]
444-
RawFrame::Fake => unimplemented!(),
445-
};
446-
unsafe {
447-
backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| {
448-
symbols.push(BacktraceSymbol {
449-
name: symbol.name().map(|m| m.as_bytes().to_vec()),
450-
filename: symbol.filename_raw().map(|b| match b {
451-
BytesOrWideString::Bytes(b) => BytesOrWide::Bytes(b.to_owned()),
452-
BytesOrWideString::Wide(b) => BytesOrWide::Wide(b.to_owned()),
453-
}),
454-
lineno: symbol.lineno(),
455-
colno: symbol.colno(),
431+
use define::*;
432+
mod define {
433+
use super::*;
434+
pub(super) type LazyResolve = impl (FnOnce() -> Capture) + Send + Sync + UnwindSafe;
435+
436+
pub(super) fn lazy_resolve(mut capture: Capture) -> LazyResolve {
437+
move || {
438+
// Use the global backtrace lock to synchronize this as it's a
439+
// requirement of the `backtrace` crate, and then actually resolve
440+
// everything.
441+
let _lock = lock();
442+
for frame in capture.frames.iter_mut() {
443+
let symbols = &mut frame.symbols;
444+
let frame = match &frame.frame {
445+
RawFrame::Actual(frame) => frame,
446+
#[cfg(test)]
447+
RawFrame::Fake => unimplemented!(),
448+
};
449+
unsafe {
450+
backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| {
451+
symbols.push(BacktraceSymbol {
452+
name: symbol.name().map(|m| m.as_bytes().to_vec()),
453+
filename: symbol.filename_raw().map(|b| match b {
454+
BytesOrWideString::Bytes(b) => BytesOrWide::Bytes(b.to_owned()),
455+
BytesOrWideString::Wide(b) => BytesOrWide::Wide(b.to_owned()),
456+
}),
457+
lineno: symbol.lineno(),
458+
colno: symbol.colno(),
459+
});
456460
});
457-
});
461+
}
458462
}
459-
}
460463

461-
capture
464+
capture
465+
}
462466
}
463467
}
464468

0 commit comments

Comments
 (0)