Skip to content

Commit fac04a6

Browse files
committed
Fixing span manipulation and indentation of the suggestion introduced by rust-lang#126187
According to comments: rust-lang#128084 (comment) https://github.com/rust-lang/rust/pull/126187/files#r1634897691
1 parent 739b1fd commit fac04a6

File tree

3 files changed

+2
-10
lines changed

3 files changed

+2
-10
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4668,9 +4668,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
46684668
&& b.expr.is_none()
46694669
{
46704670
sugg_spans.push((
4671-
// The span will point to the closing curly brace `}` of the block.
4672-
b.span.shrink_to_hi().with_lo(b.span.hi() - BytePos(1)),
4673-
"\n Ok(())\n}".to_string(),
4671+
self.tcx.sess.source_map().end_point(b.span).shrink_to_lo(),
4672+
"\n Ok(())\n".to_string(),
46744673
));
46754674
}
46764675
err.multipart_suggestion_verbose(

tests/ui/return/return-from-residual-sugg-issue-125997.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ LL | let mut _file = File::create("foo.txt")?;
1414
LL |
1515
LL +
1616
LL + Ok(())
17-
LL + }
1817
|
1918

2019
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
@@ -34,7 +33,6 @@ LL |
3433
LL | println!();
3534
LL +
3635
LL + Ok(())
37-
LL + }
3836
|
3937

4038
error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `FromResidual`)
@@ -53,7 +51,6 @@ LL | let mut _file = File::create("foo.txt")?;
5351
LL |
5452
LL ~
5553
LL + Ok(())
56-
LL + }
5754
|
5855

5956
error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `FromResidual`)
@@ -73,7 +70,6 @@ LL |
7370
LL | println!();
7471
LL ~
7572
LL + Ok(())
76-
LL + }
7773
|
7874

7975
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
@@ -93,7 +89,6 @@ LL |
9389
LL | mac!();
9490
LL +
9591
LL + Ok(())
96-
LL + }
9792
|
9893

9994
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
@@ -117,7 +112,6 @@ LL |
117112
LL | println!();
118113
LL ~
119114
LL + Ok(())
120-
LL + }
121115
|
122116

123117
error: aborting due to 6 previous errors

tests/ui/try-trait/try-operator-on-main.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ LL | // error for a `Try` type on a non-`Try` fn
1616
LL | try_trait_generic::<()>();
1717
LL +
1818
LL + Ok(())
19-
LL + }
2019
|
2120

2221
error[E0277]: the `?` operator can only be applied to values that implement `Try`

0 commit comments

Comments
 (0)