Skip to content

Commit

Permalink
Fixing span manipulation and indentation of the suggestion introduced…
Browse files Browse the repository at this point in the history
  • Loading branch information
surechen committed Aug 23, 2024
1 parent 739b1fd commit fac04a6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4668,9 +4668,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
&& b.expr.is_none()
{
sugg_spans.push((
// The span will point to the closing curly brace `}` of the block.
b.span.shrink_to_hi().with_lo(b.span.hi() - BytePos(1)),
"\n Ok(())\n}".to_string(),
self.tcx.sess.source_map().end_point(b.span).shrink_to_lo(),
"\n Ok(())\n".to_string(),
));
}
err.multipart_suggestion_verbose(
Expand Down
6 changes: 0 additions & 6 deletions tests/ui/return/return-from-residual-sugg-issue-125997.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ LL | let mut _file = File::create("foo.txt")?;
LL |
LL +
LL + Ok(())
LL + }
|

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

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

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

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

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

error: aborting due to 6 previous errors
Expand Down
1 change: 0 additions & 1 deletion tests/ui/try-trait/try-operator-on-main.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ LL | // error for a `Try` type on a non-`Try` fn
LL | try_trait_generic::<()>();
LL +
LL + Ok(())
LL + }
|

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

0 comments on commit fac04a6

Please sign in to comment.