From: Eduard-Mihai Burtescu Date: Tue, 5 Feb 2019 17:46:43 +0000 (+0200) Subject: rustc_mir: rename `Qualif::for_ty to `Qualif::any_value_of_ty`. X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=2de5b389435d97fbb547c7393f400702f109594e;p=rust.git rustc_mir: rename `Qualif::for_ty to `Qualif::any_value_of_ty`. --- diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 0d3080d3f22..f0fd598d31b 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -58,9 +58,11 @@ struct Qualif: u8 { impl<'a, 'tcx> Qualif { /// Compute the qualifications for the given type. - fn for_ty(ty: Ty<'tcx>, - tcx: TyCtxt<'a, 'tcx, 'tcx>, - param_env: ty::ParamEnv<'tcx>) -> Self { + fn any_value_of_ty( + ty: Ty<'tcx>, + tcx: TyCtxt<'a, 'tcx, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + ) -> Self { let mut qualif = Self::empty(); if !ty.is_freeze(tcx, param_env, DUMMY_SP) { qualif = qualif | Qualif::MUTABLE_INTERIOR; @@ -72,10 +74,13 @@ fn for_ty(ty: Ty<'tcx>, } /// Remove flags which are impossible for the given type. - fn restrict(&mut self, ty: Ty<'tcx>, - tcx: TyCtxt<'a, 'tcx, 'tcx>, - param_env: ty::ParamEnv<'tcx>) { - let ty_qualif = Self::for_ty(ty, tcx, param_env); + fn restrict( + &mut self, + ty: Ty<'tcx>, + tcx: TyCtxt<'a, 'tcx, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + ) { + let ty_qualif = Self::any_value_of_ty(ty, tcx, param_env); if !ty_qualif.contains(Qualif::MUTABLE_INTERIOR) { *self = *self - Qualif::MUTABLE_INTERIOR; } @@ -117,8 +122,8 @@ struct Qualifier<'a, 'tcx> { } impl<'a, 'tcx> Qualifier<'a, 'tcx> { - fn qualif_for_ty(&self, ty: Ty<'tcx>) -> Qualif { - Qualif::for_ty(ty, self.tcx, self.param_env) + fn qualify_any_value_of_ty(&self, ty: Ty<'tcx>) -> Qualif { + Qualif::any_value_of_ty(ty, self.tcx, self.param_env) } fn qualify_local(&self, local: Local) -> Qualif { @@ -217,7 +222,7 @@ fn qualify_operand(&self, operand: &Operand<'tcx>) -> Qualif { if let ty::LazyConst::Unevaluated(def_id, _) = constant.literal { // Don't peek inside trait associated constants. if self.tcx.trait_of_item(*def_id).is_some() { - self.qualif_for_ty(constant.ty) + self.qualify_any_value_of_ty(constant.ty) } else { let (bits, _) = self.tcx.at(constant.span).mir_const_qualif(*def_id); @@ -348,7 +353,7 @@ fn qualify_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Qualif { if let AggregateKind::Adt(def, ..) = **kind { if Some(def.did) == self.tcx.lang_items().unsafe_cell_type() { let ty = rvalue.ty(self.mir, self.tcx); - qualif = qualif | self.qualif_for_ty(ty); + qualif = qualif | self.qualify_any_value_of_ty(ty); assert!(qualif.contains(Qualif::MUTABLE_INTERIOR)); } @@ -444,7 +449,7 @@ fn qualify_call( } // Be conservative about the returned value of a const fn. - let qualif = self.qualif_for_ty(return_ty); + let qualif = self.qualify_any_value_of_ty(return_ty); if !is_promotable_const_fn && self.mode == Mode::Fn { qualif | Qualif::NOT_PROMOTABLE } else { @@ -491,7 +496,7 @@ fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut local_qualif = IndexVec::from_elem(None, &mir.local_decls); for arg in mir.args_iter() { - let qualif = Qualif::for_ty(mir.local_decls[arg].ty, tcx, param_env); + let qualif = Qualif::any_value_of_ty(mir.local_decls[arg].ty, tcx, param_env); local_qualif[arg] = Some(Qualif::NOT_PROMOTABLE | qualif); } @@ -661,7 +666,7 @@ fn check_const(&mut self) -> (Qualif, Lrc>) { // Account for errors in consts by using the // conservative type qualification instead. if qualif.intersects(Qualif::CONST_ERROR) { - qualif = self.qualifier().qualif_for_ty(mir.return_ty()); + qualif = self.qualifier().qualify_any_value_of_ty(mir.return_ty()); }