Skip to content

Commit 36a50c2

Browse files
committed
Auto merge of #55803 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 17 pull requests Successful merges: - #55576 (Clarify error message for -C opt-level) - #55633 (Support memcpy/memmove with differing src/dst alignment) - #55638 (Fix ICE in msg_span_from_free_region on ReEmpty) - #55659 (rustc: Delete grouping logic from the musl target) - #55719 (Sidestep link error from rustfix'ed code by using a *defined* static.) - #55736 (Elide anon lifetimes in conflicting impl note) - #55739 (Consume optimization fuel from the MIR inliner) - #55742 (Avoid panic when matching function call) - #55753 (borrow_set: remove a helper function and a clone it uses) - #55755 (Improve creation of 3 IndexVecs) - #55758 ([regression - rust2018]: unused_mut lint false positives on nightly) - #55760 (Remove intermediate font specs) - #55761 (mir: remove a hacky recursive helper function) - #55774 (wasm32-unknown-emscripten expects the rust_eh_personality symbol) - #55777 (Use `Lit` rather than `P<Lit>` in `ast::ExprKind`.) - #55783 (Deprecate mpsc channel selection) - #55788 (rustc: Request ansi colors if stderr isn't a tty) Failed merges: r? @ghost
2 parents 653da4f + d293d1e commit 36a50c2

File tree

47 files changed

+403
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+403
-172
lines changed

src/libpanic_abort/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ pub unsafe extern fn __rust_start_panic(_payload: usize) -> u32 {
9797
pub mod personalities {
9898
#[no_mangle]
9999
#[cfg(not(any(
100-
target_arch = "wasm32",
100+
all(
101+
target_arch = "wasm32",
102+
not(target_os = "emscripten"),
103+
),
101104
all(
102105
target_os = "windows",
103106
target_env = "gnu",

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3705,7 +3705,7 @@ impl<'a> LoweringContext<'a> {
37053705
let ohs = P(self.lower_expr(ohs));
37063706
hir::ExprKind::Unary(op, ohs)
37073707
}
3708-
ExprKind::Lit(ref l) => hir::ExprKind::Lit(P((**l).clone())),
3708+
ExprKind::Lit(ref l) => hir::ExprKind::Lit(P((*l).clone())),
37093709
ExprKind::Cast(ref expr, ref ty) => {
37103710
let expr = P(self.lower_expr(expr));
37113711
hir::ExprKind::Cast(expr, self.lower_ty(ty, ImplTraitContext::disallowed()))

src/librustc/infer/error_reporting/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
178178
self.msg_span_from_early_bound_and_free_regions(region)
179179
}
180180
ty::ReStatic => ("the static lifetime".to_owned(), None),
181+
ty::ReEmpty => ("an empty lifetime".to_owned(), None),
181182
_ => bug!("{:?}", region),
182183
}
183184
}

src/librustc/mir/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,20 @@ impl<'tcx> Mir<'tcx> {
304304
})
305305
}
306306

