where
T: fmt::Display + TypeFoldable<'tcx>,
{
- let predicate = self.resolve_vars_if_possible(&obligation.predicate);
+ let predicate = self.resolve_vars_if_possible(obligation.predicate.clone());
let mut err = struct_span_err!(
self.tcx.sess,
obligation.cause.span,
&obligation.predicate,
&obligation.cause.code,
&mut vec![],
+ &mut Default::default(),
);
err.emit();
/// we do not suggest increasing the overflow limit, which is not
/// going to help).
fn report_overflow_error_cycle(&self, cycle: &[PredicateObligation<'tcx>]) -> ! {
- let cycle = self.resolve_vars_if_possible(&cycle.to_owned());
+ let cycle = self.resolve_vars_if_possible(cycle.to_owned());
assert!(!cycle.is_empty());
debug!("report_overflow_error_cycle: cycle={:?}", cycle);
match bound_predicate.skip_binder() {
ty::PredicateAtom::Trait(trait_predicate, _) => {
let trait_predicate = bound_predicate.rebind(trait_predicate);
- let trait_predicate = self.resolve_vars_if_possible(&trait_predicate);
+ let trait_predicate = self.resolve_vars_if_possible(trait_predicate);
if self.tcx.sess.has_errors() && trait_predicate.references_error() {
return;
err.span_label(enclosing_scope_span, s.as_str());
}
- self.suggest_dereferences(&obligation, &mut err, &trait_ref, points_at_arg);
- self.suggest_fn_call(&obligation, &mut err, &trait_ref, points_at_arg);
- self.suggest_remove_reference(&obligation, &mut err, &trait_ref);
- self.suggest_semicolon_removal(&obligation, &mut err, span, &trait_ref);
+ self.suggest_dereferences(&obligation, &mut err, trait_ref, points_at_arg);
+ self.suggest_fn_call(&obligation, &mut err, trait_ref, points_at_arg);
+ self.suggest_remove_reference(&obligation, &mut err, trait_ref);
+ self.suggest_semicolon_removal(&obligation, &mut err, span, trait_ref);
self.note_version_mismatch(&mut err, &trait_ref);
if Some(trait_ref.def_id()) == tcx.lang_items().try_trait() {
- self.suggest_await_before_try(&mut err, &obligation, &trait_ref, span);
+ self.suggest_await_before_try(&mut err, &obligation, trait_ref, span);
}
- if self.suggest_impl_trait(&mut err, span, &obligation, &trait_ref) {
+ if self.suggest_impl_trait(&mut err, span, &obligation, trait_ref) {
err.emit();
return;
}
self.suggest_change_mut(
&obligation,
&mut err,
- &trait_ref,
+ trait_ref,
points_at_arg,
);
}
ty::PredicateAtom::RegionOutlives(predicate) => {
let predicate = bound_predicate.rebind(predicate);
- let predicate = self.resolve_vars_if_possible(&predicate);
+ let predicate = self.resolve_vars_if_possible(predicate);
let err = self
.region_outlives_predicate(&obligation.cause, predicate)
.err()
}
ty::PredicateAtom::Projection(..) | ty::PredicateAtom::TypeOutlives(..) => {
- let predicate = self.resolve_vars_if_possible(&obligation.predicate);
+ let predicate = self.resolve_vars_if_possible(obligation.predicate);
struct_span_err!(
self.tcx.sess,
span,
}
}
- OutputTypeParameterMismatch(ref found_trait_ref, ref expected_trait_ref, _) => {
- let found_trait_ref = self.resolve_vars_if_possible(&*found_trait_ref);
- let expected_trait_ref = self.resolve_vars_if_possible(&*expected_trait_ref);
+ OutputTypeParameterMismatch(found_trait_ref, expected_trait_ref, _) => {
+ let found_trait_ref = self.resolve_vars_if_possible(found_trait_ref);
+ let expected_trait_ref = self.resolve_vars_if_possible(expected_trait_ref);
if expected_trait_ref.self_ty().references_error() {
return;
fn mk_trait_obligation_with_new_self_ty(
&self,
param_env: ty::ParamEnv<'tcx>,
- trait_ref: &ty::PolyTraitRef<'tcx>,
+ trait_ref: ty::PolyTraitRef<'tcx>,
new_self_ty: Ty<'tcx>,
) -> PredicateObligation<'tcx>;
obligation: &PredicateObligation<'tcx>,
error: &MismatchedProjectionTypes<'tcx>,
) {
- let predicate = self.resolve_vars_if_possible(&obligation.predicate);
+ let predicate = self.resolve_vars_if_possible(obligation.predicate);
if predicate.references_error() {
return;
let (data, _) = self.replace_bound_vars_with_fresh_vars(
obligation.cause.span,
infer::LateBoundRegionConversionTime::HigherRankedType,
- &bound_predicate.rebind(data),
+ bound_predicate.rebind(data),
);
let mut obligations = vec![];
let normalized_ty = super::normalize_projection_type(
return None;
}
}
+ if self.tcx.impl_polarity(def_id) == ty::ImplPolarity::Negative {
+ return None;
+ }
Some(imp)
})
.collect(),
- None => all_impls.map(|def_id| self.tcx.impl_trait_ref(def_id).unwrap()).collect(),
+ None => all_impls
+ .filter_map(|def_id| {
+ if self.tcx.impl_polarity(def_id) == ty::ImplPolarity::Negative {
+ return None;
+ }
+ self.tcx.impl_trait_ref(def_id)
+ })
+ .collect(),
}
}
// Sort impl candidates so that ordering is consistent for UI tests.
let mut normalized_impl_candidates =
- impl_candidates.iter().map(normalize).collect::<Vec<String>>();
+ impl_candidates.iter().copied().map(normalize).collect::<Vec<String>>();
// Sort before taking the `..end` range,
// because the ordering of `impl_candidates` may not be deterministic:
) -> Option<(String, Option<Span>)> {
match code {
&ObligationCauseCode::BuiltinDerivedObligation(ref data) => {
- let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref);
+ let parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_ref);
match self.get_parent_trait_ref(&data.parent_code) {
Some(t) => Some(t),
None => {
fn mk_trait_obligation_with_new_self_ty(
&self,
param_env: ty::ParamEnv<'tcx>,
- trait_ref: &ty::PolyTraitRef<'tcx>,
+ trait_ref: ty::PolyTraitRef<'tcx>,
new_self_ty: Ty<'tcx>,
) -> PredicateObligation<'tcx> {
assert!(!new_self_ty.has_escaping_bound_vars());
// ambiguous impls. The latter *ought* to be a
// coherence violation, so we don't report it here.
- let predicate = self.resolve_vars_if_possible(&obligation.predicate);
+ let predicate = self.resolve_vars_if_possible(obligation.predicate);
let span = obligation.cause.span;
debug!(
&mut selcx,
param_env,
ObligationCause::dummy(),
- &cleaned_pred,
+ cleaned_pred,
)
.value;
&obligation.predicate,
&obligation.cause.code,
&mut vec![],
+ &mut Default::default(),
);
self.suggest_unsized_bound_if_applicable(err, obligation);
}
cause_code: &ObligationCauseCode<'tcx>,
) -> bool {
if let ObligationCauseCode::BuiltinDerivedObligation(ref data) = cause_code {
- let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref);
+ let parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_ref);
if obligated_types.iter().any(|ot| ot == &parent_trait_ref.skip_binder().self_ty()) {
return true;