Auto merge of #122900 - matthiaskrgr:rollup-nls90mb, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #114009 (compiler: allow transmute of ZST arrays with generics) - #122195 (Note that the caller chooses a type for type param) - #122651 (Suggest `_` for missing generic arguments in turbofish) - #122784 (Add `tag_for_variant` query) - #122839 (Split out `PredicatePolarity` from `ImplPolarity`) - #122873 (Merge my contributor emails into one using mailmap) - #122885 (Adjust better spastorino membership to triagebot's adhoc_groups) - #122888 (add a couple more tests) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::infer::region_constraints::{Constraint, RegionConstraintData};
|
||||
use crate::traits::project::ProjectAndUnifyResult;
|
||||
use rustc_infer::infer::DefineOpaqueTypes;
|
||||
use rustc_middle::mir::interpret::ErrorHandled;
|
||||
use rustc_middle::ty::{ImplPolarity, Region, RegionVid};
|
||||
use rustc_middle::ty::{Region, RegionVid};
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
||||
|
||||
@@ -96,9 +96,9 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||
ty::TraitPredicate {
|
||||
trait_ref,
|
||||
polarity: if polarity {
|
||||
ImplPolarity::Positive
|
||||
ty::PredicatePolarity::Positive
|
||||
} else {
|
||||
ImplPolarity::Negative
|
||||
ty::PredicatePolarity::Negative
|
||||
},
|
||||
},
|
||||
));
|
||||
@@ -258,7 +258,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||
trait_ref: ty::TraitRef::new(infcx.tcx, trait_did, [ty]),
|
||||
|
||||
// Auto traits are positive
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
polarity: ty::PredicatePolarity::Positive,
|
||||
}));
|
||||
|
||||
let computed_preds = param_env.caller_bounds().iter().map(|c| c.as_predicate());
|
||||
@@ -295,7 +295,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||
}) = impl_source
|
||||
{
|
||||
// Blame 'tidy' for the weird bracket placement.
|
||||
if infcx.tcx.impl_polarity(*impl_def_id) == ty::ImplPolarity::Negative {
|
||||
if infcx.tcx.impl_polarity(*impl_def_id) != ty::ImplPolarity::Positive {
|
||||
debug!(
|
||||
"evaluate_nested_obligations: found explicit negative impl\
|
||||
{:?}, bailing out",
|
||||
|
||||
@@ -206,7 +206,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
&self,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
ty: ty::Binder<'tcx, Ty<'tcx>>,
|
||||
polarity: ty::ImplPolarity,
|
||||
polarity: ty::PredicatePolarity,
|
||||
) -> Result<(ty::ClosureKind, ty::Binder<'tcx, Ty<'tcx>>), ()> {
|
||||
self.commit_if_ok(|_| {
|
||||
for trait_def_id in [
|
||||
|
||||
@@ -245,7 +245,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
associated_ty: Option<(&'static str, Ty<'tcx>)>,
|
||||
mut body_id: LocalDefId,
|
||||
) {
|
||||
if trait_pred.skip_binder().polarity == ty::ImplPolarity::Negative {
|
||||
if trait_pred.skip_binder().polarity != ty::PredicatePolarity::Positive {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4057,7 +4057,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
span,
|
||||
[*ty],
|
||||
),
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
polarity: ty::PredicatePolarity::Positive,
|
||||
});
|
||||
let Some(generics) = node.generics() else {
|
||||
continue;
|
||||
@@ -4802,7 +4802,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
|
||||
Some(desc) => format!(" {desc}"),
|
||||
None => String::new(),
|
||||
};
|
||||
if let ty::ImplPolarity::Positive = trait_predicate.polarity() {
|
||||
if let ty::PredicatePolarity::Positive = trait_predicate.polarity() {
|
||||
format!(
|
||||
"{pre_message}the trait `{}` is not implemented for{desc} `{}`{post}",
|
||||
trait_predicate.print_modifiers_and_trait_path(),
|
||||
|
||||
@@ -1905,7 +1905,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
.all_impls(trait_pred.def_id())
|
||||
.filter_map(|def_id| {
|
||||
let imp = self.tcx.impl_trait_header(def_id).unwrap();
|
||||
if imp.polarity == ty::ImplPolarity::Negative
|
||||
if imp.polarity != ty::ImplPolarity::Positive
|
||||
|| !self.tcx.is_user_visible_dep(def_id.krate)
|
||||
{
|
||||
return None;
|
||||
|
||||
@@ -584,7 +584,7 @@ fn virtual_call_violations_for_method<'tcx>(
|
||||
// implement auto traits if the underlying type does as well.
|
||||
if let ty::ClauseKind::Trait(ty::TraitPredicate {
|
||||
trait_ref: pred_trait_ref,
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
polarity: ty::PredicatePolarity::Positive,
|
||||
}) = pred.kind().skip_binder()
|
||||
&& pred_trait_ref.self_ty() == tcx.types.self_param
|
||||
&& tcx.trait_is_auto(pred_trait_ref.def_id)
|
||||
|
||||
@@ -56,7 +56,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
let mut candidates = SelectionCandidateSet { vec: Vec::new(), ambiguous: false };
|
||||
|
||||
// Negative trait predicates have different rules than positive trait predicates.
|
||||
if obligation.polarity() == ty::ImplPolarity::Negative {
|
||||
if obligation.polarity() == ty::PredicatePolarity::Negative {
|
||||
self.assemble_candidates_for_trait_alias(obligation, &mut candidates);
|
||||
self.assemble_candidates_from_impls(obligation, &mut candidates);
|
||||
self.assemble_candidates_from_caller_bounds(stack, &mut candidates)?;
|
||||
|
||||
@@ -1460,7 +1460,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
cause.span,
|
||||
[nested_ty.into(), host_effect_param],
|
||||
),
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
polarity: ty::PredicatePolarity::Positive,
|
||||
}),
|
||||
&mut nested,
|
||||
);
|
||||
@@ -1485,7 +1485,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
cause.span,
|
||||
[nested_ty.into(), host_effect_param],
|
||||
),
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
polarity: ty::PredicatePolarity::Positive,
|
||||
});
|
||||
|
||||
nested.push(Obligation::with_depth(
|
||||
|
||||
@@ -1418,10 +1418,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
|
||||
for candidate in candidates {
|
||||
if let ImplCandidate(def_id) = candidate {
|
||||
if ty::ImplPolarity::Reservation == tcx.impl_polarity(def_id)
|
||||
|| obligation.polarity() == tcx.impl_polarity(def_id)
|
||||
{
|
||||
result.push(candidate);
|
||||
match (tcx.impl_polarity(def_id), obligation.polarity()) {
|
||||
(ty::ImplPolarity::Reservation, _)
|
||||
| (ty::ImplPolarity::Positive, ty::PredicatePolarity::Positive)
|
||||
| (ty::ImplPolarity::Negative, ty::PredicatePolarity::Negative) => {
|
||||
result.push(candidate);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else {
|
||||
result.push(candidate);
|
||||
|
||||
@@ -363,7 +363,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||
|
||||
// Negative trait predicates don't require supertraits to hold, just
|
||||
// that their args are WF.
|
||||
if trait_pred.polarity == ty::ImplPolarity::Negative {
|
||||
if trait_pred.polarity == ty::PredicatePolarity::Negative {
|
||||
self.compute_negative_trait_pred(trait_ref);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user