Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deny(unused_lifetimes) to all the crates that have deny(internal). #61735

Merged
merged 12 commits into from
Jun 11, 2019
1 change: 1 addition & 0 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both deny(internal) and deny(unused_lifetimes) can be enabled through rustbuild (src\bootstrap\bin\rustc.rs) rather than through all crates individually, similarly to deny(warnings)/deny(bare_trait_objects).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. cc @flip1995

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this locally and it revealed rustc_data_structures and rustc_macros were missing deny(internal) and deny(unused_lifetimes).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like default_hash_types may be a problem.
Unlike other lints it's not universally applicable and is not a no-op for non-compiler crates.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's even worse, the rustbuild thing seems to apply to all crates, not just compiler ones.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the rustbuild thing seems to apply to all crates

I expected that, but also expected internal lints to not report anything for non-compiler crates (since they don't have TyCtxt etc).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah default_hash_types is also explicitly allowed in libstd for example.

Most of the internal lints shouldn't report anything in most of the crates. I will figure this out in #61545

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why these are deny instead of warn? This means these are hard errors even with deny-warnings = false.


#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
Expand Down
1 change: 1 addition & 0 deletions src/libfmt_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]

#![feature(nll)]
#![feature(rustc_private)]
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/hir/map/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,9 @@ struct HirItemLike<T> {
hash_bodies: bool,
}

impl<'a, 'hir, T> HashStable<StableHashingContext<'hir>> for HirItemLike<T>
where T: HashStable<StableHashingContext<'hir>>
impl<'hir, T> HashStable<StableHashingContext<'hir>> for HirItemLike<T>
where
T: HashStable<StableHashingContext<'hir>>,
{
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'hir>,
Expand Down
7 changes: 4 additions & 3 deletions src/librustc/ich/hcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,13 @@ impl<'a> HashStable<StableHashingContext<'a>> for DelimSpan {
}
}

