Auto merge of #55194 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests Successful merges: - #54300 (Updated RELEASES.md for 1.30.0) - #55013 ([NLL] Propagate bounds from generators) - #55071 (Fix ICE and report a human readable error) - #55144 (Cleanup resolve) - #55166 (Don't warn about parentheses on `match (return)`) - #55169 (Add a `copysign` function to f32 and f64) - #55178 (Stabilize slice::chunks_exact(), chunks_exact_mut(), rchunks(), rchunks_mut(), rchunks_exact(), rchunks_exact_mut())
This commit is contained in:
commit
74ff7dcb13
27 changed files with 501 additions and 236 deletions
5
src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.rs
Normal file
5
src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
const fn foo(a: i32) -> Vec<i32> {
|
||||
vec![1, 2, 3] //~ ERROR heap allocations are not allowed in const fn
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
10
src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr
Normal file
10
src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: heap allocations are not allowed in const fn
|
||||
--> $DIR/bad_const_fn_body_ice.rs:2:5
|
||||
|
|
||||
LL | vec![1, 2, 3] //~ ERROR heap allocations are not allowed in const fn
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
14
src/test/ui/consts/min_const_fn/cast_errors.rs
Normal file
14
src/test/ui/consts/min_const_fn/cast_errors.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
fn main() {}
|
||||
|
||||
const fn unsize(x: &[u8; 3]) -> &[u8] { x }
|
||||
//~^ ERROR unsizing casts are not allowed in const fn
|
||||
const fn closure() -> fn() { || {} }
|
||||
//~^ ERROR function pointers in const fn are unstable
|
||||
const fn closure2() {
|
||||
(|| {}) as fn();
|
||||
//~^ ERROR function pointers in const fn are unstable
|
||||
}
|
||||
const fn reify(f: fn()) -> unsafe fn() { f }
|
||||
//~^ ERROR function pointers in const fn are unstable
|
||||
const fn reify2() { main as unsafe fn(); }
|
||||
//~^ ERROR function pointers in const fn are unstable
|
||||
32
src/test/ui/consts/min_const_fn/cast_errors.stderr
Normal file
32
src/test/ui/consts/min_const_fn/cast_errors.stderr
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
error: unsizing casts are not allowed in const fn
|
||||
--> $DIR/cast_errors.rs:3:41
|
||||
|
|
||||
LL | const fn unsize(x: &[u8; 3]) -> &[u8] { x }
|
||||
| ^
|
||||
|
||||
error: function pointers in const fn are unstable
|
||||
--> $DIR/cast_errors.rs:5:23
|
||||
|
|
||||
LL | const fn closure() -> fn() { || {} }
|
||||
| ^^^^
|
||||
|
||||
error: function pointers in const fn are unstable
|
||||
--> $DIR/cast_errors.rs:8:5
|
||||
|
|
||||
LL | (|| {}) as fn();
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: function pointers in const fn are unstable
|
||||
--> $DIR/cast_errors.rs:11:28
|
||||
|
|
||||
LL | const fn reify(f: fn()) -> unsafe fn() { f }
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: function pointers in const fn are unstable
|
||||
--> $DIR/cast_errors.rs:13:21
|
||||
|
|
||||
LL | const fn reify2() { main as unsafe fn(); }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
error[E0621]: explicit lifetime required in the type of `x`
|
||||
--> $DIR/generator-region-requirements.rs:15:51
|
||||
|
|
||||
LL | fn dangle(x: &mut i32) -> &'static mut i32 {
|
||||
| -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32`
|
||||
...
|
||||
LL | GeneratorState::Complete(c) => return c,
|
||||
| ^ lifetime `'static` required
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0621`.
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
error[E0621]: explicit lifetime required in the type of `x`
|
||||
--> $DIR/generator-region-requirements.rs:11:9
|
||||
|
|
||||
LL | fn dangle(x: &mut i32) -> &'static mut i32 {
|
||||
| -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32`
|
||||
...
|
||||
LL | x
|
||||
| ^ lifetime `'static` required
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0621`.
|
||||
21
src/test/ui/generator/generator-region-requirements.rs
Normal file
21
src/test/ui/generator/generator-region-requirements.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// revisions: ast nll
|
||||
// ignore-compare-mode-nll
|
||||
|
||||
#![feature(generators, generator_trait)]
|
||||
#![cfg_attr(nll, feature(nll))]
|
||||
use std::ops::{Generator, GeneratorState};
|
||||
|
||||
fn dangle(x: &mut i32) -> &'static mut i32 {
|
||||
let mut g = || {
|
||||
yield;
|
||||
x
|
||||
};
|
||||
loop {
|
||||
match unsafe { g.resume() } {
|
||||
GeneratorState::Complete(c) => return c,
|
||||
GeneratorState::Yielded(_) => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
9
src/test/ui/lint/no-unused-parens-return-block.rs
Normal file
9
src/test/ui/lint/no-unused-parens-return-block.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// run-pass
|
||||
|
||||
#![deny(unused_parens)]
|
||||
#![allow(unreachable_code)]
|
||||
|
||||
fn main() {
|
||||
match (return) {} // ok
|
||||
if (return) {} // ok
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue