mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
It's not about types or consts, but the lack of regions
This commit is contained in:
parent
ead49f0beb
commit
c7b6ebdf7c
@ -236,7 +236,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let mut hidden_type = infcx.resolve_vars_if_possible(decl.hidden_type);
|
let mut hidden_type = infcx.resolve_vars_if_possible(decl.hidden_type);
|
||||||
trace!("finalized opaque type {:?} to {:#?}", opaque_type_key, hidden_type.ty.kind());
|
trace!("finalized opaque type {:?} to {:#?}", opaque_type_key, hidden_type.ty.kind());
|
||||||
if hidden_type.has_infer_types_or_consts() {
|
if hidden_type.has_non_region_infer() {
|
||||||
infcx.tcx.sess.delay_span_bug(
|
infcx.tcx.sess.delay_span_bug(
|
||||||
decl.hidden_type.span,
|
decl.hidden_type.span,
|
||||||
&format!("could not resolve {:#?}", hidden_type.ty.kind()),
|
&format!("could not resolve {:#?}", hidden_type.ty.kind()),
|
||||||
|
@ -91,14 +91,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
mutate_fulfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
|
mutate_fulfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
// No Infer()? Nothing needs doing.
|
// No Infer()? Nothing needs doing.
|
||||||
if !ty.has_infer_types_or_consts() {
|
if !ty.has_non_region_infer() {
|
||||||
debug!("no inference var, nothing needs doing");
|
debug!("no inference var, nothing needs doing");
|
||||||
return ty;
|
return ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If `ty` is a type variable, see whether we already know what it is.
|
// If `ty` is a type variable, see whether we already know what it is.
|
||||||
ty = self.resolve_vars_if_possible(ty);
|
ty = self.resolve_vars_if_possible(ty);
|
||||||
if !ty.has_infer_types_or_consts() {
|
if !ty.has_non_region_infer() {
|
||||||
debug!(?ty);
|
debug!(?ty);
|
||||||
return ty;
|
return ty;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let get_operand_ty = |expr| {
|
let get_operand_ty = |expr| {
|
||||||
let ty = self.typeck_results.borrow().expr_ty_adjusted(expr);
|
let ty = self.typeck_results.borrow().expr_ty_adjusted(expr);
|
||||||
let ty = self.resolve_vars_if_possible(ty);
|
let ty = self.resolve_vars_if_possible(ty);
|
||||||
if ty.has_infer_types_or_consts() {
|
if ty.has_non_region_infer() {
|
||||||
assert!(self.is_tainted_by_errors());
|
assert!(self.is_tainted_by_errors());
|
||||||
self.tcx.ty_error()
|
self.tcx.ty_error()
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,7 +149,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||||||
target_features: &FxHashSet<Symbol>,
|
target_features: &FxHashSet<Symbol>,
|
||||||
) -> Option<InlineAsmType> {
|
) -> Option<InlineAsmType> {
|
||||||
let ty = (self.get_operand_ty)(expr);
|
let ty = (self.get_operand_ty)(expr);
|
||||||
if ty.has_infer_types_or_consts() {
|
if ty.has_non_region_infer() {
|
||||||
bug!("inference variable in asm operand ty: {:?} {:?}", expr, ty);
|
bug!("inference variable in asm operand ty: {:?} {:?}", expr, ty);
|
||||||
}
|
}
|
||||||
let asm_ty_isize = match self.tcx.sess.target.pointer_width {
|
let asm_ty_isize = match self.tcx.sess.target.pointer_width {
|
||||||
|
@ -471,7 +471,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// This has nothing here because it means we did string
|
// This has nothing here because it means we did string
|
||||||
// concatenation (e.g., "Hello " + "World!"). This means
|
// concatenation (e.g., "Hello " + "World!"). This means
|
||||||
// we don't want the note in the else clause to be emitted
|
// we don't want the note in the else clause to be emitted
|
||||||
} else if lhs_ty.has_param_types_or_consts() {
|
} else if lhs_ty.has_non_region_param() {
|
||||||
// Look for a TraitPredicate in the Fulfillment errors,
|
// Look for a TraitPredicate in the Fulfillment errors,
|
||||||
// and use it to generate a suggestion.
|
// and use it to generate a suggestion.
|
||||||
//
|
//
|
||||||
@ -657,7 +657,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
format!("cannot apply unary operator `{}`", op.as_str()),
|
format!("cannot apply unary operator `{}`", op.as_str()),
|
||||||
);
|
);
|
||||||
|
|
||||||
if operand_ty.has_param_types_or_consts() {
|
if operand_ty.has_non_region_param() {
|
||||||
let predicates = errors.iter().filter_map(|error| {
|
let predicates = errors.iter().filter_map(|error| {
|
||||||
error.obligation.predicate.to_opt_poly_trait_pred()
|
error.obligation.predicate.to_opt_poly_trait_pred()
|
||||||
});
|
});
|
||||||
|
@ -1428,9 +1428,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
|
|||||||
let substituted_pred = predicates.rebind(pred).subst(tcx, substs);
|
let substituted_pred = predicates.rebind(pred).subst(tcx, substs);
|
||||||
// Don't check non-defaulted params, dependent defaults (including lifetimes)
|
// Don't check non-defaulted params, dependent defaults (including lifetimes)
|
||||||
// or preds with multiple params.
|
// or preds with multiple params.
|
||||||
if substituted_pred.has_param_types_or_consts()
|
if substituted_pred.has_non_region_param() || param_count.params.len() > 1 || has_region
|
||||||
|| param_count.params.len() > 1
|
|
||||||
|| has_region
|
|
||||||
{
|
{
|
||||||
None
|
None
|
||||||
} else if predicates.0.predicates.iter().any(|&(p, _)| p == substituted_pred) {
|
} else if predicates.0.predicates.iter().any(|&(p, _)| p == substituted_pred) {
|
||||||
|
@ -712,9 +712,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
) -> bool {
|
) -> bool {
|
||||||
// Reject any attempt to unify two unevaluated constants that contain inference
|
// Reject any attempt to unify two unevaluated constants that contain inference
|
||||||
// variables, since inference variables in queries lead to ICEs.
|
// variables, since inference variables in queries lead to ICEs.
|
||||||
if a.substs.has_infer_types_or_consts()
|
if a.substs.has_non_region_infer()
|
||||||
|| b.substs.has_infer_types_or_consts()
|
|| b.substs.has_non_region_infer()
|
||||||
|| param_env.has_infer_types_or_consts()
|
|| param_env.has_non_region_infer()
|
||||||
{
|
{
|
||||||
debug!("a or b or param_env contain infer vars in its substs -> cannot unify");
|
debug!("a or b or param_env contain infer vars in its substs -> cannot unify");
|
||||||
return false;
|
return false;
|
||||||
@ -1734,7 +1734,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
// Postpone the evaluation of constants whose substs depend on inference
|
// Postpone the evaluation of constants whose substs depend on inference
|
||||||
// variables
|
// variables
|
||||||
if substs.has_infer_types_or_consts() {
|
if substs.has_non_region_infer() {
|
||||||
let ac = AbstractConst::new(self.tcx, unevaluated);
|
let ac = AbstractConst::new(self.tcx, unevaluated);
|
||||||
match ac {
|
match ac {
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
@ -2072,21 +2072,17 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
|
|||||||
) -> SubstsRef<'tcx> {
|
) -> SubstsRef<'tcx> {
|
||||||
tcx.mk_substs(substs.iter().enumerate().map(|(idx, arg)| {
|
tcx.mk_substs(substs.iter().enumerate().map(|(idx, arg)| {
|
||||||
match arg.unpack() {
|
match arg.unpack() {
|
||||||
GenericArgKind::Type(_)
|
GenericArgKind::Type(_) if arg.has_non_region_param() || arg.has_non_region_infer() => {
|
||||||
if arg.has_param_types_or_consts() || arg.has_infer_types_or_consts() =>
|
|
||||||
{
|
|
||||||
tcx.mk_ty(ty::Placeholder(ty::PlaceholderType {
|
tcx.mk_ty(ty::Placeholder(ty::PlaceholderType {
|
||||||
universe: ty::UniverseIndex::ROOT,
|
universe: ty::UniverseIndex::ROOT,
|
||||||
name: ty::BoundVar::from_usize(idx),
|
name: ty::BoundVar::from_usize(idx),
|
||||||
}))
|
}))
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
GenericArgKind::Const(ct)
|
GenericArgKind::Const(ct) if ct.has_non_region_infer() || ct.has_non_region_param() => {
|
||||||
if ct.has_infer_types_or_consts() || ct.has_param_types_or_consts() =>
|
|
||||||
{
|
|
||||||
let ty = ct.ty();
|
let ty = ct.ty();
|
||||||
// If the type references param or infer, replace that too...
|
// If the type references param or infer, replace that too...
|
||||||
if ty.has_param_types_or_consts() || ty.has_infer_types_or_consts() {
|
if ty.has_non_region_param() || ty.has_non_region_infer() {
|
||||||
bug!("const `{ct}`'s type should not reference params or types");
|
bug!("const `{ct}`'s type should not reference params or types");
|
||||||
}
|
}
|
||||||
tcx.mk_const(ty::ConstS {
|
tcx.mk_const(ty::ConstS {
|
||||||
|
@ -357,7 +357,7 @@ where
|
|||||||
// In NLL, we don't have type inference variables
|
// In NLL, we don't have type inference variables
|
||||||
// floating around, so we can do this rather imprecise
|
// floating around, so we can do this rather imprecise
|
||||||
// variant of the occurs-check.
|
// variant of the occurs-check.
|
||||||
assert!(!generalized_ty.has_infer_types_or_consts());
|
assert!(!generalized_ty.has_non_region_infer());
|
||||||
}
|
}
|
||||||
|
|
||||||
self.infcx.inner.borrow_mut().type_variables().instantiate(vid, generalized_ty);
|
self.infcx.inner.borrow_mut().type_variables().instantiate(vid, generalized_ty);
|
||||||
|
@ -32,7 +32,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
if !t.has_infer_types_or_consts() {
|
if !t.has_non_region_infer() {
|
||||||
t // micro-optimize -- if there is nothing in this type that this fold affects...
|
t // micro-optimize -- if there is nothing in this type that this fold affects...
|
||||||
} else {
|
} else {
|
||||||
let t = self.infcx.shallow_resolve(t);
|
let t = self.infcx.shallow_resolve(t);
|
||||||
@ -41,7 +41,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fold_const(&mut self, ct: Const<'tcx>) -> Const<'tcx> {
|
fn fold_const(&mut self, ct: Const<'tcx>) -> Const<'tcx> {
|
||||||
if !ct.has_infer_types_or_consts() {
|
if !ct.has_non_region_infer() {
|
||||||
ct // micro-optimize -- if there is nothing in this const that this fold affects...
|
ct // micro-optimize -- if there is nothing in this const that this fold affects...
|
||||||
} else {
|
} else {
|
||||||
let ct = self.infcx.shallow_resolve(ct);
|
let ct = self.infcx.shallow_resolve(ct);
|
||||||
|
@ -45,7 +45,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
//
|
//
|
||||||
// When trying to evaluate constants containing inference variables,
|
// When trying to evaluate constants containing inference variables,
|
||||||
// use `Infcx::const_eval_resolve` instead.
|
// use `Infcx::const_eval_resolve` instead.
|
||||||
if ct.substs.has_infer_types_or_consts() {
|
if ct.substs.has_non_region_infer() {
|
||||||
bug!("did not expect inference variables here");
|
bug!("did not expect inference variables here");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
//
|
//
|
||||||
// When trying to evaluate constants containing inference variables,
|
// When trying to evaluate constants containing inference variables,
|
||||||
// use `Infcx::const_eval_resolve` instead.
|
// use `Infcx::const_eval_resolve` instead.
|
||||||
if ct.substs.has_infer_types_or_consts() {
|
if ct.substs.has_non_region_infer() {
|
||||||
bug!("did not expect inference variables here");
|
bug!("did not expect inference variables here");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ impl<'tcx> Body<'tcx> {
|
|||||||
is_polymorphic: false,
|
is_polymorphic: false,
|
||||||
tainted_by_errors,
|
tainted_by_errors,
|
||||||
};
|
};
|
||||||
body.is_polymorphic = body.has_param_types_or_consts();
|
body.is_polymorphic = body.has_non_region_param();
|
||||||
body
|
body
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ impl<'tcx> Body<'tcx> {
|
|||||||
is_polymorphic: false,
|
is_polymorphic: false,
|
||||||
tainted_by_errors: None,
|
tainted_by_errors: None,
|
||||||
};
|
};
|
||||||
body.is_polymorphic = body.has_param_types_or_consts();
|
body.is_polymorphic = body.has_non_region_param();
|
||||||
body
|
body
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2760,7 +2760,7 @@ fn pretty_print_const_value<'tcx>(
|
|||||||
}
|
}
|
||||||
// Aggregates, printed as array/tuple/struct/variant construction syntax.
|
// Aggregates, printed as array/tuple/struct/variant construction syntax.
|
||||||
//
|
//
|
||||||
// NB: the `has_param_types_or_consts` check ensures that we can use
|
// NB: the `has_non_region_param` check ensures that we can use
|
||||||
// the `destructure_const` query with an empty `ty::ParamEnv` without
|
// the `destructure_const` query with an empty `ty::ParamEnv` without
|
||||||
// introducing ICEs (e.g. via `layout_of`) from missing bounds.
|
// introducing ICEs (e.g. via `layout_of`) from missing bounds.
|
||||||
// E.g. `transmute([0usize; 2]): (u8, *mut T)` needs to know `T: Sized`
|
// E.g. `transmute([0usize; 2]): (u8, *mut T)` needs to know `T: Sized`
|
||||||
@ -2768,7 +2768,7 @@ fn pretty_print_const_value<'tcx>(
|
|||||||
//
|
//
|
||||||
// FIXME(eddyb) for `--emit=mir`/`-Z dump-mir`, we should provide the
|
// FIXME(eddyb) for `--emit=mir`/`-Z dump-mir`, we should provide the
|
||||||
// correct `ty::ParamEnv` to allow printing *all* constant values.
|
// correct `ty::ParamEnv` to allow printing *all* constant values.
|
||||||
(_, ty::Array(..) | ty::Tuple(..) | ty::Adt(..)) if !ty.has_param_types_or_consts() => {
|
(_, ty::Array(..) | ty::Tuple(..) | ty::Adt(..)) if !ty.has_non_region_param() => {
|
||||||
let ct = tcx.lift(ct).unwrap();
|
let ct = tcx.lift(ct).unwrap();
|
||||||
let ty = tcx.lift(ty).unwrap();
|
let ty = tcx.lift(ty).unwrap();
|
||||||
if let Some(contents) = tcx.try_destructure_mir_constant(
|
if let Some(contents) = tcx.try_destructure_mir_constant(
|
||||||
|
@ -71,16 +71,16 @@ impl<'tcx> AbstractConst<'tcx> {
|
|||||||
walk_abstract_const::<!, _>(tcx, self, |node| {
|
walk_abstract_const::<!, _>(tcx, self, |node| {
|
||||||
match node.root(tcx) {
|
match node.root(tcx) {
|
||||||
Node::Leaf(leaf) => {
|
Node::Leaf(leaf) => {
|
||||||
if leaf.has_infer_types_or_consts() {
|
if leaf.has_non_region_infer() {
|
||||||
failure_kind = FailureKind::MentionsInfer;
|
failure_kind = FailureKind::MentionsInfer;
|
||||||
} else if leaf.has_param_types_or_consts() {
|
} else if leaf.has_non_region_param() {
|
||||||
failure_kind = cmp::min(failure_kind, FailureKind::MentionsParam);
|
failure_kind = cmp::min(failure_kind, FailureKind::MentionsParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Node::Cast(_, _, ty) => {
|
Node::Cast(_, _, ty) => {
|
||||||
if ty.has_infer_types_or_consts() {
|
if ty.has_non_region_infer() {
|
||||||
failure_kind = FailureKind::MentionsInfer;
|
failure_kind = FailureKind::MentionsInfer;
|
||||||
} else if ty.has_param_types_or_consts() {
|
} else if ty.has_non_region_param() {
|
||||||
failure_kind = cmp::min(failure_kind, FailureKind::MentionsParam);
|
failure_kind = cmp::min(failure_kind, FailureKind::MentionsParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ pub fn simplify_type<'tcx>(
|
|||||||
// don't unify with anything else as long as they are fully normalized.
|
// don't unify with anything else as long as they are fully normalized.
|
||||||
//
|
//
|
||||||
// We will have to be careful with lazy normalization here.
|
// We will have to be careful with lazy normalization here.
|
||||||
TreatParams::AsPlaceholder if !ty.has_infer_types_or_consts() => {
|
TreatParams::AsPlaceholder if !ty.has_non_region_infer() => {
|
||||||
debug!("treating `{}` as a placeholder", ty);
|
debug!("treating `{}` as a placeholder", ty);
|
||||||
Some(PlaceholderSimplifiedType)
|
Some(PlaceholderSimplifiedType)
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
|
|||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
) -> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
|
) -> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
|
||||||
debug_assert!(!ty.has_infer_types_or_consts());
|
debug_assert!(!ty.has_non_region_infer());
|
||||||
|
|
||||||
// First try computing a static layout.
|
// First try computing a static layout.
|
||||||
let err = match tcx.layout_of(param_env.and(ty)) {
|
let err = match tcx.layout_of(param_env.and(ty)) {
|
||||||
@ -260,7 +260,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
|
|||||||
let tail = tcx.struct_tail_erasing_lifetimes(pointee, param_env);
|
let tail = tcx.struct_tail_erasing_lifetimes(pointee, param_env);
|
||||||
match tail.kind() {
|
match tail.kind() {
|
||||||
ty::Param(_) | ty::Projection(_) => {
|
ty::Param(_) | ty::Projection(_) => {
|
||||||
debug_assert!(tail.has_param_types_or_consts());
|
debug_assert!(tail.has_non_region_param());
|
||||||
Ok(SizeSkeleton::Pointer { non_zero, tail: tcx.erase_regions(tail) })
|
Ok(SizeSkeleton::Pointer { non_zero, tail: tcx.erase_regions(tail) })
|
||||||
}
|
}
|
||||||
_ => bug!(
|
_ => bug!(
|
||||||
|
@ -104,8 +104,8 @@ pub trait TypeVisitable<'tcx>: fmt::Debug + Clone {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn has_param_types_or_consts(&self) -> bool {
|
fn has_non_region_param(&self) -> bool {
|
||||||
self.has_type_flags(TypeFlags::HAS_TY_PARAM | TypeFlags::HAS_CT_PARAM)
|
self.has_type_flags(TypeFlags::NEEDS_SUBST - TypeFlags::HAS_RE_PARAM)
|
||||||
}
|
}
|
||||||
fn has_infer_regions(&self) -> bool {
|
fn has_infer_regions(&self) -> bool {
|
||||||
self.has_type_flags(TypeFlags::HAS_RE_INFER)
|
self.has_type_flags(TypeFlags::HAS_RE_INFER)
|
||||||
@ -113,8 +113,8 @@ pub trait TypeVisitable<'tcx>: fmt::Debug + Clone {
|
|||||||
fn has_infer_types(&self) -> bool {
|
fn has_infer_types(&self) -> bool {
|
||||||
self.has_type_flags(TypeFlags::HAS_TY_INFER)
|
self.has_type_flags(TypeFlags::HAS_TY_INFER)
|
||||||
}
|
}
|
||||||
fn has_infer_types_or_consts(&self) -> bool {
|
fn has_non_region_infer(&self) -> bool {
|
||||||
self.has_type_flags(TypeFlags::HAS_TY_INFER | TypeFlags::HAS_CT_INFER)
|
self.has_type_flags(TypeFlags::NEEDS_INFER - TypeFlags::HAS_RE_INFER)
|
||||||
}
|
}
|
||||||
fn needs_infer(&self) -> bool {
|
fn needs_infer(&self) -> bool {
|
||||||
self.has_type_flags(TypeFlags::NEEDS_INFER)
|
self.has_type_flags(TypeFlags::NEEDS_INFER)
|
||||||
|
@ -290,7 +290,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
|
|||||||
impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
|
impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
|
||||||
#[instrument(level = "debug", skip(self))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
fn visit_const(&mut self, c: Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_const(&mut self, c: Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
if !c.has_param_types_or_consts() {
|
if !c.has_non_region_param() {
|
||||||
return ControlFlow::CONTINUE;
|
return ControlFlow::CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_mir_const(&mut self, constant: ConstantKind<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_mir_const(&mut self, constant: ConstantKind<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
if !constant.has_param_types_or_consts() {
|
if !constant.has_non_region_param() {
|
||||||
return ControlFlow::CONTINUE;
|
return ControlFlow::CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
|
|||||||
|
|
||||||
#[instrument(level = "debug", skip(self))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
if !ty.has_param_types_or_consts() {
|
if !ty.has_non_region_param() {
|
||||||
return ControlFlow::CONTINUE;
|
return ControlFlow::CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +373,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for HasUsedGenericParams<'a> {
|
|||||||
|
|
||||||
#[instrument(level = "debug", skip(self))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
fn visit_const(&mut self, c: Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_const(&mut self, c: Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
if !c.has_param_types_or_consts() {
|
if !c.has_non_region_param() {
|
||||||
return ControlFlow::CONTINUE;
|
return ControlFlow::CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for HasUsedGenericParams<'a> {
|
|||||||
|
|
||||||
#[instrument(level = "debug", skip(self))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
if !ty.has_param_types_or_consts() {
|
if !ty.has_non_region_param() {
|
||||||
return ControlFlow::CONTINUE;
|
return ControlFlow::CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
|
|||||||
|
|
||||||
// Encode impl generic params if the substitutions contain parameters (implying
|
// Encode impl generic params if the substitutions contain parameters (implying
|
||||||
// polymorphization is enabled) and this isn't an inherent impl.
|
// polymorphization is enabled) and this isn't an inherent impl.
|
||||||
if impl_trait_ref.is_some() && substs.iter().any(|a| a.has_param_types_or_consts()) {
|
if impl_trait_ref.is_some() && substs.iter().any(|a| a.has_non_region_param()) {
|
||||||
self = self.path_generic_args(
|
self = self.path_generic_args(
|
||||||
|this| {
|
|this| {
|
||||||
this.path_append_ns(
|
this.path_append_ns(
|
||||||
|
@ -236,9 +236,9 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Err(ErrorHandled::TooGeneric) => {
|
Err(ErrorHandled::TooGeneric) => {
|
||||||
let err = if uv.has_infer_types_or_consts() {
|
let err = if uv.has_non_region_infer() {
|
||||||
NotConstEvaluatable::MentionsInfer
|
NotConstEvaluatable::MentionsInfer
|
||||||
} else if uv.has_param_types_or_consts() {
|
} else if uv.has_non_region_param() {
|
||||||
NotConstEvaluatable::MentionsParam
|
NotConstEvaluatable::MentionsParam
|
||||||
} else {
|
} else {
|
||||||
let guar = infcx.tcx.sess.delay_span_bug(span, format!("Missing value for constant, but no error reported?"));
|
let guar = infcx.tcx.sess.delay_span_bug(span, format!("Missing value for constant, but no error reported?"));
|
||||||
@ -254,7 +254,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
|
|||||||
}
|
}
|
||||||
Err(ErrorHandled::Reported(e)) => Err(NotConstEvaluatable::Error(e)),
|
Err(ErrorHandled::Reported(e)) => Err(NotConstEvaluatable::Error(e)),
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
if uv.substs.has_param_types_or_consts() {
|
if uv.substs.has_non_region_param() {
|
||||||
assert!(matches!(infcx.tcx.def_kind(uv.def.did), DefKind::AnonConst));
|
assert!(matches!(infcx.tcx.def_kind(uv.def.did), DefKind::AnonConst));
|
||||||
let mir_body = infcx.tcx.mir_for_ctfe_opt_const_arg(uv.def);
|
let mir_body = infcx.tcx.mir_for_ctfe_opt_const_arg(uv.def);
|
||||||
|
|
||||||
|
@ -661,7 +661,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if !trait_ref.has_infer_types_or_consts()
|
} else if !trait_ref.has_non_region_infer()
|
||||||
&& self.predicate_can_apply(obligation.param_env, trait_ref)
|
&& self.predicate_can_apply(obligation.param_env, trait_ref)
|
||||||
{
|
{
|
||||||
// If a where-clause may be useful, remind the
|
// If a where-clause may be useful, remind the
|
||||||
@ -2093,7 +2093,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
// Pick the first substitution that still contains inference variables as the one
|
// Pick the first substitution that still contains inference variables as the one
|
||||||
// we're going to emit an error for. If there are none (see above), fall back to
|
// we're going to emit an error for. If there are none (see above), fall back to
|
||||||
// a more general error.
|
// a more general error.
|
||||||
let subst = data.trait_ref.substs.iter().find(|s| s.has_infer_types_or_consts());
|
let subst = data.trait_ref.substs.iter().find(|s| s.has_non_region_infer());
|
||||||
|
|
||||||
let mut err = if let Some(subst) = subst {
|
let mut err = if let Some(subst) = subst {
|
||||||
self.emit_inference_failure_err(body_id, span, subst, ErrorCode::E0283, true)
|
self.emit_inference_failure_err(body_id, span, subst, ErrorCode::E0283, true)
|
||||||
@ -2323,7 +2323,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
.substs
|
.substs
|
||||||
.iter()
|
.iter()
|
||||||
.chain(Some(data.term.into_arg()))
|
.chain(Some(data.term.into_arg()))
|
||||||
.find(|g| g.has_infer_types_or_consts());
|
.find(|g| g.has_non_region_infer());
|
||||||
if let Some(subst) = subst {
|
if let Some(subst) = subst {
|
||||||
let mut err = self.emit_inference_failure_err(
|
let mut err = self.emit_inference_failure_err(
|
||||||
body_id,
|
body_id,
|
||||||
@ -2352,7 +2352,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
if predicate.references_error() || self.is_tainted_by_errors() {
|
if predicate.references_error() || self.is_tainted_by_errors() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let subst = data.substs.iter().find(|g| g.has_infer_types_or_consts());
|
let subst = data.substs.iter().find(|g| g.has_non_region_infer());
|
||||||
if let Some(subst) = subst {
|
if let Some(subst) = subst {
|
||||||
let err = self.emit_inference_failure_err(
|
let err = self.emit_inference_failure_err(
|
||||||
body_id,
|
body_id,
|
||||||
|
@ -1231,7 +1231,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let trait_pred = self.resolve_vars_if_possible(trait_pred);
|
let trait_pred = self.resolve_vars_if_possible(trait_pred);
|
||||||
if trait_pred.has_infer_types_or_consts() {
|
if trait_pred.has_non_region_infer() {
|
||||||
// Do not ICE while trying to find if a reborrow would succeed on a trait with
|
// Do not ICE while trying to find if a reborrow would succeed on a trait with
|
||||||
// unresolved bindings.
|
// unresolved bindings.
|
||||||
return;
|
return;
|
||||||
|
@ -279,7 +279,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
|||||||
|
|
||||||
debug!(?obligation, "pre-resolve");
|
debug!(?obligation, "pre-resolve");
|
||||||
|
|
||||||
if obligation.predicate.has_infer_types_or_consts() {
|
if obligation.predicate.has_non_region_infer() {
|
||||||
obligation.predicate =
|
obligation.predicate =
|
||||||
self.selcx.infcx().resolve_vars_if_possible(obligation.predicate);
|
self.selcx.infcx().resolve_vars_if_possible(obligation.predicate);
|
||||||
}
|
}
|
||||||
@ -569,7 +569,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
(Err(ErrorHandled::TooGeneric), _) | (_, Err(ErrorHandled::TooGeneric)) => {
|
(Err(ErrorHandled::TooGeneric), _) | (_, Err(ErrorHandled::TooGeneric)) => {
|
||||||
if c1.has_infer_types_or_consts() || c2.has_infer_types_or_consts() {
|
if c1.has_non_region_infer() || c2.has_non_region_infer() {
|
||||||
ProcessResult::Unchanged
|
ProcessResult::Unchanged
|
||||||
} else {
|
} else {
|
||||||
// Two different constants using generic parameters ~> error.
|
// Two different constants using generic parameters ~> error.
|
||||||
@ -726,11 +726,11 @@ fn substs_infer_vars<'a, 'tcx>(
|
|||||||
.resolve_vars_if_possible(substs)
|
.resolve_vars_if_possible(substs)
|
||||||
.skip_binder() // ok because this check doesn't care about regions
|
.skip_binder() // ok because this check doesn't care about regions
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|arg| arg.has_infer_types_or_consts())
|
.filter(|arg| arg.has_non_region_infer())
|
||||||
.flat_map(|arg| {
|
.flat_map(|arg| {
|
||||||
let mut walker = arg.walk();
|
let mut walker = arg.walk();
|
||||||
while let Some(c) = walker.next() {
|
while let Some(c) = walker.next() {
|
||||||
if !c.has_infer_types_or_consts() {
|
if !c.has_non_region_infer() {
|
||||||
walker.visited.remove(&c);
|
walker.visited.remove(&c);
|
||||||
walker.skip_current_subtree();
|
walker.skip_current_subtree();
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ pub fn can_type_implement_copy<'tcx>(
|
|||||||
// to begin with, and point to the bad field's span instead.
|
// to begin with, and point to the bad field's span instead.
|
||||||
let cause = if field
|
let cause = if field
|
||||||
.ty(tcx, traits::InternalSubsts::identity_for_item(tcx, adt.did()))
|
.ty(tcx, traits::InternalSubsts::identity_for_item(tcx, adt.did()))
|
||||||
.has_param_types_or_consts()
|
.has_non_region_param()
|
||||||
{
|
{
|
||||||
parent_cause.clone()
|
parent_cause.clone()
|
||||||
} else {
|
} else {
|
||||||
|
@ -170,7 +170,7 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'tcx>(
|
|||||||
result
|
result
|
||||||
);
|
);
|
||||||
|
|
||||||
if result && ty.has_infer_types_or_consts() {
|
if result && ty.has_non_region_infer() {
|
||||||
// Because of inference "guessing", selection can sometimes claim
|
// Because of inference "guessing", selection can sometimes claim
|
||||||
// to succeed while the success requires a guess. To ensure
|
// to succeed while the success requires a guess. To ensure
|
||||||
// this function's result remains infallible, we must confirm
|
// this function's result remains infallible, we must confirm
|
||||||
|
@ -1488,7 +1488,7 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
|
|||||||
candidate_set.push_candidate(ctor(data));
|
candidate_set.push_candidate(ctor(data));
|
||||||
|
|
||||||
if potentially_unnormalized_candidates
|
if potentially_unnormalized_candidates
|
||||||
&& !obligation.predicate.has_infer_types_or_consts()
|
&& !obligation.predicate.has_non_region_infer()
|
||||||
{
|
{
|
||||||
// HACK: Pick the first trait def candidate for a fully
|
// HACK: Pick the first trait def candidate for a fully
|
||||||
// inferred predicate. This is to allow duplicates that
|
// inferred predicate. This is to allow duplicates that
|
||||||
|
@ -174,7 +174,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
|
|
||||||
debug!(?stack, ?candidates, "winnowed to {} candidates", candidates.len());
|
debug!(?stack, ?candidates, "winnowed to {} candidates", candidates.len());
|
||||||
|
|
||||||
let needs_infer = stack.obligation.predicate.has_infer_types_or_consts();
|
let needs_infer = stack.obligation.predicate.has_non_region_infer();
|
||||||
|
|
||||||
// If there are STILL multiple candidates, we can further
|
// If there are STILL multiple candidates, we can further
|
||||||
// reduce the list by dropping duplicates -- including
|
// reduce the list by dropping duplicates -- including
|
||||||
@ -889,11 +889,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
obligation: &TraitObligation<'tcx>,
|
obligation: &TraitObligation<'tcx>,
|
||||||
candidates: &mut SelectionCandidateSet<'tcx>,
|
candidates: &mut SelectionCandidateSet<'tcx>,
|
||||||
) {
|
) {
|
||||||
if obligation.has_param_types_or_consts() {
|
if obligation.has_non_region_param() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if obligation.has_infer_types_or_consts() {
|
if obligation.has_non_region_infer() {
|
||||||
candidates.ambiguous = true;
|
candidates.ambiguous = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -728,7 +728,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
(Err(ErrorHandled::TooGeneric), _) | (_, Err(ErrorHandled::TooGeneric)) => {
|
(Err(ErrorHandled::TooGeneric), _) | (_, Err(ErrorHandled::TooGeneric)) => {
|
||||||
if c1.has_infer_types_or_consts() || c2.has_infer_types_or_consts() {
|
if c1.has_non_region_infer() || c2.has_non_region_infer() {
|
||||||
Ok(EvaluatedToAmbig)
|
Ok(EvaluatedToAmbig)
|
||||||
} else {
|
} else {
|
||||||
// Two different constants using generic parameters ~> error.
|
// Two different constants using generic parameters ~> error.
|
||||||
@ -1520,7 +1520,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
if !generics.params.is_empty()
|
if !generics.params.is_empty()
|
||||||
&& obligation.predicate.substs[generics.parent_count..]
|
&& obligation.predicate.substs[generics.parent_count..]
|
||||||
.iter()
|
.iter()
|
||||||
.any(|&p| p.has_infer_types_or_consts() && self.infcx.shallow_resolve(p) != p)
|
.any(|&p| p.has_non_region_infer() && self.infcx.shallow_resolve(p) != p)
|
||||||
{
|
{
|
||||||
ProjectionMatchesProjection::Ambiguous
|
ProjectionMatchesProjection::Ambiguous
|
||||||
} else {
|
} else {
|
||||||
|
@ -79,7 +79,7 @@ fn compute_implied_outlives_bounds<'tcx>(
|
|||||||
// implied bounds in some cases, mostly when dealing with projections.
|
// implied bounds in some cases, mostly when dealing with projections.
|
||||||
fulfill_cx.register_predicate_obligations(
|
fulfill_cx.register_predicate_obligations(
|
||||||
infcx,
|
infcx,
|
||||||
obligations.iter().filter(|o| o.predicate.has_infer_types_or_consts()).cloned(),
|
obligations.iter().filter(|o| o.predicate.has_non_region_infer()).cloned(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// From the full set of obligations, just filter down to the
|
// From the full set of obligations, just filter down to the
|
||||||
|
@ -135,30 +135,30 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
|||||||
|
|
||||||
impl<'a, 'tcx> IsThirPolymorphic<'a, 'tcx> {
|
impl<'a, 'tcx> IsThirPolymorphic<'a, 'tcx> {
|
||||||
fn expr_is_poly(&mut self, expr: &thir::Expr<'tcx>) -> bool {
|
fn expr_is_poly(&mut self, expr: &thir::Expr<'tcx>) -> bool {
|
||||||
if expr.ty.has_param_types_or_consts() {
|
if expr.ty.has_non_region_param() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
thir::ExprKind::NamedConst { substs, .. } => substs.has_param_types_or_consts(),
|
thir::ExprKind::NamedConst { substs, .. } => substs.has_non_region_param(),
|
||||||
thir::ExprKind::ConstParam { .. } => true,
|
thir::ExprKind::ConstParam { .. } => true,
|
||||||
thir::ExprKind::Repeat { value, count } => {
|
thir::ExprKind::Repeat { value, count } => {
|
||||||
self.visit_expr(&self.thir()[value]);
|
self.visit_expr(&self.thir()[value]);
|
||||||
count.has_param_types_or_consts()
|
count.has_non_region_param()
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pat_is_poly(&mut self, pat: &thir::Pat<'tcx>) -> bool {
|
fn pat_is_poly(&mut self, pat: &thir::Pat<'tcx>) -> bool {
|
||||||
if pat.ty.has_param_types_or_consts() {
|
if pat.ty.has_non_region_param() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
match pat.kind {
|
match pat.kind {
|
||||||
thir::PatKind::Constant { value } => value.has_param_types_or_consts(),
|
thir::PatKind::Constant { value } => value.has_non_region_param(),
|
||||||
thir::PatKind::Range(box thir::PatRange { lo, hi, .. }) => {
|
thir::PatKind::Range(box thir::PatRange { lo, hi, .. }) => {
|
||||||
lo.has_param_types_or_consts() || hi.has_param_types_or_consts()
|
lo.has_non_region_param() || hi.has_non_region_param()
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,7 @@ fn layout_of_uncached<'tcx>(
|
|||||||
let univariant = |fields: &[TyAndLayout<'_>], repr: &ReprOptions, kind| {
|
let univariant = |fields: &[TyAndLayout<'_>], repr: &ReprOptions, kind| {
|
||||||
Ok(tcx.intern_layout(univariant_uninterned(cx, ty, fields, repr, kind)?))
|
Ok(tcx.intern_layout(univariant_uninterned(cx, ty, fields, repr, kind)?))
|
||||||
};
|
};
|
||||||
debug_assert!(!ty.has_infer_types_or_consts());
|
debug_assert!(!ty.has_non_region_infer());
|
||||||
|
|
||||||
Ok(match *ty.kind() {
|
Ok(match *ty.kind() {
|
||||||
// Basic scalars.
|
// Basic scalars.
|
||||||
@ -1688,7 +1688,7 @@ fn record_layout_for_printing_outlined<'tcx>(
|
|||||||
// Ignore layouts that are done with non-empty environments or
|
// Ignore layouts that are done with non-empty environments or
|
||||||
// non-monomorphic layouts, as the user only wants to see the stuff
|
// non-monomorphic layouts, as the user only wants to see the stuff
|
||||||
// resulting from the final codegen session.
|
// resulting from the final codegen session.
|
||||||
if layout.ty.has_param_types_or_consts() || !cx.param_env.caller_bounds().is_empty() {
|
if layout.ty.has_non_region_param() || !cx.param_env.caller_bounds().is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1238,7 +1238,7 @@ fn ty_auto_deref_stability<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, precedenc
|
|||||||
ty::Adt(..) if ty.has_placeholders() || ty.has_opaque_types() => {
|
ty::Adt(..) if ty.has_placeholders() || ty.has_opaque_types() => {
|
||||||
Position::ReborrowStable(precedence).into()
|
Position::ReborrowStable(precedence).into()
|
||||||
},
|
},
|
||||||
ty::Adt(_, substs) if substs.has_param_types_or_consts() => {
|
ty::Adt(_, substs) if substs.has_non_region_param() => {
|
||||||
TyPosition::new_deref_stable_for_result(precedence, ty)
|
TyPosition::new_deref_stable_for_result(precedence, ty)
|
||||||
},
|
},
|
||||||
ty::Bool
|
ty::Bool
|
||||||
|
Loading…
Reference in New Issue
Block a user