307+
/// Returns an iterator over all user-declared mutable locals.
308+
#[inline]
309+
pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a {
310+
(self.arg_count + 1..self.local_decls.len()).filter_map(move |index| {
311+
let local = Local::new(index);
312+
let decl = &self.local_decls[local];
313+
if decl.is_user_variable.is_some() && decl.mutability == Mutability::Mut {
314+
Some(local)
315+
} else {
316+
None
317+
}
318+
})
319+
}
320+
307321
/// Returns an iterator over all user-declared mutable arguments and locals.
308322
#[inline]
309323
pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a {

src/librustc/session/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2082,7 +2082,7 @@ pub fn build_session_options_and_crate_config(
20822082
error_format,
20832083
&format!(
20842084
"optimization level needs to be \
2085-
between 0-3 (instead was `{}`)",
2085+
between 0-3, s or z (instead was `{}`)",
20862086
arg
20872087
),
20882088
);

src/librustc/traits/specialize/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,10 @@ fn to_pretty_impl_header(tcx: TyCtxt<'_, '_, '_>, impl_def_id: DefId) -> Option<
396396
if !substs.is_noop() {
397397
types_without_default_bounds.extend(substs.types());
398398
w.push('<');
399-
w.push_str(&substs.iter().map(|k| k.to_string()).collect::<Vec<_>>().join(", "));
399+
w.push_str(&substs.iter()
400+
.map(|k| k.to_string())
401+
.filter(|k| &k[..] != "'_")
402+
.collect::<Vec<_>>().join(", "));
400403
w.push('>');
401404
}
402405

src/librustc/ty/query/on_disk_cache.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,7 @@ impl<'sess> OnDiskCache<'sess> {
450450
.map(|&(cnum, ..)| cnum)
451451
.max()
452452
.unwrap_or(0) + 1;
453-
let mut map = IndexVec::new();
454-
map.resize(map_size as usize, None);
453+
let mut map = IndexVec::from_elem_n(None, map_size as usize);
455454

456455
for &(prev_cnum, ref crate_name, crate_disambiguator) in prev_cnums {
457456
let key = (crate_name.clone(), crate_disambiguator);

src/librustc_codegen_llvm/abi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,10 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
225225
// ...and then memcpy it to the intended destination.
226226
base::call_memcpy(bx,
227227
bx.pointercast(dst.llval, Type::i8p(cx)),
228+
self.layout.align,
228229
bx.pointercast(llscratch, Type::i8p(cx)),
230+
scratch_align,
229231
C_usize(cx, self.layout.size.bytes()),
230-
self.layout.align.min(scratch_align),
231232
MemFlags::empty());
232233

233234
bx.lifetime_end(llscratch, scratch_size);

src/librustc_codegen_llvm/base.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use mir::place::PlaceRef;
5353
use attributes;
5454
use builder::{Builder, MemFlags};
5555
use callee;
56-
use common::{C_bool, C_bytes_in_context, C_i32, C_usize};
56+
use common::{C_bool, C_bytes_in_context, C_usize};
5757
use rustc_mir::monomorphize::item::DefPathBasedNames;
5858
use common::{C_struct_in_context, C_array, val_ty};
5959
use consts;
@@ -77,7 +77,6 @@ use rustc_data_structures::sync::Lrc;
7777
use std::any::Any;
7878
use std::cmp;
7979
use std::ffi::CString;
80-
use std::i32;
8180
use std::ops::{Deref, DerefMut};
8281
use std::sync::mpsc;
8382
use std::time::{Instant, Duration};
@@ -319,8 +318,8 @@ pub fn coerce_unsized_into(
319318
}
320319

321320
if src_f.layout.ty == dst_f.layout.ty {
322-
memcpy_ty(bx, dst_f.llval, src_f.llval, src_f.layout,
323-
src_f.align.min(dst_f.align), MemFlags::empty());
321+
memcpy_ty(bx, dst_f.llval, dst_f.align, src_f.llval, src_f.align,
322+
src_f.layout, MemFlags::empty());
324323
} else {
325324
coerce_unsized_into(bx, src_f, dst_f);
326325
}
@@ -420,44 +419,42 @@ pub fn to_immediate_scalar(
420419
pub fn call_memcpy(
421420
bx: &Builder<'_, 'll, '_>,
422421
dst: &'ll Value,
422+
dst_align: Align,
423423
src: &'ll Value,
424+
src_align: Align,
424425
n_bytes: &'ll Value,
425-
align: Align,
426426
flags: MemFlags,
427427
) {
428428
if flags.contains(MemFlags::NONTEMPORAL) {
429429
// HACK(nox): This is inefficient but there is no nontemporal memcpy.
430-
let val = bx.load(src, align);
430+
let val = bx.load(src, src_align);
431431
let ptr = bx.pointercast(dst, val_ty(val).ptr_to());
432-
bx.store_with_flags(val, ptr, align, flags);
432+
bx.store_with_flags(val, ptr, dst_align, flags);
433433
return;
434434
}
435435
let cx = bx.cx;
436-
let ptr_width = &cx.sess().target.target.target_pointer_width;
437-
let key = format!("llvm.memcpy.p0i8.p0i8.i{}", ptr_width);
438-
let memcpy = cx.get_intrinsic(&key);
439436
let src_ptr = bx.pointercast(src, Type::i8p(cx));
440437
let dst_ptr = bx.pointercast(dst, Type::i8p(cx));
441438
let size = bx.intcast(n_bytes, cx.isize_ty, false);
442-
let align = C_i32(cx, align.abi() as i32);
443-
let volatile = C_bool(cx, flags.contains(MemFlags::VOLATILE));
444-
bx.call(memcpy, &[dst_ptr, src_ptr, size, align, volatile], None);
439+
let volatile = flags.contains(MemFlags::VOLATILE);
440+
bx.memcpy(dst_ptr, dst_align.abi(), src_ptr, src_align.abi(), size, volatile);
445441
}
446442

447443
pub fn memcpy_ty(
448444
bx: &Builder<'_, 'll, 'tcx>,
449445
dst: &'ll Value,
446+
dst_align: Align,
450447
src: &'ll Value,
448+
src_align: Align,
451449
layout: TyLayout<'tcx>,
452-
align: Align,
453450
flags: MemFlags,
454451
) {
455452
let size = layout.size.bytes();
456453
if size == 0 {
457454
return;
458455
}
459456

460-
call_memcpy(bx, dst, src, C_usize(bx.cx, size), align, flags);
457+
call_memcpy(bx, dst, dst_align, src, src_align, C_usize(bx.cx, size), flags);
461458
}
462459

463460
pub fn call_memset(

src/librustc_codegen_llvm/builder.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,24 @@ impl Builder<'a, 'll, 'tcx> {
781781
}
782782
}
783783

784+
pub fn memcpy(&self, dst: &'ll Value, dst_align: u64,
785+
src: &'ll Value, src_align: u64,
786+
size: &'ll Value, is_volatile: bool) -> &'ll Value {
787+
unsafe {
788+
llvm::LLVMRustBuildMemCpy(self.llbuilder, dst, dst_align as c_uint,
789+
src, src_align as c_uint, size, is_volatile)
790+
}
791+
}
792+
793+
pub fn memmove(&self, dst: &'ll Value, dst_align: u64,
794+
src: &'ll Value, src_align: u64,
795+
size: &'ll Value, is_volatile: bool) -> &'ll Value {
796+
unsafe {
797+
llvm::LLVMRustBuildMemMove(self.llbuilder, dst, dst_align as c_uint,
798+
src, src_align as c_uint, size, is_volatile)
799+
}
800+
}
801+
784802
pub fn minnum(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
785803
self.count_insn("minnum");
786804
unsafe {

0 commit comments

Comments
 (0)