1
Fork 0

Rollup merge of #122813 - nnethercote:nicer-quals, r=compiler-errors

Qualifier tweaking

Adding and removing qualifiers in some cases that make things nicer. Details in individual commits.

r? `@compiler-errors`
This commit is contained in:
Matthias Krüger 2024-04-17 05:44:52 +02:00 committed by GitHub
commit 45940fe6d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
62 changed files with 346 additions and 399 deletions

View file

@ -8,15 +8,14 @@
//! In this case we try to build an abstract representation of this constant using
//! `thir_abstract_const` which can then be checked for structural equality with other
//! generic constants mentioned in the `caller_bounds` of the current environment.
use rustc_hir::def::DefKind;
use rustc_infer::infer::InferCtxt;
use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::traits::ObligationCause;
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
use rustc_middle::ty::{self, TyCtxt, TypeVisitable, TypeVisitableExt, TypeVisitor};
use rustc_span::Span;
use rustc_span::{Span, DUMMY_SP};
use crate::traits::ObligationCtxt;
@ -116,12 +115,12 @@ pub fn is_const_evaluatable<'tcx>(
tcx.dcx()
.struct_span_fatal(
// Slightly better span than just using `span` alone
if span == rustc_span::DUMMY_SP { tcx.def_span(uv.def) } else { span },
if span == DUMMY_SP { tcx.def_span(uv.def) } else { span },
"failed to evaluate generic const expression",
)
.with_note("the crate this constant originates from uses `#![feature(generic_const_exprs)]`")
.with_span_suggestion_verbose(
rustc_span::DUMMY_SP,
DUMMY_SP,
"consider enabling this feature",
"#![feature(generic_const_exprs)]\n",
rustc_errors::Applicability::MaybeIncorrect,

View file

@ -4251,7 +4251,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
type_diffs: &[TypeError<'tcx>],
span: Span,
prev_ty: Ty<'tcx>,
body_id: hir::HirId,
body_id: HirId,
param_env: ty::ParamEnv<'tcx>,
) -> Vec<Option<(Span, (DefId, Ty<'tcx>))>> {
let ocx = ObligationCtxt::new(self.infcx);
@ -4764,7 +4764,7 @@ impl<'v> Visitor<'v> for ReturnsVisitor<'v> {
/// Collect all the awaited expressions within the input expression.
#[derive(Default)]
struct AwaitsVisitor {
awaits: Vec<hir::HirId>,
awaits: Vec<HirId>,
}
impl<'v> Visitor<'v> for AwaitsVisitor {