pub fn hash_stable_trait_impls<'a, 'gcx, W>(
pub fn hash_stable_trait_impls<'a, W>(
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>,
blanket_impls: &[DefId],
non_blanket_impls: &FxHashMap<fast_reject::SimplifiedType, Vec<DefId>>)
where W: StableHasherResult
non_blanket_impls: &FxHashMap<fast_reject::SimplifiedType, Vec<DefId>>,
) where
W: StableHasherResult,
{
{
let mut blanket_impls: SmallVec<[_; 8]> = blanket_impls
Expand Down
23 changes: 9 additions & 14 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundVar {
}
}

impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for ty::Binder<T>
where T: HashStable<StableHashingContext<'a>>
impl<'a, T> HashStable<StableHashingContext<'a>> for ty::Binder<T>
where
T: HashStable<StableHashingContext<'a>>,
{
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
Expand Down Expand Up @@ -192,9 +193,7 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for region::Scope {
}
}

impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
for ty::TyVid
{
impl<'a> HashStable<StableHashingContext<'a>> for ty::TyVid {
fn hash_stable<W: StableHasherResult>(&self,
_hcx: &mut StableHashingContext<'a>,
_hasher: &mut StableHasher<W>) {
Expand All @@ -204,9 +203,7 @@ for ty::TyVid
}
}

impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
for ty::IntVid
{
impl<'a> HashStable<StableHashingContext<'a>> for ty::IntVid {
fn hash_stable<W: StableHasherResult>(&self,
_hcx: &mut StableHashingContext<'a>,
_hasher: &mut StableHasher<W>) {
Expand All @@ -216,9 +213,7 @@ for ty::IntVid
}
}

impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
for ty::FloatVid
{
impl<'a> HashStable<StableHashingContext<'a>> for ty::FloatVid {
fn hash_stable<W: StableHasherResult>(&self,
_hcx: &mut StableHashingContext<'a>,
_hasher: &mut StableHasher<W>) {
Expand All @@ -228,9 +223,9 @@ for ty::FloatVid
}
}

impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>>
for ty::steal::Steal<T>
where T: HashStable<StableHashingContext<'a>>
impl<'a, T> HashStable<StableHashingContext<'a>> for ty::steal::Steal<T>
where
T: HashStable<StableHashingContext<'a>>,
{
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/region_constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ impl<'a, 'gcx, 'tcx> GenericKind<'tcx> {
}
}

impl<'a, 'gcx, 'tcx> VerifyBound<'tcx> {
impl<'tcx> VerifyBound<'tcx> {
pub fn must_hold(&self) -> bool {
match self {
VerifyBound::IfEq(..) => false,
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#![allow(explicit_outlives_requirements)]

#![feature(arbitrary_self_types)]
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ impl LintPassObject for EarlyLintPassObject {}

impl LintPassObject for LateLintPassObject {}

pub trait LintContext<'tcx>: Sized {
pub trait LintContext: Sized {
type PassObject: LintPassObject;

fn sess(&self) -> &Session;
Expand Down Expand Up @@ -700,7 +700,7 @@ impl<'a, T: EarlyLintPass> EarlyContextAndPass<'a, T> {
}
}

impl<'a, 'tcx> LintContext<'tcx> for LateContext<'a, 'tcx> {
impl LintContext for LateContext<'_, '_> {
type PassObject = LateLintPassObject;

/// Gets the overall compiler `Session` object.
Expand Down Expand Up @@ -728,7 +728,7 @@ impl<'a, 'tcx> LintContext<'tcx> for LateContext<'a, 'tcx> {
}
}

impl<'a> LintContext<'a> for EarlyContext<'a> {
impl LintContext for EarlyContext<'_> {
type PassObject = EarlyLintPassObject;

/// Gets the overall compiler `Session` object.
Expand Down
18 changes: 9 additions & 9 deletions src/librustc/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ macro_rules! impl_stable_hash_for {
// We want to use the enum name both in the `impl ... for $enum_name` as well as for
// importing all the variants. Unfortunately it seems we have to take the name
// twice for this purpose
(impl<$($lt:lifetime $(: $lt_bound:lifetime)? ),* $(,)? $($T:ident),* $(,)?>
(impl<$($T:ident),* $(,)?>
for enum $enum_name:path
[ $enum_path:path ]
{
Expand All @@ -91,7 +91,7 @@ macro_rules! impl_stable_hash_for {
$( { $($named_field:ident $(-> $named_delegate:tt)?),* } )?
),* $(,)?
}) => {
impl<'a, $($lt $(: $lt_bound)?,)* $($T,)*>
impl<$($T,)*>
::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>
for $enum_name
where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),*
Expand All @@ -117,13 +117,13 @@ macro_rules! impl_stable_hash_for {
// Structs
(struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => {
impl_stable_hash_for!(
impl<'tcx> for struct $struct_name { $($field $(-> $delegate)?),* }
impl<> for struct $struct_name { $($field $(-> $delegate)?),* }
);
};
(impl<$($lt:lifetime $(: $lt_bound:lifetime)? ),* $(,)? $($T:ident),* $(,)?> for struct $struct_name:path {
(impl<$($T:ident),* $(,)?> for struct $struct_name:path {
$($field:ident $(-> $delegate:tt)?),* $(,)?
}) => {
impl<'a, $($lt $(: $lt_bound)?,)* $($T,)*>
impl<$($T,)*>
::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $struct_name
where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),*
{
Expand All @@ -143,12 +143,12 @@ macro_rules! impl_stable_hash_for {
// We cannot use normal parentheses here, the parser won't allow it
(tuple_struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => {
impl_stable_hash_for!(
impl<'tcx> for tuple_struct $struct_name { $($field $(-> $delegate)?),* }
impl<> for tuple_struct $struct_name { $($field $(-> $delegate)?),* }
);
};
(impl<$($lt:lifetime $(: $lt_bound:lifetime)? ),* $(,)? $($T:ident),* $(,)?>
(impl<$($T:ident),* $(,)?>
for tuple_struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => {
impl<'a, $($lt $(: $lt_bound)?,)* $($T,)*>
impl<$($T,)*>
::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $struct_name
where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),*
{
Expand All @@ -170,7 +170,7 @@ macro_rules! impl_stable_hash_for {
macro_rules! impl_stable_hash_for_spanned {
($T:path) => (

impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ::syntax::source_map::Spanned<$T>
impl HashStable<StableHashingContext<'a>> for ::syntax::source_map::Spanned<$T>
{
#[inline]
fn hash_stable<W: StableHasherResult>(&self,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/interpret/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl From<AllocId> for Pointer {
}
}

impl<'tcx> Pointer<()> {
impl Pointer<()> {
#[inline(always)]
pub fn new(alloc_id: AllocId, offset: Size) -> Self {
Pointer { alloc_id, offset, tag: () }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl<Tag> From<Double> for Scalar<Tag> {
}
}

impl<'tcx> Scalar<()> {
impl Scalar<()> {
#[inline(always)]
fn check_data(data: u128, size: u8) {
debug_assert_eq!(truncate(data, Size::from_bytes(size as u64)), data,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ pub enum PlaceContext {
NonUse(NonUseContext),
}

impl<'tcx> PlaceContext {
impl PlaceContext {
/// Returns `true` if this place context represents a drop.
pub fn is_drop(&self) -> bool {
match *self {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ macro_rules! options {
return op;
}

impl<'a> dep_tracking::DepTrackingHash for $struct_name {
impl dep_tracking::DepTrackingHash for $struct_name {
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
let mut sub_hashes = BTreeMap::new();
$({
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
// the final synthesized generics: we don't want our generated docs page to contain something
// like 'T: Copy + Clone', as that's redundant. Therefore, we keep track of a separate
// 'user_env', which only holds the predicates that will actually be displayed to the user.
fn evaluate_predicates<'b, 'gcx, 'c>(
fn evaluate_predicates<'b, 'c>(
Centril marked this conversation as resolved.
Show resolved Hide resolved
&self,
infcx: &InferCtxt<'b, 'tcx, 'c>,
trait_did: DefId,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ where
folder: &mut F,
) -> chalk_engine::ExClause<Self>;

fn visit_ex_clause_with<'gcx: 'tcx, V: TypeVisitor<'tcx>>(
fn visit_ex_clause_with<V: TypeVisitor<'tcx>>(
ex_clause: &chalk_engine::ExClause<Self>,
visitor: &mut V,
) -> bool;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/query/type_op/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ BraceStructLiftImpl! {
}

impl_stable_hash_for! {
impl<'tcx, T> for struct Normalize<T> {
impl<T> for struct Normalize<T> {
value
}
}
9 changes: 3 additions & 6 deletions src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ pub enum IntercrateAmbiguityCause {
impl IntercrateAmbiguityCause {
/// Emits notes when the overlap is caused by complex intercrate ambiguities.
/// See #23980 for details.
pub fn add_intercrate_ambiguity_hint<'a, 'tcx>(
&self,
err: &mut errors::DiagnosticBuilder<'_>,
) {
pub fn add_intercrate_ambiguity_hint(&self, err: &mut errors::DiagnosticBuilder<'_>) {
err.note(&self.intercrate_ambiguity_hint());
}

Expand Down Expand Up @@ -2299,7 +2296,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
/// candidates and prefer where-clause candidates.
///
/// See the comment for "SelectionCandidate" for more details.
fn candidate_should_be_dropped_in_favor_of<'o>(
fn candidate_should_be_dropped_in_favor_of(
&mut self,
victim: &EvaluatedCandidate<'tcx>,
other: &EvaluatedCandidate<'tcx>,
Expand Down Expand Up @@ -2423,7 +2420,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
// These cover the traits that are built-in to the language
// itself: `Copy`, `Clone` and `Sized`.

fn assemble_builtin_bound_candidates<'o>(
fn assemble_builtin_bound_candidates(
&mut self,
conditions: BuiltinImplConditions<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableClosureData<'tcx, N> {
}
}

impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData<N> {
impl<N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData<N> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "VtableBuiltinData(nested={:?})", self.nested)
}
}

impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableAutoImplData<N> {
impl<N: fmt::Debug> fmt::Debug for traits::VtableAutoImplData<N> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/fast_reject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ impl<D: Copy + Debug + Ord + Eq + Hash> SimplifiedTypeGen<D> {
}
}

impl<'a, 'gcx, D> HashStable<StableHashingContext<'a>> for SimplifiedTypeGen<D>
where D: Copy + Debug + Ord + Eq + Hash +
HashStable<StableHashingContext<'a>>,
impl<'a, D> HashStable<StableHashingContext<'a>> for SimplifiedTypeGen<D>
where
D: Copy + Debug + Ord + Eq + Hash + HashStable<StableHashingContext<'a>>,
{
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,10 @@ fn resolve_associated_item<'a, 'tcx>(
}
}

fn needs_fn_once_adapter_shim<'a, 'tcx>(actual_closure_kind: ty::ClosureKind,
trait_closure_kind: ty::ClosureKind)
-> Result<bool, ()>
{
fn needs_fn_once_adapter_shim(
actual_closure_kind: ty::ClosureKind,
trait_closure_kind: ty::ClosureKind,
) -> Result<bool, ()> {
match (actual_closure_kind, trait_closure_kind) {
(ty::ClosureKind::Fn, ty::ClosureKind::Fn) |
(ty::ClosureKind::FnMut, ty::ClosureKind::FnMut) |
Expand Down
9 changes: 5 additions & 4 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1678,10 +1678,11 @@ impl ty::query::TyCtxtAt<'a, 'tcx, '_> {
}
}

impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
where C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
C::TyLayout: MaybeResult<TyLayout<'tcx>>,
C: HasParamEnv<'tcx>
impl<'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
where
C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
C::TyLayout: MaybeResult<TyLayout<'tcx>>,
eddyb marked this conversation as resolved.
Show resolved Hide resolved
C: HasParamEnv<'tcx>,
{
fn for_variant(this: TyLayout<'tcx>, cx: &C, variant_index: VariantIdx) -> TyLayout<'tcx> {
let details = match this.variants {
Expand Down
7 changes: 4 additions & 3 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl AssocItem {

/// Tests whether the associated item admits a non-trivial implementation
/// for !
pub fn relevant_for_never<'tcx>(&self) -> bool {
pub fn relevant_for_never(&self) -> bool {
match self.kind {
AssocKind::Existential |
AssocKind::Const |
Expand Down Expand Up @@ -1614,8 +1614,9 @@ pub struct Placeholder<T> {
pub name: T,
}

impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for Placeholder<T>
where T: HashStable<StableHashingContext<'a>>
impl<'a, T> HashStable<StableHashingContext<'a>> for Placeholder<T>
where
T: HashStable<StableHashingContext<'a>>,
{
fn hash_stable<W: StableHasherResult>(
&self,
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/ty/print/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pub use self::pretty::*;

pub mod obsolete;

// FIXME(eddyb) false positive, the lifetime parameters are used with `P: Printer<...>`.
#[allow(unused_lifetimes)]
pub trait Print<'gcx, 'tcx, P> {
type Output;
type Error;
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/ty/query/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use crate::ich::StableHashingContext;

// Query configuration and description traits.

// FIXME(eddyb) false positive, the lifetime parameter is used for `Key`/`Value`.
#[allow(unused_lifetimes)]
pub trait QueryConfig<'tcx> {
const NAME: QueryName;
const CATEGORY: ProfileCategory;
Expand Down
Loading