mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Auto merge of #132580 - compiler-errors:globs, r=Noratrieb
Remove unnecessary pub enum glob-imports from `rustc_middle::ty` We used to have an idiom in the compiler where we'd prefix or suffix all the variants of an enum, for example `BoundRegionKind`, with something like `Br`, and then *glob-import* that enum variant directly. `@noratrieb` brought this up, and I think that it's easier to read when we just use the normal style `EnumName::Variant`. This PR is a bit large, but it's just naming. The only somewhat opinionated change that this PR does is rename `BorrowKind::Imm` to `BorrowKind::Immutable` and same for the other variants. I think these enums are used sparingly enough that the extra length is fine. r? `@noratrieb` or reassign
This commit is contained in:
commit
096277e989
@ -817,7 +817,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||
) {
|
||||
match captured_place.info.capture_kind {
|
||||
ty::UpvarCapture::ByRef(
|
||||
ty::BorrowKind::MutBorrow | ty::BorrowKind::UniqueImmBorrow,
|
||||
ty::BorrowKind::Mutable | ty::BorrowKind::UniqueImmutable,
|
||||
) => {
|
||||
capture_reason = format!("mutable borrow of `{upvar}`");
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||
/// Returns `true` if a closure is inferred to be an `FnMut` closure.
|
||||
fn is_closure_fn_mut(&self, fr: RegionVid) -> bool {
|
||||
if let Some(ty::ReLateParam(late_param)) = self.to_error_region(fr).as_deref()
|
||||
&& let ty::BoundRegionKind::BrEnv = late_param.bound_region
|
||||
&& let ty::BoundRegionKind::ClosureEnv = late_param.bound_region
|
||||
&& let DefiningTy::Closure(_, args) = self.regioncx.universal_regions().defining_ty
|
||||
{
|
||||
return args.as_closure().kind() == ty::ClosureKind::FnMut;
|
||||
|
@ -301,7 +301,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
|
||||
}
|
||||
|
||||
ty::ReLateParam(late_param) => match late_param.bound_region {
|
||||
ty::BoundRegionKind::BrNamed(region_def_id, name) => {
|
||||
ty::BoundRegionKind::Named(region_def_id, name) => {
|
||||
// Get the span to point to, even if we don't use the name.
|
||||
let span = tcx.hir().span_if_local(region_def_id).unwrap_or(DUMMY_SP);
|
||||
debug!(
|
||||
@ -332,7 +332,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::BoundRegionKind::BrEnv => {
|
||||
ty::BoundRegionKind::ClosureEnv => {
|
||||
let def_ty = self.regioncx.universal_regions().defining_ty;
|
||||
|
||||
let closure_kind = match def_ty {
|
||||
@ -369,7 +369,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
|
||||
})
|
||||
}
|
||||
|
||||
ty::BoundRegionKind::BrAnon => None,
|
||||
ty::BoundRegionKind::Anon => None,
|
||||
},
|
||||
|
||||
ty::ReBound(..)
|
||||
|
@ -1332,9 +1332,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
|
||||
let region_ctxt_fn = || {
|
||||
let reg_info = match br.kind {
|
||||
ty::BoundRegionKind::BrAnon => sym::anon,
|
||||
ty::BoundRegionKind::BrNamed(_, name) => name,
|
||||
ty::BoundRegionKind::BrEnv => sym::env,
|
||||
ty::BoundRegionKind::Anon => sym::anon,
|
||||
ty::BoundRegionKind::Named(_, name) => name,
|
||||
ty::BoundRegionKind::ClosureEnv => sym::env,
|
||||
};
|
||||
|
||||
RegionCtxt::LateBound(reg_info)
|
||||
|
@ -264,9 +264,9 @@ impl<'a, 'b, 'tcx> NllTypeRelating<'a, 'b, 'tcx> {
|
||||
self.type_checker.constraints.placeholder_region(self.type_checker.infcx, placeholder);
|
||||
|
||||
let reg_info = match placeholder.bound.kind {
|
||||
ty::BoundRegionKind::BrAnon => sym::anon,
|
||||
ty::BoundRegionKind::BrNamed(_, name) => name,
|
||||
ty::BoundRegionKind::BrEnv => sym::env,
|
||||
ty::BoundRegionKind::Anon => sym::anon,
|
||||
ty::BoundRegionKind::Named(_, name) => name,
|
||||
ty::BoundRegionKind::ClosureEnv => sym::env,
|
||||
};
|
||||
|
||||
if cfg!(debug_assertions) {
|
||||
|
@ -696,14 +696,13 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
||||
let closure_sig = args.as_closure().sig();
|
||||
let inputs_and_output = closure_sig.inputs_and_output();
|
||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
|
||||
inputs_and_output
|
||||
.bound_vars()
|
||||
.iter()
|
||||
.chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
|
||||
inputs_and_output.bound_vars().iter().chain(iter::once(
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv),
|
||||
)),
|
||||
);
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind: ty::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
};
|
||||
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
|
||||
let closure_ty = tcx.closure_env_ty(
|
||||
@ -751,15 +750,13 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
||||
DefiningTy::CoroutineClosure(def_id, args) => {
|
||||
assert_eq!(self.mir_def.to_def_id(), def_id);
|
||||
let closure_sig = args.as_coroutine_closure().coroutine_closure_sig();
|
||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
|
||||
closure_sig
|
||||
.bound_vars()
|
||||
.iter()
|
||||
.chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
|
||||
);
|
||||
let bound_vars =
|
||||
tcx.mk_bound_variable_kinds_from_iter(closure_sig.bound_vars().iter().chain(
|
||||
iter::once(ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv)),
|
||||
));
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind: ty::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
};
|
||||
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
|
||||
let closure_kind = args.as_coroutine_closure().kind();
|
||||
|
@ -710,7 +710,7 @@ pub fn check_tied_features(
|
||||
/// applied to the method prototype.
|
||||
fn should_inherit_track_caller(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
if let Some(impl_item) = tcx.opt_associated_item(def_id)
|
||||
&& let ty::AssocItemContainer::ImplContainer = impl_item.container
|
||||
&& let ty::AssocItemContainer::Impl = impl_item.container
|
||||
&& let Some(trait_item) = impl_item.trait_item_def_id
|
||||
{
|
||||
return tcx.codegen_fn_attrs(trait_item).flags.intersects(CodegenFnAttrFlags::TRACK_CALLER);
|
||||
|
@ -1189,8 +1189,8 @@ fn compare_self_type<'tcx>(
|
||||
|
||||
let self_string = |method: ty::AssocItem| {
|
||||
let untransformed_self_ty = match method.container {
|
||||
ty::ImplContainer => impl_trait_ref.self_ty(),
|
||||
ty::TraitContainer => tcx.types.self_param,
|
||||
ty::AssocItemContainer::Impl => impl_trait_ref.self_ty(),
|
||||
ty::AssocItemContainer::Trait => tcx.types.self_param,
|
||||
};
|
||||
let self_arg_ty = tcx.fn_sig(method.def_id).instantiate_identity().input(0);
|
||||
let param_env = ty::ParamEnv::reveal_all();
|
||||
@ -2224,10 +2224,8 @@ fn param_env_with_gat_bounds<'tcx>(
|
||||
|
||||
for impl_ty in impl_tys_to_install {
|
||||
let trait_ty = match impl_ty.container {
|
||||
ty::AssocItemContainer::TraitContainer => impl_ty,
|
||||
ty::AssocItemContainer::ImplContainer => {
|
||||
tcx.associated_item(impl_ty.trait_item_def_id.unwrap())
|
||||
}
|
||||
ty::AssocItemContainer::Trait => impl_ty,
|
||||
ty::AssocItemContainer::Impl => tcx.associated_item(impl_ty.trait_item_def_id.unwrap()),
|
||||
};
|
||||
|
||||
let mut bound_vars: smallvec::SmallVec<[ty::BoundVariableKind; 8]> =
|
||||
@ -2246,7 +2244,7 @@ fn param_env_with_gat_bounds<'tcx>(
|
||||
.into()
|
||||
}
|
||||
GenericParamDefKind::Lifetime => {
|
||||
let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name);
|
||||
let kind = ty::BoundRegionKind::Named(param.def_id, param.name);
|
||||
let bound_var = ty::BoundVariableKind::Region(kind);
|
||||
bound_vars.push(bound_var);
|
||||
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
|
@ -178,19 +178,19 @@ pub fn check_intrinsic_type(
|
||||
let name_str = intrinsic_name.as_str();
|
||||
|
||||
let bound_vars = tcx.mk_bound_variable_kinds(&[
|
||||
ty::BoundVariableKind::Region(ty::BrAnon),
|
||||
ty::BoundVariableKind::Region(ty::BrAnon),
|
||||
ty::BoundVariableKind::Region(ty::BrEnv),
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv),
|
||||
]);
|
||||
let mk_va_list_ty = |mutbl| {
|
||||
tcx.lang_items().va_list().map(|did| {
|
||||
let region = ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::ZERO,
|
||||
kind: ty::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
});
|
||||
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::from_u32(2),
|
||||
kind: ty::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
});
|
||||
let va_list_ty = tcx.type_of(did).instantiate(tcx, &[region.into()]);
|
||||
(Ty::new_ref(tcx, env_region, va_list_ty, mutbl), va_list_ty)
|
||||
@ -509,7 +509,8 @@ pub fn check_intrinsic_type(
|
||||
);
|
||||
let discriminant_def_id = assoc_items[0];
|
||||
|
||||
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon };
|
||||
let br =
|
||||
ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon };
|
||||
(
|
||||
1,
|
||||
0,
|
||||
@ -573,10 +574,14 @@ pub fn check_intrinsic_type(
|
||||
}
|
||||
|
||||
sym::raw_eq => {
|
||||
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon };
|
||||
let br =
|
||||
ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon };
|
||||
let param_ty_lhs =
|
||||
Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
|
||||
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrAnon };
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_u32(1),
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
};
|
||||
let param_ty_rhs =
|
||||
Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
|
||||
(1, 0, vec![param_ty_lhs, param_ty_rhs], tcx.types.bool)
|
||||
|
@ -1048,8 +1048,10 @@ fn check_associated_item(
|
||||
.coherent_trait(tcx.parent(item.trait_item_def_id.unwrap_or(item_id.into())))?;
|
||||
|
||||
let self_ty = match item.container {
|
||||
ty::TraitContainer => tcx.types.self_param,
|
||||
ty::ImplContainer => tcx.type_of(item.container_id(tcx)).instantiate_identity(),
|
||||
ty::AssocItemContainer::Trait => tcx.types.self_param,
|
||||
ty::AssocItemContainer::Impl => {
|
||||
tcx.type_of(item.container_id(tcx)).instantiate_identity()
|
||||
}
|
||||
};
|
||||
|
||||
match item.kind {
|
||||
@ -1072,7 +1074,7 @@ fn check_associated_item(
|
||||
check_method_receiver(wfcx, hir_sig, item, self_ty)
|
||||
}
|
||||
ty::AssocKind::Type => {
|
||||
if let ty::AssocItemContainer::TraitContainer = item.container {
|
||||
if let ty::AssocItemContainer::Trait = item.container {
|
||||
check_associated_type_bounds(wfcx, item, span)
|
||||
}
|
||||
if item.defaultness(tcx).has_value() {
|
||||
|
@ -634,7 +634,7 @@ fn get_new_lifetime_name<'tcx>(
|
||||
.collect_referenced_late_bound_regions(poly_trait_ref)
|
||||
.into_iter()
|
||||
.filter_map(|lt| {
|
||||
if let ty::BoundRegionKind::BrNamed(_, name) = lt {
|
||||
if let ty::BoundRegionKind::Named(_, name) = lt {
|
||||
Some(name.as_str().to_string())
|
||||
} else {
|
||||
None
|
||||
|
@ -322,7 +322,7 @@ fn late_arg_as_bound_arg<'tcx>(
|
||||
let name = tcx.item_name(def_id);
|
||||
match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
ty::BoundVariableKind::Region(ty::BrNamed(def_id, name))
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name))
|
||||
}
|
||||
GenericParamKind::Type { .. } => {
|
||||
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id, name))
|
||||
@ -337,7 +337,7 @@ fn late_arg_as_bound_arg<'tcx>(
|
||||
fn generic_param_def_as_bound_arg(param: &ty::GenericParamDef) -> ty::BoundVariableKind {
|
||||
match param.kind {
|
||||
ty::GenericParamDefKind::Lifetime => {
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::BrNamed(param.def_id, param.name))
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(param.def_id, param.name))
|
||||
}
|
||||
ty::GenericParamDefKind::Type { .. } => {
|
||||
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(param.def_id, param.name))
|
||||
|
@ -644,7 +644,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
ty::GenericParamDefKind::Lifetime => {
|
||||
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(num_bound_vars),
|
||||
kind: ty::BoundRegionKind::BrNamed(param.def_id, param.name),
|
||||
kind: ty::BoundRegionKind::Named(param.def_id, param.name),
|
||||
})
|
||||
.into()
|
||||
}
|
||||
@ -830,8 +830,8 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GenericParamAndBoundVarCollector<'_, 't
|
||||
}
|
||||
ty::ReBound(db, br) if db >= self.depth => {
|
||||
self.vars.insert(match br.kind {
|
||||
ty::BrNamed(def_id, name) => (def_id, name),
|
||||
ty::BrAnon | ty::BrEnv => {
|
||||
ty::BoundRegionKind::Named(def_id, name) => (def_id, name),
|
||||
ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => {
|
||||
let guar = self
|
||||
.cx
|
||||
.dcx()
|
||||
|
@ -314,7 +314,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
let name = lifetime_name(def_id);
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_u32(index),
|
||||
kind: ty::BrNamed(def_id.to_def_id(), name),
|
||||
kind: ty::BoundRegionKind::Named(def_id.to_def_id(), name),
|
||||
};
|
||||
ty::Region::new_bound(tcx, debruijn, br)
|
||||
}
|
||||
@ -332,7 +332,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
ty::Region::new_late_param(
|
||||
tcx,
|
||||
scope.to_def_id(),
|
||||
ty::BrNamed(id.to_def_id(), name),
|
||||
ty::BoundRegionKind::Named(id.to_def_id(), name),
|
||||
)
|
||||
|
||||
// (*) -- not late-bound, won't change
|
||||
@ -2449,15 +2449,17 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
) {
|
||||
for br in referenced_regions.difference(&constrained_regions) {
|
||||
let br_name = match *br {
|
||||
ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon | ty::BrEnv => {
|
||||
"an anonymous lifetime".to_string()
|
||||
}
|
||||
ty::BrNamed(_, name) => format!("lifetime `{name}`"),
|
||||
ty::BoundRegionKind::Named(_, kw::UnderscoreLifetime)
|
||||
| ty::BoundRegionKind::Anon
|
||||
| ty::BoundRegionKind::ClosureEnv => "an anonymous lifetime".to_string(),
|
||||
ty::BoundRegionKind::Named(_, name) => format!("lifetime `{name}`"),
|
||||
};
|
||||
|
||||
let mut err = generate_err(&br_name);
|
||||
|
||||
if let ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon = *br {
|
||||
if let ty::BoundRegionKind::Named(_, kw::UnderscoreLifetime)
|
||||
| ty::BoundRegionKind::Anon = *br
|
||||
{
|
||||
// The only way for an anonymous lifetime to wind up
|
||||
// in the return type but **also** be unconstrained is
|
||||
// if it only appears in "associated types" in the
|
||||
|
@ -194,21 +194,21 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>
|
||||
let panic_info_ty = tcx.type_of(panic_info_did).instantiate(tcx, &[ty::GenericArg::from(
|
||||
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::from_u32(1),
|
||||
kind: ty::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
}),
|
||||
)]);
|
||||
let panic_info_ref_ty = Ty::new_imm_ref(
|
||||
tcx,
|
||||
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::ZERO,
|
||||
kind: ty::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
}),
|
||||
panic_info_ty,
|
||||
);
|
||||
|
||||
let bounds = tcx.mk_bound_variable_kinds(&[
|
||||
ty::BoundVariableKind::Region(ty::BrAnon),
|
||||
ty::BoundVariableKind::Region(ty::BrAnon),
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
|
||||
]);
|
||||
let expected_sig = ty::Binder::bind_with_vars(
|
||||
tcx.mk_fn_sig([panic_info_ref_ty], tcx.types.never, false, fn_sig.safety, ExternAbi::Rust),
|
||||
|
@ -21,13 +21,12 @@ use rustc_middle::hir::place::ProjectionKind;
|
||||
pub use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection};
|
||||
use rustc_middle::mir::FakeReadCause;
|
||||
use rustc_middle::ty::{
|
||||
self, AdtKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt as _, adjustment,
|
||||
self, AdtKind, BorrowKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt as _, adjustment,
|
||||
};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_span::{ErrorGuaranteed, Span};
|
||||
use rustc_trait_selection::infer::InferCtxtExt;
|
||||
use tracing::{debug, trace};
|
||||
use ty::BorrowKind::ImmBorrow;
|
||||
|
||||
use crate::fn_ctxt::FnCtxt;
|
||||
|
||||
@ -63,7 +62,7 @@ pub trait Delegate<'tcx> {
|
||||
fn copy(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
|
||||
// In most cases, copying data from `x` is equivalent to doing `*&x`, so by default
|
||||
// we treat a copy of `x` as a borrow of `x`.
|
||||
self.borrow(place_with_id, diag_expr_id, ty::BorrowKind::ImmBorrow)
|
||||
self.borrow(place_with_id, diag_expr_id, ty::BorrowKind::Immutable)
|
||||
}
|
||||
|
||||
/// The path at `assignee_place` is being assigned to.
|
||||
@ -387,7 +386,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
||||
}
|
||||
|
||||
hir::ExprKind::Let(hir::LetExpr { pat, init, .. }) => {
|
||||
self.walk_local(init, pat, None, || self.borrow_expr(init, ty::ImmBorrow))?;
|
||||
self.walk_local(init, pat, None, || self.borrow_expr(init, BorrowKind::Immutable))?;
|
||||
}
|
||||
|
||||
hir::ExprKind::Match(discr, arms, _) => {
|
||||
@ -626,7 +625,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
||||
}
|
||||
|
||||
if needs_to_be_read {
|
||||
self.borrow_expr(discr, ty::ImmBorrow)?;
|
||||
self.borrow_expr(discr, BorrowKind::Immutable)?;
|
||||
} else {
|
||||
let closure_def_id = match discr_place.place.base {
|
||||
PlaceBase::Upvar(upvar_id) => Some(upvar_id.closure_expr_id),
|
||||
@ -785,8 +784,8 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
||||
// Reborrowing a Pin is like a combinations of a deref and a borrow, so we do
|
||||
// both.
|
||||
let bk = match mutbl {
|
||||
ty::Mutability::Not => ty::BorrowKind::ImmBorrow,
|
||||
ty::Mutability::Mut => ty::BorrowKind::MutBorrow,
|
||||
ty::Mutability::Not => ty::BorrowKind::Immutable,
|
||||
ty::Mutability::Mut => ty::BorrowKind::Mutable,
|
||||
};
|
||||
self.delegate.borrow_mut().borrow(&place_with_id, place_with_id.hir_id, bk);
|
||||
}
|
||||
@ -909,7 +908,11 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
||||
// binding when lowering pattern guards to ensure that the guard does not
|
||||
// modify the scrutinee.
|
||||
if has_guard {
|
||||
self.delegate.borrow_mut().borrow(place, discr_place.hir_id, ImmBorrow);
|
||||
self.delegate.borrow_mut().borrow(
|
||||
place,
|
||||
discr_place.hir_id,
|
||||
BorrowKind::Immutable,
|
||||
);
|
||||
}
|
||||
|
||||
// It is also a borrow or copy/move of the value being matched.
|
||||
|
@ -1047,7 +1047,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let container_id = assoc_item.container_id(tcx);
|
||||
debug!(?def_id, ?container, ?container_id);
|
||||
match container {
|
||||
ty::TraitContainer => {
|
||||
ty::AssocItemContainer::Trait => {
|
||||
if let Err(e) = callee::check_legal_trait_for_method_call(
|
||||
tcx,
|
||||
path_span,
|
||||
@ -1059,7 +1059,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self.set_tainted_by_errors(e);
|
||||
}
|
||||
}
|
||||
ty::ImplContainer => {
|
||||
ty::AssocItemContainer::Impl => {
|
||||
if segments.len() == 1 {
|
||||
// `<T>::assoc` will end up here, and so
|
||||
// can `T::assoc`. If this came from an
|
||||
|
@ -1796,7 +1796,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
false,
|
||||
|did| {
|
||||
let assoc_item = self.tcx.associated_item(did);
|
||||
assoc_item.container == ty::AssocItemContainer::TraitContainer
|
||||
assoc_item.container == ty::AssocItemContainer::Trait
|
||||
&& assoc_item.container_id(self.tcx) == clone_trait_did
|
||||
},
|
||||
)
|
||||
|
@ -239,7 +239,7 @@ fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Opti
|
||||
let expected_type = if let Some(&hir::Ty { kind: hir::TyKind::Infer, span, .. }) = node.ty() {
|
||||
if let Some(item) = tcx.opt_associated_item(def_id.into())
|
||||
&& let ty::AssocKind::Const = item.kind
|
||||
&& let ty::ImplContainer = item.container
|
||||
&& let ty::AssocItemContainer::Impl = item.container
|
||||
&& let Some(trait_item_def_id) = item.trait_item_def_id
|
||||
{
|
||||
let impl_def_id = item.container_id(tcx);
|
||||
|
@ -480,7 +480,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
ProbeScope::Single(def_id) => {
|
||||
let item = self.tcx.associated_item(def_id);
|
||||
// FIXME(fn_delegation): Delegation to inherent methods is not yet supported.
|
||||
assert_eq!(item.container, AssocItemContainer::TraitContainer);
|
||||
assert_eq!(item.container, AssocItemContainer::Trait);
|
||||
|
||||
let trait_def_id = self.tcx.parent(def_id);
|
||||
let trait_span = self.tcx.def_span(trait_def_id);
|
||||
@ -1406,7 +1406,7 @@ impl<'tcx> Pick<'tcx> {
|
||||
tcx.def_path_str(self.item.def_id),
|
||||
));
|
||||
}
|
||||
(ty::AssocKind::Const, ty::AssocItemContainer::TraitContainer) => {
|
||||
(ty::AssocKind::Const, ty::AssocItemContainer::Trait) => {
|
||||
let def_id = self.item.container_id(tcx);
|
||||
lint.span_suggestion(
|
||||
span,
|
||||
|
@ -44,8 +44,8 @@ use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection, Pro
|
||||
use rustc_middle::mir::FakeReadCause;
|
||||
use rustc_middle::traits::ObligationCauseCode;
|
||||
use rustc_middle::ty::{
|
||||
self, ClosureSizeProfileData, Ty, TyCtxt, TypeVisitableExt as _, TypeckResults, UpvarArgs,
|
||||
UpvarCapture,
|
||||
self, BorrowKind, ClosureSizeProfileData, Ty, TyCtxt, TypeVisitableExt as _, TypeckResults,
|
||||
UpvarArgs, UpvarCapture,
|
||||
};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_session::lint;
|
||||
@ -381,7 +381,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let closure_env_region: ty::Region<'_> =
|
||||
ty::Region::new_bound(self.tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::ZERO,
|
||||
kind: ty::BoundRegionKind::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
});
|
||||
|
||||
let num_args = args
|
||||
@ -441,7 +441,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
rustc_abi::ExternAbi::Rust,
|
||||
),
|
||||
self.tcx.mk_bound_variable_kinds(&[ty::BoundVariableKind::Region(
|
||||
ty::BoundRegionKind::BrEnv,
|
||||
ty::BoundRegionKind::ClosureEnv,
|
||||
)]),
|
||||
),
|
||||
);
|
||||
@ -646,7 +646,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
},
|
||||
|
||||
ty::UpvarCapture::ByRef(
|
||||
ty::BorrowKind::MutBorrow | ty::BorrowKind::UniqueImmBorrow,
|
||||
ty::BorrowKind::Mutable | ty::BorrowKind::UniqueImmutable,
|
||||
) => {
|
||||
match closure_kind {
|
||||
ty::ClosureKind::Fn => {
|
||||
@ -1681,7 +1681,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
ty::UpvarCapture::ByValue
|
||||
}
|
||||
hir::CaptureBy::Value { .. } | hir::CaptureBy::Ref => {
|
||||
ty::UpvarCapture::ByRef(ty::ImmBorrow)
|
||||
ty::UpvarCapture::ByRef(BorrowKind::Immutable)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1869,7 +1869,7 @@ fn should_reborrow_from_env_of_parent_coroutine_closure<'tcx>(
|
||||
Some(Projection { kind: ProjectionKind::Deref, .. })
|
||||
))
|
||||
// (2.)
|
||||
|| matches!(child_capture.info.capture_kind, UpvarCapture::ByRef(ty::BorrowKind::MutBorrow))
|
||||
|| matches!(child_capture.info.capture_kind, UpvarCapture::ByRef(ty::BorrowKind::Mutable))
|
||||
}
|
||||
|
||||
/// Truncate the capture so that the place being borrowed is in accordance with RFC 1240,
|
||||
@ -1984,7 +1984,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
|
||||
|
||||
// We need to restrict Fake Read precision to avoid fake reading unsafe code,
|
||||
// such as deref of a raw pointer.
|
||||
let dummy_capture_kind = ty::UpvarCapture::ByRef(ty::BorrowKind::ImmBorrow);
|
||||
let dummy_capture_kind = ty::UpvarCapture::ByRef(ty::BorrowKind::Immutable);
|
||||
|
||||
let (place, _) = restrict_capture_precision(place.place.clone(), dummy_capture_kind);
|
||||
|
||||
@ -2025,7 +2025,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
|
||||
|
||||
// Raw pointers don't inherit mutability
|
||||
if place_with_id.place.deref_tys().any(Ty::is_unsafe_ptr) {
|
||||
capture_kind = ty::UpvarCapture::ByRef(ty::BorrowKind::ImmBorrow);
|
||||
capture_kind = ty::UpvarCapture::ByRef(ty::BorrowKind::Immutable);
|
||||
}
|
||||
|
||||
self.capture_information.push((place, ty::CaptureInfo {
|
||||
@ -2037,7 +2037,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
|
||||
self.borrow(assignee_place, diag_expr_id, ty::BorrowKind::MutBorrow);
|
||||
self.borrow(assignee_place, diag_expr_id, ty::BorrowKind::Mutable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2331,16 +2331,16 @@ fn determine_capture_info(
|
||||
(ty::UpvarCapture::ByRef(ref_a), ty::UpvarCapture::ByRef(ref_b)) => {
|
||||
match (ref_a, ref_b) {
|
||||
// Take LHS:
|
||||
(ty::UniqueImmBorrow | ty::MutBorrow, ty::ImmBorrow)
|
||||
| (ty::MutBorrow, ty::UniqueImmBorrow) => capture_info_a,
|
||||
(BorrowKind::UniqueImmutable | BorrowKind::Mutable, BorrowKind::Immutable)
|
||||
| (BorrowKind::Mutable, BorrowKind::UniqueImmutable) => capture_info_a,
|
||||
|
||||
// Take RHS:
|
||||
(ty::ImmBorrow, ty::UniqueImmBorrow | ty::MutBorrow)
|
||||
| (ty::UniqueImmBorrow, ty::MutBorrow) => capture_info_b,
|
||||
(BorrowKind::Immutable, BorrowKind::UniqueImmutable | BorrowKind::Mutable)
|
||||
| (BorrowKind::UniqueImmutable, BorrowKind::Mutable) => capture_info_b,
|
||||
|
||||
(ty::ImmBorrow, ty::ImmBorrow)
|
||||
| (ty::UniqueImmBorrow, ty::UniqueImmBorrow)
|
||||
| (ty::MutBorrow, ty::MutBorrow) => {
|
||||
(BorrowKind::Immutable, BorrowKind::Immutable)
|
||||
| (BorrowKind::UniqueImmutable, BorrowKind::UniqueImmutable)
|
||||
| (BorrowKind::Mutable, BorrowKind::Mutable) => {
|
||||
bug!("Expected unequal capture kinds");
|
||||
}
|
||||
}
|
||||
@ -2367,12 +2367,12 @@ fn truncate_place_to_len_and_update_capture_kind<'tcx>(
|
||||
// Note that if the place contained Deref of a raw pointer it would've not been MutBorrow, so
|
||||
// we don't need to worry about that case here.
|
||||
match curr_mode {
|
||||
ty::UpvarCapture::ByRef(ty::BorrowKind::MutBorrow) => {
|
||||
ty::UpvarCapture::ByRef(ty::BorrowKind::Mutable) => {
|
||||
for i in len..place.projections.len() {
|
||||
if place.projections[i].kind == ProjectionKind::Deref
|
||||
&& is_mut_ref(place.ty_before_projection(i))
|
||||
{
|
||||
*curr_mode = ty::UpvarCapture::ByRef(ty::BorrowKind::UniqueImmBorrow);
|
||||
*curr_mode = ty::UpvarCapture::ByRef(ty::BorrowKind::UniqueImmutable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -753,7 +753,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
||||
r: ty::Region<'tcx>,
|
||||
) -> ty::Region<'tcx> {
|
||||
let var = self.canonical_var(info, r.into());
|
||||
let br = ty::BoundRegion { var, kind: ty::BrAnon };
|
||||
let br = ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon };
|
||||
ty::Region::new_bound(self.cx(), self.binder_index, br)
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ fn check_fn(tcx: TyCtxt<'_>, parent_def_id: LocalDefId) {
|
||||
}
|
||||
|
||||
for bound_var in sig.bound_vars() {
|
||||
let ty::BoundVariableKind::Region(ty::BoundRegionKind::BrNamed(def_id, name)) = bound_var
|
||||
let ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name)) = bound_var
|
||||
else {
|
||||
span_bug!(tcx.def_span(parent_def_id), "unexpected non-lifetime binder on fn sig");
|
||||
};
|
||||
@ -215,7 +215,7 @@ where
|
||||
for arg in t.bound_vars() {
|
||||
let arg: ty::BoundVariableKind = arg;
|
||||
match arg {
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::BrNamed(def_id, ..))
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, ..))
|
||||
| ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id, _)) => {
|
||||
added.push(def_id);
|
||||
let unique = self.in_scope_parameters.insert(def_id, ParamKind::Late);
|
||||
@ -318,7 +318,7 @@ where
|
||||
ParamKind::Free(def_id, name) => ty::Region::new_late_param(
|
||||
self.tcx,
|
||||
self.parent_def_id.to_def_id(),
|
||||
ty::BoundRegionKind::BrNamed(def_id, name),
|
||||
ty::BoundRegionKind::Named(def_id, name),
|
||||
),
|
||||
// Totally ignore late bound args from binders.
|
||||
ParamKind::Late => return true,
|
||||
@ -489,11 +489,11 @@ fn extract_def_id_from_arg<'tcx>(
|
||||
ty::ReEarlyParam(ebr) => generics.region_param(ebr, tcx).def_id,
|
||||
ty::ReBound(
|
||||
_,
|
||||
ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, ..), .. },
|
||||
ty::BoundRegion { kind: ty::BoundRegionKind::Named(def_id, ..), .. },
|
||||
)
|
||||
| ty::ReLateParam(ty::LateParamRegion {
|
||||
scope: _,
|
||||
bound_region: ty::BoundRegionKind::BrNamed(def_id, ..),
|
||||
bound_region: ty::BoundRegionKind::Named(def_id, ..),
|
||||
}) => def_id,
|
||||
_ => unreachable!(),
|
||||
},
|
||||
@ -558,11 +558,11 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for FunctionalVariances<'tcx> {
|
||||
ty::ReEarlyParam(ebr) => self.generics.region_param(ebr, self.tcx).def_id,
|
||||
ty::ReBound(
|
||||
_,
|
||||
ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, ..), .. },
|
||||
ty::BoundRegion { kind: ty::BoundRegionKind::Named(def_id, ..), .. },
|
||||
)
|
||||
| ty::ReLateParam(ty::LateParamRegion {
|
||||
scope: _,
|
||||
bound_region: ty::BoundRegionKind::BrNamed(def_id, ..),
|
||||
bound_region: ty::BoundRegionKind::Named(def_id, ..),
|
||||
}) => def_id,
|
||||
_ => {
|
||||
return Ok(a);
|
||||
|
@ -26,8 +26,8 @@ pub(crate) enum MethodLateContext {
|
||||
pub(crate) fn method_context(cx: &LateContext<'_>, id: LocalDefId) -> MethodLateContext {
|
||||
let item = cx.tcx.associated_item(id);
|
||||
match item.container {
|
||||
ty::TraitContainer => MethodLateContext::TraitAutoImpl,
|
||||
ty::ImplContainer => match cx.tcx.impl_trait_ref(item.container_id(cx.tcx)) {
|
||||
ty::AssocItemContainer::Trait => MethodLateContext::TraitAutoImpl,
|
||||
ty::AssocItemContainer::Impl => match cx.tcx.impl_trait_ref(item.container_id(cx.tcx)) {
|
||||
Some(_) => MethodLateContext::TraitImpl,
|
||||
None => MethodLateContext::PlainImpl,
|
||||
},
|
||||
|
@ -1203,8 +1203,8 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
|
||||
DefKind::AssocTy => {
|
||||
let assoc_item = tcx.associated_item(def_id);
|
||||
match assoc_item.container {
|
||||
ty::AssocItemContainer::ImplContainer => true,
|
||||
ty::AssocItemContainer::TraitContainer => assoc_item.defaultness(tcx).has_value(),
|
||||
ty::AssocItemContainer::Impl => true,
|
||||
ty::AssocItemContainer::Trait => assoc_item.defaultness(tcx).has_value(),
|
||||
}
|
||||
}
|
||||
DefKind::TyParam => {
|
||||
@ -1336,7 +1336,7 @@ fn should_encode_const(def_kind: DefKind) -> bool {
|
||||
|
||||
fn should_encode_fn_impl_trait_in_trait<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
|
||||
if let Some(assoc_item) = tcx.opt_associated_item(def_id)
|
||||
&& assoc_item.container == ty::AssocItemContainer::TraitContainer
|
||||
&& assoc_item.container == ty::AssocItemContainer::Trait
|
||||
&& assoc_item.kind == ty::AssocKind::Fn
|
||||
{
|
||||
true
|
||||
@ -1649,7 +1649,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
self.tables.assoc_container.set_some(def_id.index, item.container);
|
||||
|
||||
match item.container {
|
||||
AssocItemContainer::TraitContainer => {
|
||||
AssocItemContainer::Trait => {
|
||||
if let ty::AssocKind::Type = item.kind {
|
||||
self.encode_explicit_item_bounds(def_id);
|
||||
self.encode_explicit_item_super_predicates(def_id);
|
||||
@ -1659,7 +1659,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
AssocItemContainer::ImplContainer => {
|
||||
AssocItemContainer::Impl => {
|
||||
if let Some(trait_item_def_id) = item.trait_item_def_id {
|
||||
self.tables.trait_item_def_id.set_some(def_id.index, trait_item_def_id.into());
|
||||
}
|
||||
|
@ -223,8 +223,8 @@ fixed_size_enum! {
|
||||
|
||||
fixed_size_enum! {
|
||||
ty::AssocItemContainer {
|
||||
( TraitContainer )
|
||||
( ImplContainer )
|
||||
( Trait )
|
||||
( Impl )
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,10 @@ impl<'tcx> ClosureOutlivesSubjectTy<'tcx> {
|
||||
pub fn bind(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Self {
|
||||
let inner = tcx.fold_regions(ty, |r, depth| match r.kind() {
|
||||
ty::ReVar(vid) => {
|
||||
let br = ty::BoundRegion { var: ty::BoundVar::new(vid.index()), kind: ty::BrAnon };
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::new(vid.index()),
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
};
|
||||
ty::Region::new_bound(tcx, depth, br)
|
||||
}
|
||||
_ => bug!("unexpected region in ClosureOutlivesSubjectTy: {r:?}"),
|
||||
|
@ -10,8 +10,8 @@ use crate::ty;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable, Hash, Encodable, Decodable)]
|
||||
pub enum AssocItemContainer {
|
||||
TraitContainer,
|
||||
ImplContainer,
|
||||
Trait,
|
||||
Impl,
|
||||
}
|
||||
|
||||
/// Information about an associated item
|
||||
@ -63,16 +63,16 @@ impl AssocItem {
|
||||
#[inline]
|
||||
pub fn trait_container(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
|
||||
match self.container {
|
||||
AssocItemContainer::ImplContainer => None,
|
||||
AssocItemContainer::TraitContainer => Some(tcx.parent(self.def_id)),
|
||||
AssocItemContainer::Impl => None,
|
||||
AssocItemContainer::Trait => Some(tcx.parent(self.def_id)),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn impl_container(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
|
||||
match self.container {
|
||||
AssocItemContainer::ImplContainer => Some(tcx.parent(self.def_id)),
|
||||
AssocItemContainer::TraitContainer => None,
|
||||
AssocItemContainer::Impl => Some(tcx.parent(self.def_id)),
|
||||
AssocItemContainer::Trait => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ use rustc_span::def_id::LocalDefIdMap;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::{Span, Symbol};
|
||||
|
||||
use self::BorrowKind::*;
|
||||
use super::TyCtxt;
|
||||
use crate::hir::place::{
|
||||
Place as HirPlace, PlaceBase as HirPlaceBase, ProjectionKind as HirProjectionKind,
|
||||
@ -334,7 +333,7 @@ pub fn place_to_string_for_capture<'tcx>(tcx: TyCtxt<'tcx>, place: &HirPlace<'tc
|
||||
#[derive(TypeFoldable, TypeVisitable)]
|
||||
pub enum BorrowKind {
|
||||
/// Data must be immutable and is aliasable.
|
||||
ImmBorrow,
|
||||
Immutable,
|
||||
|
||||
/// Data must be immutable but not aliasable. This kind of borrow
|
||||
/// cannot currently be expressed by the user and is used only in
|
||||
@ -382,17 +381,17 @@ pub enum BorrowKind {
|
||||
/// borrow, it's just used when translating closures.
|
||||
///
|
||||
/// FIXME: Rename this to indicate the borrow is actually not immutable.
|
||||
UniqueImmBorrow,
|
||||
UniqueImmutable,
|
||||
|
||||
/// Data is mutable and not aliasable.
|
||||
MutBorrow,
|
||||
Mutable,
|
||||
}
|
||||
|
||||
impl BorrowKind {
|
||||
pub fn from_mutbl(m: hir::Mutability) -> BorrowKind {
|
||||
match m {
|
||||
hir::Mutability::Mut => MutBorrow,
|
||||
hir::Mutability::Not => ImmBorrow,
|
||||
hir::Mutability::Mut => BorrowKind::Mutable,
|
||||
hir::Mutability::Not => BorrowKind::Immutable,
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,13 +401,13 @@ impl BorrowKind {
|
||||
/// question.
|
||||
pub fn to_mutbl_lossy(self) -> hir::Mutability {
|
||||
match self {
|
||||
MutBorrow => hir::Mutability::Mut,
|
||||
ImmBorrow => hir::Mutability::Not,
|
||||
BorrowKind::Mutable => hir::Mutability::Mut,
|
||||
BorrowKind::Immutable => hir::Mutability::Not,
|
||||
|
||||
// We have no type corresponding to a unique imm borrow, so
|
||||
// use `&mut`. It gives all the capabilities of a `&uniq`
|
||||
// and hence is a safe "over approximation".
|
||||
UniqueImmBorrow => hir::Mutability::Mut,
|
||||
BorrowKind::UniqueImmutable => hir::Mutability::Mut,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1059,7 +1059,7 @@ impl<'tcx> CommonLifetimes<'tcx> {
|
||||
.map(|v| {
|
||||
mk(ty::ReBound(ty::DebruijnIndex::from(i), ty::BoundRegion {
|
||||
var: ty::BoundVar::from(v),
|
||||
kind: ty::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
}))
|
||||
})
|
||||
.collect()
|
||||
@ -1982,7 +1982,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
region = self.map_opaque_lifetime_to_parent_lifetime(def_id);
|
||||
continue;
|
||||
}
|
||||
break (scope, ty::BrNamed(def_id.into(), self.item_name(def_id.into())));
|
||||
break (
|
||||
scope,
|
||||
ty::BoundRegionKind::Named(def_id.into(), self.item_name(def_id.into())),
|
||||
);
|
||||
};
|
||||
|
||||
let is_impl_item = match self.hir_node_by_def_id(suitable_region_binding_scope) {
|
||||
@ -3091,7 +3094,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
return ty::Region::new_late_param(
|
||||
self,
|
||||
new_parent.to_def_id(),
|
||||
ty::BoundRegionKind::BrNamed(
|
||||
ty::BoundRegionKind::Named(
|
||||
lbv.to_def_id(),
|
||||
self.item_name(lbv.to_def_id()),
|
||||
),
|
||||
|
@ -399,7 +399,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
let index = entry.index();
|
||||
let var = ty::BoundVar::from_usize(index);
|
||||
let kind = entry
|
||||
.or_insert_with(|| ty::BoundVariableKind::Region(ty::BrAnon))
|
||||
.or_insert_with(|| ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon))
|
||||
.expect_region();
|
||||
let br = ty::BoundRegion { var, kind };
|
||||
ty::Region::new_bound(self.tcx, ty::INNERMOST, br)
|
||||
|
@ -690,7 +690,7 @@ impl<'tcx> Instance<'tcx> {
|
||||
&& !matches!(
|
||||
tcx.opt_associated_item(def),
|
||||
Some(ty::AssocItem {
|
||||
container: ty::AssocItemContainer::TraitContainer,
|
||||
container: ty::AssocItemContainer::Trait,
|
||||
..
|
||||
})
|
||||
)
|
||||
|
@ -49,19 +49,12 @@ pub use rustc_session::lint::RegisteredTools;
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::symbol::{Ident, Symbol, kw, sym};
|
||||
use rustc_span::{ExpnId, ExpnKind, Span};
|
||||
pub use rustc_type_ir::ConstKind::{
|
||||
Bound as BoundCt, Error as ErrorCt, Expr as ExprCt, Infer as InferCt, Param as ParamCt,
|
||||
Placeholder as PlaceholderCt, Unevaluated, Value,
|
||||
};
|
||||
pub use rustc_type_ir::relate::VarianceDiagInfo;
|
||||
pub use rustc_type_ir::*;
|
||||
use tracing::{debug, instrument};
|
||||
pub use vtable::*;
|
||||
use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
|
||||
|
||||
pub use self::AssocItemContainer::*;
|
||||
pub use self::BorrowKind::*;
|
||||
pub use self::IntVarValue::*;
|
||||
pub use self::closure::{
|
||||
BorrowKind, CAPTURE_STRUCT_LOCAL, CaptureInfo, CapturedPlace, ClosureTypeInfo,
|
||||
MinCaptureInformationMap, MinCaptureList, RootVariableMinCaptureList, UpvarCapture, UpvarId,
|
||||
@ -91,7 +84,6 @@ pub use self::predicate::{
|
||||
RegionOutlivesPredicate, SubtypePredicate, ToPolyTraitRef, TraitPredicate, TraitRef,
|
||||
TypeOutlivesPredicate,
|
||||
};
|
||||
pub use self::region::BoundRegionKind::*;
|
||||
pub use self::region::{
|
||||
BoundRegion, BoundRegionKind, EarlyParamRegion, LateParamRegion, Region, RegionKind, RegionVid,
|
||||
};
|
||||
@ -902,7 +894,7 @@ impl rustc_type_ir::inherent::PlaceholderLike for PlaceholderRegion {
|
||||
}
|
||||
|
||||
fn new(ui: UniverseIndex, var: BoundVar) -> Self {
|
||||
Placeholder { universe: ui, bound: BoundRegion { var, kind: BoundRegionKind::BrAnon } }
|
||||
Placeholder { universe: ui, bound: BoundRegion { var, kind: BoundRegionKind::Anon } }
|
||||
}
|
||||
}
|
||||
|
||||
@ -2078,7 +2070,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
let Some(item) = self.opt_associated_item(def_id) else {
|
||||
return false;
|
||||
};
|
||||
if item.container != ty::AssocItemContainer::ImplContainer {
|
||||
if item.container != ty::AssocItemContainer::Impl {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2483,7 +2483,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||
| ty::RePlaceholder(ty::Placeholder {
|
||||
bound: ty::BoundRegion { kind: br, .. }, ..
|
||||
}) => {
|
||||
if let ty::BrNamed(_, name) = br
|
||||
if let ty::BoundRegionKind::Named(_, name) = br
|
||||
&& br.is_named()
|
||||
{
|
||||
p!(write("{}", name));
|
||||
@ -2569,7 +2569,7 @@ impl<'a, 'tcx> ty::TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> {
|
||||
// If this is an anonymous placeholder, don't rename. Otherwise, in some
|
||||
// async fns, we get a `for<'r> Send` bound
|
||||
match kind {
|
||||
ty::BrAnon | ty::BrEnv => r,
|
||||
ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => r,
|
||||
_ => {
|
||||
// Index doesn't matter, since this is just for naming and these never get bound
|
||||
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind };
|
||||
@ -2688,12 +2688,13 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||
binder_level_idx: ty::DebruijnIndex,
|
||||
br: ty::BoundRegion| {
|
||||
let (name, kind) = match br.kind {
|
||||
ty::BrAnon | ty::BrEnv => {
|
||||
ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => {
|
||||
let name = next_name(self);
|
||||
|
||||
if let Some(lt_idx) = lifetime_idx {
|
||||
if lt_idx > binder_level_idx {
|
||||
let kind = ty::BrNamed(CRATE_DEF_ID.to_def_id(), name);
|
||||
let kind =
|
||||
ty::BoundRegionKind::Named(CRATE_DEF_ID.to_def_id(), name);
|
||||
return ty::Region::new_bound(
|
||||
tcx,
|
||||
ty::INNERMOST,
|
||||
@ -2702,14 +2703,14 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
(name, ty::BrNamed(CRATE_DEF_ID.to_def_id(), name))
|
||||
(name, ty::BoundRegionKind::Named(CRATE_DEF_ID.to_def_id(), name))
|
||||
}
|
||||
ty::BrNamed(def_id, kw::UnderscoreLifetime | kw::Empty) => {
|
||||
ty::BoundRegionKind::Named(def_id, kw::UnderscoreLifetime | kw::Empty) => {
|
||||
let name = next_name(self);
|
||||
|
||||
if let Some(lt_idx) = lifetime_idx {
|
||||
if lt_idx > binder_level_idx {
|
||||
let kind = ty::BrNamed(def_id, name);
|
||||
let kind = ty::BoundRegionKind::Named(def_id, name);
|
||||
return ty::Region::new_bound(
|
||||
tcx,
|
||||
ty::INNERMOST,
|
||||
@ -2718,9 +2719,9 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
(name, ty::BrNamed(def_id, name))
|
||||
(name, ty::BoundRegionKind::Named(def_id, name))
|
||||
}
|
||||
ty::BrNamed(_, name) => {
|
||||
ty::BoundRegionKind::Named(_, name) => {
|
||||
if let Some(lt_idx) = lifetime_idx {
|
||||
if lt_idx > binder_level_idx {
|
||||
let kind = br.kind;
|
||||
|
@ -56,7 +56,7 @@ impl<'tcx> Region<'tcx> {
|
||||
bound_region: ty::BoundRegion,
|
||||
) -> Region<'tcx> {
|
||||
// Use a pre-interned one when possible.
|
||||
if let ty::BoundRegion { var, kind: ty::BrAnon } = bound_region
|
||||
if let ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon } = bound_region
|
||||
&& let Some(inner) = tcx.lifetimes.re_late_bounds.get(debruijn.as_usize())
|
||||
&& let Some(re) = inner.get(var.as_usize()).copied()
|
||||
{
|
||||
@ -147,7 +147,7 @@ impl<'tcx> rustc_type_ir::inherent::Region<TyCtxt<'tcx>> for Region<'tcx> {
|
||||
}
|
||||
|
||||
fn new_anon_bound(tcx: TyCtxt<'tcx>, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self {
|
||||
Region::new_bound(tcx, debruijn, ty::BoundRegion { var, kind: ty::BoundRegionKind::BrAnon })
|
||||
Region::new_bound(tcx, debruijn, ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon })
|
||||
}
|
||||
|
||||
fn new_static(tcx: TyCtxt<'tcx>) -> Self {
|
||||
@ -311,7 +311,7 @@ impl<'tcx> Region<'tcx> {
|
||||
Some(tcx.generics_of(binding_item).region_param(ebr, tcx).def_id)
|
||||
}
|
||||
ty::ReLateParam(ty::LateParamRegion {
|
||||
bound_region: ty::BoundRegionKind::BrNamed(def_id, _),
|
||||
bound_region: ty::BoundRegionKind::Named(def_id, _),
|
||||
..
|
||||
}) => Some(def_id),
|
||||
_ => None,
|
||||
@ -355,7 +355,7 @@ impl std::fmt::Debug for EarlyParamRegion {
|
||||
/// Similar to a placeholder region as we create `LateParam` regions when entering a binder
|
||||
/// except they are always in the root universe and instead of using a boundvar to distinguish
|
||||
/// between others we use the `DefId` of the parameter. For this reason the `bound_region` field
|
||||
/// should basically always be `BoundRegionKind::BrNamed` as otherwise there is no way of telling
|
||||
/// should basically always be `BoundRegionKind::Named` as otherwise there is no way of telling
|
||||
/// different parameters apart.
|
||||
pub struct LateParamRegion {
|
||||
pub scope: DefId,
|
||||
@ -366,17 +366,17 @@ pub struct LateParamRegion {
|
||||
#[derive(HashStable)]
|
||||
pub enum BoundRegionKind {
|
||||
/// An anonymous region parameter for a given fn (&T)
|
||||
BrAnon,
|
||||
Anon,
|
||||
|
||||
/// Named region parameters for functions (a in &'a T)
|
||||
///
|
||||
/// The `DefId` is needed to distinguish free regions in
|
||||
/// the event of shadowing.
|
||||
BrNamed(DefId, Symbol),
|
||||
Named(DefId, Symbol),
|
||||
|
||||
/// Anonymous region for the implicit env pointer parameter
|
||||
/// to a closure
|
||||
BrEnv,
|
||||
ClosureEnv,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
|
||||
@ -399,9 +399,9 @@ impl<'tcx> rustc_type_ir::inherent::BoundVarLike<TyCtxt<'tcx>> for BoundRegion {
|
||||
impl core::fmt::Debug for BoundRegion {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self.kind {
|
||||
BoundRegionKind::BrAnon => write!(f, "{:?}", self.var),
|
||||
BoundRegionKind::BrEnv => write!(f, "{:?}.Env", self.var),
|
||||
BoundRegionKind::BrNamed(def, symbol) => {
|
||||
BoundRegionKind::Anon => write!(f, "{:?}", self.var),
|
||||
BoundRegionKind::ClosureEnv => write!(f, "{:?}.Env", self.var),
|
||||
BoundRegionKind::Named(def, symbol) => {
|
||||
write!(f, "{:?}.Named({:?}, {:?})", self.var, def, symbol)
|
||||
}
|
||||
}
|
||||
@ -411,9 +411,7 @@ impl core::fmt::Debug for BoundRegion {
|
||||
impl BoundRegionKind {
|
||||
pub fn is_named(&self) -> bool {
|
||||
match *self {
|
||||
BoundRegionKind::BrNamed(_, name) => {
|
||||
name != kw::UnderscoreLifetime && name != kw::Empty
|
||||
}
|
||||
BoundRegionKind::Named(_, name) => name != kw::UnderscoreLifetime && name != kw::Empty,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -421,7 +419,7 @@ impl BoundRegionKind {
|
||||
pub fn get_name(&self) -> Option<Symbol> {
|
||||
if self.is_named() {
|
||||
match *self {
|
||||
BoundRegionKind::BrNamed(_, name) => return Some(name),
|
||||
BoundRegionKind::Named(_, name) => return Some(name),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@ -431,7 +429,7 @@ impl BoundRegionKind {
|
||||
|
||||
pub fn get_id(&self) -> Option<DefId> {
|
||||
match *self {
|
||||
BoundRegionKind::BrNamed(id, _) => Some(id),
|
||||
BoundRegionKind::Named(id, _) => Some(id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -62,15 +62,15 @@ impl<'tcx> fmt::Debug for ty::adjustment::Adjustment<'tcx> {
|
||||
impl fmt::Debug for ty::BoundRegionKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
ty::BrAnon => write!(f, "BrAnon"),
|
||||
ty::BrNamed(did, name) => {
|
||||
ty::BoundRegionKind::Anon => write!(f, "BrAnon"),
|
||||
ty::BoundRegionKind::Named(did, name) => {
|
||||
if did.is_crate_root() {
|
||||
write!(f, "BrNamed({name})")
|
||||
} else {
|
||||
write!(f, "BrNamed({did:?}, {name})")
|
||||
}
|
||||
}
|
||||
ty::BrEnv => write!(f, "BrEnv"),
|
||||
ty::BoundRegionKind::ClosureEnv => write!(f, "BrEnv"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -735,8 +735,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
let ty = self.fold_regions(decl.ty, |re, debruijn| {
|
||||
assert_eq!(re, self.lifetimes.re_erased);
|
||||
let var = ty::BoundVar::from_usize(vars.len());
|
||||
vars.push(ty::BoundVariableKind::Region(ty::BrAnon));
|
||||
ty::Region::new_bound(self, debruijn, ty::BoundRegion { var, kind: ty::BrAnon })
|
||||
vars.push(ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon));
|
||||
ty::Region::new_bound(self, debruijn, ty::BoundRegion {
|
||||
var,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
})
|
||||
});
|
||||
ty::EarlyBinder::bind(ty::Binder::bind_with_vars(
|
||||
ty,
|
||||
|
@ -72,8 +72,8 @@ pub fn call_kind<'tcx>(
|
||||
let parent = tcx.opt_associated_item(method_did).and_then(|assoc| {
|
||||
let container_id = assoc.container_id(tcx);
|
||||
match assoc.container {
|
||||
AssocItemContainer::ImplContainer => tcx.trait_id_of_impl(container_id),
|
||||
AssocItemContainer::TraitContainer => Some(container_id),
|
||||
AssocItemContainer::Impl => tcx.trait_id_of_impl(container_id),
|
||||
AssocItemContainer::Trait => Some(container_id),
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1193,11 +1193,11 @@ impl<'tcx> Cx<'tcx> {
|
||||
ty::UpvarCapture::ByValue => captured_place_expr,
|
||||
ty::UpvarCapture::ByRef(upvar_borrow) => {
|
||||
let borrow_kind = match upvar_borrow {
|
||||
ty::BorrowKind::ImmBorrow => BorrowKind::Shared,
|
||||
ty::BorrowKind::UniqueImmBorrow => {
|
||||
ty::BorrowKind::Immutable => BorrowKind::Shared,
|
||||
ty::BorrowKind::UniqueImmutable => {
|
||||
BorrowKind::Mut { kind: mir::MutBorrowKind::ClosureCapture }
|
||||
}
|
||||
ty::BorrowKind::MutBorrow => {
|
||||
ty::BorrowKind::Mutable => {
|
||||
BorrowKind::Mut { kind: mir::MutBorrowKind::Default }
|
||||
}
|
||||
};
|
||||
|
@ -335,12 +335,12 @@ impl RustcInternal for BoundVariableKind {
|
||||
),
|
||||
}),
|
||||
BoundVariableKind::Region(kind) => rustc_ty::BoundVariableKind::Region(match kind {
|
||||
BoundRegionKind::BrAnon => rustc_ty::BoundRegionKind::BrAnon,
|
||||
BoundRegionKind::BrNamed(def, symbol) => rustc_ty::BoundRegionKind::BrNamed(
|
||||
BoundRegionKind::BrAnon => rustc_ty::BoundRegionKind::Anon,
|
||||
BoundRegionKind::BrNamed(def, symbol) => rustc_ty::BoundRegionKind::Named(
|
||||
def.0.internal(tables, tcx),
|
||||
Symbol::intern(symbol),
|
||||
),
|
||||
BoundRegionKind::BrEnv => rustc_ty::BoundRegionKind::BrEnv,
|
||||
BoundRegionKind::BrEnv => rustc_ty::BoundRegionKind::ClosureEnv,
|
||||
}),
|
||||
BoundVariableKind::Const => rustc_ty::BoundVariableKind::Const,
|
||||
}
|
||||
|
@ -243,11 +243,11 @@ impl<'tcx> Stable<'tcx> for ty::BoundRegionKind {
|
||||
use stable_mir::ty::BoundRegionKind;
|
||||
|
||||
match self {
|
||||
ty::BoundRegionKind::BrAnon => BoundRegionKind::BrAnon,
|
||||
ty::BoundRegionKind::BrNamed(def_id, symbol) => {
|
||||
ty::BoundRegionKind::Anon => BoundRegionKind::BrAnon,
|
||||
ty::BoundRegionKind::Named(def_id, symbol) => {
|
||||
BoundRegionKind::BrNamed(tables.br_named_def(*def_id), symbol.to_string())
|
||||
}
|
||||
ty::BoundRegionKind::BrEnv => BoundRegionKind::BrEnv,
|
||||
ty::BoundRegionKind::ClosureEnv => BoundRegionKind::BrEnv,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -418,7 +418,7 @@ pub(crate) fn mir_const_from_ty_const<'tcx>(
|
||||
ty: Ty<'tcx>,
|
||||
) -> stable_mir::ty::MirConst {
|
||||
let kind = match ty_const.kind() {
|
||||
ty::Value(ty, val) => {
|
||||
ty::ConstKind::Value(ty, val) => {
|
||||
let val = match val {
|
||||
ty::ValTree::Leaf(scalar) => ty::ValTree::Leaf(scalar),
|
||||
ty::ValTree::Branch(branch) => {
|
||||
@ -435,19 +435,19 @@ pub(crate) fn mir_const_from_ty_const<'tcx>(
|
||||
))
|
||||
}
|
||||
}
|
||||
ty::ParamCt(param) => stable_mir::ty::ConstantKind::Param(param.stable(tables)),
|
||||
ty::ErrorCt(_) => unreachable!(),
|
||||
ty::InferCt(_) => unreachable!(),
|
||||
ty::BoundCt(_, _) => unimplemented!(),
|
||||
ty::PlaceholderCt(_) => unimplemented!(),
|
||||
ty::Unevaluated(uv) => {
|
||||
ty::ConstKind::Param(param) => stable_mir::ty::ConstantKind::Param(param.stable(tables)),
|
||||
ty::ConstKind::Error(_) => unreachable!(),
|
||||
ty::ConstKind::Infer(_) => unreachable!(),
|
||||
ty::ConstKind::Bound(_, _) => unimplemented!(),
|
||||
ty::ConstKind::Placeholder(_) => unimplemented!(),
|
||||
ty::ConstKind::Unevaluated(uv) => {
|
||||
stable_mir::ty::ConstantKind::Unevaluated(stable_mir::ty::UnevaluatedConst {
|
||||
def: tables.const_def(uv.def),
|
||||
args: uv.args.stable(tables),
|
||||
promoted: None,
|
||||
})
|
||||
}
|
||||
ty::ExprCt(_) => unimplemented!(),
|
||||
ty::ConstKind::Expr(_) => unimplemented!(),
|
||||
};
|
||||
let stable_ty = tables.intern_ty(ty);
|
||||
let id = tables.intern_mir_const(mir::Const::Ty(ty, ty_const));
|
||||
@ -459,7 +459,7 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
|
||||
|
||||
fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
|
||||
let kind = match self.kind() {
|
||||
ty::Value(ty, val) => {
|
||||
ty::ConstKind::Value(ty, val) => {
|
||||
let val = match val {
|
||||
ty::ValTree::Leaf(scalar) => ty::ValTree::Leaf(scalar),
|
||||
ty::ValTree::Branch(branch) => {
|
||||
@ -478,16 +478,16 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
|
||||
)
|
||||
}
|
||||
}
|
||||
ty::ParamCt(param) => stable_mir::ty::TyConstKind::Param(param.stable(tables)),
|
||||
ty::Unevaluated(uv) => stable_mir::ty::TyConstKind::Unevaluated(
|
||||
ty::ConstKind::Param(param) => stable_mir::ty::TyConstKind::Param(param.stable(tables)),
|
||||
ty::ConstKind::Unevaluated(uv) => stable_mir::ty::TyConstKind::Unevaluated(
|
||||
tables.const_def(uv.def),
|
||||
uv.args.stable(tables),
|
||||
),
|
||||
ty::ErrorCt(_) => unreachable!(),
|
||||
ty::InferCt(_) => unreachable!(),
|
||||
ty::BoundCt(_, _) => unimplemented!(),
|
||||
ty::PlaceholderCt(_) => unimplemented!(),
|
||||
ty::ExprCt(_) => unimplemented!(),
|
||||
ty::ConstKind::Error(_) => unreachable!(),
|
||||
ty::ConstKind::Infer(_) => unreachable!(),
|
||||
ty::ConstKind::Bound(_, _) => unimplemented!(),
|
||||
ty::ConstKind::Placeholder(_) => unimplemented!(),
|
||||
ty::ConstKind::Expr(_) => unimplemented!(),
|
||||
};
|
||||
let id = tables.intern_ty_const(tables.tcx.lift(*self).unwrap());
|
||||
stable_mir::ty::TyConst::new(kind, id)
|
||||
|
@ -290,7 +290,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
|
||||
|
||||
// Bound lifetimes use indices starting at 1,
|
||||
// see `BinderLevel` for more details.
|
||||
ty::ReBound(debruijn, ty::BoundRegion { var, kind: ty::BrAnon }) => {
|
||||
ty::ReBound(debruijn, ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon }) => {
|
||||
let binder = &self.binders[self.binders.len() - 1 - debruijn.index()];
|
||||
let depth = binder.lifetime_depths.start + var.as_u32();
|
||||
|
||||
@ -568,7 +568,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
|
||||
|
||||
// We may still encounter unevaluated consts due to the printing
|
||||
// logic sometimes passing identity-substituted impl headers.
|
||||
ty::Unevaluated(ty::UnevaluatedConst { def, args, .. }) => {
|
||||
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, args, .. }) => {
|
||||
return self.print_def_path(def, args);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,10 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
|
||||
// Find the index of the named region that was part of the
|
||||
// error. We will then search the function parameters for a bound
|
||||
// region at the right depth with the same index
|
||||
(Some(rbv::ResolvedArg::EarlyBound(id)), ty::BrNamed(def_id, _)) => {
|
||||
(
|
||||
Some(rbv::ResolvedArg::EarlyBound(id)),
|
||||
ty::BoundRegionKind::Named(def_id, _),
|
||||
) => {
|
||||
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
|
||||
if id.to_def_id() == def_id {
|
||||
return ControlFlow::Break(arg);
|
||||
@ -112,7 +115,7 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
|
||||
// region at the right depth with the same index
|
||||
(
|
||||
Some(rbv::ResolvedArg::LateBound(debruijn_index, _, id)),
|
||||
ty::BrNamed(def_id, _),
|
||||
ty::BoundRegionKind::Named(def_id, _),
|
||||
) => {
|
||||
debug!(
|
||||
"FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}",
|
||||
@ -191,14 +194,17 @@ impl<'tcx> Visitor<'tcx> for TyPathVisitor<'tcx> {
|
||||
fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) -> Self::Result {
|
||||
match (self.tcx.named_bound_var(lifetime.hir_id), self.bound_region) {
|
||||
// the lifetime of the TyPath!
|
||||
(Some(rbv::ResolvedArg::EarlyBound(id)), ty::BrNamed(def_id, _)) => {
|
||||
(Some(rbv::ResolvedArg::EarlyBound(id)), ty::BoundRegionKind::Named(def_id, _)) => {
|
||||
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
|
||||
if id.to_def_id() == def_id {
|
||||
return ControlFlow::Break(());
|
||||
}
|
||||
}
|
||||
|
||||
(Some(rbv::ResolvedArg::LateBound(debruijn_index, _, id)), ty::BrNamed(def_id, _)) => {
|
||||
(
|
||||
Some(rbv::ResolvedArg::LateBound(debruijn_index, _, id)),
|
||||
ty::BoundRegionKind::Named(def_id, _),
|
||||
) => {
|
||||
debug!("FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}", debruijn_index,);
|
||||
debug!("id={:?}", id);
|
||||
debug!("def_id={:?}", def_id);
|
||||
|
@ -60,7 +60,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
let is_impl_item = region_info.is_impl_item;
|
||||
|
||||
match br {
|
||||
ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon => {}
|
||||
ty::BoundRegionKind::Named(_, kw::UnderscoreLifetime) | ty::BoundRegionKind::Anon => {}
|
||||
_ => {
|
||||
/* not an anonymous region */
|
||||
debug!("try_report_named_anon_conflict: not an anonymous region");
|
||||
|
@ -29,16 +29,16 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
|
||||
)) => {
|
||||
let span = *span;
|
||||
let (sub_span, sub_symbol) = match sub_name {
|
||||
ty::BrNamed(def_id, symbol) => {
|
||||
ty::BoundRegionKind::Named(def_id, symbol) => {
|
||||
(Some(self.tcx().def_span(def_id)), Some(symbol))
|
||||
}
|
||||
ty::BrAnon | ty::BrEnv => (None, None),
|
||||
ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => (None, None),
|
||||
};
|
||||
let (sup_span, sup_symbol) = match sup_name {
|
||||
ty::BrNamed(def_id, symbol) => {
|
||||
ty::BoundRegionKind::Named(def_id, symbol) => {
|
||||
(Some(self.tcx().def_span(def_id)), Some(symbol))
|
||||
}
|
||||
ty::BrAnon | ty::BrEnv => (None, None),
|
||||
ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => (None, None),
|
||||
};
|
||||
let diag = match (sub_span, sup_span, sub_symbol, sup_symbol) {
|
||||
(Some(sub_span), Some(sup_span), Some(&sub_symbol), Some(&sup_symbol)) => {
|
||||
|
@ -59,11 +59,11 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
let simple_ident = param.param.pat.simple_ident();
|
||||
|
||||
let (has_impl_path, impl_path) = match ctxt.assoc_item.container {
|
||||
AssocItemContainer::TraitContainer => {
|
||||
AssocItemContainer::Trait => {
|
||||
let id = ctxt.assoc_item.container_id(tcx);
|
||||
(true, tcx.def_path_str(id))
|
||||
}
|
||||
AssocItemContainer::ImplContainer => (false, String::new()),
|
||||
AssocItemContainer::Impl => (false, String::new()),
|
||||
};
|
||||
|
||||
let mut err = self.tcx().dcx().create_err(ButCallingIntroduces {
|
||||
|
@ -46,7 +46,7 @@ pub fn find_param_with_region<'tcx>(
|
||||
ty::ReLateParam(late_param) => (late_param.scope, late_param.bound_region),
|
||||
ty::ReEarlyParam(ebr) => {
|
||||
let region_def = tcx.generics_of(generic_param_scope).region_param(ebr, tcx).def_id;
|
||||
(tcx.parent(region_def), ty::BoundRegionKind::BrNamed(region_def, ebr.name))
|
||||
(tcx.parent(region_def), ty::BoundRegionKind::Named(region_def, ebr.name))
|
||||
}
|
||||
_ => return None, // not a free region
|
||||
};
|
||||
|
@ -993,7 +993,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
fn report_inference_failure(&self, var_origin: RegionVariableOrigin) -> Diag<'_> {
|
||||
let br_string = |br: ty::BoundRegionKind| {
|
||||
let mut s = match br {
|
||||
ty::BrNamed(_, name) => name.to_string(),
|
||||
ty::BoundRegionKind::Named(_, name) => name.to_string(),
|
||||
_ => String::new(),
|
||||
};
|
||||
if !s.is_empty() {
|
||||
@ -1103,7 +1103,7 @@ fn msg_span_from_named_region<'tcx>(
|
||||
("the anonymous lifetime defined here".to_string(), Some(ty.span))
|
||||
} else {
|
||||
match fr.bound_region {
|
||||
ty::BoundRegionKind::BrNamed(param_def_id, name) => {
|
||||
ty::BoundRegionKind::Named(param_def_id, name) => {
|
||||
let span = tcx.def_span(param_def_id);
|
||||
let text = if name == kw::UnderscoreLifetime {
|
||||
"the anonymous lifetime as defined here".to_string()
|
||||
@ -1112,7 +1112,7 @@ fn msg_span_from_named_region<'tcx>(
|
||||
};
|
||||
(text, Some(span))
|
||||
}
|
||||
ty::BrAnon => (
|
||||
ty::BoundRegionKind::Anon => (
|
||||
"the anonymous lifetime as defined here".to_string(),
|
||||
Some(tcx.def_span(generic_param_scope)),
|
||||
),
|
||||
@ -1125,11 +1125,11 @@ fn msg_span_from_named_region<'tcx>(
|
||||
}
|
||||
ty::ReStatic => ("the static lifetime".to_owned(), alt_span),
|
||||
ty::RePlaceholder(ty::PlaceholderRegion {
|
||||
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, name), .. },
|
||||
bound: ty::BoundRegion { kind: ty::BoundRegionKind::Named(def_id, name), .. },
|
||||
..
|
||||
}) => (format!("the lifetime `{name}` as defined here"), Some(tcx.def_span(def_id))),
|
||||
ty::RePlaceholder(ty::PlaceholderRegion {
|
||||
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon, .. },
|
||||
bound: ty::BoundRegion { kind: ty::BoundRegionKind::Anon, .. },
|
||||
..
|
||||
}) => ("an anonymous lifetime".to_owned(), None),
|
||||
_ => bug!("{:?}", region),
|
||||
|
@ -48,7 +48,7 @@ impl<'a> DescriptionCtx<'a> {
|
||||
} else {
|
||||
let scope = fr.scope.expect_local();
|
||||
match fr.bound_region {
|
||||
ty::BoundRegionKind::BrNamed(_, name) => {
|
||||
ty::BoundRegionKind::Named(_, name) => {
|
||||
let span = if let Some(param) = tcx
|
||||
.hir()
|
||||
.get_generics(scope)
|
||||
@ -64,7 +64,7 @@ impl<'a> DescriptionCtx<'a> {
|
||||
(Some(span), "as_defined", name.to_string())
|
||||
}
|
||||
}
|
||||
ty::BrAnon => {
|
||||
ty::BoundRegionKind::Anon => {
|
||||
let span = Some(tcx.def_span(scope));
|
||||
(span, "defined_here", String::new())
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ fn plug_infer_with_placeholders<'tcx>(
|
||||
universe: self.universe,
|
||||
bound: ty::BoundRegion {
|
||||
var: self.next_var(),
|
||||
kind: ty::BoundRegionKind::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
@ -624,9 +624,8 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||
debug!("equating consts:\nc1= {:?}\nc2= {:?}", c1, c2);
|
||||
|
||||
use rustc_hir::def::DefKind;
|
||||
use ty::Unevaluated;
|
||||
match (c1.kind(), c2.kind()) {
|
||||
(Unevaluated(a), Unevaluated(b))
|
||||
(ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b))
|
||||
if a.def == b.def && tcx.def_kind(a.def) == DefKind::AssocConst =>
|
||||
{
|
||||
if let Ok(new_obligations) = infcx
|
||||
@ -644,7 +643,8 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||
));
|
||||
}
|
||||
}
|
||||
(_, Unevaluated(_)) | (Unevaluated(_), _) => (),
|
||||
(_, ty::ConstKind::Unevaluated(_))
|
||||
| (ty::ConstKind::Unevaluated(_), _) => (),
|
||||
(_, _) => {
|
||||
if let Ok(new_obligations) = infcx
|
||||
.at(&obligation.cause, obligation.param_env)
|
||||
|
@ -660,7 +660,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
.into()
|
||||
}
|
||||
GenericParamDefKind::Lifetime => {
|
||||
let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name);
|
||||
let kind = ty::BoundRegionKind::Named(param.def_id, param.name);
|
||||
let bound_var = ty::BoundVariableKind::Region(kind);
|
||||
bound_vars.push(bound_var);
|
||||
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
|
@ -890,9 +890,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
);
|
||||
|
||||
use rustc_hir::def::DefKind;
|
||||
use ty::Unevaluated;
|
||||
match (c1.kind(), c2.kind()) {
|
||||
(Unevaluated(a), Unevaluated(b))
|
||||
(ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b))
|
||||
if a.def == b.def && tcx.def_kind(a.def) == DefKind::AssocConst =>
|
||||
{
|
||||
if let Ok(InferOk { obligations, value: () }) = self
|
||||
@ -912,7 +911,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
);
|
||||
}
|
||||
}
|
||||
(_, Unevaluated(_)) | (Unevaluated(_), _) => (),
|
||||
(_, ty::ConstKind::Unevaluated(_))
|
||||
| (ty::ConstKind::Unevaluated(_), _) => (),
|
||||
(_, _) => {
|
||||
if let Ok(InferOk { obligations, value: () }) = self
|
||||
.infcx
|
||||
@ -3183,7 +3183,7 @@ fn bind_coroutine_hidden_types_above<'tcx>(
|
||||
ty::ReErased => {
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_u32(counter),
|
||||
kind: ty::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
};
|
||||
counter += 1;
|
||||
ty::Region::new_bound(tcx, current_depth, br)
|
||||
@ -3196,9 +3196,11 @@ fn bind_coroutine_hidden_types_above<'tcx>(
|
||||
bty.instantiate(tcx, args)
|
||||
})
|
||||
.collect();
|
||||
let bound_vars =
|
||||
tcx.mk_bound_variable_kinds_from_iter(bound_vars.iter().chain(
|
||||
(num_bound_variables..counter).map(|_| ty::BoundVariableKind::Region(ty::BrAnon)),
|
||||
));
|
||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
|
||||
bound_vars.iter().chain(
|
||||
(num_bound_variables..counter)
|
||||
.map(|_| ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon)),
|
||||
),
|
||||
);
|
||||
ty::Binder::bind_with_vars(hidden_types, bound_vars)
|
||||
}
|
||||
|
@ -76,12 +76,13 @@ fn fn_sig_for_fn_abi<'tcx>(
|
||||
ty::Closure(def_id, args) => {
|
||||
let sig = args.as_closure().sig();
|
||||
|
||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
|
||||
sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
|
||||
);
|
||||
let bound_vars =
|
||||
tcx.mk_bound_variable_kinds_from_iter(sig.bound_vars().iter().chain(iter::once(
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv),
|
||||
)));
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind: ty::BoundRegionKind::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
};
|
||||
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
|
||||
let env_ty = tcx.closure_env_ty(
|
||||
@ -105,12 +106,13 @@ fn fn_sig_for_fn_abi<'tcx>(
|
||||
ty::CoroutineClosure(def_id, args) => {
|
||||
let coroutine_ty = Ty::new_coroutine_closure(tcx, def_id, args);
|
||||
let sig = args.as_coroutine_closure().coroutine_closure_sig();
|
||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
|
||||
sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
|
||||
);
|
||||
let bound_vars =
|
||||
tcx.mk_bound_variable_kinds_from_iter(sig.bound_vars().iter().chain(iter::once(
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv),
|
||||
)));
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind: ty::BoundRegionKind::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
};
|
||||
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
|
||||
// When this `CoroutineClosure` comes from a `ConstructCoroutineInClosureShim`,
|
||||
@ -161,11 +163,11 @@ fn fn_sig_for_fn_abi<'tcx>(
|
||||
let sig = args.as_coroutine().sig();
|
||||
|
||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(iter::once(
|
||||
ty::BoundVariableKind::Region(ty::BrEnv),
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv),
|
||||
));
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind: ty::BoundRegionKind::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
};
|
||||
|
||||
let env_ty = Ty::new_mut_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), ty);
|
||||
|
@ -140,7 +140,7 @@ fn associated_item_from_trait_item_ref(trait_item_ref: &hir::TraitItemRef) -> ty
|
||||
kind,
|
||||
def_id: owner_id.to_def_id(),
|
||||
trait_item_def_id: Some(owner_id.to_def_id()),
|
||||
container: ty::TraitContainer,
|
||||
container: ty::AssocItemContainer::Trait,
|
||||
fn_has_self_parameter: has_self,
|
||||
opt_rpitit_info: None,
|
||||
}
|
||||
@ -159,7 +159,7 @@ fn associated_item_from_impl_item_ref(impl_item_ref: &hir::ImplItemRef) -> ty::A
|
||||
kind,
|
||||
def_id: def_id.to_def_id(),
|
||||
trait_item_def_id: impl_item_ref.trait_item_def_id,
|
||||
container: ty::ImplContainer,
|
||||
container: ty::AssocItemContainer::Impl,
|
||||
fn_has_self_parameter: has_self,
|
||||
opt_rpitit_info: None,
|
||||
}
|
||||
@ -267,7 +267,7 @@ fn associated_type_for_impl_trait_in_trait(
|
||||
kind: ty::AssocKind::Type,
|
||||
def_id,
|
||||
trait_item_def_id: None,
|
||||
container: ty::TraitContainer,
|
||||
container: ty::AssocItemContainer::Trait,
|
||||
fn_has_self_parameter: false,
|
||||
opt_rpitit_info: Some(ImplTraitInTraitData::Trait {
|
||||
fn_def_id: fn_def_id.to_def_id(),
|
||||
@ -319,7 +319,7 @@ fn associated_type_for_impl_trait_in_impl(
|
||||
kind: ty::AssocKind::Type,
|
||||
def_id,
|
||||
trait_item_def_id: Some(trait_assoc_def_id),
|
||||
container: ty::ImplContainer,
|
||||
container: ty::AssocItemContainer::Impl,
|
||||
fn_has_self_parameter: false,
|
||||
opt_rpitit_info: Some(ImplTraitInTraitData::Impl { fn_def_id: impl_fn_def_id.to_def_id() }),
|
||||
});
|
||||
|
@ -135,7 +135,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
|
||||
|
||||
if tcx.def_kind(def_id) == DefKind::AssocFn
|
||||
&& let assoc_item = tcx.associated_item(def_id)
|
||||
&& assoc_item.container == ty::AssocItemContainer::TraitContainer
|
||||
&& assoc_item.container == ty::AssocItemContainer::Trait
|
||||
&& assoc_item.defaultness(tcx).has_value()
|
||||
{
|
||||
let sig = tcx.fn_sig(def_id).instantiate_identity();
|
||||
|
@ -304,7 +304,9 @@ pub(crate) fn clean_middle_region(region: ty::Region<'_>) -> Option<Lifetime> {
|
||||
match *region {
|
||||
ty::ReStatic => Some(Lifetime::statik()),
|
||||
_ if !region.has_name() => None,
|
||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) => Some(Lifetime(name)),
|
||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(_, name), .. }) => {
|
||||
Some(Lifetime(name))
|
||||
}
|
||||
ty::ReEarlyParam(ref data) => Some(Lifetime(data.name)),
|
||||
ty::ReBound(..)
|
||||
| ty::ReLateParam(..)
|
||||
@ -1317,8 +1319,8 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
|
||||
simplify::move_bounds_to_generic_parameters(&mut generics);
|
||||
|
||||
let provided = match assoc_item.container {
|
||||
ty::ImplContainer => true,
|
||||
ty::TraitContainer => tcx.defaultness(assoc_item.def_id).has_value(),
|
||||
ty::AssocItemContainer::Impl => true,
|
||||
ty::AssocItemContainer::Trait => tcx.defaultness(assoc_item.def_id).has_value(),
|
||||
};
|
||||
if provided {
|
||||
AssocConstItem(Box::new(Constant {
|
||||
@ -1335,10 +1337,10 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
|
||||
|
||||
if assoc_item.fn_has_self_parameter {
|
||||
let self_ty = match assoc_item.container {
|
||||
ty::ImplContainer => {
|
||||
ty::AssocItemContainer::Impl => {
|
||||
tcx.type_of(assoc_item.container_id(tcx)).instantiate_identity()
|
||||
}
|
||||
ty::TraitContainer => tcx.types.self_param,
|
||||
ty::AssocItemContainer::Trait => tcx.types.self_param,
|
||||
};
|
||||
let self_arg_ty =
|
||||
tcx.fn_sig(assoc_item.def_id).instantiate_identity().input(0).skip_binder();
|
||||
@ -1355,13 +1357,13 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
|
||||
}
|
||||
|
||||
let provided = match assoc_item.container {
|
||||
ty::ImplContainer => true,
|
||||
ty::TraitContainer => assoc_item.defaultness(tcx).has_value(),
|
||||
ty::AssocItemContainer::Impl => true,
|
||||
ty::AssocItemContainer::Trait => assoc_item.defaultness(tcx).has_value(),
|
||||
};
|
||||
if provided {
|
||||
let defaultness = match assoc_item.container {
|
||||
ty::ImplContainer => Some(assoc_item.defaultness(tcx)),
|
||||
ty::TraitContainer => None,
|
||||
ty::AssocItemContainer::Impl => Some(assoc_item.defaultness(tcx)),
|
||||
ty::AssocItemContainer::Trait => None,
|
||||
};
|
||||
MethodItem(item, defaultness)
|
||||
} else {
|
||||
@ -1392,7 +1394,7 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
|
||||
}
|
||||
|
||||
let mut predicates = tcx.explicit_predicates_of(assoc_item.def_id).predicates;
|
||||
if let ty::TraitContainer = assoc_item.container {
|
||||
if let ty::AssocItemContainer::Trait = assoc_item.container {
|
||||
let bounds = tcx.explicit_item_bounds(assoc_item.def_id).iter_identity_copied();
|
||||
predicates = tcx.arena.alloc_from_iter(bounds.chain(predicates.iter().copied()));
|
||||
}
|
||||
@ -1403,7 +1405,7 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
|
||||
});
|
||||
simplify::move_bounds_to_generic_parameters(&mut generics);
|
||||
|
||||
if let ty::TraitContainer = assoc_item.container {
|
||||
if let ty::AssocItemContainer::Trait = assoc_item.container {
|
||||
// Move bounds that are (likely) directly attached to the associated type
|
||||
// from the where-clause to the associated type.
|
||||
// There is no guarantee that this is what the user actually wrote but we have
|
||||
@ -1896,7 +1898,9 @@ fn clean_trait_object_lifetime_bound<'tcx>(
|
||||
match *region {
|
||||
ty::ReStatic => Some(Lifetime::statik()),
|
||||
ty::ReEarlyParam(region) if region.name != kw::Empty => Some(Lifetime(region.name)),
|
||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) if name != kw::Empty => {
|
||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(_, name), .. })
|
||||
if name != kw::Empty =>
|
||||
{
|
||||
Some(Lifetime(name))
|
||||
}
|
||||
ty::ReEarlyParam(_)
|
||||
@ -2141,7 +2145,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
||||
.iter()
|
||||
.flat_map(|pred| pred.bound_vars())
|
||||
.filter_map(|var| match var {
|
||||
ty::BoundVariableKind::Region(ty::BrNamed(def_id, name))
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name))
|
||||
if name != kw::UnderscoreLifetime =>
|
||||
{
|
||||
Some(GenericParamDef::lifetime(def_id, name))
|
||||
@ -3118,7 +3122,7 @@ fn clean_bound_vars(bound_vars: &ty::List<ty::BoundVariableKind>) -> Vec<Generic
|
||||
bound_vars
|
||||
.into_iter()
|
||||
.filter_map(|var| match var {
|
||||
ty::BoundVariableKind::Region(ty::BrNamed(def_id, name))
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name))
|
||||
if name != kw::UnderscoreLifetime =>
|
||||
{
|
||||
Some(GenericParamDef::lifetime(def_id, name))
|
||||
|
@ -703,8 +703,8 @@ impl Item {
|
||||
| TyMethodItem(..) | MethodItem(..) => {
|
||||
let assoc_item = tcx.associated_item(def_id);
|
||||
let is_trait_item = match assoc_item.container {
|
||||
ty::TraitContainer => true,
|
||||
ty::ImplContainer => {
|
||||
ty::AssocItemContainer::Trait => true,
|
||||
ty::AssocItemContainer::Impl => {
|
||||
// Trait impl items always inherit the impl's visibility --
|
||||
// we don't want to show `pub`.
|
||||
tcx.impl_trait_ref(tcx.parent(assoc_item.def_id)).is_some()
|
||||
|
@ -80,7 +80,7 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
|
||||
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
|
||||
|
||||
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId, bk: ty::BorrowKind) {
|
||||
if bk == ty::BorrowKind::MutBorrow {
|
||||
if bk == ty::BorrowKind::Mutable {
|
||||
if let PlaceBase::Local(id) = cmt.place.base {
|
||||
if Some(id) == self.hir_id_low && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) {
|
||||
self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id));
|
||||
|
@ -2,6 +2,7 @@ use clippy_utils::diagnostics::span_lint;
|
||||
use rustc_ast::ast;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::ty::AssocItemContainer;
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::{Span, sym};
|
||||
|
||||
@ -138,7 +139,6 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
||||
}
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
|
||||
use rustc_middle::ty::{ImplContainer, TraitContainer};
|
||||
if rustc_middle::lint::in_external_macro(cx.sess(), impl_item.span) || is_executable_or_proc_macro(cx) {
|
||||
return;
|
||||
}
|
||||
@ -156,8 +156,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
||||
let assoc_item = cx.tcx.associated_item(impl_item.owner_id);
|
||||
let container_id = assoc_item.container_id(cx.tcx);
|
||||
let trait_def_id = match assoc_item.container {
|
||||
TraitContainer => Some(container_id),
|
||||
ImplContainer => cx.tcx.impl_trait_ref(container_id).map(|t| t.skip_binder().def_id),
|
||||
AssocItemContainer::Trait => Some(container_id),
|
||||
AssocItemContainer::Impl => cx.tcx.impl_trait_ref(container_id).map(|t| t.skip_binder().def_id),
|
||||
};
|
||||
|
||||
if let Some(trait_def_id) = trait_def_id {
|
||||
|
@ -417,8 +417,8 @@ impl<'tcx> euv::Delegate<'tcx> for MutablyUsedVariablesCtxt<'tcx> {
|
||||
// a closure, it'll return this variant whereas if you have just an index access, it'll
|
||||
// return `ImmBorrow`. So if there is "Unique" and it's a mutable reference, we add it
|
||||
// to the mutably used variables set.
|
||||
if borrow == ty::BorrowKind::MutBorrow
|
||||
|| (borrow == ty::BorrowKind::UniqueImmBorrow && base_ty.ref_mutability() == Some(Mutability::Mut))
|
||||
if borrow == ty::BorrowKind::Mutable
|
||||
|| (borrow == ty::BorrowKind::UniqueImmutable && base_ty.ref_mutability() == Some(Mutability::Mut))
|
||||
{
|
||||
self.add_mutably_used_var(*vid);
|
||||
} else if self.is_in_unsafe_block(id) {
|
||||
@ -426,7 +426,7 @@ impl<'tcx> euv::Delegate<'tcx> for MutablyUsedVariablesCtxt<'tcx> {
|
||||
// upon!
|
||||
self.add_mutably_used_var(*vid);
|
||||
}
|
||||
} else if borrow == ty::ImmBorrow {
|
||||
} else if borrow == ty::BorrowKind::Immutable {
|
||||
// If there is an `async block`, it'll contain a call to a closure which we need to
|
||||
// go into to ensure all "mutate" checks are found.
|
||||
if let Node::Expr(Expr {
|
||||
|
@ -102,7 +102,7 @@ fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> HirIdSet {
|
||||
struct S(HirIdSet);
|
||||
impl Delegate<'_> for S {
|
||||
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: HirId, kind: BorrowKind) {
|
||||
if matches!(kind, BorrowKind::ImmBorrow | BorrowKind::UniqueImmBorrow) {
|
||||
if matches!(kind, BorrowKind::Immutable | BorrowKind::UniqueImmutable) {
|
||||
self.0.insert(match place.place.base {
|
||||
PlaceBase::Local(id) => id,
|
||||
PlaceBase::Upvar(id) => id.var_path.hir_id,
|
||||
@ -127,7 +127,7 @@ fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> HirIdSet {
|
||||
struct S(HirIdSet);
|
||||
impl Delegate<'_> for S {
|
||||
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: HirId, kind: BorrowKind) {
|
||||
if matches!(kind, BorrowKind::MutBorrow) {
|
||||
if matches!(kind, BorrowKind::Mutable) {
|
||||
self.0.insert(match place.place.base {
|
||||
PlaceBase::Local(id) => id,
|
||||
PlaceBase::Upvar(id) => id.var_path.hir_id,
|
||||
|
@ -217,7 +217,7 @@ fn is_option_as_mut_use(tcx: TyCtxt<'_>, expr_id: HirId) -> bool {
|
||||
|
||||
impl<'tcx> Delegate<'tcx> for MutationVisitor<'tcx> {
|
||||
fn borrow(&mut self, cat: &PlaceWithHirId<'tcx>, diag_expr_id: HirId, bk: ty::BorrowKind) {
|
||||
if let ty::BorrowKind::MutBorrow = bk
|
||||
if let ty::BorrowKind::Mutable = bk
|
||||
&& is_potentially_local_place(self.local_id, &cat.place)
|
||||
&& !is_option_as_mut_use(self.tcx, diag_expr_id)
|
||||
{
|
||||
|
@ -1209,8 +1209,8 @@ pub fn can_move_expr_to_closure<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'
|
||||
let capture = match capture.info.capture_kind {
|
||||
UpvarCapture::ByValue => CaptureKind::Value,
|
||||
UpvarCapture::ByRef(kind) => match kind {
|
||||
BorrowKind::ImmBorrow => CaptureKind::Ref(Mutability::Not),
|
||||
BorrowKind::UniqueImmBorrow | BorrowKind::MutBorrow => {
|
||||
BorrowKind::Immutable => CaptureKind::Ref(Mutability::Not),
|
||||
BorrowKind::UniqueImmutable | BorrowKind::Mutable => {
|
||||
CaptureKind::Ref(Mutability::Mut)
|
||||
},
|
||||
},
|
||||
@ -3340,8 +3340,8 @@ pub fn get_path_from_caller_to_method_type<'tcx>(
|
||||
let assoc_item = tcx.associated_item(method);
|
||||
let def_id = assoc_item.container_id(tcx);
|
||||
match assoc_item.container {
|
||||
rustc_ty::TraitContainer => get_path_to_callee(tcx, from, def_id),
|
||||
rustc_ty::ImplContainer => {
|
||||
rustc_ty::AssocItemContainer::Trait => get_path_to_callee(tcx, from, def_id),
|
||||
rustc_ty::AssocItemContainer::Impl => {
|
||||
let ty = tcx.type_of(def_id).instantiate_identity();
|
||||
get_path_to_ty(tcx, from, ty, args)
|
||||
},
|
||||
|
@ -67,7 +67,7 @@ impl<'tcx> Delegate<'tcx> for MutVarsDelegate {
|
||||
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
|
||||
|
||||
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, bk: ty::BorrowKind) {
|
||||
if bk == ty::BorrowKind::MutBorrow {
|
||||
if bk == ty::BorrowKind::Mutable {
|
||||
self.update(cmt);
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,10 @@ fn main() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
m[0] += 10;
|
||||
//~^ NOTE: Capturing m[] -> MutBorrow
|
||||
//~| NOTE: Min Capture m[] -> MutBorrow
|
||||
//~^ NOTE: Capturing m[] -> Mutable
|
||||
//~| NOTE: Min Capture m[] -> Mutable
|
||||
m[1] += 40;
|
||||
//~^ NOTE: Capturing m[] -> MutBorrow
|
||||
//~^ NOTE: Capturing m[] -> Mutable
|
||||
};
|
||||
|
||||
c();
|
||||
|
@ -20,12 +20,12 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing m[] -> MutBorrow
|
||||
note: Capturing m[] -> Mutable
|
||||
--> $DIR/arrays-completely-captured.rs:15:9
|
||||
|
|
||||
LL | m[0] += 10;
|
||||
| ^
|
||||
note: Capturing m[] -> MutBorrow
|
||||
note: Capturing m[] -> Mutable
|
||||
--> $DIR/arrays-completely-captured.rs:18:9
|
||||
|
|
||||
LL | m[1] += 40;
|
||||
@ -43,7 +43,7 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture m[] -> MutBorrow
|
||||
note: Min Capture m[] -> Mutable
|
||||
--> $DIR/arrays-completely-captured.rs:15:9
|
||||
|
|
||||
LL | m[0] += 10;
|
||||
|
@ -26,8 +26,8 @@ fn big_box() {
|
||||
//~^ NOTE: Capturing t[(0, 0),Deref,(0, 0)] -> ByValue
|
||||
//~| NOTE: Min Capture t[(0, 0)] -> ByValue
|
||||
println!("{} {:?}", t.1, p);
|
||||
//~^ NOTE: Capturing t[(1, 0)] -> ImmBorrow
|
||||
//~| NOTE: Min Capture t[(1, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing t[(1, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture t[(1, 0)] -> Immutable
|
||||
};
|
||||
|
||||
c();
|
||||
|
@ -25,7 +25,7 @@ note: Capturing t[(0, 0),Deref,(0, 0)] -> ByValue
|
||||
|
|
||||
LL | let p = t.0.0;
|
||||
| ^^^^^
|
||||
note: Capturing t[(1, 0)] -> ImmBorrow
|
||||
note: Capturing t[(1, 0)] -> Immutable
|
||||
--> $DIR/by_value.rs:28:29
|
||||
|
|
||||
LL | println!("{} {:?}", t.1, p);
|
||||
@ -48,7 +48,7 @@ note: Min Capture t[(0, 0)] -> ByValue
|
||||
|
|
||||
LL | let p = t.0.0;
|
||||
| ^^^^^
|
||||
note: Min Capture t[(1, 0)] -> ImmBorrow
|
||||
note: Min Capture t[(1, 0)] -> Immutable
|
||||
--> $DIR/by_value.rs:28:29
|
||||
|
|
||||
LL | println!("{} {:?}", t.1, p);
|
||||
|
@ -20,15 +20,15 @@ fn main() {
|
||||
//~^ First Pass analysis includes:
|
||||
//~| Min Capture analysis includes:
|
||||
println!("{:?}", p);
|
||||
//~^ NOTE: Capturing p[] -> ImmBorrow
|
||||
//~| NOTE: Min Capture p[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing p[] -> Immutable
|
||||
//~| NOTE: Min Capture p[] -> Immutable
|
||||
println!("{:?}", p.x);
|
||||
//~^ NOTE: Capturing p[(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing p[(0, 0)] -> Immutable
|
||||
|
||||
println!("{:?}", q.x);
|
||||
//~^ NOTE: Capturing q[(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing q[(0, 0)] -> Immutable
|
||||
println!("{:?}", q);
|
||||
//~^ NOTE: Capturing q[] -> ImmBorrow
|
||||
//~| NOTE: Min Capture q[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing q[] -> Immutable
|
||||
//~| NOTE: Min Capture q[] -> Immutable
|
||||
};
|
||||
}
|
||||
|
@ -20,22 +20,22 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing p[] -> ImmBorrow
|
||||
note: Capturing p[] -> Immutable
|
||||
--> $DIR/capture-analysis-1.rs:22:26
|
||||
|
|
||||
LL | println!("{:?}", p);
|
||||
| ^
|
||||
note: Capturing p[(0, 0)] -> ImmBorrow
|
||||
note: Capturing p[(0, 0)] -> Immutable
|
||||
--> $DIR/capture-analysis-1.rs:25:26
|
||||
|
|
||||
LL | println!("{:?}", p.x);
|
||||
| ^^^
|
||||
note: Capturing q[(0, 0)] -> ImmBorrow
|
||||
note: Capturing q[(0, 0)] -> Immutable
|
||||
--> $DIR/capture-analysis-1.rs:28:26
|
||||
|
|
||||
LL | println!("{:?}", q.x);
|
||||
| ^^^
|
||||
note: Capturing q[] -> ImmBorrow
|
||||
note: Capturing q[] -> Immutable
|
||||
--> $DIR/capture-analysis-1.rs:30:26
|
||||
|
|
||||
LL | println!("{:?}", q);
|
||||
@ -53,12 +53,12 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture p[] -> ImmBorrow
|
||||
note: Min Capture p[] -> Immutable
|
||||
--> $DIR/capture-analysis-1.rs:22:26
|
||||
|
|
||||
LL | println!("{:?}", p);
|
||||
| ^
|
||||
note: Min Capture q[] -> ImmBorrow
|
||||
note: Min Capture q[] -> Immutable
|
||||
--> $DIR/capture-analysis-1.rs:30:26
|
||||
|
|
||||
LL | println!("{:?}", q);
|
||||
|
@ -22,7 +22,7 @@ fn main() {
|
||||
//~^ NOTE: Capturing p[(0, 0)] -> ByValue
|
||||
//~| NOTE: p[] captured as ByValue here
|
||||
println!("{:?}", p);
|
||||
//~^ NOTE: Capturing p[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing p[] -> Immutable
|
||||
//~| NOTE: Min Capture p[] -> ByValue
|
||||
//~| NOTE: p[] used here
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ note: Capturing p[(0, 0)] -> ByValue
|
||||
|
|
||||
LL | let _x = p.x;
|
||||
| ^^^
|
||||
note: Capturing p[] -> ImmBorrow
|
||||
note: Capturing p[] -> Immutable
|
||||
--> $DIR/capture-analysis-2.rs:24:26
|
||||
|
|
||||
LL | println!("{:?}", p);
|
||||
|
@ -27,7 +27,7 @@ fn main() {
|
||||
//~^ NOTE: Capturing a[(0, 0),(0, 0)] -> ByValue
|
||||
//~| NOTE: a[(0, 0)] captured as ByValue here
|
||||
println!("{:?}", a.b);
|
||||
//~^ NOTE: Capturing a[(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing a[(0, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture a[(0, 0)] -> ByValue
|
||||
//~| NOTE: a[(0, 0)] used here
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ note: Capturing a[(0, 0),(0, 0)] -> ByValue
|
||||
|
|
||||
LL | let _x = a.b.c;
|
||||
| ^^^^^
|
||||
note: Capturing a[(0, 0)] -> ImmBorrow
|
||||
note: Capturing a[(0, 0)] -> Immutable
|
||||
--> $DIR/capture-analysis-3.rs:29:26
|
||||
|
|
||||
LL | println!("{:?}", a.b);
|
||||
|
@ -27,6 +27,6 @@ fn main() {
|
||||
//~^ NOTE: Capturing a[(0, 0)] -> ByValue
|
||||
//~| NOTE: Min Capture a[(0, 0)] -> ByValue
|
||||
println!("{:?}", a.b.c);
|
||||
//~^ NOTE: Capturing a[(0, 0),(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing a[(0, 0),(0, 0)] -> Immutable
|
||||
};
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ note: Capturing a[(0, 0)] -> ByValue
|
||||
|
|
||||
LL | let _x = a.b;
|
||||
| ^^^
|
||||
note: Capturing a[(0, 0),(0, 0)] -> ImmBorrow
|
||||
note: Capturing a[(0, 0),(0, 0)] -> Immutable
|
||||
--> $DIR/capture-analysis-4.rs:29:26
|
||||
|
|
||||
LL | println!("{:?}", a.b.c);
|
||||
|
@ -18,8 +18,8 @@ fn main() {
|
||||
//~^ First Pass analysis includes:
|
||||
//~| Min Capture analysis includes:
|
||||
println!("{}", p.x);
|
||||
//~^ NOTE: Capturing p[(0, 0)] -> ImmBorrow
|
||||
//~| NOTE: Min Capture p[(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing p[(0, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture p[(0, 0)] -> Immutable
|
||||
};
|
||||
|
||||
// `c` should only capture `p.x`, therefore mutating `p.y` is allowed.
|
||||
|
@ -20,7 +20,7 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing p[(0, 0)] -> ImmBorrow
|
||||
note: Capturing p[(0, 0)] -> Immutable
|
||||
--> $DIR/capture-disjoint-field-struct.rs:20:24
|
||||
|
|
||||
LL | println!("{}", p.x);
|
||||
@ -38,7 +38,7 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture p[(0, 0)] -> ImmBorrow
|
||||
note: Min Capture p[(0, 0)] -> Immutable
|
||||
--> $DIR/capture-disjoint-field-struct.rs:20:24
|
||||
|
|
||||
LL | println!("{}", p.x);
|
||||
|
@ -13,8 +13,8 @@ fn main() {
|
||||
//~^ First Pass analysis includes:
|
||||
//~| Min Capture analysis includes:
|
||||
println!("{}", t.0);
|
||||
//~^ NOTE: Capturing t[(0, 0)] -> ImmBorrow
|
||||
//~| NOTE: Min Capture t[(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing t[(0, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture t[(0, 0)] -> Immutable
|
||||
};
|
||||
|
||||
// `c` only captures t.0, therefore mutating t.1 is allowed.
|
||||
|
@ -20,7 +20,7 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing t[(0, 0)] -> ImmBorrow
|
||||
note: Capturing t[(0, 0)] -> Immutable
|
||||
--> $DIR/capture-disjoint-field-tuple.rs:15:24
|
||||
|
|
||||
LL | println!("{}", t.0);
|
||||
@ -38,7 +38,7 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture t[(0, 0)] -> ImmBorrow
|
||||
note: Min Capture t[(0, 0)] -> Immutable
|
||||
--> $DIR/capture-disjoint-field-tuple.rs:15:24
|
||||
|
|
||||
LL | println!("{}", t.0);
|
||||
|
@ -21,14 +21,14 @@ fn multi_variant_enum() {
|
||||
//~^ First Pass analysis includes:
|
||||
//~| Min Capture analysis includes:
|
||||
if let Info::Point(_, _, str) = point {
|
||||
//~^ NOTE: Capturing point[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing point[] -> Immutable
|
||||
//~| NOTE: Capturing point[(2, 0)] -> ByValue
|
||||
//~| NOTE: Min Capture point[] -> ByValue
|
||||
println!("{}", str);
|
||||
}
|
||||
|
||||
if let Info::Meta(_, v) = meta {
|
||||
//~^ NOTE: Capturing meta[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing meta[] -> Immutable
|
||||
//~| NOTE: Capturing meta[(1, 1)] -> ByValue
|
||||
//~| NOTE: Min Capture meta[] -> ByValue
|
||||
println!("{:?}", v);
|
||||
|
@ -30,7 +30,7 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing point[] -> ImmBorrow
|
||||
note: Capturing point[] -> Immutable
|
||||
--> $DIR/capture-enums.rs:23:41
|
||||
|
|
||||
LL | if let Info::Point(_, _, str) = point {
|
||||
@ -40,7 +40,7 @@ note: Capturing point[(2, 0)] -> ByValue
|
||||
|
|
||||
LL | if let Info::Point(_, _, str) = point {
|
||||
| ^^^^^
|
||||
note: Capturing meta[] -> ImmBorrow
|
||||
note: Capturing meta[] -> Immutable
|
||||
--> $DIR/capture-enums.rs:30:35
|
||||
|
|
||||
LL | if let Info::Meta(_, v) = meta {
|
||||
|
@ -39,13 +39,13 @@ fn main() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
let x = &p.a.p.x;
|
||||
//~^ NOTE: Capturing p[(0, 0),(0, 0),(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing p[(0, 0),(0, 0),(0, 0)] -> Immutable
|
||||
p.b.q.y = 9;
|
||||
//~^ NOTE: Capturing p[(1, 0),(1, 0),(1, 0)] -> MutBorrow
|
||||
//~| NOTE: p[] captured as MutBorrow here
|
||||
//~^ NOTE: Capturing p[(1, 0),(1, 0),(1, 0)] -> Mutable
|
||||
//~| NOTE: p[] captured as Mutable here
|
||||
println!("{:?}", p);
|
||||
//~^ NOTE: Capturing p[] -> ImmBorrow
|
||||
//~| NOTE: Min Capture p[] -> MutBorrow
|
||||
//~^ NOTE: Capturing p[] -> Immutable
|
||||
//~| NOTE: Min Capture p[] -> Mutable
|
||||
//~| NOTE: p[] used here
|
||||
};
|
||||
}
|
||||
|
@ -20,17 +20,17 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing p[(0, 0),(0, 0),(0, 0)] -> ImmBorrow
|
||||
note: Capturing p[(0, 0),(0, 0),(0, 0)] -> Immutable
|
||||
--> $DIR/deep-multilevel-struct.rs:41:18
|
||||
|
|
||||
LL | let x = &p.a.p.x;
|
||||
| ^^^^^^^
|
||||
note: Capturing p[(1, 0),(1, 0),(1, 0)] -> MutBorrow
|
||||
note: Capturing p[(1, 0),(1, 0),(1, 0)] -> Mutable
|
||||
--> $DIR/deep-multilevel-struct.rs:43:9
|
||||
|
|
||||
LL | p.b.q.y = 9;
|
||||
| ^^^^^^^
|
||||
note: Capturing p[] -> ImmBorrow
|
||||
note: Capturing p[] -> Immutable
|
||||
--> $DIR/deep-multilevel-struct.rs:46:26
|
||||
|
|
||||
LL | println!("{:?}", p);
|
||||
@ -48,11 +48,11 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture p[] -> MutBorrow
|
||||
note: Min Capture p[] -> Mutable
|
||||
--> $DIR/deep-multilevel-struct.rs:43:9
|
||||
|
|
||||
LL | p.b.q.y = 9;
|
||||
| ^^^^^^^ p[] captured as MutBorrow here
|
||||
| ^^^^^^^ p[] captured as Mutable here
|
||||
...
|
||||
LL | println!("{:?}", p);
|
||||
| ^ p[] used here
|
||||
|
@ -13,13 +13,13 @@ fn main() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
let x = &t.0.0.0;
|
||||
//~^ NOTE: Capturing t[(0, 0),(0, 0),(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing t[(0, 0),(0, 0),(0, 0)] -> Immutable
|
||||
t.1.1.1 = 9;
|
||||
//~^ NOTE: Capturing t[(1, 0),(1, 0),(1, 0)] -> MutBorrow
|
||||
//~| NOTE: t[] captured as MutBorrow here
|
||||
//~^ NOTE: Capturing t[(1, 0),(1, 0),(1, 0)] -> Mutable
|
||||
//~| NOTE: t[] captured as Mutable here
|
||||
println!("{:?}", t);
|
||||
//~^ NOTE: Min Capture t[] -> MutBorrow
|
||||
//~| NOTE: Capturing t[] -> ImmBorrow
|
||||
//~^ NOTE: Min Capture t[] -> Mutable
|
||||
//~| NOTE: Capturing t[] -> Immutable
|
||||
//~| NOTE: t[] used here
|
||||
};
|
||||
}
|
||||
|
@ -20,17 +20,17 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing t[(0, 0),(0, 0),(0, 0)] -> ImmBorrow
|
||||
note: Capturing t[(0, 0),(0, 0),(0, 0)] -> Immutable
|
||||
--> $DIR/deep-multilevel-tuple.rs:15:18
|
||||
|
|
||||
LL | let x = &t.0.0.0;
|
||||
| ^^^^^^^
|
||||
note: Capturing t[(1, 0),(1, 0),(1, 0)] -> MutBorrow
|
||||
note: Capturing t[(1, 0),(1, 0),(1, 0)] -> Mutable
|
||||
--> $DIR/deep-multilevel-tuple.rs:17:9
|
||||
|
|
||||
LL | t.1.1.1 = 9;
|
||||
| ^^^^^^^
|
||||
note: Capturing t[] -> ImmBorrow
|
||||
note: Capturing t[] -> Immutable
|
||||
--> $DIR/deep-multilevel-tuple.rs:20:26
|
||||
|
|
||||
LL | println!("{:?}", t);
|
||||
@ -48,11 +48,11 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture t[] -> MutBorrow
|
||||
note: Min Capture t[] -> Mutable
|
||||
--> $DIR/deep-multilevel-tuple.rs:17:9
|
||||
|
|
||||
LL | t.1.1.1 = 9;
|
||||
| ^^^^^^^ t[] captured as MutBorrow here
|
||||
| ^^^^^^^ t[] captured as Mutable here
|
||||
...
|
||||
LL | println!("{:?}", t);
|
||||
| ^ t[] used here
|
||||
|
@ -44,9 +44,9 @@ fn structs() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
let Point { x: ref mut x, y: _, id: moved_id } = p;
|
||||
//~^ NOTE: Capturing p[(0, 0)] -> MutBorrow
|
||||
//~^ NOTE: Capturing p[(0, 0)] -> Mutable
|
||||
//~| NOTE: Capturing p[(2, 0)] -> ByValue
|
||||
//~| NOTE: Min Capture p[(0, 0)] -> MutBorrow
|
||||
//~| NOTE: Min Capture p[(0, 0)] -> Mutable
|
||||
//~| NOTE: Min Capture p[(2, 0)] -> ByValue
|
||||
|
||||
println!("{}, {}", x, moved_id);
|
||||
@ -65,11 +65,11 @@ fn tuples() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
let (ref mut x, ref ref_str, (moved_s, _)) = t;
|
||||
//~^ NOTE: Capturing t[(0, 0)] -> MutBorrow
|
||||
//~| NOTE: Capturing t[(1, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing t[(0, 0)] -> Mutable
|
||||
//~| NOTE: Capturing t[(1, 0)] -> Immutable
|
||||
//~| NOTE: Capturing t[(2, 0),(0, 0)] -> ByValue
|
||||
//~| NOTE: Min Capture t[(0, 0)] -> MutBorrow
|
||||
//~| NOTE: Min Capture t[(1, 0)] -> ImmBorrow
|
||||
//~| NOTE: Min Capture t[(0, 0)] -> Mutable
|
||||
//~| NOTE: Min Capture t[(1, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture t[(2, 0),(0, 0)] -> ByValue
|
||||
|
||||
println!("{}, {} {}", x, ref_str, moved_s);
|
||||
|
@ -86,7 +86,7 @@ LL | | println!("{}, {}", x, moved_id);
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing p[(0, 0)] -> MutBorrow
|
||||
note: Capturing p[(0, 0)] -> Mutable
|
||||
--> $DIR/destructure_patterns.rs:46:58
|
||||
|
|
||||
LL | let Point { x: ref mut x, y: _, id: moved_id } = p;
|
||||
@ -109,7 +109,7 @@ LL | | println!("{}, {}", x, moved_id);
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture p[(0, 0)] -> MutBorrow
|
||||
note: Min Capture p[(0, 0)] -> Mutable
|
||||
--> $DIR/destructure_patterns.rs:46:58
|
||||
|
|
||||
LL | let Point { x: ref mut x, y: _, id: moved_id } = p;
|
||||
@ -132,12 +132,12 @@ LL | | println!("{}, {} {}", x, ref_str, moved_s);
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing t[(0, 0)] -> MutBorrow
|
||||
note: Capturing t[(0, 0)] -> Mutable
|
||||
--> $DIR/destructure_patterns.rs:67:54
|
||||
|
|
||||
LL | let (ref mut x, ref ref_str, (moved_s, _)) = t;
|
||||
| ^
|
||||
note: Capturing t[(1, 0)] -> ImmBorrow
|
||||
note: Capturing t[(1, 0)] -> Immutable
|
||||
--> $DIR/destructure_patterns.rs:67:54
|
||||
|
|
||||
LL | let (ref mut x, ref ref_str, (moved_s, _)) = t;
|
||||
@ -160,12 +160,12 @@ LL | | println!("{}, {} {}", x, ref_str, moved_s);
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture t[(0, 0)] -> MutBorrow
|
||||
note: Min Capture t[(0, 0)] -> Mutable
|
||||
--> $DIR/destructure_patterns.rs:67:54
|
||||
|
|
||||
LL | let (ref mut x, ref ref_str, (moved_s, _)) = t;
|
||||
| ^
|
||||
note: Min Capture t[(1, 0)] -> ImmBorrow
|
||||
note: Min Capture t[(1, 0)] -> Immutable
|
||||
--> $DIR/destructure_patterns.rs:67:54
|
||||
|
|
||||
LL | let (ref mut x, ref ref_str, (moved_s, _)) = t;
|
||||
|
@ -13,7 +13,7 @@ fn main() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
println!("This uses new capture analyysis to capture s={}", s);
|
||||
//~^ NOTE: Capturing s[] -> ImmBorrow
|
||||
//~| NOTE: Min Capture s[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing s[] -> Immutable
|
||||
//~| NOTE: Min Capture s[] -> Immutable
|
||||
};
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing s[] -> ImmBorrow
|
||||
note: Capturing s[] -> Immutable
|
||||
--> $DIR/feature-gate-capture_disjoint_fields.rs:15:69
|
||||
|
|
||||
LL | println!("This uses new capture analyysis to capture s={}", s);
|
||||
@ -38,7 +38,7 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture s[] -> ImmBorrow
|
||||
note: Min Capture s[] -> Immutable
|
||||
--> $DIR/feature-gate-capture_disjoint_fields.rs:15:69
|
||||
|
|
||||
LL | println!("This uses new capture analyysis to capture s={}", s);
|
||||
|
@ -24,8 +24,8 @@ impl Data {
|
||||
|v| self.filter.allowed(*v),
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
//~| NOTE: Capturing self[Deref,(0, 0)] -> ImmBorrow
|
||||
//~| NOTE: Min Capture self[Deref,(0, 0)] -> ImmBorrow
|
||||
//~| NOTE: Capturing self[Deref,(0, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture self[Deref,(0, 0)] -> Immutable
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ error: First Pass analysis includes:
|
||||
LL | |v| self.filter.allowed(*v),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: Capturing self[Deref,(0, 0)] -> ImmBorrow
|
||||
note: Capturing self[Deref,(0, 0)] -> Immutable
|
||||
--> $DIR/filter-on-struct-member.rs:24:17
|
||||
|
|
||||
LL | |v| self.filter.allowed(*v),
|
||||
@ -16,7 +16,7 @@ error: Min Capture analysis includes:
|
||||
LL | |v| self.filter.allowed(*v),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: Min Capture self[Deref,(0, 0)] -> ImmBorrow
|
||||
note: Min Capture self[Deref,(0, 0)] -> Immutable
|
||||
--> $DIR/filter-on-struct-member.rs:24:17
|
||||
|
|
||||
LL | |v| self.filter.allowed(*v),
|
||||
|
@ -19,8 +19,8 @@ fn main() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
unsafe { u.value }
|
||||
//~^ NOTE: Capturing u[(0, 0)] -> ImmBorrow
|
||||
//~| NOTE: Min Capture u[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing u[(0, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture u[] -> Immutable
|
||||
};
|
||||
|
||||
c();
|
||||
|
@ -20,7 +20,7 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing u[(0, 0)] -> ImmBorrow
|
||||
note: Capturing u[(0, 0)] -> Immutable
|
||||
--> $DIR/issue-87378.rs:21:17
|
||||
|
|
||||
LL | unsafe { u.value }
|
||||
@ -38,7 +38,7 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture u[] -> ImmBorrow
|
||||
note: Min Capture u[] -> Immutable
|
||||
--> $DIR/issue-87378.rs:21:17
|
||||
|
|
||||
LL | unsafe { u.value }
|
||||
|
@ -24,7 +24,7 @@ pub fn test1() {
|
||||
//~| ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
println!("{:?}", f.0);
|
||||
//~^ NOTE: Capturing f[(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing f[(0, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture f[] -> ByValue
|
||||
};
|
||||
|
||||
@ -52,7 +52,7 @@ fn test2() {
|
||||
//~| ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
println!("{}", character.hp)
|
||||
//~^ NOTE: Capturing character[(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing character[(0, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture character[(0, 0)] -> ByValue
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,7 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing f[(0, 0)] -> ImmBorrow
|
||||
note: Capturing f[(0, 0)] -> Immutable
|
||||
--> $DIR/issue-88476.rs:26:26
|
||||
|
|
||||
LL | println!("{:?}", f.0);
|
||||
@ -69,7 +69,7 @@ LL | |
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing character[(0, 0)] -> ImmBorrow
|
||||
note: Capturing character[(0, 0)] -> Immutable
|
||||
--> $DIR/issue-88476.rs:54:24
|
||||
|
|
||||
LL | println!("{}", character.hp)
|
||||
|
@ -13,8 +13,8 @@ fn test_1_should_capture() {
|
||||
//~^ First Pass analysis includes:
|
||||
//~| Min Capture analysis includes:
|
||||
match variant {
|
||||
//~^ NOTE: Capturing variant[] -> ImmBorrow
|
||||
//~| NOTE: Min Capture variant[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing variant[] -> Immutable
|
||||
//~| NOTE: Min Capture variant[] -> Immutable
|
||||
Some(_) => {}
|
||||
_ => {}
|
||||
}
|
||||
@ -64,9 +64,9 @@ fn test_6_should_capture_single_variant() {
|
||||
//~^ First Pass analysis includes:
|
||||
//~| Min Capture analysis includes:
|
||||
match variant {
|
||||
//~^ NOTE: Capturing variant[] -> ImmBorrow
|
||||
//~| NOTE: Capturing variant[(0, 0)] -> ImmBorrow
|
||||
//~| NOTE: Min Capture variant[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing variant[] -> Immutable
|
||||
//~| NOTE: Capturing variant[(0, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture variant[] -> Immutable
|
||||
SingleVariant::Points(a) => {
|
||||
println!("{:?}", a);
|
||||
}
|
||||
@ -131,8 +131,8 @@ fn test_5_should_capture_multi_variant() {
|
||||
//~^ First Pass analysis includes:
|
||||
//~| Min Capture analysis includes:
|
||||
match variant {
|
||||
//~^ NOTE: Capturing variant[] -> ImmBorrow
|
||||
//~| NOTE: Min Capture variant[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing variant[] -> Immutable
|
||||
//~| NOTE: Min Capture variant[] -> Immutable
|
||||
MVariant::A => {}
|
||||
_ => {}
|
||||
}
|
||||
@ -149,8 +149,8 @@ fn test_7_should_capture_slice_len() {
|
||||
//~^ First Pass analysis includes:
|
||||
//~| Min Capture analysis includes:
|
||||
match slice {
|
||||
//~^ NOTE: Capturing slice[] -> ImmBorrow
|
||||
//~| NOTE: Min Capture slice[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing slice[] -> Immutable
|
||||
//~| NOTE: Min Capture slice[] -> Immutable
|
||||
[_,_,_] => {},
|
||||
_ => {}
|
||||
}
|
||||
@ -161,8 +161,8 @@ fn test_7_should_capture_slice_len() {
|
||||
//~^ First Pass analysis includes:
|
||||
//~| Min Capture analysis includes:
|
||||
match slice {
|
||||
//~^ NOTE: Capturing slice[] -> ImmBorrow
|
||||
//~| NOTE: Min Capture slice[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing slice[] -> Immutable
|
||||
//~| NOTE: Min Capture slice[] -> Immutable
|
||||
[] => {},
|
||||
_ => {}
|
||||
}
|
||||
@ -173,8 +173,8 @@ fn test_7_should_capture_slice_len() {
|
||||
//~^ First Pass analysis includes:
|
||||
//~| Min Capture analysis includes:
|
||||
match slice {
|
||||
//~^ NOTE: Capturing slice[] -> ImmBorrow
|
||||
//~| NOTE: Min Capture slice[] -> ImmBorrow
|
||||
//~^ NOTE: Capturing slice[] -> Immutable
|
||||
//~| NOTE: Min Capture slice[] -> Immutable
|
||||
[_, .. ,_] => {},
|
||||
_ => {}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing variant[] -> ImmBorrow
|
||||
note: Capturing variant[] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:15:15
|
||||
|
|
||||
LL | match variant {
|
||||
@ -28,7 +28,7 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture variant[] -> ImmBorrow
|
||||
note: Min Capture variant[] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:15:15
|
||||
|
|
||||
LL | match variant {
|
||||
@ -68,12 +68,12 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing variant[] -> ImmBorrow
|
||||
note: Capturing variant[] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:66:15
|
||||
|
|
||||
LL | match variant {
|
||||
| ^^^^^^^
|
||||
note: Capturing variant[(0, 0)] -> ImmBorrow
|
||||
note: Capturing variant[(0, 0)] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:66:15
|
||||
|
|
||||
LL | match variant {
|
||||
@ -91,7 +91,7 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture variant[] -> ImmBorrow
|
||||
note: Min Capture variant[] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:66:15
|
||||
|
|
||||
LL | match variant {
|
||||
@ -142,7 +142,7 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing variant[] -> ImmBorrow
|
||||
note: Capturing variant[] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:133:15
|
||||
|
|
||||
LL | match variant {
|
||||
@ -160,7 +160,7 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture variant[] -> ImmBorrow
|
||||
note: Min Capture variant[] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:133:15
|
||||
|
|
||||
LL | match variant {
|
||||
@ -178,7 +178,7 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing slice[] -> ImmBorrow
|
||||
note: Capturing slice[] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:151:15
|
||||
|
|
||||
LL | match slice {
|
||||
@ -196,7 +196,7 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture slice[] -> ImmBorrow
|
||||
note: Min Capture slice[] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:151:15
|
||||
|
|
||||
LL | match slice {
|
||||
@ -214,7 +214,7 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing slice[] -> ImmBorrow
|
||||
note: Capturing slice[] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:163:15
|
||||
|
|
||||
LL | match slice {
|
||||
@ -232,7 +232,7 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture slice[] -> ImmBorrow
|
||||
note: Min Capture slice[] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:163:15
|
||||
|
|
||||
LL | match slice {
|
||||
@ -250,7 +250,7 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing slice[] -> ImmBorrow
|
||||
note: Capturing slice[] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:175:15
|
||||
|
|
||||
LL | match slice {
|
||||
@ -268,7 +268,7 @@ LL | | }
|
||||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Min Capture slice[] -> ImmBorrow
|
||||
note: Min Capture slice[] -> Immutable
|
||||
--> $DIR/patterns-capture-analysis.rs:175:15
|
||||
|
|
||||
LL | match slice {
|
||||
|
@ -17,7 +17,7 @@ fn simple_move_closure() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
t.0.0 = "new S".into();
|
||||
//~^ NOTE: Capturing t[(0, 0),(0, 0)] -> MutBorrow
|
||||
//~^ NOTE: Capturing t[(0, 0),(0, 0)] -> Mutable
|
||||
//~| NOTE: Min Capture t[(0, 0),(0, 0)] -> ByValue
|
||||
};
|
||||
c();
|
||||
@ -36,7 +36,7 @@ fn simple_ref() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
*ref_s += 10;
|
||||
//~^ NOTE: Capturing ref_s[Deref] -> MutBorrow
|
||||
//~^ NOTE: Capturing ref_s[Deref] -> Mutable
|
||||
//~| NOTE: Min Capture ref_s[] -> ByValue
|
||||
};
|
||||
c();
|
||||
@ -58,7 +58,7 @@ fn struct_contains_ref_to_another_struct_1() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
t.0.0 = "new s".into();
|
||||
//~^ NOTE: Capturing t[(0, 0),Deref,(0, 0)] -> MutBorrow
|
||||
//~^ NOTE: Capturing t[(0, 0),Deref,(0, 0)] -> Mutable
|
||||
//~| NOTE: Min Capture t[(0, 0)] -> ByValue
|
||||
};
|
||||
|
||||
@ -82,7 +82,7 @@ fn struct_contains_ref_to_another_struct_2() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
let _t = t.0.0;
|
||||
//~^ NOTE: Capturing t[(0, 0),Deref,(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing t[(0, 0),Deref,(0, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture t[(0, 0)] -> ByValue
|
||||
};
|
||||
|
||||
@ -127,7 +127,7 @@ fn truncate_box_derefs() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
let _t = b.0;
|
||||
//~^ NOTE: Capturing b[Deref,(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing b[Deref,(0, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture b[] -> ByValue
|
||||
};
|
||||
|
||||
@ -144,7 +144,7 @@ fn truncate_box_derefs() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
println!("{}", b.0);
|
||||
//~^ NOTE: Capturing b[Deref,(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing b[Deref,(0, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture b[] -> ByValue
|
||||
};
|
||||
|
||||
@ -162,7 +162,7 @@ fn truncate_box_derefs() {
|
||||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
println!("{}", t.1.0);
|
||||
//~^ NOTE: Capturing t[(1, 0),Deref,(0, 0)] -> ImmBorrow
|
||||
//~^ NOTE: Capturing t[(1, 0),Deref,(0, 0)] -> Immutable
|
||||
//~| NOTE: Min Capture t[(1, 0)] -> ByValue
|
||||
};
|
||||
}
|
||||
@ -182,7 +182,7 @@ fn box_mut_1() {
|
||||
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
|
||||
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
//~| First Pass analysis includes:
|
||||
//~| NOTE: Capturing box_p_foo[Deref,Deref,(0, 0)] -> MutBorrow
|
||||
//~| NOTE: Capturing box_p_foo[Deref,Deref,(0, 0)] -> Mutable
|
||||
//~| Min Capture analysis includes:
|
||||
//~| NOTE: Min Capture box_p_foo[] -> ByValue
|
||||
}
|
||||
@ -200,7 +200,7 @@ fn box_mut_2() {
|
||||
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
|
||||
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
//~| First Pass analysis includes:
|
||||
//~| NOTE: Capturing p_foo[Deref,Deref,(0, 0)] -> MutBorrow
|
||||
//~| NOTE: Capturing p_foo[Deref,Deref,(0, 0)] -> Mutable
|
||||
//~| Min Capture analysis includes:
|
||||
//~| NOTE: Min Capture p_foo[] -> ByValue
|
||||
}
|
||||
@ -214,7 +214,7 @@ fn returned_closure_owns_copy_type_data() -> impl Fn() -> i32 {
|
||||
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
|
||||
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
//~| First Pass analysis includes:
|
||||
//~| NOTE: Capturing x[] -> ImmBorrow
|
||||
//~| NOTE: Capturing x[] -> Immutable
|
||||
//~| Min Capture analysis includes:
|
||||
//~| NOTE: Min Capture x[] -> ByValue
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user