Skip to content

Commit

Permalink
Auto merge of rust-lang#78162 - GuillaumeGomez:rollup-6a4qiqu, r=Guil…
Browse files Browse the repository at this point in the history
…laumeGomez

Rollup of 9 pull requests

Successful merges:

 - rust-lang#78046 (Add codegen test for issue rust-lang#73827)
 - rust-lang#78061 (Optimize const value interning for ZST types)
 - rust-lang#78070 (we can test std and core panic macros together)
 - rust-lang#78076 (Move orphan module-name/mod.rs files into module-name.rs files)
 - rust-lang#78129 (Wrapping intrinsics doc links update.)
 - rust-lang#78133 (Add some MIR-related regression tests)
 - rust-lang#78144 (Don't update `entries` in `TypedArena` if T does not need drop)
 - rust-lang#78145 (Drop unneeded `mut`)
 - rust-lang#78157 (Remove unused type from librustdoc)

Failed merges:

r? `@ghost`
  • Loading branch information
bors committed Oct 20, 2020
2 parents 981346f + 1df5346 commit 31530e5
Show file tree
Hide file tree
Showing 22 changed files with 242 additions and 90 deletions.
8 changes: 6 additions & 2 deletions compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_pretty/src/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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) }
})
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions compiler/rustc_mir/src/interpret/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
12 changes: 6 additions & 6 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 0 additions & 9 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs
Original file line number Diff line number Diff line change
@@ -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]
}
}
21 changes: 18 additions & 3 deletions src/test/ui/consts/const-eval/const_panic.rs
Original file line number Diff line number Diff line change
@@ -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
82 changes: 66 additions & 16 deletions src/test/ui/consts/const-eval/const_panic.stderr
Original file line number Diff line number Diff line change
@@ -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

12 changes: 0 additions & 12 deletions src/test/ui/consts/const-eval/const_panic_libcore.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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)

Expand Down
33 changes: 0 additions & 33 deletions src/test/ui/consts/const-eval/const_panic_libcore_main.stderr

This file was deleted.

5 changes: 5 additions & 0 deletions src/test/ui/issues/issue-68010-large-zst-consts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// build-pass

fn main() {
println!("{}", [(); std::usize::MAX].len());
}
14 changes: 14 additions & 0 deletions src/test/ui/mir/auxiliary/issue_76375_aux.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions src/test/ui/mir/issue-68841.rs
Original file line number Diff line number Diff line change
@@ -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();
}
Loading

0 comments on commit 31530e5

Please sign in to comment.