Skip to content

Commit 4f62014

Browse files
committed
Address unused tuple struct fields
1 parent 9f15a88 commit 4f62014

File tree

7 files changed

+12
-16
lines changed

7 files changed

+12
-16
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)]

library/alloc/src/boxed/thin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ struct WithHeader<H>(NonNull<u8>, PhantomData<H>);
171171
/// An opaque representation of `WithHeader<H>` to avoid the
172172
/// projection invariance of `<T as Pointee>::Metadata`.
173173
#[repr(transparent)]
174-
struct WithOpaqueHeader(NonNull<u8>);
174+
struct WithOpaqueHeader(#[allow(unused_tuple_struct_fields)] NonNull<u8>);
175175

176176
impl WithOpaqueHeader {
177177
#[cfg(not(no_global_oom_handling))]

src/librustdoc/clean/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1821,11 +1821,8 @@ fn maybe_expand_private_type_alias<'tcx>(
18211821
}
18221822
_ => None,
18231823
});
1824-
if let Some(ct) = const_ {
1825-
args.insert(
1826-
param.def_id.to_def_id(),
1827-
SubstParam::Constant(clean_const(ct, cx)),
1828-
);
1824+
if let Some(_) = const_ {
1825+
args.insert(param.def_id.to_def_id(), SubstParam::Constant);
18291826
}
18301827
// FIXME(const_generics_defaults)
18311828
indices.consts += 1;

src/librustdoc/clean/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2546,7 +2546,7 @@ pub(crate) enum TypeBindingKind {
25462546
pub(crate) enum SubstParam {
25472547
Type(Type),
25482548
Lifetime(Lifetime),
2549-
Constant(Constant),
2549+
Constant,
25502550
}
25512551

25522552
impl SubstParam {

0 commit comments

Comments
 (0)