Only keep one version of ImplicitSelfKind.
This commit is contained in:
parent
5338f5f1d4
commit
ffe20d61d6
@ -9,10 +9,7 @@
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_middle::{
|
||||
hir::place::PlaceBase,
|
||||
mir::{
|
||||
self, BindingForm, ClearCrossCrate, ImplicitSelfKind, Local, LocalDecl, LocalInfo,
|
||||
LocalKind, Location,
|
||||
},
|
||||
mir::{self, BindingForm, ClearCrossCrate, Local, LocalDecl, LocalInfo, LocalKind, Location},
|
||||
};
|
||||
use rustc_span::source_map::DesugaringKind;
|
||||
use rustc_span::symbol::{kw, Symbol};
|
||||
@ -312,7 +309,7 @@ pub(crate) fn report_mutability_error(
|
||||
&& !matches!(
|
||||
decl.local_info,
|
||||
Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::ImplicitSelf(
|
||||
ImplicitSelfKind::MutRef
|
||||
hir::ImplicitSelfKind::MutRef
|
||||
))))
|
||||
)
|
||||
{
|
||||
@ -1074,7 +1071,7 @@ fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<Symb
|
||||
//
|
||||
// Deliberately fall into this case for all implicit self types,
|
||||
// so that we don't fall in to the next case with them.
|
||||
*kind == mir::ImplicitSelfKind::MutRef
|
||||
*kind == hir::ImplicitSelfKind::MutRef
|
||||
}
|
||||
_ if Some(kw::SelfLower) == local_name => {
|
||||
// Otherwise, check if the name is the `self` keyword - in which case
|
||||
|
@ -2661,7 +2661,7 @@ pub struct FnDecl<'hir> {
|
||||
}
|
||||
|
||||
/// Represents what type of implicit self a function has, if any.
|
||||
#[derive(Copy, Clone, Encodable, Decodable, Debug, HashStable_Generic)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
|
||||
pub enum ImplicitSelfKind {
|
||||
/// Represents a `fn x(self);`.
|
||||
Imm,
|
||||
|
@ -18,7 +18,7 @@
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def::{CtorKind, Namespace};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
|
||||
use rustc_hir::{self, GeneratorKind};
|
||||
use rustc_hir::{self, GeneratorKind, ImplicitSelfKind};
|
||||
use rustc_hir::{self as hir, HirId};
|
||||
use rustc_session::Session;
|
||||
use rustc_target::abi::{Size, VariantIdx};
|
||||
@ -653,22 +653,6 @@ pub enum BindingForm<'tcx> {
|
||||
RefForGuard,
|
||||
}
|
||||
|
||||
/// Represents what type of implicit self a function has, if any.
|
||||
#[derive(Clone, Copy, PartialEq, Debug, TyEncodable, TyDecodable, HashStable)]
|
||||
pub enum ImplicitSelfKind {
|
||||
/// Represents a `fn x(self);`.
|
||||
Imm,
|
||||
/// Represents a `fn x(mut self);`.
|
||||
Mut,
|
||||
/// Represents a `fn x(&self);`.
|
||||
ImmRef,
|
||||
/// Represents a `fn x(&mut self);`.
|
||||
MutRef,
|
||||
/// Represents when a function does not have a self argument or
|
||||
/// when a function has a `self: X` argument.
|
||||
None,
|
||||
}
|
||||
|
||||
TrivialTypeTraversalAndLiftImpls! { BindingForm<'tcx>, }
|
||||
|
||||
mod binding_form_impl {
|
||||
|
@ -11,7 +11,7 @@
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_hir::{GeneratorKind, Node};
|
||||
use rustc_hir::{GeneratorKind, ImplicitSelfKind, Node};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
|
||||
use rustc_middle::hir::place::PlaceBase as HirPlaceBase;
|
||||
@ -170,13 +170,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
|
||||
// Make sure that inferred closure args have no type span
|
||||
.and_then(|ty| if arg.pat.span != ty.span { Some(ty.span) } else { None });
|
||||
self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() {
|
||||
match fn_decl.implicit_self {
|
||||
hir::ImplicitSelfKind::Imm => Some(ImplicitSelfKind::Imm),
|
||||
hir::ImplicitSelfKind::Mut => Some(ImplicitSelfKind::Mut),
|
||||
hir::ImplicitSelfKind::ImmRef => Some(ImplicitSelfKind::ImmRef),
|
||||
hir::ImplicitSelfKind::MutRef => Some(ImplicitSelfKind::MutRef),
|
||||
_ => None,
|
||||
}
|
||||
Some(fn_decl.implicit_self)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -1,10 +1,10 @@
|
||||
pub use crate::very_unstable::hir::ImplicitSelfKind;
|
||||
pub use crate::very_unstable::middle::mir::{
|
||||
visit::MutVisitor, AggregateKind, AssertKind, BasicBlock, BasicBlockData, BinOp, BindingForm,
|
||||
BlockTailInfo, Body, BorrowKind, CastKind, ClearCrossCrate, Constant, ConstantKind,
|
||||
CopyNonOverlapping, Coverage, FakeReadCause, Field, GeneratorInfo, ImplicitSelfKind,
|
||||
InlineAsmOperand, Local, LocalDecl, LocalInfo, LocalKind, Location, MirPhase, MirSource,
|
||||
NullOp, Operand, Place, PlaceRef, ProjectionElem, ProjectionKind, Promoted, RetagKind, Rvalue,
|
||||
Safety, SourceInfo, SourceScope, SourceScopeData, SourceScopeLocalData, Statement,
|
||||
StatementKind, UnOp, UserTypeProjection, UserTypeProjections, VarBindingForm, VarDebugInfo,
|
||||
VarDebugInfoContents,
|
||||
CopyNonOverlapping, Coverage, FakeReadCause, Field, GeneratorInfo, InlineAsmOperand, Local,
|
||||
LocalDecl, LocalInfo, LocalKind, Location, MirPhase, MirSource, NullOp, Operand, Place,
|
||||
PlaceRef, ProjectionElem, ProjectionKind, Promoted, RetagKind, Rvalue, Safety, SourceInfo,
|
||||
SourceScope, SourceScopeData, SourceScopeLocalData, Statement, StatementKind, UnOp,
|
||||
UserTypeProjection, UserTypeProjections, VarBindingForm, VarDebugInfo, VarDebugInfoContents,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user