Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use rustc_hir::{
CoroutineDesugaring, CoroutineKind, CoroutineSource, LangItem, PatField, find_attr,
};
use rustc_index::bit_set::DenseBitSet;
use rustc_infer::traits::TraitErrors;
use rustc_middle::bug;
use rustc_middle::hir::nested_filter::OnlyBodies;
use rustc_middle::mir::{
Expand Down Expand Up @@ -1462,7 +1463,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
let cause = ObligationCause::misc(expr.span, self.mir_def_id());
ocx.register_bound(cause, self.infcx.param_env, ty, clone_trait);
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty()
if let TraitErrors::HasErrors(errors) = errors
&& errors.iter().all(|error| {
match error.obligation.predicate.as_clause().and_then(|c| c.as_trait_clause()) {
Some(clause) => match clause.self_ty().skip_binder().kind() {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1534,9 +1534,9 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
) && !has_sugg
{
let skip_for_simple_clone =
has_deref && !has_overloaded_deref && errors.is_empty();
has_deref && !has_overloaded_deref && errors.no_errors();
if !skip_for_simple_clone {
let msg = match &errors[..] {
let msg = match errors.as_slice() {
[] => "you can `clone` the value and consume it, but \
this might not be your desired behavior"
.to_string(),
Expand All @@ -1553,7 +1553,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
the following trait bounds could be satisfied: \
{}",
listify(
&errors,
errors.as_slice(),
|e: &FulfillmentError<'tcx>| format!(
"`{}`",
e.obligation.predicate
Expand All @@ -1569,7 +1569,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
Applicability::MaybeIncorrect,
);

suggested_cloning = errors.is_empty();
suggested_cloning = errors.no_errors();

for error in errors {
if let FulfillmentErrorCode::Select(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/move_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
return CloneSuggestion::NotEmitted;
};

if !errors.is_empty() {
if errors.has_errors() {
return CloneSuggestion::NotEmitted;
}
let sugg = vec![
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,8 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
match self
.infcx
.type_implements_trait_shallow(clone_trait, ty.peel_refs(), self.infcx.param_env)
.as_deref()
.as_ref()
.map(|it| it.as_slice())
{
Some([]) => {
// FIXME: This error message isn't useful, since we're just
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
)
}));

if ocx.evaluate_obligations_error_on_ambiguity().is_empty() && count > 0 {
if ocx.evaluate_obligations_error_on_ambiguity().no_errors() && count > 0 {
diag.span_suggestion_verbose(
tcx.hir_body(*body).value.peel_blocks().span.shrink_to_lo(),
msg!("dereference the return value"),
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_borrowck/src/type_check/liveness/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_index::bit_set::DenseBitSet;
use rustc_index::interval::IntervalSet;
use rustc_infer::infer::canonical::QueryRegionConstraints;
use rustc_infer::traits::TraitErrors;
use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, HasLocalDecls, Local, Location};
use rustc_middle::traits::query::DropckOutlivesResult;
use rustc_middle::ty::relate::Relate;
Expand Down Expand Up @@ -660,12 +661,12 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> {
span,
) {
Ok(_) => ocx.evaluate_obligations_error_on_ambiguity(),
Err(e) => e,
Err(e) => TraitErrors::HasErrors(e),
};

// Could have no errors if a type lowering error, say, caused the query
// to fail.
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
typeck.infcx.err_ctxt().report_fulfillment_errors(errors);
}
});
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub fn validate_trivial_unsize<'tcx>(
) else {
return false;
};
if !ocx.evaluate_obligations_error_on_ambiguity().is_empty() {
if !ocx.evaluate_obligations_error_on_ambiguity().no_errors() {
return false;
}
infcx.leak_check(universe, None).is_ok()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
}));

let errors = ocx.evaluate_obligations_error_on_ambiguity();
if errors.is_empty() {
if errors.no_errors() {
Some(ConstConditionsHold::Yes)
} else {
tcx.dcx()
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Qualif for HasMutInterior {
);
ocx.register_obligation(obligation);
let errors = ocx.evaluate_obligations_error_on_ambiguity();
!errors.is_empty()
!errors.no_errors()
}

fn is_structural_in_adt_value<'tcx>(_cx: &ConstCx<'_, 'tcx>, adt: AdtDef<'tcx>) -> bool {
Expand Down Expand Up @@ -195,7 +195,7 @@ impl Qualif for NeedsNonConstDrop {
},
),
));
!ocx.evaluate_obligations_error_on_ambiguity().is_empty()
!ocx.evaluate_obligations_error_on_ambiguity().no_errors()
}

fn is_structural_in_adt_value<'tcx>(cx: &ConstCx<'_, 'tcx>, adt: AdtDef<'tcx>) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub(crate) fn type_implements_dyn_trait<'tcx, M: Machine<'tcx>>(
});
Obligation::new(ecx.tcx.tcx, ObligationCause::dummy(), param_env, pred)
}));
let type_impls_trait = ocx.evaluate_obligations_error_on_ambiguity().is_empty();
let type_impls_trait = ocx.evaluate_obligations_error_on_ambiguity().no_errors();
// Since `assumed_wf_tys=[]` the choice of LocalDefId is irrelevant, so using the "default"
let regions_are_valid = ocx.resolve_regions(CRATE_DEF_ID, param_env, []).is_empty();

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/util/compare_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ pub fn relate_types<'tcx>(
Ok(()) => {}
Err(_) => return false,
};
ocx.evaluate_obligations_error_on_ambiguity().is_empty()
ocx.evaluate_obligations_error_on_ambiguity().no_errors()
}
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/autoderef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
ty,
);
let errors = ocx.try_evaluate_obligations();
if !errors.is_empty() {
if !errors.no_errors() {
// We shouldn't have errors here in the old solver, except for
// evaluate/fulfill mismatches, but that's not a reason for an ICE.
debug!(?errors, "encountered errors while fulfilling");
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/always_applicable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ fn ensure_impl_predicates_are_implied_by_item_defn<'tcx>(
// obligation cause code, and perhaps some custom logic in `report_region_errors`.

let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if !errors.no_errors() {
let mut guar = None;
let mut root_predicates = FxHashSet::default();
for error in errors {
Expand Down
12 changes: 8 additions & 4 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_hir::attrs::ReprAttr::ReprPacked;
use rustc_hir::def::{CtorKind, DefKind};
use rustc_hir::{LangItem, Node, find_attr, intravisit};
use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt};
use rustc_infer::traits::{Obligation, ObligationCauseCode, WellFormedLoc};
use rustc_infer::traits::{Obligation, ObligationCauseCode, TraitErrors, WellFormedLoc};
use rustc_lint_defs::builtin::UNSUPPORTED_CALLING_CONVENTIONS;
use rustc_macros::Diagnostic;
use rustc_middle::hir::nested_filter;
Expand Down Expand Up @@ -409,7 +409,7 @@ fn check_opaque_meets_bounds<'tcx>(
// Check that all obligations are satisfied by the implementation's
// version.
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
let guar = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(guar);
}
Expand Down Expand Up @@ -2292,7 +2292,7 @@ pub(super) fn check_coroutine_obligations(

let errors = ocx.evaluate_obligations_error_on_ambiguity();
debug!(?errors);
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
}

Expand Down Expand Up @@ -2336,5 +2336,9 @@ pub(super) fn check_potentially_region_dependent_goals<'tcx>(

let errors = ocx.evaluate_obligations_error_on_ambiguity();
debug!(?errors);
if errors.is_empty() { Ok(()) } else { Err(infcx.err_ctxt().report_fulfillment_errors(errors)) }
if let TraitErrors::HasErrors(errors) = errors {
Err(infcx.err_ctxt().report_fulfillment_errors(errors))
} else {
Ok(())
}
}
6 changes: 3 additions & 3 deletions compiler/rustc_hir_analysis/src/check/compare_eii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{self as hir, FnSig, HirId, ItemKind, find_attr};
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::{ObligationCause, ObligationCauseCode};
use rustc_infer::traits::{ObligationCause, ObligationCauseCode, TraitErrors};
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, TypeVisitableExt, TypingMode, Unnormalized};
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol};
Expand Down Expand Up @@ -138,7 +138,7 @@ pub(crate) fn compare_eii_function_types<'tcx>(
// Check that all obligations are satisfied by the implementation's
// version.
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
}
Expand Down Expand Up @@ -207,7 +207,7 @@ pub(crate) fn compare_eii_statics<'tcx>(
// Check that all obligations are satisfied by the implementation's
// version.
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
}
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit::VisitorExt;
use rustc_hir::{self as hir, AmbigArg, GenericParamKind, ImplItemKind, intravisit};
use rustc_infer::infer::{self, BoundRegionConversionTime, InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::util;
use rustc_infer::traits::{TraitErrors, util};
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::{
self, BottomUpFolder, GenericArgs, GenericParamDefKind, Generics, RegionExt, Ty, TyCtxt,
Expand Down Expand Up @@ -382,7 +382,7 @@ fn compare_method_clause_entailment<'tcx>(
// Check that all obligations are satisfied by the implementation's
// version.
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
}
Expand Down Expand Up @@ -691,7 +691,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
// Check that all obligations are satisfied by the implementation's
// RPITs.
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
if let Err(guar) = try_report_async_mismatch(tcx, infcx, &errors, trait_m, impl_m, impl_sig)
{
return Err(guar);
Expand Down Expand Up @@ -1277,7 +1277,7 @@ fn check_region_late_boundedness<'tcx>(
};

let errors = ocx.try_evaluate_obligations();
if !errors.is_empty() {
if !errors.no_errors() {
return None;
}

Expand Down Expand Up @@ -2294,7 +2294,7 @@ fn compare_const_clause_entailment<'tcx>(
// Check that all obligations are satisfied by the implementation's
// version.
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
}

Expand Down Expand Up @@ -2429,7 +2429,7 @@ fn compare_type_clause_entailment<'tcx>(
// Check that all obligations are satisfied by the implementation's
// version.
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
}
Expand Down Expand Up @@ -2560,7 +2560,7 @@ pub(super) fn check_type_bounds<'tcx>(
// version.
ocx.register_obligations(obligations);
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
param_env,
Unnormalized::new_wip(trait_m_sig.inputs_and_output),
));
if !ocx.evaluate_obligations_error_on_ambiguity().is_empty() {
if !ocx.evaluate_obligations_error_on_ambiguity().no_errors() {
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (selection)");
return;
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_hir_analysis/src/check/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::ops::Not;
use rustc_hir as hir;
use rustc_hir::{Node, find_attr};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_infer::traits::TraitErrors;
use rustc_middle::span_bug;
use rustc_middle::ty::{self, TyCtxt, TypingMode, Unnormalized};
use rustc_session::config::EntryFnType;
Expand Down Expand Up @@ -133,7 +134,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) -> Result<(), ErrorGuar
let norm_return_ty = ocx.normalize(&cause, param_env, Unnormalized::new_wip(return_ty));
ocx.register_bound(cause, param_env, norm_return_ty, term_did);
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::Visitor;
use rustc_index::bit_set::DenseBitSet;
use rustc_infer::infer::{self, TyCtxtInferExt as _};
use rustc_infer::traits::ObligationCause;
use rustc_infer::traits::{ObligationCause, TraitErrors};
use rustc_middle::middle::stability::EvalResult;
use rustc_middle::query::Providers;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
Expand Down Expand Up @@ -694,7 +694,7 @@ pub fn check_function_signature<'tcx>(
match ocx.eq(&cause, param_env, expected_sig, actual_sig) {
Ok(()) => {
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
}
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_hir::lang_items::LangItem;
use rustc_hir::{AmbigArg, ItemKind, find_attr};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::traits::PredicateObligations;
use rustc_infer::traits::{PredicateObligations, TraitErrors};
use rustc_lint_defs::builtin::SHADOWING_SUPERTRAIT_ITEMS;
use rustc_macros::Diagnostic;
use rustc_middle::mir::interpret::ErrorHandled;
Expand Down Expand Up @@ -178,7 +178,7 @@ where
f(&mut wfcx)?;

let errors = wfcx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if let TraitErrors::HasErrors(errors) = errors {
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
}

Expand Down Expand Up @@ -1888,7 +1888,7 @@ fn receiver_is_valid<'tcx>(
if let Ok(()) = wfcx.infcx.commit_if_ok(|_| {
let ocx = ObligationCtxt::new(wfcx.infcx);
ocx.eq(&cause, wfcx.param_env, self_ty, receiver_ty)?;
if ocx.evaluate_obligations_error_on_ambiguity().is_empty() {
if ocx.evaluate_obligations_error_on_ambiguity().no_errors() {
Ok(())
} else {
Err(NoSolution)
Expand Down Expand Up @@ -1927,7 +1927,7 @@ fn receiver_is_valid<'tcx>(
if let Ok(()) = wfcx.infcx.commit_if_ok(|_| {
let ocx = ObligationCtxt::new(wfcx.infcx);
ocx.eq(&cause, wfcx.param_env, self_ty, potential_self_ty)?;
if ocx.evaluate_obligations_error_on_ambiguity().is_empty() {
if ocx.evaluate_obligations_error_on_ambiguity().no_errors() {
Ok(())
} else {
Err(NoSolution)
Expand Down
Loading
Loading