Skip to content

Commit 040a5cc

Browse files
committed
Remove FullfillmentError::span method
1 parent 374ed1f commit 040a5cc

File tree

6 files changed

+17
-22
lines changed

6 files changed

+17
-22
lines changed

compiler/rustc_infer/src/traits/mod.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_middle::traits::query::NoSolution;
1717
use rustc_middle::traits::solve::Certainty;
1818
use rustc_middle::ty::error::{ExpectedFound, TypeError};
1919
use rustc_middle::ty::{self, Const, ToPredicate, Ty, TyCtxt};
20-
use rustc_span::{DesugaringKind, ExpnKind, Span};
20+
use rustc_span::Span;
2121

2222
pub use self::ImplSource::*;
2323
pub use self::SelectionError::*;
@@ -206,19 +206,6 @@ impl<'tcx> FulfillmentError<'tcx> {
206206
) -> FulfillmentError<'tcx> {
207207
FulfillmentError { obligation, code, root_obligation }
208208
}
209-
210-
pub fn span(&self) -> Span {
211-
let mut span = self.obligation.cause.span;
212-
// We want to ignore desugarings here: spans are equivalent even
213-
// if one is the result of a desugaring and the other is not.
214-
let expn_data = span.ctxt().outer_expn_data();
215-
if let ExpnKind::Desugaring(desugaring) = expn_data.kind
216-
&& DesugaringKind::QuestionMark != desugaring
217-
{
218-
span = expn_data.call_site;
219-
}
220-
span
221-
}
222209
}
223210

224211
impl<'tcx> PolyTraitObligation<'tcx> {

compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
125125
});
126126

127127
for (index, error) in errors.iter().enumerate() {
128-
error_map.entry(error.span()).or_default().push(ErrorDescriptor {
128+
error_map.entry(error.obligation.cause.span).or_default().push(ErrorDescriptor {
129129
predicate: error.obligation.predicate,
130130
index: Some(index),
131131
});
@@ -171,7 +171,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
171171
reported = Some(guar);
172172
self.reported_trait_errors
173173
.borrow_mut()
174-
.entry(error.span())
174+
.entry(error.obligation.cause.span)
175175
.or_insert_with(|| (vec![], guar))
176176
.0
177177
.push(error.obligation.predicate);
@@ -1489,7 +1489,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
14891489
error.obligation.clone(),
14901490
&error.root_obligation,
14911491
selection_error,
1492-
error.span(),
1492+
error.obligation.cause.span,
14931493
),
14941494
FulfillmentErrorCode::ProjectionError(ref e) => {
14951495
self.report_projection_error(&error.obligation, e)

tests/ui/coroutine/issue-88653.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
use std::ops::Coroutine;
77

88
fn foo(bar: bool) -> impl Coroutine<(bool,)> {
9-
//~^ ERROR: type mismatch in coroutine arguments [E0631]
10-
//~| NOTE: expected due to this
11-
//~| NOTE: expected coroutine signature `fn((bool,)) -> _`
9+
//~^ ERROR type mismatch in coroutine arguments [E0631]
10+
//~| NOTE expected due to this
11+
//~| NOTE expected coroutine signature `fn((bool,)) -> _`
12+
//~| NOTE in this expansion of desugaring of `impl Trait`
13+
//~| NOTE in this expansion of desugaring of `impl Trait`
1214
|bar| {
13-
//~^ NOTE: found signature defined here
15+
//~^ NOTE found signature defined here
1416
if bar {
1517
yield bar;
1618
}

tests/ui/for/for-c-in-str.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ fn main() {
66
//~| NOTE `&str` is not an iterator
77
//~| HELP the trait `Iterator` is not implemented for `&str`
88
//~| NOTE required for `&str` to implement `IntoIterator`
9+
//~| NOTE in this expansion of desugaring of `for` loop
10+
//~| NOTE in this expansion of desugaring of `for` loop
11+
//~| NOTE in this expansion of desugaring of `for` loop
912
println!();
1013
}
1114
}

tests/ui/iterators/float_iterator_hint.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ fn main() {
66
//~| `{float}` is not an iterator
77
//~| NOTE if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
88
//~| NOTE required for `{float}` to implement `IntoIterator`
9+
//~| NOTE in this expansion of desugaring of `for` loop
10+
//~| NOTE in this expansion of desugaring of `for` loop
11+
//~| NOTE in this expansion of desugaring of `for` loop
12+
//~| NOTE in this expansion of desugaring of `for` loop
913
println!();
1014
}
1115
}

tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a
3333
| |__________________________________________________________________________^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
3434
|
3535
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
36-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3736

3837
error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
3938
--> $DIR/issue-76168-hr-outlives-3.rs:6:1

0 commit comments

Comments
 (0)