Skip to content

Commit

Permalink
Address unused tuple struct fields
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Nov 27, 2023
1 parent 9f15a88 commit 4f62014
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use rustc_target::abi::FieldIdx;
use smallvec::SmallVec;
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::marker::PhantomData;
use std::ops::Deref;
use std::rc::Rc;

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

/// Associate some local constants with the `'tcx` lifetime
struct TyCtxtConsts<'tcx>(TyCtxt<'tcx>);
struct TyCtxtConsts<'tcx>(PhantomData<&'tcx ()>);
impl<'tcx> TyCtxtConsts<'tcx> {
const DEREF_PROJECTION: &'tcx [PlaceElem<'tcx>; 1] = &[ProjectionElem::Deref];
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_transform/src/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ pub(crate) fn provide(providers: &mut Providers) {
enum Context {
Safe,
/// in an `unsafe fn`
UnsafeFn(HirId),
UnsafeFn,
/// in a *used* `unsafe` block
/// (i.e. a block without unused-unsafe warning)
UnsafeBlock(HirId),
Expand All @@ -407,7 +407,7 @@ impl<'tcx> intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'_, 'tcx> {
};
let unused_unsafe = match (self.context, used) {
(_, false) => UnusedUnsafe::Unused,
(Context::Safe, true) | (Context::UnsafeFn(_), true) => {
(Context::Safe, true) | (Context::UnsafeFn, true) => {
let previous_context = self.context;
self.context = Context::UnsafeBlock(block.hir_id);
intravisit::walk_block(self, block);
Expand Down Expand Up @@ -454,7 +454,7 @@ fn check_unused_unsafe(
let body = tcx.hir().body(body_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let context = match tcx.hir().fn_sig_by_hir_id(hir_id) {
Some(sig) if sig.header.unsafety == hir::Unsafety::Unsafe => Context::UnsafeFn(hir_id),
Some(sig) if sig.header.unsafety == hir::Unsafety::Unsafe => Context::UnsafeFn,
_ => Context::Safe,
};

Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_resolve/src/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
// ```
//
// In that case, the impl-trait is lowered as an additional generic parameter.
self.with_impl_trait(ImplTraitContext::Universal(self.parent_def), |this| {
self.with_impl_trait(ImplTraitContext::Universal, |this| {
visit::walk_generic_param(this, param)
});
}
Expand Down Expand Up @@ -310,9 +310,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
if p.is_placeholder {
self.visit_macro_invoc(p.id)
} else {
self.with_impl_trait(ImplTraitContext::Universal(self.parent_def), |this| {
visit::walk_param(this, p)
})
self.with_impl_trait(ImplTraitContext::Universal, |this| visit::walk_param(this, p))
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl<'a> ParentScope<'a> {
#[derive(Copy, Debug, Clone)]
enum ImplTraitContext {
Existential,
Universal(LocalDefId),
Universal,
}

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/boxed/thin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ struct WithHeader<H>(NonNull<u8>, PhantomData<H>);
/// An opaque representation of `WithHeader<H>` to avoid the
/// projection invariance of `<T as Pointee>::Metadata`.
#[repr(transparent)]
struct WithOpaqueHeader(NonNull<u8>);
struct WithOpaqueHeader(#[allow(unused_tuple_struct_fields)] NonNull<u8>);

impl WithOpaqueHeader {
#[cfg(not(no_global_oom_handling))]
Expand Down
7 changes: 2 additions & 5 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1821,11 +1821,8 @@ fn maybe_expand_private_type_alias<'tcx>(
}
_ => None,
});
if let Some(ct) = const_ {
args.insert(
param.def_id.to_def_id(),
SubstParam::Constant(clean_const(ct, cx)),
);
if let Some(_) = const_ {
args.insert(param.def_id.to_def_id(), SubstParam::Constant);
}
// FIXME(const_generics_defaults)
indices.consts += 1;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2546,7 +2546,7 @@ pub(crate) enum TypeBindingKind {
pub(crate) enum SubstParam {
Type(Type),
Lifetime(Lifetime),
Constant(Constant),
Constant,
}

impl SubstParam {
Expand Down

0 comments on commit 4f62014

Please sign in to comment.