Skip to content

Commit 31530e5

Browse files
committed
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`
2 parents 981346f + 1df5346 commit 31530e5

File tree

22 files changed

+242
-90
lines changed

22 files changed

+242
-90
lines changed

compiler/rustc_arena/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,12 @@ impl<T> TypedArena<T> {
217217
let mut chunks = self.chunks.borrow_mut();
218218
let mut new_cap;
219219
if let Some(last_chunk) = chunks.last_mut() {
220-
let used_bytes = self.ptr.get() as usize - last_chunk.start() as usize;
221-
last_chunk.entries = used_bytes / mem::size_of::<T>();
220+
// If a type is `!needs_drop`, we don't need to keep track of how many elements
221+
// the chunk stores - the field will be ignored anyway.
222+
if mem::needs_drop::<T>() {
223+
let used_bytes = self.ptr.get() as usize - last_chunk.start() as usize;
224+
last_chunk.entries = used_bytes / mem::size_of::<T>();
225+
}
222226

223227
// If the previous chunk's len is less than HUGE_PAGE
224228
// bytes, then this chunk will be least double the previous

compiler/rustc_ast_pretty/src/pp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl Printer {
390390
self.scan_stack.pop_front().unwrap()
391391
}
392392

393-
fn scan_top(&mut self) -> usize {
393+
fn scan_top(&self) -> usize {
394394
*self.scan_stack.front().unwrap()
395395
}
396396

@@ -484,7 +484,7 @@ impl Printer {
484484
self.pending_indentation += amount;
485485
}
486486

487-
fn get_top(&mut self) -> PrintStackElem {
487+
fn get_top(&self) -> PrintStackElem {
488488
*self.print_stack.last().unwrap_or({
489489
&PrintStackElem { offset: 0, pbreak: PrintStackBreak::Broken(Breaks::Inconsistent) }
490490
})

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'a> Comments<'a> {
6363
}
6464

6565
pub fn trailing_comment(
66-
&mut self,
66+
&self,
6767
span: rustc_span::Span,
6868
next_pos: Option<BytePos>,
6969
) -> Option<Comment> {

compiler/rustc_mir/src/interpret/intern.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir
187187
return walked;
188188
}
189189
}
190+
191+
// ZSTs do not need validation unless they're uninhabited
192+
if mplace.layout.is_zst() && !mplace.layout.abi.is_uninhabited() {
193+
return Ok(());
194+
}
195+
190196
self.walk_aggregate(mplace, fields)
191197
}
192198

library/core/src/intrinsics.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,22 +1660,22 @@ extern "rust-intrinsic" {
16601660
/// Returns (a + b) mod 2<sup>N</sup>, where N is the width of T in bits.
16611661
///
16621662
/// The stabilized versions of this intrinsic are available on the integer
1663-
/// primitives via the `checked_add` method. For example,
1664-
/// [`u32::checked_add`]
1663+
/// primitives via the `wrapping_add` method. For example,
1664+
/// [`u32::wrapping_add`]
16651665
#[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
16661666
pub fn wrapping_add<T: Copy>(a: T, b: T) -> T;
16671667
/// Returns (a - b) mod 2<sup>N</sup>, where N is the width of T in bits.
16681668
///
16691669
/// The stabilized versions of this intrinsic are available on the integer
1670-
/// primitives via the `checked_sub` method. For example,
1671-
/// [`u32::checked_sub`]
1670+
/// primitives via the `wrapping_sub` method. For example,
1671+
/// [`u32::wrapping_sub`]
16721672
#[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
16731673
pub fn wrapping_sub<T: Copy>(a: T, b: T) -> T;
16741674
/// Returns (a * b) mod 2<sup>N</sup>, where N is the width of T in bits.
16751675
///
16761676
/// The stabilized versions of this intrinsic are available on the integer
1677-
/// primitives via the `checked_mul` method. For example,
1678-
/// [`u32::checked_mul`]
1677+
/// primitives via the `wrapping_mul` method. For example,
1678+
/// [`u32::wrapping_mul`]
16791679
#[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
16801680
pub fn wrapping_mul<T: Copy>(a: T, b: T) -> T;
16811681

src/librustdoc/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ mod theme;
8585
mod visit_ast;
8686
mod visit_lib;
8787

88-
struct Output {
89-
krate: clean::Crate,
90-
renderinfo: config::RenderInfo,
91-
renderopts: config::RenderOptions,
92-
}
93-
9488
pub fn main() {
9589
rustc_driver::set_sigpipe_handler();
9690
rustc_driver::install_ice_hook();
@@ -521,15 +515,12 @@ fn main_options(options: config::Options) -> MainResult {
521515

522516
krate.version = crate_version;
523517

524-
let out = Output { krate, renderinfo, renderopts };
525-
526518
if show_coverage {
527519
// if we ran coverage, bail early, we don't need to also generate docs at this point
528520
// (also we didn't load in any of the useful passes)
529521
return Ok(());
530522
}
531523

532-
let Output { krate, renderinfo, renderopts } = out;
533524
info!("going to format");
534525
let (error_format, edition, debugging_options) = diag_opts;
535526
let diag = core::new_handler(error_format, None, &debugging_options);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This test checks that bounds checks are elided when
2+
// index is part of a (x | y) < C style condition
3+
4+
// min-llvm-version: 11.0.0
5+
// compile-flags: -O
6+
7+
#![crate_type = "lib"]
8+
9+
// CHECK-LABEL: @get
10+
#[no_mangle]
11+
pub fn get(array: &[u8; 8], x: usize, y: usize) -> u8 {
12+
if x > 7 || y > 7 {
13+
0
14+
} else {
15+
// CHECK-NOT: panic_bounds_check
16+
array[y]
17+
}
18+
}

0 commit comments

Comments
 (0)