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

Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
351d532
interpret: call caller_location logic the same way codegen does, and …
RalfJung Oct 28, 2023
04fa124
share the track_caller handling within a mir::Body
RalfJung Oct 28, 2023
552abdc
Rename a few remaining references to abort terminator
tmiasko Oct 29, 2023
4b14048
improve and fix x install
onur-ozkan Oct 30, 2023
745c600
Talk about `gen fn` in diagnostics about `gen fn`
oli-obk Oct 30, 2023
bc926f7
Add a custom panic message for resuming `gen` blocks after they panicked
oli-obk Oct 30, 2023
a2486db
Fix missing leading space in suggestion
gurry Oct 30, 2023
82f34fd
Fix #117284, Fix unused variables lint issue for args in macro
chenyukang Oct 30, 2023
972ee01
Add regression test
oli-obk Oct 30, 2023
8d03e13
Don't treat closures/coroutines as part of the public API
oli-obk Oct 30, 2023
251021c
Merge two equal match arms
oli-obk Oct 30, 2023
43ff2a7
Some manual rustfmt as rustfmt is broken on this file
oli-obk Oct 30, 2023
006e43c
Rollup merge of #117317 - RalfJung:track-caller, r=oli-obk
matthiaskrgr Oct 30, 2023
dfe0a6a
Rollup merge of #117357 - tmiasko:terminate, r=wesleywiser
matthiaskrgr Oct 30, 2023
b4269e1
Rollup merge of #117383 - onur-ozkan:fix-x-install, r=albertlarsan68
matthiaskrgr Oct 30, 2023
399aae3
Rollup merge of #117389 - oli-obk:gen_fn, r=compiler-errors
matthiaskrgr Oct 30, 2023
da5475b
Rollup merge of #117390 - chenyukang:yukang-fix-117284-unused-macro, …
matthiaskrgr Oct 30, 2023
7730b41
Rollup merge of #117395 - gurry:117380-wrong-parent-sugg, r=Nilstrieb
matthiaskrgr Oct 30, 2023
3f4edea
Rollup merge of #117396 - oli-obk:privacy_visitor_types, r=compiler-e…
matthiaskrgr Oct 30, 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
2 changes: 2 additions & 0 deletions compiler/rustc_middle/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ middle_assert_coroutine_resume_after_return = coroutine resumed after completion
middle_assert_divide_by_zero =
attempt to divide `{$val}` by zero

middle_assert_gen_resume_after_panic = `gen` fn or block cannot be further iterated on after it panicked

middle_assert_misaligned_ptr_deref =
misaligned pointer dereference: address must be a multiple of {$required} but is {$found}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_middle/src/mir/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ impl<O> AssertKind<O> {
middle_assert_coroutine_resume_after_return
}
ResumedAfterPanic(CoroutineKind::Async(_)) => middle_assert_async_resume_after_panic,
// FIXME(gen_blocks): custom error message for `gen` blocks
ResumedAfterPanic(CoroutineKind::Gen(_)) => middle_assert_async_resume_after_panic,
ResumedAfterPanic(CoroutineKind::Gen(_)) => middle_assert_gen_resume_after_panic,
ResumedAfterPanic(CoroutineKind::Coroutine) => {
middle_assert_coroutine_resume_after_panic
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_parse/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ parse_found_expr_would_be_stmt = expected expression, found `{$token}`
parse_function_body_equals_expr = function body cannot be `= expression;`
.suggestion = surround the expression with `{"{"}` and `{"}"}` instead of `=` and `;`

parse_gen_block = `gen` blocks are not yet implemented
.help = only the keyword is reserved for now
parse_gen_fn = `gen` functions are not yet implemented
.help = for now you can use `gen {"{}"}` blocks and return `impl Iterator` instead

parse_generic_args_in_pat_require_turbofish_syntax = generic args in patterns require the turbofish syntax

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,9 @@ pub(crate) struct CatchAfterTry {
}

#[derive(Diagnostic)]
#[diag(parse_gen_block)]
#[diag(parse_gen_fn)]
#[help]
pub(crate) struct GenBlock {
pub(crate) struct GenFn {
#[primary_span]
pub span: Span,
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2372,7 +2372,7 @@ impl<'a> Parser<'a> {
}

if let Gen::Yes { span, .. } = genness {
self.sess.emit_err(errors::GenBlock { span });
self.sess.emit_err(errors::GenFn { span });
}

if !self.eat_keyword_case(kw::Fn, case) {
Expand Down
25 changes: 25 additions & 0 deletions tests/ui/coroutine/gen_block_panic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//compile-flags: --edition 2024 -Zunstable-options
// run-pass
#![feature(gen_blocks)]

fn main() {
let mut iter = gen {
yield 42;
panic!("foo");
yield 69; //~ WARN: unreachable statement
};
assert_eq!(iter.next(), Some(42));
let mut tmp = std::panic::AssertUnwindSafe(&mut iter);
match std::panic::catch_unwind(move || tmp.next()) {
Ok(_) => unreachable!(),
Err(err) => assert_eq!(*err.downcast::<&'static str>().unwrap(), "foo"),
}

match std::panic::catch_unwind(move || iter.next()) {
Ok(_) => unreachable!(),
Err(err) => assert_eq!(
*err.downcast::<&'static str>().unwrap(),
"`gen fn` should just keep returning `None` after panicking",
),
}
}
12 changes: 12 additions & 0 deletions tests/ui/coroutine/gen_block_panic.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
warning: unreachable statement
--> $DIR/gen_block_panic.rs:9:9
|
LL | panic!("foo");
| ------------- any code following this expression is unreachable
LL | yield 69;
| ^^^^^^^^^ unreachable statement
|
= note: `#[warn(unreachable_code)]` on by default

warning: 1 warning emitted

4 changes: 2 additions & 2 deletions tests/ui/coroutine/gen_fn.e2024.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error: `gen` blocks are not yet implemented
error: `gen` functions are not yet implemented
--> $DIR/gen_fn.rs:4:1
|
LL | gen fn foo() {}
| ^^^
|
= help: only the keyword is reserved for now
= help: for now you can use `gen {}` blocks and return `impl Iterator` instead

error: aborting due to previous error

2 changes: 1 addition & 1 deletion tests/ui/coroutine/gen_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

gen fn foo() {}
//[none]~^ ERROR: expected one of `#`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found `gen`
//[e2024]~^^ ERROR: `gen` blocks are not yet implemented
//[e2024]~^^ ERROR: `gen` functions are not yet implemented

fn main() {}