1
Fork 0

Avoid unnecessary rustc_span::DUMMY_SP usage.

In some cases `DUMMY_SP` is already imported. In other cases this commit
adds the necessary import, in files where `DUMMY_SP` is used more than
once.
This commit is contained in:
Nicholas Nethercote 2024-03-06 16:39:02 +11:00
parent 63f70b3d10
commit 27374a0214
13 changed files with 35 additions and 53 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,