Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f4a9d29
Remove `rustc_symbol_mangling/messages.ftl`.
nnethercote Oct 17, 2023
041f031
Properly restore snapshot when failing to recover parsing ternary
clubby789 Oct 26, 2023
3bbc70a
Restrict param constraint suggestion
estebank Oct 26, 2023
84c9c4a
NVPTX: Allow PassMode::Direct for ptx kernels for now
kjetilkjeka Oct 26, 2023
4d33876
Documentation and error message improvements related to PassMode::Dir…
kjetilkjeka Oct 26, 2023
e81a5c6
Recover ternary expression as error
clubby789 Oct 26, 2023
72d5f4b
Hide internal methods from documentation
jhpratt Oct 27, 2023
bb45c81
Link to correct issue in PassMode::Direct ptx-kernel exception
Oct 27, 2023
ccb36a6
std::thread: add SAFETY comment
RalfJung Oct 27, 2023
b915fc8
fix miri target information for Test step
onur-ozkan Oct 27, 2023
7449478
Account for type param from other item in `note_and_explain`
estebank Oct 26, 2023
df8852a
Rollup merge of #116834 - nnethercote:rustc_symbol_mangling, r=davidtwco
matthiaskrgr Oct 27, 2023
b229537
Rollup merge of #117212 - clubby789:fix-ternary-recover, r=compiler-e…
matthiaskrgr Oct 27, 2023
a77f743
Rollup merge of #117246 - estebank:issue-117209, r=petrochenkov
matthiaskrgr Oct 27, 2023
c3d56be
Rollup merge of #117247 - kjetilkjeka:nvptx_direct_passmode_exception…
matthiaskrgr Oct 27, 2023
60b071f
Rollup merge of #117270 - jhpratt:hide-print-internals, r=ChrisDenton
matthiaskrgr Oct 27, 2023
f9d62a8
Rollup merge of #117281 - RalfJung:thread-safety, r=thomcc
matthiaskrgr Oct 27, 2023
b9015da
Rollup merge of #117287 - onur-ozkan:fix-miri-target-info, r=RalfJung
matthiaskrgr Oct 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Properly restore snapshot when failing to recover parsing ternary
  • Loading branch information
clubby789 committed Oct 26, 2023
commit 041f0313cf39f1be4fbceebf3186fe5254e7be78
6 changes: 2 additions & 4 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,13 +1454,11 @@ impl<'a> Parser<'a> {
}
Err(err) => {
err.cancel();
self.restore_snapshot(snapshot);
}
};
}
} else {
self.restore_snapshot(snapshot);
};
}
self.restore_snapshot(snapshot);

false
}
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/parser/ternary_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ fn c() { //~ NOTE this function should return `Result` or `Option` to accept `?`
//~| NOTE in this expansion of desugaring of operator `?`
}

fn bad() {
// regression test for #117208
v ? return;
//~^ ERROR expected one of
//~| NOTE expected one of
}

fn main() { //~ NOTE this function should return `Result` or `Option` to accept `?`
let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
//~^ ERROR Rust has no ternary operator
Expand Down
16 changes: 11 additions & 5 deletions tests/ui/parser/ternary_operator.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,22 @@ LL | let x = 5 > 2 ? f32::MAX : f32::MIN;
|
= help: use an `if-else` expression instead

error: expected one of `.`, `;`, `?`, `}`, or an operator, found keyword `return`
--> $DIR/ternary_operator.rs:54:9
|
LL | v ? return;
| ^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator

error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
--> $DIR/ternary_operator.rs:53:37
--> $DIR/ternary_operator.rs:60:37
|
LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: Rust has no ternary operator
--> $DIR/ternary_operator.rs:53:19
--> $DIR/ternary_operator.rs:60:19
|
LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -93,15 +99,15 @@ LL | let x = 5 > 2 ? f32::MAX : f32::MIN;
= help: the trait `FromResidual<_>` is not implemented for `()`

error[E0277]: the `?` operator can only be applied to values that implement `Try`
--> $DIR/ternary_operator.rs:53:17
--> $DIR/ternary_operator.rs:60:17
|
LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
| ^^^ the `?` operator cannot be applied to type `{integer}`
|
= help: the trait `Try` is not implemented for `{integer}`

error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/ternary_operator.rs:53:19
--> $DIR/ternary_operator.rs:60:19
|
LL | fn main() {
| --------- this function should return `Result` or `Option` to accept `?`
Expand All @@ -110,6 +116,6 @@ LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
|
= help: the trait `FromResidual<_>` is not implemented for `()`

error: aborting due to 13 previous errors
error: aborting due to 14 previous errors

For more information about this error, try `rustc --explain E0277`.