Skip to content

Commit 285fcb0

Browse files
Rollup merge of rust-lang#156021 - nnethercote:clean-up-some-traits, r=jackh726
Clean up some traits I was looking at various traits and found some unnecessary trait bounds, and some unnecessary traits. Details in individual commits. r? @Nadrieril
2 parents c8a4c2e + 9119225 commit 285fcb0

9 files changed

Lines changed: 10 additions & 38 deletions

File tree

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ use super::{DescribePlaceOpt, RegionName, RegionNameSource, UseSpans};
4747
use crate::borrow_set::{BorrowData, TwoPhaseActivation};
4848
use crate::diagnostics::conflict_errors::StorageDeadOrDrop::LocalStorageDead;
4949
use crate::diagnostics::{CapturedMessageOpt, call_kind, find_all_local_uses};
50-
use crate::prefixes::IsPrefixOf;
5150
use crate::{InitializationRequiringAction, MirBorrowckCtxt, WriteKind, borrowck_errors};
5251

5352
#[derive(Debug)]

compiler/rustc_borrowck/src/prefixes.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@ use rustc_middle::mir::{PlaceRef, ProjectionElem};
88

99
use super::MirBorrowckCtxt;
1010

11-
pub(crate) trait IsPrefixOf<'tcx> {
12-
fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool;
13-
}
14-
15-
impl<'tcx> IsPrefixOf<'tcx> for PlaceRef<'tcx> {
16-
fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool {
17-
self.local == other.local
18-
&& self.projection.len() <= other.projection.len()
19-
&& self.projection == &other.projection[..self.projection.len()]
20-
}
21-
}
22-
2311
pub(super) struct Prefixes<'tcx> {
2412
kind: PrefixSet,
2513
next: Option<PlaceRef<'tcx>>,

compiler/rustc_borrowck/src/region_infer/values.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,19 +426,13 @@ impl ToElementIndex<'_> for RegionVid {
426426
}
427427

428428
impl<'tcx> ToElementIndex<'tcx> for ty::PlaceholderRegion<'tcx> {
429-
fn add_to_row<N: Idx>(self, values: &mut RegionValues<'tcx, N>, row: N) -> bool
430-
where
431-
Self: Into<ty::PlaceholderRegion<'tcx>>,
432-
{
429+
fn add_to_row<N: Idx>(self, values: &mut RegionValues<'tcx, N>, row: N) -> bool {
433430
let placeholder: ty::PlaceholderRegion<'tcx> = self.into();
434431
let index = values.placeholder_indices.lookup_index(placeholder);
435432
values.placeholders.insert(row, index)
436433
}
437434

438-
fn contained_in_row<N: Idx>(self, values: &RegionValues<'tcx, N>, row: N) -> bool
439-
where
440-
Self: Into<ty::PlaceholderRegion<'tcx>>,
441-
{
435+
fn contained_in_row<N: Idx>(self, values: &RegionValues<'tcx, N>, row: N) -> bool {
442436
let placeholder: ty::PlaceholderRegion<'tcx> = self.into();
443437
let index = values.placeholder_indices.lookup_index(placeholder);
444438
values.placeholders.contains(row, index)

compiler/rustc_error_messages/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,7 @@ pub fn fluent_value_from_str_list_sep_by_and(l: Vec<Cow<'_, str>>) -> FluentValu
268268
type Args = ();
269269
type Error = ();
270270

271-
fn construct(lang: LanguageIdentifier, _args: Self::Args) -> Result<Self, Self::Error>
272-
where
273-
Self: Sized,
274-
{
271+
fn construct(lang: LanguageIdentifier, _args: Self::Args) -> Result<Self, Self::Error> {
275272
let locale = icu_locale_from_unic_langid(lang)
276273
.unwrap_or_else(|| rustc_baked_icu_data::supported_locales::EN);
277274
let list_formatter = icu_list::ListFormatter::try_new_and_unstable(

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,7 @@ impl<'a, F: FnOnce(&mut Diag<'_, ()>)> Diagnostic<'a, ()> for DiagDecorator<F> {
143143
/// Trait implemented by error types. This should not be implemented manually. Instead, use
144144
/// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic].
145145
#[rustc_diagnostic_item = "Subdiagnostic"]
146-
pub trait Subdiagnostic
147-
where
148-
Self: Sized,
149-
{
146+
pub trait Subdiagnostic {
150147
/// Add a subdiagnostic to an existing diagnostic.
151148
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>);
152149
}

compiler/rustc_hir/src/intravisit.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ use rustc_span::{Ident, Span, Symbol};
7171

7272
use crate::hir::*;
7373

74-
pub trait IntoVisitor<'hir> {
75-
type Visitor: Visitor<'hir>;
76-
fn into_visitor(&self) -> Self::Visitor;
77-
}
78-
7974
#[derive(Copy, Clone, Debug)]
8075
pub enum FnKind<'a> {
8176
/// `#[xxx] pub async/const/extern "Abi" fn foo()`

compiler/rustc_infer/src/infer/snapshot/undo_log.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ where
126126

127127
fn extend<J>(&mut self, undos: J)
128128
where
129-
Self: Sized,
130129
J: IntoIterator<Item = T>,
131130
{
132131
if self.in_snapshot() {

compiler/rustc_middle/src/mir/statement.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,12 @@ impl From<Local> for Place<'_> {
478478
}
479479

480480
impl<'tcx> PlaceRef<'tcx> {
481+
pub fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool {
482+
self.local == other.local
483+
&& self.projection.len() <= other.projection.len()
484+
&& self.projection == &other.projection[..self.projection.len()]
485+
}
486+
481487
/// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
482488
/// a single deref of a local.
483489
pub fn local_or_deref_local(&self) -> Option<Local> {

compiler/rustc_pattern_analysis/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ pub use rustc_index::{Idx, IndexVec}; // re-exported to avoid rustc_index versio
2525
use crate::constructor::{Constructor, ConstructorSet, IntRange};
2626
use crate::pat::DeconstructedPat;
2727

28-
pub trait Captures<'a> {}
29-
impl<'a, T: ?Sized> Captures<'a> for T {}
30-
3128
/// `bool` newtype that indicates whether this is a privately uninhabited field that we should skip
3229
/// during analysis.
3330
#[derive(Copy, Clone, Debug, PartialEq, Eq)]

0 commit comments

Comments
 (0)