Pass spans to perform_locally_in_new_solver · rust-lang/rust@6e1690a (original) (raw)

`@@ -5,7 +5,7 @@ use rustc_infer::traits::query::type_op::ImpliedOutlivesBounds;

`

5

5

`use rustc_middle::infer::canonical::CanonicalQueryResponse;

`

6

6

`use rustc_middle::traits::ObligationCause;

`

7

7

`use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, TypeFolder, TypeVisitableExt};

`

8

``

`-

use rustc_span::DUMMY_SP;

`

``

8

`+

use rustc_span::Span;

`

9

9

`use rustc_span::def_id::CRATE_DEF_ID;

`

10

10

`use rustc_type_ir::outlives::{Component, push_outlives_components};

`

11

11

`use smallvec::{SmallVec, smallvec};

`

`@@ -45,11 +45,12 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {

`

45

45

`fn perform_locally_with_next_solver(

`

46

46

`ocx: &ObligationCtxt<'_, 'tcx>,

`

47

47

`key: ParamEnvAnd<'tcx, Self>,

`

``

48

`+

span: Span,

`

48

49

`) -> Result<Self::QueryResponse, NoSolution> {

`

49

50

`if ocx.infcx.tcx.sess.opts.unstable_opts.no_implied_bounds_compat {

`

50

``

`-

compute_implied_outlives_bounds_inner(ocx, key.param_env, key.value.ty)

`

``

51

`+

compute_implied_outlives_bounds_inner(ocx, key.param_env, key.value.ty, span)

`

51

52

`} else {

`

52

``

`-

compute_implied_outlives_bounds_compat_inner(ocx, key.param_env, key.value.ty)

`

``

53

`+

compute_implied_outlives_bounds_compat_inner(ocx, key.param_env, key.value.ty, span)

`

53

54

`}

`

54

55

`}

`

55

56

`}

`

`@@ -58,13 +59,14 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>(

`

58

59

`ocx: &ObligationCtxt<'_, 'tcx>,

`

59

60

`param_env: ty::ParamEnv<'tcx>,

`

60

61

`ty: Ty<'tcx>,

`

``

62

`+

span: Span,

`

61

63

`) -> Result<Vec<OutlivesBound<'tcx>>, NoSolution> {

`

62

64

`let normalize_op = |ty| -> Result<_, NoSolution> {

`

63

65

`// We must normalize the type so we can compute the right outlives components.

`

64

66

`` // for example, if we have some constrained param type like T: Trait<Out = U>,

``

65

67

`` // and we know that &'a T::Out is WF, then we want to imply U: 'a.

``

66

68

`let ty = ocx

`

67

``

`-

.deeply_normalize(&ObligationCause::dummy(), param_env, ty)

`

``

69

`+

.deeply_normalize(&ObligationCause::dummy_with_span(span), param_env, ty)

`

68

70

`.map_err(|_| NoSolution)?;

`

69

71

`if !ocx.select_all_or_error().is_empty() {

`

70

72

`return Err(NoSolution);

`

`@@ -142,6 +144,7 @@ pub fn compute_implied_outlives_bounds_compat_inner<'tcx>(

`

142

144

`ocx: &ObligationCtxt<'_, 'tcx>,

`

143

145

`param_env: ty::ParamEnv<'tcx>,

`

144

146

`ty: Ty<'tcx>,

`

``

147

`+

span: Span,

`

145

148

`) -> Result<Vec<OutlivesBound<'tcx>>, NoSolution> {

`

146

149

`let tcx = ocx.infcx.tcx;

`

147

150

``

`@@ -171,8 +174,8 @@ pub fn compute_implied_outlives_bounds_compat_inner<'tcx>(

`

171

174

`// FIXME(@lcnr): It's not really "always fine", having fewer implied

`

172

175

`// bounds can be backward incompatible, e.g. #101951 was caused by

`

173

176

`` // us not dealing with inference vars in TypeOutlives predicates.

``

174

``

`-

let obligations = wf::obligations(ocx.infcx, param_env, CRATE_DEF_ID, 0, arg, DUMMY_SP)

`

175

``

`-

.unwrap_or_default();

`

``

177

`+

let obligations =

`

``

178

`+

wf::obligations(ocx.infcx, param_env, CRATE_DEF_ID, 0, arg, span).unwrap_or_default();

`

176

179

``

177

180

`for obligation in obligations {

`

178

181

`debug!(?obligation);

`

`@@ -255,7 +258,7 @@ pub fn compute_implied_outlives_bounds_compat_inner<'tcx>(

`

255

258

`` // Need to manually normalize in the new solver as wf::obligations does not.

``

256

259

`if ocx.infcx.next_trait_solver() {

`

257

260

` ty_a = ocx

`

258

``

`-

.deeply_normalize(&ObligationCause::dummy(), param_env, ty_a)

`

``

261

`+

.deeply_normalize(&ObligationCause::dummy_with_span(span), param_env, ty_a)

`

259

262

`.map_err(|_| NoSolution)?;

`

260

263

`}

`

261

264

`let mut components = smallvec![];

`