Skip to content

Commit ffe20d6

Browse files
committed
Only keep one version of ImplicitSelfKind.
1 parent 5338f5f commit ffe20d6

File tree

5 files changed

+13
-38
lines changed

5 files changed

+13
-38
lines changed

Diff for: compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ use rustc_middle::mir::{Mutability, Place, PlaceRef, ProjectionElem};
99
use rustc_middle::ty::{self, Ty, TyCtxt};
1010
use rustc_middle::{
1111
hir::place::PlaceBase,
12-
mir::{
13-
self, BindingForm, ClearCrossCrate, ImplicitSelfKind, Local, LocalDecl, LocalInfo,
14-
LocalKind, Location,
15-
},
12+
mir::{self, BindingForm, ClearCrossCrate, Local, LocalDecl, LocalInfo, LocalKind, Location},
1613
};
1714
use rustc_span::source_map::DesugaringKind;
1815
use rustc_span::symbol::{kw, Symbol};
@@ -312,7 +309,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
312309
&& !matches!(
313310
decl.local_info,
314311
Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::ImplicitSelf(
315-
ImplicitSelfKind::MutRef
312+
hir::ImplicitSelfKind::MutRef
316313
))))
317314
)
318315
{
@@ -1074,7 +1071,7 @@ fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<Symb
10741071
//
10751072
// Deliberately fall into this case for all implicit self types,
10761073
// so that we don't fall in to the next case with them.
1077-
*kind == mir::ImplicitSelfKind::MutRef
1074+
*kind == hir::ImplicitSelfKind::MutRef
10781075
}
10791076
_ if Some(kw::SelfLower) == local_name => {
10801077
// Otherwise, check if the name is the `self` keyword - in which case

Diff for: compiler/rustc_hir/src/hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2661,7 +2661,7 @@ pub struct FnDecl<'hir> {
26612661
}
26622662

26632663
/// Represents what type of implicit self a function has, if any.
2664-
#[derive(Copy, Clone, Encodable, Decodable, Debug, HashStable_Generic)]
2664+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
26652665
pub enum ImplicitSelfKind {
26662666
/// Represents a `fn x(self);`.
26672667
Imm,

Diff for: compiler/rustc_middle/src/mir/mod.rs

+1-17
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_data_structures::captures::Captures;
1818
use rustc_errors::ErrorGuaranteed;
1919
use rustc_hir::def::{CtorKind, Namespace};
2020
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
21-
use rustc_hir::{self, GeneratorKind};
21+
use rustc_hir::{self, GeneratorKind, ImplicitSelfKind};
2222
use rustc_hir::{self as hir, HirId};
2323
use rustc_session::Session;
2424
use rustc_target::abi::{Size, VariantIdx};
@@ -653,22 +653,6 @@ pub enum BindingForm<'tcx> {
653653
RefForGuard,
654654
}
655655

656-
/// Represents what type of implicit self a function has, if any.
657-
#[derive(Clone, Copy, PartialEq, Debug, TyEncodable, TyDecodable, HashStable)]
658-
pub enum ImplicitSelfKind {
659-
/// Represents a `fn x(self);`.
660-
Imm,
661-
/// Represents a `fn x(mut self);`.
662-
Mut,
663-
/// Represents a `fn x(&self);`.
664-
ImmRef,
665-
/// Represents a `fn x(&mut self);`.
666-
MutRef,
667-
/// Represents when a function does not have a self argument or
668-
/// when a function has a `self: X` argument.
669-
None,
670-
}
671-
672656
TrivialTypeTraversalAndLiftImpls! { BindingForm<'tcx>, }
673657

674658
mod binding_form_impl {

Diff for: compiler/rustc_mir_build/src/build/mod.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_errors::ErrorGuaranteed;
1111
use rustc_hir as hir;
1212
use rustc_hir::def_id::{DefId, LocalDefId};
1313
use rustc_hir::lang_items::LangItem;
14-
use rustc_hir::{GeneratorKind, Node};
14+
use rustc_hir::{GeneratorKind, ImplicitSelfKind, Node};
1515
use rustc_index::vec::{Idx, IndexVec};
1616
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
1717
use rustc_middle::hir::place::PlaceBase as HirPlaceBase;
@@ -170,13 +170,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
170170
// Make sure that inferred closure args have no type span
171171
.and_then(|ty| if arg.pat.span != ty.span { Some(ty.span) } else { None });
172172
self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() {
173-
match fn_decl.implicit_self {
174-
hir::ImplicitSelfKind::Imm => Some(ImplicitSelfKind::Imm),
175-
hir::ImplicitSelfKind::Mut => Some(ImplicitSelfKind::Mut),
176-
hir::ImplicitSelfKind::ImmRef => Some(ImplicitSelfKind::ImmRef),
177-
hir::ImplicitSelfKind::MutRef => Some(ImplicitSelfKind::MutRef),
178-
_ => None,
179-
}
173+
Some(fn_decl.implicit_self)
180174
} else {
181175
None
182176
};

Diff for: compiler/rustc_smir/src/mir.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
pub use crate::very_unstable::hir::ImplicitSelfKind;
12
pub use crate::very_unstable::middle::mir::{
23
visit::MutVisitor, AggregateKind, AssertKind, BasicBlock, BasicBlockData, BinOp, BindingForm,
34
BlockTailInfo, Body, BorrowKind, CastKind, ClearCrossCrate, Constant, ConstantKind,
4-
CopyNonOverlapping, Coverage, FakeReadCause, Field, GeneratorInfo, ImplicitSelfKind,
5-
InlineAsmOperand, Local, LocalDecl, LocalInfo, LocalKind, Location, MirPhase, MirSource,
6-
NullOp, Operand, Place, PlaceRef, ProjectionElem, ProjectionKind, Promoted, RetagKind, Rvalue,
7-
Safety, SourceInfo, SourceScope, SourceScopeData, SourceScopeLocalData, Statement,
8-
StatementKind, UnOp, UserTypeProjection, UserTypeProjections, VarBindingForm, VarDebugInfo,
9-
VarDebugInfoContents,
5+
CopyNonOverlapping, Coverage, FakeReadCause, Field, GeneratorInfo, InlineAsmOperand, Local,
6+
LocalDecl, LocalInfo, LocalKind, Location, MirPhase, MirSource, NullOp, Operand, Place,
7+
PlaceRef, ProjectionElem, ProjectionKind, Promoted, RetagKind, Rvalue, Safety, SourceInfo,
8+
SourceScope, SourceScopeData, SourceScopeLocalData, Statement, StatementKind, UnOp,
9+
UserTypeProjection, UserTypeProjections, VarBindingForm, VarDebugInfo, VarDebugInfoContents,
1010
};

0 commit comments

Comments
 (0)