Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #117387

Merged
merged 33 commits into from
Oct 30, 2023
Merged
Changes from 2 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
40cc891
Remove from cranelift codegen LLVM intrinsics that are no longer needed
eduardosm Oct 10, 2023
a302610
Merge commit '93a5433f17ab5ed48cc88f1e69b0713b16183373' into sync_cg_…
bjorn3 Oct 24, 2023
6d30a7d
Merge branch 'sync_from_rust'
bjorn3 Oct 24, 2023
2c1dbed
Print variadic argument pattern in HIR pretty printer
DaniPopes Oct 24, 2023
6aead74
Remove unnecessary CVarArgs name skipping logic
DaniPopes Oct 25, 2023
160b179
Allows `#[diagnostic::on_unimplemented]` attributes to have multiple
weiznich Oct 26, 2023
1e39bbf
Update Cranelift to 0.101.2 and disable host-arch feature of cranelif…
bjorn3 Oct 25, 2023
1cb7bdb
Update target-lexicon to 0.12.12
bjorn3 Oct 26, 2023
9e20870
Auto merge of #116609 - eduardosm:bump-stdarch, r=workingjubilee
bors Oct 28, 2023
da1ed4d
Auto merge of #81746 - bjorn3:cg_clif_rustup_component, r=Mark-Simula…
bors Oct 28, 2023
827a6d8
Use the LLVM rustc backend as external assembler
bjorn3 Oct 29, 2023
b1e7051
Unconditionally handle int $$0x29 using a shim
bjorn3 Oct 29, 2023
35453ac
Stabilize inline asm usage on all platforms
bjorn3 Oct 29, 2023
69c6aa5
Avoid infinite recursion when cranelift is the default codegen backend
bjorn3 Oct 29, 2023
9436eae
Merge pull request #1403 from rust-lang/use_llvm_backend_as_assembler
bjorn3 Oct 29, 2023
e281e6f
Sync from rust e5cfc55477eceed1317a02189fdf77a4a98f2124
bjorn3 Oct 29, 2023
dde5880
Rustup to rustc 1.75.0-nightly (e5cfc5547 2023-10-28)
bjorn3 Oct 29, 2023
a9b21bb
Merge commit 'dde58803fd6cbb270c7a437f36a8a3a29fbef679' into sync_cg_…
bjorn3 Oct 29, 2023
c561325
Ignore RPIT duplicated lifetimes in opaque_types_defined_by
compiler-errors Oct 29, 2023
6d69eb1
coverage: Replace manual debug indents with nested tracing spans
Zalathar Oct 29, 2023
2f1be08
coverage: Inline the "recursive" worker methods for assigning counters
Zalathar Oct 29, 2023
10c4734
coverage: Use a tracing span to group the parts of a sum-up expression
Zalathar Oct 29, 2023
441068b
Use ImageDataType for allocation type
Ayush1325 Oct 25, 2023
0c8bdd0
Fail typeck for illegal break-with-value
gurry Oct 30, 2023
3f7e506
deduce_param_attrs: explain a read-only case
RalfJung Oct 30, 2023
2915707
Rollup merge of #117147 - DaniPopes:pphir-fn-variadic, r=compiler-errors
fmease Oct 30, 2023
098bb37
Rollup merge of #117177 - Ayush1325:uefi-alloc-type, r=workingjubilee
fmease Oct 30, 2023
5eb76fa
Rollup merge of #117205 - weiznich:multiple_notes_for_on_unimplemente…
fmease Oct 30, 2023
9a8d800
Rollup merge of #117350 - Zalathar:counters-indent, r=oli-obk
fmease Oct 30, 2023
fd5ffab
Rollup merge of #117365 - bjorn3:sync_cg_clif-2023-10-29, r=oli-obk
fmease Oct 30, 2023
12eb539
Rollup merge of #117371 - compiler-errors:unique-params, r=oli-obk
fmease Oct 30, 2023
4f4b38c
Rollup merge of #117382 - gurry:114529-ice-const-eval, r=oli-obk
fmease Oct 30, 2023
288ab16
Rollup merge of #117385 - RalfJung:deduce_param_attrs, r=oli-obk
fmease 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
13 changes: 9 additions & 4 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
@@ -625,10 +625,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
};

// If the loop context is not a `loop { }`, then break with
// a value is illegal, and `opt_coerce_to` will be `None`.
// Just set expectation to error in that case.
let coerce_to = opt_coerce_to.unwrap_or_else(|| Ty::new_misc_error(tcx));
let coerce_to = match opt_coerce_to {
Some(c) => c,
None => {
// If the loop context is not a `loop { }`, then break with
// a value is illegal, and `opt_coerce_to` will be `None`.
// Return error in that case (#114529).
return Ty::new_misc_error(tcx);
}
};

// Recurse without `enclosing_breakables` borrowed.
e_ty = self.check_expr_with_hint(e, coerce_to);
20 changes: 20 additions & 0 deletions tests/ui/typeck/issue-114529-illegal-break-with-value.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Regression test for issue #114529
// Tests that we do not ICE during const eval for a
// break-with-value in contexts where it is illegal

#[allow(while_true)]
fn main() {
[(); {
while true {
break 9; //~ ERROR `break` with value from a `while` loop
};
51
}];

[(); {
while let Some(v) = Some(9) {
break v; //~ ERROR `break` with value from a `while` loop
};
51
}];
}
29 changes: 29 additions & 0 deletions tests/ui/typeck/issue-114529-illegal-break-with-value.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
error[E0571]: `break` with value from a `while` loop
--> $DIR/issue-114529-illegal-break-with-value.rs:9:13
|
LL | while true {
| ---------- you can't `break` with a value in a `while` loop
LL | break 9;
| ^^^^^^^ can only break with a value inside `loop` or breakable block
|
help: use `break` on its own without a value inside this `while` loop
|
LL | break;
| ~~~~~

error[E0571]: `break` with value from a `while` loop
--> $DIR/issue-114529-illegal-break-with-value.rs:16:13
|
LL | while let Some(v) = Some(9) {
| --------------------------- you can't `break` with a value in a `while` loop
LL | break v;
| ^^^^^^^ can only break with a value inside `loop` or breakable block
|
help: use `break` on its own without a value inside this `while` loop
|
LL | break;
| ~~~~~

error: aborting due to 2 previous errors

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