mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Auto merge of #78162 - GuillaumeGomez:rollup-6a4qiqu, r=GuillaumeGomez
Rollup of 9 pull requests Successful merges: - #78046 (Add codegen test for issue #73827) - #78061 (Optimize const value interning for ZST types) - #78070 (we can test std and core panic macros together) - #78076 (Move orphan module-name/mod.rs files into module-name.rs files) - #78129 (Wrapping intrinsics doc links update.) - #78133 (Add some MIR-related regression tests) - #78144 (Don't update `entries` in `TypedArena` if T does not need drop) - #78145 (Drop unneeded `mut`) - #78157 (Remove unused type from librustdoc) Failed merges: r? `@ghost`
This commit is contained in:
commit
31530e5d13
@ -217,8 +217,12 @@ impl<T> TypedArena<T> {
|
||||
let mut chunks = self.chunks.borrow_mut();
|
||||
let mut new_cap;
|
||||
if let Some(last_chunk) = chunks.last_mut() {
|
||||
let used_bytes = self.ptr.get() as usize - last_chunk.start() as usize;
|
||||
last_chunk.entries = used_bytes / mem::size_of::<T>();
|
||||
// If a type is `!needs_drop`, we don't need to keep track of how many elements
|
||||
// the chunk stores - the field will be ignored anyway.
|
||||
if mem::needs_drop::<T>() {
|
||||
let used_bytes = self.ptr.get() as usize - last_chunk.start() as usize;
|
||||
last_chunk.entries = used_bytes / mem::size_of::<T>();
|
||||
}
|
||||
|
||||
// If the previous chunk's len is less than HUGE_PAGE
|
||||
// bytes, then this chunk will be least double the previous
|
||||
|
@ -390,7 +390,7 @@ impl Printer {
|
||||
self.scan_stack.pop_front().unwrap()
|
||||
}
|
||||
|
||||
fn scan_top(&mut self) -> usize {
|
||||
fn scan_top(&self) -> usize {
|
||||
*self.scan_stack.front().unwrap()
|
||||
}
|
||||
|
||||
@ -484,7 +484,7 @@ impl Printer {
|
||||
self.pending_indentation += amount;
|
||||
}
|
||||
|
||||
fn get_top(&mut self) -> PrintStackElem {
|
||||
fn get_top(&self) -> PrintStackElem {
|
||||
*self.print_stack.last().unwrap_or({
|
||||
&PrintStackElem { offset: 0, pbreak: PrintStackBreak::Broken(Breaks::Inconsistent) }
|
||||
})
|
||||
|
@ -63,7 +63,7 @@ impl<'a> Comments<'a> {
|
||||
}
|
||||
|
||||
pub fn trailing_comment(
|
||||
&mut self,
|
||||
&self,
|
||||
span: rustc_span::Span,
|
||||
next_pos: Option<BytePos>,
|
||||
) -> Option<Comment> {
|
||||
|
@ -187,6 +187,12 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir
|
||||
return walked;
|
||||
}
|
||||
}
|
||||
|
||||
// ZSTs do not need validation unless they're uninhabited
|
||||
if mplace.layout.is_zst() && !mplace.layout.abi.is_uninhabited() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
self.walk_aggregate(mplace, fields)
|
||||
}
|
||||
|
||||
|
@ -1660,22 +1660,22 @@ extern "rust-intrinsic" {
|
||||
/// Returns (a + b) mod 2<sup>N</sup>, where N is the width of T in bits.
|
||||
///
|
||||
/// The stabilized versions of this intrinsic are available on the integer
|
||||
/// primitives via the `checked_add` method. For example,
|
||||
/// [`u32::checked_add`]
|
||||
/// primitives via the `wrapping_add` method. For example,
|
||||
/// [`u32::wrapping_add`]
|
||||
#[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
|
||||
pub fn wrapping_add<T: Copy>(a: T, b: T) -> T;
|
||||
/// Returns (a - b) mod 2<sup>N</sup>, where N is the width of T in bits.
|
||||
///
|
||||
/// The stabilized versions of this intrinsic are available on the integer
|
||||
/// primitives via the `checked_sub` method. For example,
|
||||
/// [`u32::checked_sub`]
|
||||
/// primitives via the `wrapping_sub` method. For example,
|
||||
/// [`u32::wrapping_sub`]
|
||||
#[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
|
||||
pub fn wrapping_sub<T: Copy>(a: T, b: T) -> T;
|
||||
/// Returns (a * b) mod 2<sup>N</sup>, where N is the width of T in bits.
|
||||
///
|
||||
/// The stabilized versions of this intrinsic are available on the integer
|
||||
/// primitives via the `checked_mul` method. For example,
|
||||
/// [`u32::checked_mul`]
|
||||
/// primitives via the `wrapping_mul` method. For example,
|
||||
/// [`u32::wrapping_mul`]
|
||||
#[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
|
||||
pub fn wrapping_mul<T: Copy>(a: T, b: T) -> T;
|
||||
|
||||
|
@ -85,12 +85,6 @@ mod theme;
|
||||
mod visit_ast;
|
||||
mod visit_lib;
|
||||
|
||||
struct Output {
|
||||
krate: clean::Crate,
|
||||
renderinfo: config::RenderInfo,
|
||||
renderopts: config::RenderOptions,
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
rustc_driver::set_sigpipe_handler();
|
||||
rustc_driver::install_ice_hook();
|
||||
@ -521,15 +515,12 @@ fn main_options(options: config::Options) -> MainResult {
|
||||
|
||||
krate.version = crate_version;
|
||||
|
||||
let out = Output { krate, renderinfo, renderopts };
|
||||
|
||||
if show_coverage {
|
||||
// if we ran coverage, bail early, we don't need to also generate docs at this point
|
||||
// (also we didn't load in any of the useful passes)
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let Output { krate, renderinfo, renderopts } = out;
|
||||
info!("going to format");
|
||||
let (error_format, edition, debugging_options) = diag_opts;
|
||||
let diag = core::new_handler(error_format, None, &debugging_options);
|
||||
|
@ -0,0 +1,18 @@
|
||||
// This test checks that bounds checks are elided when
|
||||
// index is part of a (x | y) < C style condition
|
||||
|
||||
// min-llvm-version: 11.0.0
|
||||
// compile-flags: -O
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// CHECK-LABEL: @get
|
||||
#[no_mangle]
|
||||
pub fn get(array: &[u8; 8], x: usize, y: usize) -> u8 {
|
||||
if x > 7 || y > 7 {
|
||||
0
|
||||
} else {
|
||||
// CHECK-NOT: panic_bounds_check
|
||||
array[y]
|
||||
}
|
||||
}
|
@ -1,11 +1,26 @@
|
||||
#![feature(const_panic)]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
pub const Z: () = panic!("cheese");
|
||||
const Z: () = std::panic!("cheese");
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
pub const Y: () = unreachable!();
|
||||
const Z2: () = std::panic!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
pub const X: () = unimplemented!();
|
||||
const Y: () = std::unreachable!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const X: () = std::unimplemented!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const Z_CORE: () = core::panic!("cheese");
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const Z2_CORE: () = core::panic!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const Y_CORE: () = core::unreachable!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const X_CORE: () = core::unimplemented!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
@ -1,33 +1,83 @@
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic.rs:4:19
|
||||
--> $DIR/const_panic.rs:4:15
|
||||
|
|
||||
LL | pub const Z: () = panic!("cheese");
|
||||
| ------------------^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:4:19
|
||||
LL | const Z: () = std::panic!("cheese");
|
||||
| --------------^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:4:15
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic.rs:7:19
|
||||
--> $DIR/const_panic.rs:7:16
|
||||
|
|
||||
LL | pub const Y: () = unreachable!();
|
||||
| ------------------^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:7:19
|
||||
LL | const Z2: () = std::panic!();
|
||||
| ---------------^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:7:16
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic.rs:10:19
|
||||
--> $DIR/const_panic.rs:10:15
|
||||
|
|
||||
LL | pub const X: () = unimplemented!();
|
||||
| ------------------^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:10:19
|
||||
LL | const Y: () = std::unreachable!();
|
||||
| --------------^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:10:15
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic.rs:13:15
|
||||
|
|
||||
LL | const X: () = std::unimplemented!();
|
||||
| --------------^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:13:15
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic.rs:16:20
|
||||
|
|
||||
LL | const Z_CORE: () = core::panic!("cheese");
|
||||
| -------------------^^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:16:20
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic.rs:19:21
|
||||
|
|
||||
LL | const Z2_CORE: () = core::panic!();
|
||||
| --------------------^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:19:21
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic.rs:22:20
|
||||
|
|
||||
LL | const Y_CORE: () = core::unreachable!();
|
||||
| -------------------^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:22:20
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic.rs:25:20
|
||||
|
|
||||
LL | const X_CORE: () = core::unimplemented!();
|
||||
| -------------------^^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:25:20
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
#![no_std]
|
||||
#![crate_type = "lib"]
|
||||
#![feature(const_panic)]
|
||||
|
||||
const Z: () = panic!("cheese");
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const Y: () = unreachable!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const X: () = unimplemented!();
|
||||
//~^ ERROR any use of this value will cause an error
|
@ -1,31 +1,31 @@
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic_libcore.rs:5:15
|
||||
--> $DIR/const_panic_libcore_bin.rs:9:15
|
||||
|
|
||||
LL | const Z: () = panic!("cheese");
|
||||
| --------------^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'cheese', $DIR/const_panic_libcore.rs:5:15
|
||||
| the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:9:15
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic_libcore.rs:8:15
|
||||
--> $DIR/const_panic_libcore_bin.rs:12:15
|
||||
|
|
||||
LL | const Y: () = unreachable!();
|
||||
| --------------^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore.rs:8:15
|
||||
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:12:15
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic_libcore.rs:11:15
|
||||
--> $DIR/const_panic_libcore_bin.rs:15:15
|
||||
|
|
||||
LL | const X: () = unimplemented!();
|
||||
| --------------^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore.rs:11:15
|
||||
| the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:15:15
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
@ -1,33 +0,0 @@
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic_libcore_main.rs:9:15
|
||||
|
|
||||
LL | const Z: () = panic!("cheese");
|
||||
| --------------^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_main.rs:9:15
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic_libcore_main.rs:12:15
|
||||
|
|
||||
LL | const Y: () = unreachable!();
|
||||
| --------------^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_main.rs:12:15
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic_libcore_main.rs:15:15
|
||||
|
|
||||
LL | const X: () = unimplemented!();
|
||||
| --------------^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_main.rs:15:15
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
5
src/test/ui/issues/issue-68010-large-zst-consts.rs
Normal file
5
src/test/ui/issues/issue-68010-large-zst-consts.rs
Normal file
@ -0,0 +1,5 @@
|
||||
// build-pass
|
||||
|
||||
fn main() {
|
||||
println!("{}", [(); std::usize::MAX].len());
|
||||
}
|
14
src/test/ui/mir/auxiliary/issue_76375_aux.rs
Normal file
14
src/test/ui/mir/auxiliary/issue_76375_aux.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// edition:2018
|
||||
// compile-flags: -Z mir-opt-level=2 -Z unsound-mir-opts
|
||||
|
||||
#[inline(always)]
|
||||
pub fn f(s: bool) -> String {
|
||||
let a = "Hello world!".to_string();
|
||||
let b = a;
|
||||
let c = b;
|
||||
if s {
|
||||
c
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
}
|
15
src/test/ui/mir/issue-68841.rs
Normal file
15
src/test/ui/mir/issue-68841.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// compile-flags: -Z mir-opt-level=2
|
||||
// edition:2018
|
||||
// build-pass
|
||||
|
||||
#![feature(async_closure)]
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
fn async_closure() -> impl Future<Output = u8> {
|
||||
(async move || -> u8 { 42 })()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _fut = async_closure();
|
||||
}
|
48
src/test/ui/mir/issue-75053.rs
Normal file
48
src/test/ui/mir/issue-75053.rs
Normal file
@ -0,0 +1,48 @@
|
||||
// compile-flags: -Z mir-opt-level=2
|
||||
// build-pass
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
trait MyIndex<T> {
|
||||
type O;
|
||||
fn my_index(self) -> Self::O;
|
||||
}
|
||||
trait MyFrom<T>: Sized {
|
||||
type Error;
|
||||
fn my_from(value: T) -> Result<Self, Self::Error>;
|
||||
}
|
||||
|
||||
trait F {}
|
||||
impl F for () {}
|
||||
type DummyT<T> = impl F;
|
||||
fn _dummy_t<T>() -> DummyT<T> {}
|
||||
|
||||
struct Phantom1<T>(PhantomData<T>);
|
||||
struct Phantom2<T>(PhantomData<T>);
|
||||
struct Scope<T>(Phantom2<DummyT<T>>);
|
||||
|
||||
impl<T> Scope<T> {
|
||||
fn new() -> Self {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
|
||||
type Error = ();
|
||||
fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
|
||||
type O = T;
|
||||
fn my_index(self) -> Self::O {
|
||||
MyFrom::my_from(self.0).ok().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
|
||||
}
|
15
src/test/ui/mir/issue-76375.rs
Normal file
15
src/test/ui/mir/issue-76375.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// edition:2018
|
||||
// build-pass
|
||||
// compile-flags: -Z mir-opt-level=2 -L.
|
||||
// aux-build:issue_76375_aux.rs
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
extern crate issue_76375_aux;
|
||||
|
||||
pub async fn g() {
|
||||
issue_76375_aux::f(true);
|
||||
h().await;
|
||||
}
|
||||
|
||||
pub async fn h() {}
|
16
src/test/ui/mir/issue-77911.rs
Normal file
16
src/test/ui/mir/issue-77911.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// compile-flags: -Z mir-opt-level=2
|
||||
// ignore-cloudabi no std::fs
|
||||
// build-pass
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{BufRead, BufReader};
|
||||
|
||||
fn file_lines() -> impl Iterator<Item = String> {
|
||||
BufReader::new(File::open("").unwrap())
|
||||
.lines()
|
||||
.map(Result::unwrap)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
for _ in file_lines() {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user