1
Fork 0

Auto merge of #102150 - matthiaskrgr:rollup-6xmd8f3, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #102113 (OpTy: fix a method taking self rather than &self)
 - #102118 (rustdoc: clean up line numbers on code examples)
 - #102123 (Add note to clippy::non_expressive_names doc)
 - #102125 (rustdoc: remove no-op CSS `.content .item-info { position: relative }`)
 - #102127 (Use appropriate variable names)
 - #102128 (Const unification is already infallible, remove the error handling logic)
 - #102133 (Use valtrees for comparison)
 - #102135 (Improve some AllTypes fields name)
 - #102144 (Extend const_convert with const {FormResidual, Try} for ControlFlow.)
 - #102147 (rustdoc: remove no-op CSS `.location:empty { border: none }`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-09-23 06:52:39 +00:00
commit bc4d574ff2
13 changed files with 96 additions and 76 deletions

View file

@ -280,7 +280,7 @@ impl<'tcx, Prov: Provenance> PlaceTy<'tcx, Prov> {
#[inline(always)]
#[cfg_attr(debug_assertions, track_caller)] // only in debug builds due to perf (see #98980)
pub fn assert_mem_place(self) -> MPlaceTy<'tcx, Prov> {
pub fn assert_mem_place(&self) -> MPlaceTy<'tcx, Prov> {
self.try_as_mplace().unwrap()
}
}

View file

@ -147,11 +147,7 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
ty::ConstKind::Infer(InferConst::Var(a_vid)),
ty::ConstKind::Infer(InferConst::Var(b_vid)),
) => {
self.inner
.borrow_mut()
.const_unification_table()
.unify_var_var(a_vid, b_vid)
.map_err(|e| const_unification_error(a_is_expected, e))?;
self.inner.borrow_mut().const_unification_table().union(a_vid, b_vid);
return Ok(a);
}
@ -246,21 +242,17 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
let value = ConstInferUnifier { infcx: self, span, param_env, for_universe, target_vid }
.relate(ct, ct)?;
self.inner
.borrow_mut()
.const_unification_table()
.unify_var_value(
target_vid,
ConstVarValue {
origin: ConstVariableOrigin {
kind: ConstVariableOriginKind::ConstInference,
span: DUMMY_SP,
},
val: ConstVariableValue::Known { value },
self.inner.borrow_mut().const_unification_table().union_value(
target_vid,
ConstVarValue {
origin: ConstVariableOrigin {
kind: ConstVariableOriginKind::ConstInference,
span: DUMMY_SP,
},
)
.map(|()| value)
.map_err(|e| const_unification_error(vid_is_expected, e))
val: ConstVariableValue::Known { value },
},
);
Ok(value)
}
fn unify_integral_variable(
@ -768,13 +760,6 @@ pub trait ConstEquateRelation<'tcx>: TypeRelation<'tcx> {
fn const_equate_obligation(&mut self, a: ty::Const<'tcx>, b: ty::Const<'tcx>);
}
pub fn const_unification_error<'tcx>(
a_is_expected: bool,
(a, b): (ty::Const<'tcx>, ty::Const<'tcx>),
) -> TypeError<'tcx> {
TypeError::ConstMismatch(ExpectedFound::new(a_is_expected, a, b))
}
fn int_unification_error<'tcx>(
a_is_expected: bool,
v: (ty::IntVarValue, ty::IntVarValue),

View file

@ -129,7 +129,7 @@ impl<'tcx> UnifyKey for ty::ConstVid<'tcx> {
}
impl<'tcx> UnifyValue for ConstVarValue<'tcx> {
type Error = (ty::Const<'tcx>, ty::Const<'tcx>);
type Error = NoError;
fn unify_values(&value1: &Self, &value2: &Self) -> Result<Self, Self::Error> {
Ok(match (value1.val, value2.val) {

View file

@ -384,14 +384,7 @@ impl DeepRejectCtxt {
// they might unify with any value.
ty::ConstKind::Unevaluated(_) | ty::ConstKind::Error(_) => true,
ty::ConstKind::Value(obl) => match k {
ty::ConstKind::Value(imp) => {
// FIXME(valtrees): Once we have valtrees, we can just
// compare them directly here.
match (obl.try_to_scalar_int(), imp.try_to_scalar_int()) {
(Some(obl), Some(imp)) => obl == imp,
_ => true,
}
}
ty::ConstKind::Value(imp) => obl == imp,
_ => true,
},

View file

@ -35,8 +35,8 @@ pub(crate) fn target_from_impl_item<'tcx>(
match impl_item.kind {
hir::ImplItemKind::Const(..) => Target::AssocConst,
hir::ImplItemKind::Fn(..) => {
let parent_hir_id = tcx.hir().get_parent_item(impl_item.hir_id());
let containing_item = tcx.hir().expect_item(parent_hir_id);
let parent_def_id = tcx.hir().get_parent_item(impl_item.hir_id());
let containing_item = tcx.hir().expect_item(parent_def_id);
let containing_impl_is_for_trait = match &containing_item.kind {
hir::ItemKind::Impl(impl_) => impl_.of_trait.is_some(),
_ => bug!("parent of an ImplItem must be an Impl"),
@ -640,8 +640,8 @@ impl CheckAttrVisitor<'_> {
let span = meta.span();
if let Some(location) = match target {
Target::AssocTy => {
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
let containing_item = self.tcx.hir().expect_item(parent_hir_id);
let parent_def_id = self.tcx.hir().get_parent_item(hir_id);
let containing_item = self.tcx.hir().expect_item(parent_def_id);
if Target::from_item(containing_item) == Target::Impl {
Some("type alias in implementation block")
} else {
@ -649,8 +649,8 @@ impl CheckAttrVisitor<'_> {
}
}
Target::AssocConst => {
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
let containing_item = self.tcx.hir().expect_item(parent_hir_id);
let parent_def_id = self.tcx.hir().get_parent_item(hir_id);
let containing_item = self.tcx.hir().expect_item(parent_def_id);
// We can't link to trait impl's consts.
let err = "associated constant in trait implementation block";
match containing_item.kind {