Skip to content

Rollup of 9 pull requests #78162

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

Merged
merged 21 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
64c239c
Add codegen test for issue #73827
bugadani Oct 17, 2020
1d07d69
Optimize const value interning for ZST types
wesleywiser Oct 17, 2020
762ded1
we can test std and core panic macros together
RalfJung Oct 18, 2020
66c1fc4
Move orphan module-name/mod.rs files into module-name.rs files
est31 Oct 18, 2020
061cf53
Wrapping intrinsics update link
mbartlett21 Oct 20, 2020
35b7374
Add test for issue-68841
JohnTitor Oct 20, 2020
7d4d64d
Add test for issue-75053
JohnTitor Oct 20, 2020
af337e8
Add test for issue-76375
JohnTitor Oct 20, 2020
a619865
Add test for issue-77911
JohnTitor Oct 20, 2020
13f0f49
Drop unneeded `mut`
LingMan Oct 12, 2020
2705cae
Track element count only for types that need drop
bugadani Oct 20, 2020
f382504
Remove unused type from librustdoc
GuillaumeGomez Oct 20, 2020
2c1de08
Rollup merge of #78046 - bugadani:issue-73827, r=nikic
GuillaumeGomez Oct 20, 2020
3fea201
Rollup merge of #78061 - wesleywiser:opt_zst_const_interning, r=oli-obk
GuillaumeGomez Oct 20, 2020
6adc989
Rollup merge of #78070 - RalfJung:const-panic-test, r=oli-obk
GuillaumeGomez Oct 20, 2020
01e6019
Rollup merge of #78076 - est31:orphan_mod, r=Mark-Simulacrum
GuillaumeGomez Oct 20, 2020
adda858
Rollup merge of #78129 - mbartlett21:patch-1, r=kennytm
GuillaumeGomez Oct 20, 2020
a8a424f
Rollup merge of #78133 - JohnTitor:mir-tests, r=lcnr
GuillaumeGomez Oct 20, 2020
ad218f9
Rollup merge of #78144 - bugadani:elements-nodrop, r=oli-obk
GuillaumeGomez Oct 20, 2020
0c2dbb2
Rollup merge of #78145 - LingMan:ast_pretty_mut, r=jonas-schievink
GuillaumeGomez Oct 20, 2020
1df5346
Rollup merge of #78157 - GuillaumeGomez:remove-unused-type, r=jyn514
GuillaumeGomez Oct 20, 2020
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
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
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