mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +00:00
Drive-by DUMMY_SP
-> Span
and fmt changes
Noticed these while doing something else. There's no practical change, but it's preferable to use `DUMMY_SP` as little as possible, particularly when we have perfectlly useful `Span`s available.
This commit is contained in:
parent
8a497723e3
commit
b4a424feb8
@ -100,7 +100,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||||||
locations: Locations,
|
locations: Locations,
|
||||||
) {
|
) {
|
||||||
for (predicate, span) in instantiated_predicates {
|
for (predicate, span) in instantiated_predicates {
|
||||||
debug!(?predicate);
|
debug!(?span, ?predicate);
|
||||||
let category = ConstraintCategory::Predicate(span);
|
let category = ConstraintCategory::Predicate(span);
|
||||||
let predicate = self.normalize_with_category(predicate, locations, category);
|
let predicate = self.normalize_with_category(predicate, locations, category);
|
||||||
self.prove_predicate(predicate, locations, category);
|
self.prove_predicate(predicate, locations, category);
|
||||||
|
@ -8,7 +8,7 @@ use rustc_middle::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, Const
|
|||||||
use rustc_middle::traits::query::NoSolution;
|
use rustc_middle::traits::query::NoSolution;
|
||||||
use rustc_middle::traits::ObligationCause;
|
use rustc_middle::traits::ObligationCause;
|
||||||
use rustc_middle::ty::{self, GenericArgKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
|
use rustc_middle::ty::{self, GenericArgKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::Span;
|
||||||
use rustc_trait_selection::solve::deeply_normalize;
|
use rustc_trait_selection::solve::deeply_normalize;
|
||||||
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
|
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
|
||||||
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
|
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
|
||||||
@ -183,7 +183,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
|
|||||||
|
|
||||||
// we don't actually use this for anything, but
|
// we don't actually use this for anything, but
|
||||||
// the `TypeOutlives` code needs an origin.
|
// the `TypeOutlives` code needs an origin.
|
||||||
let origin = infer::RelateParamBound(DUMMY_SP, t1, None);
|
let origin = infer::RelateParamBound(self.span, t1, None);
|
||||||
|
|
||||||
TypeOutlives::new(
|
TypeOutlives::new(
|
||||||
&mut *self,
|
&mut *self,
|
||||||
|
@ -10,7 +10,7 @@ use rustc_middle::mir::ConstraintCategory;
|
|||||||
use rustc_middle::traits::query::OutlivesBound;
|
use rustc_middle::traits::query::OutlivesBound;
|
||||||
use rustc_middle::traits::ObligationCause;
|
use rustc_middle::traits::ObligationCause;
|
||||||
use rustc_middle::ty::{self, RegionVid, Ty, TypeVisitableExt};
|
use rustc_middle::ty::{self, RegionVid, Ty, TypeVisitableExt};
|
||||||
use rustc_span::{ErrorGuaranteed, DUMMY_SP};
|
use rustc_span::{ErrorGuaranteed, Span};
|
||||||
use rustc_trait_selection::solve::deeply_normalize;
|
use rustc_trait_selection::solve::deeply_normalize;
|
||||||
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
|
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
|
||||||
use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
|
use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
|
||||||
@ -269,7 +269,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
|
|||||||
debug!("build: input_or_output={:?}", ty);
|
debug!("build: input_or_output={:?}", ty);
|
||||||
// We add implied bounds from both the unnormalized and normalized ty.
|
// We add implied bounds from both the unnormalized and normalized ty.
|
||||||
// See issue #87748
|
// See issue #87748
|
||||||
let constraints_unnorm = self.add_implied_bounds(ty);
|
let constraints_unnorm = self.add_implied_bounds(ty, span);
|
||||||
if let Some(c) = constraints_unnorm {
|
if let Some(c) = constraints_unnorm {
|
||||||
constraints.push(c)
|
constraints.push(c)
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
|
|||||||
// ```
|
// ```
|
||||||
// Both &Self::Bar and &() are WF
|
// Both &Self::Bar and &() are WF
|
||||||
if ty != norm_ty {
|
if ty != norm_ty {
|
||||||
let constraints_norm = self.add_implied_bounds(norm_ty);
|
let constraints_norm = self.add_implied_bounds(norm_ty, span);
|
||||||
if let Some(c) = constraints_norm {
|
if let Some(c) = constraints_norm {
|
||||||
constraints.push(c)
|
constraints.push(c)
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
|
|||||||
|
|
||||||
// We currently add implied bounds from the normalized ty only.
|
// We currently add implied bounds from the normalized ty only.
|
||||||
// This is more conservative and matches wfcheck behavior.
|
// This is more conservative and matches wfcheck behavior.
|
||||||
let c = self.add_implied_bounds(norm_ty);
|
let c = self.add_implied_bounds(norm_ty, span);
|
||||||
constraints.extend(c);
|
constraints.extend(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,11 +361,15 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
|
|||||||
/// the same time, compute and add any implied bounds that come
|
/// the same time, compute and add any implied bounds that come
|
||||||
/// from this local.
|
/// from this local.
|
||||||
#[instrument(level = "debug", skip(self))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
fn add_implied_bounds(&mut self, ty: Ty<'tcx>) -> Option<&'tcx QueryRegionConstraints<'tcx>> {
|
fn add_implied_bounds(
|
||||||
|
&mut self,
|
||||||
|
ty: Ty<'tcx>,
|
||||||
|
span: Span,
|
||||||
|
) -> Option<&'tcx QueryRegionConstraints<'tcx>> {
|
||||||
let TypeOpOutput { output: bounds, constraints, .. } = self
|
let TypeOpOutput { output: bounds, constraints, .. } = self
|
||||||
.param_env
|
.param_env
|
||||||
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
|
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
|
||||||
.fully_perform(self.infcx, DUMMY_SP)
|
.fully_perform(self.infcx, span)
|
||||||
.map_err(|_: ErrorGuaranteed| debug!("failed to compute implied bounds {:?}", ty))
|
.map_err(|_: ErrorGuaranteed| debug!("failed to compute implied bounds {:?}", ty))
|
||||||
.ok()?;
|
.ok()?;
|
||||||
debug!(?bounds, ?constraints);
|
debug!(?bounds, ?constraints);
|
||||||
|
@ -37,7 +37,7 @@ use rustc_mir_dataflow::points::DenseLocationMap;
|
|||||||
use rustc_span::def_id::CRATE_DEF_ID;
|
use rustc_span::def_id::CRATE_DEF_ID;
|
||||||
use rustc_span::source_map::Spanned;
|
use rustc_span::source_map::Spanned;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
|
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
|
||||||
use rustc_trait_selection::traits::query::type_op::custom::scrape_region_constraints;
|
use rustc_trait_selection::traits::query::type_op::custom::scrape_region_constraints;
|
||||||
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
|
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
|
||||||
@ -1014,7 +1014,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
let mut checker = Self {
|
let mut checker = Self {
|
||||||
infcx,
|
infcx,
|
||||||
last_span: DUMMY_SP,
|
last_span: body.span,
|
||||||
body,
|
body,
|
||||||
user_type_annotations: &body.user_type_annotations,
|
user_type_annotations: &body.user_type_annotations,
|
||||||
param_env,
|
param_env,
|
||||||
@ -2766,7 +2766,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||||||
self.param_env,
|
self.param_env,
|
||||||
self.known_type_outlives_obligations,
|
self.known_type_outlives_obligations,
|
||||||
locations,
|
locations,
|
||||||
DUMMY_SP, // irrelevant; will be overridden.
|
self.body.span, // irrelevant; will be overridden.
|
||||||
ConstraintCategory::Boring, // same as above.
|
ConstraintCategory::Boring, // same as above.
|
||||||
self.borrowck_context.constraints,
|
self.borrowck_context.constraints,
|
||||||
)
|
)
|
||||||
|
@ -1630,7 +1630,7 @@ fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>(
|
|||||||
#[instrument(level = "debug", skip(tcx))]
|
#[instrument(level = "debug", skip(tcx))]
|
||||||
fn predicates_defined_on(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> {
|
fn predicates_defined_on(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> {
|
||||||
let mut result = tcx.explicit_predicates_of(def_id);
|
let mut result = tcx.explicit_predicates_of(def_id);
|
||||||
debug!("predicates_defined_on: explicit_predicates_of({:?}) = {:?}", def_id, result,);
|
debug!("predicates_defined_on: explicit_predicates_of({:?}) = {:?}", def_id, result);
|
||||||
let inferred_outlives = tcx.inferred_outlives_of(def_id);
|
let inferred_outlives = tcx.inferred_outlives_of(def_id);
|
||||||
if !inferred_outlives.is_empty() {
|
if !inferred_outlives.is_empty() {
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -405,7 +405,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
/// will instantiate fresh inference variables for each canonical
|
/// will instantiate fresh inference variables for each canonical
|
||||||
/// variable instead. Therefore, the result of this method must be
|
/// variable instead. Therefore, the result of this method must be
|
||||||
/// properly unified
|
/// properly unified
|
||||||
#[instrument(level = "debug", skip(self, cause, param_env))]
|
#[instrument(level = "debug", skip(self, param_env))]
|
||||||
fn query_response_instantiation_guess<R>(
|
fn query_response_instantiation_guess<R>(
|
||||||
&self,
|
&self,
|
||||||
cause: &ObligationCause<'tcx>,
|
cause: &ObligationCause<'tcx>,
|
||||||
|
@ -62,9 +62,10 @@ fn implied_outlives_bounds<'a, 'tcx>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut constraints = QueryRegionConstraints::default();
|
let mut constraints = QueryRegionConstraints::default();
|
||||||
|
let span = infcx.tcx.def_span(body_id);
|
||||||
let Ok(InferOk { value: mut bounds, obligations }) = infcx
|
let Ok(InferOk { value: mut bounds, obligations }) = infcx
|
||||||
.instantiate_nll_query_response_and_region_obligations(
|
.instantiate_nll_query_response_and_region_obligations(
|
||||||
&ObligationCause::dummy(),
|
&ObligationCause::dummy_with_span(span),
|
||||||
param_env,
|
param_env,
|
||||||
&canonical_var_values,
|
&canonical_var_values,
|
||||||
canonical_result,
|
canonical_result,
|
||||||
@ -80,8 +81,6 @@ fn implied_outlives_bounds<'a, 'tcx>(
|
|||||||
bounds.retain(|bound| !bound.has_placeholders());
|
bounds.retain(|bound| !bound.has_placeholders());
|
||||||
|
|
||||||
if !constraints.is_empty() {
|
if !constraints.is_empty() {
|
||||||
let span = infcx.tcx.def_span(body_id);
|
|
||||||
|
|
||||||
debug!(?constraints);
|
debug!(?constraints);
|
||||||
if !constraints.member_constraints.is_empty() {
|
if !constraints.member_constraints.is_empty() {
|
||||||
span_bug!(span, "{:#?}", constraints.member_constraints);
|
span_bug!(span, "{:#?}", constraints.member_constraints);
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ImpliedOutlivesBounds { ty: &'?2 mut StateContext<'?3, usize> } }
|
error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ImpliedOutlivesBounds { ty: &'?2 mut StateContext<'?3, usize> } }
|
||||||
|
--> $DIR/issue-80409.rs:49:30
|
||||||
|
|
|
|
||||||
= query stack during panic:
|
LL | builder.state().on_entry(|_| {});
|
||||||
|
| ^^^
|
||||||
|
|
|
||||||
|
note:
|
||||||
|
--> $DIR/issue-80409.rs:49:30
|
||||||
|
|
|
||||||
|
LL | builder.state().on_entry(|_| {});
|
||||||
|
| ^^^
|
||||||
|
|
||||||
|
query stack during panic:
|
||||||
end of query stack
|
end of query stack
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
//@[no-compat] check-fail
|
//@[no-compat] check-fail
|
||||||
//@[no-compat] known-bug: #80409
|
//@[no-compat] known-bug: #80409
|
||||||
//@[no-compat] failure-status: 101
|
//@[no-compat] failure-status: 101
|
||||||
|
//@[no-compat] normalize-stderr-test "delayed at.*" -> ""
|
||||||
//@[no-compat] normalize-stderr-test "note: .*\n\n" -> ""
|
//@[no-compat] normalize-stderr-test "note: .*\n\n" -> ""
|
||||||
//@[no-compat] normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
|
//@[no-compat] normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
|
||||||
//@[no-compat] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
|
//@[no-compat] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
|
||||||
|
Loading…
Reference in New Issue
Block a user