Skip to content

Commit 87380cb

Browse files
committed
Address unused tuple struct fields in the compiler
1 parent 9f15a88 commit 87380cb

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

compiler/rustc_borrowck/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use rustc_target::abi::FieldIdx;
4242
use smallvec::SmallVec;
4343
use std::cell::RefCell;
4444
use std::collections::BTreeMap;
45+
use std::marker::PhantomData;
4546
use std::ops::Deref;
4647
use std::rc::Rc;
4748

@@ -100,7 +101,7 @@ use renumber::RegionCtxt;
100101
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
101102

102103
/// Associate some local constants with the `'tcx` lifetime
103-
struct TyCtxtConsts<'tcx>(TyCtxt<'tcx>);
104+
struct TyCtxtConsts<'tcx>(PhantomData<&'tcx ()>);
104105
impl<'tcx> TyCtxtConsts<'tcx> {
105106
const DEREF_PROJECTION: &'tcx [PlaceElem<'tcx>; 1] = &[ProjectionElem::Deref];
106107
}

compiler/rustc_mir_transform/src/check_unsafety.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ pub(crate) fn provide(providers: &mut Providers) {
385385
enum Context {
386386
Safe,
387387
/// in an `unsafe fn`
388-
UnsafeFn(HirId),
388+
UnsafeFn,
389389
/// in a *used* `unsafe` block
390390
/// (i.e. a block without unused-unsafe warning)
391391
UnsafeBlock(HirId),
@@ -407,7 +407,7 @@ impl<'tcx> intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'_, 'tcx> {
407407
};
408408
let unused_unsafe = match (self.context, used) {
409409
(_, false) => UnusedUnsafe::Unused,
410-
(Context::Safe, true) | (Context::UnsafeFn(_), true) => {
410+
(Context::Safe, true) | (Context::UnsafeFn, true) => {
411411
let previous_context = self.context;
412412
self.context = Context::UnsafeBlock(block.hir_id);
413413
intravisit::walk_block(self, block);
@@ -454,7 +454,7 @@ fn check_unused_unsafe(
454454
let body = tcx.hir().body(body_id);
455455
let hir_id = tcx.local_def_id_to_hir_id(def_id);
456456
let context = match tcx.hir().fn_sig_by_hir_id(hir_id) {
457-
Some(sig) if sig.header.unsafety == hir::Unsafety::Unsafe => Context::UnsafeFn(hir_id),
457+
Some(sig) if sig.header.unsafety == hir::Unsafety::Unsafe => Context::UnsafeFn,
458458
_ => Context::Safe,
459459
};
460460

compiler/rustc_resolve/src/def_collector.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
223223
// ```
224224
//
225225
// In that case, the impl-trait is lowered as an additional generic parameter.
226-
self.with_impl_trait(ImplTraitContext::Universal(self.parent_def), |this| {
226+
self.with_impl_trait(ImplTraitContext::Universal, |this| {
227227
visit::walk_generic_param(this, param)
228228
});
229229
}
@@ -310,9 +310,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
310310
if p.is_placeholder {
311311
self.visit_macro_invoc(p.id)
312312
} else {
313-
self.with_impl_trait(ImplTraitContext::Universal(self.parent_def), |this| {
314-
visit::walk_param(this, p)
315-
})
313+
self.with_impl_trait(ImplTraitContext::Universal, |this| visit::walk_param(this, p))
316314
}
317315
}
318316

compiler/rustc_resolve/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl<'a> ParentScope<'a> {
172172
#[derive(Copy, Debug, Clone)]
173173
enum ImplTraitContext {
174174
Existential,
175-
Universal(LocalDefId),
175+
Universal,
176176
}
177177

178178
#[derive(Debug)]

0 commit comments

Comments
 (0)