mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
fix the span in the suggestion of remove question mark
This commit is contained in:
parent
2e6ac7fe5b
commit
2195fa6a9b
@ -764,7 +764,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
Some(ty) if expected == ty => {
|
||||
let source_map = self.tcx.sess.source_map();
|
||||
err.span_suggestion(
|
||||
source_map.end_point(cause.span),
|
||||
source_map.end_point(cause.span()),
|
||||
"try removing this `?`",
|
||||
"",
|
||||
Applicability::MachineApplicable,
|
||||
|
@ -0,0 +1,9 @@
|
||||
// https://github.com/rust-lang/rust/issues/114392
|
||||
|
||||
fn foo() -> Option<()> {
|
||||
let x = Some(());
|
||||
(x?)
|
||||
//~^ ERROR `?` operator has incompatible types
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,22 @@
|
||||
error[E0308]: `?` operator has incompatible types
|
||||
--> $DIR/remove-question-symbol-with-paren.rs:5:6
|
||||
|
|
||||
LL | (x?)
|
||||
| ^^ expected `Option<()>`, found `()`
|
||||
|
|
||||
= note: `?` operator cannot convert from `()` to `Option<()>`
|
||||
= note: expected enum `Option<()>`
|
||||
found unit type `()`
|
||||
help: try removing this `?`
|
||||
|
|
||||
LL - (x?)
|
||||
LL + (x)
|
||||
|
|
||||
help: try wrapping the expression in `Some`
|
||||
|
|
||||
LL | (Some(x?))
|
||||
| +++++ +
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
Loading…
Reference in New Issue
Block a user