Skip to content

Commit 12e8cda

Browse files
committed
Auto merge of rust-lang#124248 - matthiaskrgr:rollup-tt6fq7h, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - rust-lang#124236 (crashes: add a couple more ICE tests) - rust-lang#124240 (add a couple tests for fixed ICEs.) - rust-lang#124246 (Add comma at one place in `abs()` documentation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3288583 + f840afb commit 12e8cda

13 files changed

+187
-1
lines changed

library/core/src/num/int_macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3199,7 +3199,7 @@ macro_rules! int_impl {
31993199
/// that code in debug mode will trigger a panic on this case and
32003200
/// optimized code will return
32013201
#[doc = concat!("`", stringify!($SelfT), "::MIN`")]
3202-
/// without a panic. If you do not want this behavior consider
3202+
/// without a panic. If you do not want this behavior, consider
32033203
/// using [`unsigned_abs`](Self::unsigned_abs) instead.
32043204
///
32053205
/// # Examples

tests/crashes/123664.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@ known-bug: #123664
2+
#![feature(generic_const_exprs, effects)]
3+
const fn with_positive<F: ~const Fn()>() {}
4+
pub fn main() {}

tests/crashes/123955.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: #123955
2+
//@ compile-flags: -Clto -Zvirtual-function-elimination
3+
//@ only-x86_64
4+
pub fn main() {
5+
_ = Box::new(()) as Box<dyn Send>;
6+
}

tests/crashes/124092.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ known-bug: #124092
2+
//@ compile-flags: -Zvirtual-function-elimination=true -Clto=true
3+
//@ only-x86_64
4+
const X: for<'b> fn(&'b ()) = |&()| ();
5+
fn main() {
6+
let dyn_debug = Box::new(X) as Box<fn(&'static ())> as Box<dyn Send>;
7+
}

tests/crashes/124182.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ known-bug: #124182
2+
struct LazyLock<T> {
3+
data: (Copy, fn() -> T),
4+
}
5+
6+
impl<T> LazyLock<T> {
7+
pub const fn new(f: fn() -> T) -> LazyLock<T> {
8+
LazyLock { data: (None, f) }
9+
}
10+
}
11+
12+
struct A<T = i32>(Option<T>);
13+
14+
impl<T> Default for A<T> {
15+
fn default() -> Self {
16+
A(None)
17+
}
18+
}
19+
20+
static EMPTY_SET: LazyLock<A<i32>> = LazyLock::new(A::default);
21+
22+
fn main() {}

tests/crashes/124189.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ known-bug: #124189
2+
trait Trait {
3+
type Type;
4+
}
5+
6+
impl<T> Trait for T {
7+
type Type = ();
8+
}
9+
10+
fn f(_: <&Copy as Trait>::Type) {}
11+
12+
fn main() {
13+
f(());
14+
}

tests/crashes/124207.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ known-bug: #124207
2+
#![feature(transmutability)]
3+
#![feature(type_alias_impl_trait)]
4+
trait OpaqueTrait {}
5+
type OpaqueType = impl OpaqueTrait;
6+
trait AnotherTrait {}
7+
impl<T: std::mem::BikeshedIntrinsicFrom<(), ()>> AnotherTrait for T {}
8+
impl AnotherTrait for OpaqueType {}
9+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// issue rust-lang/rust#121463
2+
// ICE non-ADT in struct pattern
3+
#![feature(box_patterns)]
4+
5+
fn main() {
6+
let mut a = E::StructVar { boxed: Box::new(5_i32) };
7+
//~^ ERROR failed to resolve: use of undeclared type `E`
8+
match a {
9+
E::StructVar { box boxed } => { }
10+
//~^ ERROR failed to resolve: use of undeclared type `E`
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0433]: failed to resolve: use of undeclared type `E`
2+
--> $DIR/non-ADT-struct-pattern-box-pattern-ice-121463.rs:6:17
3+
|
4+
LL | let mut a = E::StructVar { boxed: Box::new(5_i32) };
5+
| ^
6+
| |
7+
| use of undeclared type `E`
8+
| help: a trait with a similar name exists: `Eq`
9+
10+
error[E0433]: failed to resolve: use of undeclared type `E`
11+
--> $DIR/non-ADT-struct-pattern-box-pattern-ice-121463.rs:9:9
12+
|
13+
LL | E::StructVar { box boxed } => { }
14+
| ^
15+
| |
16+
| use of undeclared type `E`
17+
| help: a trait with a similar name exists: `Eq`
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0433`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// issue: rust-lang/rust#114463
2+
// ICE cannot convert `ReFree ..` to a region vid
3+
#![feature(generic_const_exprs)]
4+
//~^ WARN the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
5+
fn bug<'a>() {
6+
[(); (|_: &'a u8| (), 0).1];
7+
//~^ ERROR cannot capture late-bound lifetime in constant
8+
}
9+
10+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/cannot-convert-refree-ice-114463.rs:3:12
3+
|
4+
LL | #![feature(generic_const_exprs)]
5+
| ^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error: cannot capture late-bound lifetime in constant
11+
--> $DIR/cannot-convert-refree-ice-114463.rs:6:16
12+
|
13+
LL | fn bug<'a>() {
14+
| -- lifetime defined here
15+
LL | [(); (|_: &'a u8| (), 0).1];
16+
| ^^
17+
18+
error: aborting due to 1 previous error; 1 warning emitted
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// ICE: ImmTy { imm: Scalar(alloc1), ty: *const dyn Sync } input to a fat-to-thin cast (*const dyn Sync -> *const usize
2+
// or with -Zextra-const-ub-checks: expected wide pointer extra data (e.g. slice length or trait object vtable)
3+
// issue: rust-lang/rust#121413
4+
//@ compile-flags: -Zextra-const-ub-checks
5+
// ignore-tidy-linelength
6+
#![feature(const_refs_to_static)]
7+
const REF_INTERIOR_MUT: &usize = {
8+
static FOO: Sync = AtomicUsize::new(0);
9+
//~^ ERROR failed to resolve: use of undeclared type `AtomicUsize`
10+
//~| WARN trait objects without an explicit `dyn` are deprecated
11+
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
12+
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
13+
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
14+
unsafe { &*(&FOO as *const _ as *const usize) }
15+
};
16+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
error[E0433]: failed to resolve: use of undeclared type `AtomicUsize`
2+
--> $DIR/const_refs_to_static-ice-121413.rs:8:24
3+
|
4+
LL | static FOO: Sync = AtomicUsize::new(0);
5+
| ^^^^^^^^^^^ use of undeclared type `AtomicUsize`
6+
|
7+
help: consider importing this struct
8+
|
9+
LL + use std::sync::atomic::AtomicUsize;
10+
|
11+
12+
warning: trait objects without an explicit `dyn` are deprecated
13+
--> $DIR/const_refs_to_static-ice-121413.rs:8:17
14+
|
15+
LL | static FOO: Sync = AtomicUsize::new(0);
16+
| ^^^^
17+
|
18+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
19+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
20+
= note: `#[warn(bare_trait_objects)]` on by default
21+
help: if this is an object-safe trait, use `dyn`
22+
|
23+
LL | static FOO: dyn Sync = AtomicUsize::new(0);
24+
| +++
25+
26+
error[E0277]: the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
27+
--> $DIR/const_refs_to_static-ice-121413.rs:8:17
28+
|
29+
LL | static FOO: Sync = AtomicUsize::new(0);
30+
| ^^^^ doesn't have a size known at compile-time
31+
|
32+
= help: the trait `Sized` is not implemented for `(dyn Sync + 'static)`
33+
34+
error[E0277]: the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
35+
--> $DIR/const_refs_to_static-ice-121413.rs:8:24
36+
|
37+
LL | static FOO: Sync = AtomicUsize::new(0);
38+
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
39+
|
40+
= help: the trait `Sized` is not implemented for `(dyn Sync + 'static)`
41+
= note: constant expressions must have a statically known size
42+
43+
error: aborting due to 3 previous errors; 1 warning emitted
44+
45+
Some errors have detailed explanations: E0277, E0433.
46+
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)