Skip to content

Commit ee8d23d

Browse files
committed
Auto merge of #52574 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests Successful merges: - #52502 (fix unsafety: don't call ptr_rotate for ZST) - #52505 (rustc: Remove a workaround in ThinLTO fixed upstream) - #52526 (Enable run-pass/sepcomp-lib-lto.rs on Android) - #52527 (Remove duplicate E0396 tests) - #52539 (rustc: Fix two custom attributes with custom derive) - #52540 (Fix docker/run.sh script when run locally) - #52573 (Cleanups) Failed merges: r? @ghost
2 parents 878dd0b + 7bf3578 commit ee8d23d

File tree

12 files changed

+73
-61
lines changed

12 files changed

+73
-61
lines changed

src/ci/docker/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ objdir=$root_dir/obj
9999

100100
mkdir -p $HOME/.cargo
101101
mkdir -p $objdir/tmp
102-
mkdir $objdir/cores
102+
mkdir -p $objdir/cores
103103

104104
args=
105105
if [ "$SCCACHE_BUCKET" != "" ]; then

src/libcore/slice/rotate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ impl<T> RawArray<T> {
4848
/// # Safety
4949
///
5050
/// The specified range must be valid for reading and writing.
51-
/// The type `T` must have non-zero size.
5251
///
5352
/// # Algorithm
5453
///
@@ -73,6 +72,7 @@ pub unsafe fn ptr_rotate<T>(mut left: usize, mid: *mut T, mut right: usize) {
7372
loop {
7473
let delta = cmp::min(left, right);
7574
if delta <= RawArray::<T>::cap() {
75+
// We will always hit this immediately for ZST.
7676
break;
7777
}
7878

src/librustc/hir/map/blocks.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ impl MaybeFnLike for ast::Item {
5151
}
5252
}
5353

54+
impl MaybeFnLike for ast::ImplItem {
55+
fn is_fn_like(&self) -> bool {
56+
match self.node { ast::ImplItemKind::Method(..) => true, _ => false, }
57+
}
58+
}
59+
5460
impl MaybeFnLike for ast::TraitItem {
5561
fn is_fn_like(&self) -> bool {
5662
match self.node {
@@ -141,7 +147,7 @@ impl<'a> FnLikeNode<'a> {
141147
let fn_like = match node {
142148
map::NodeItem(item) => item.is_fn_like(),
143149
map::NodeTraitItem(tm) => tm.is_fn_like(),
144-
map::NodeImplItem(_) => true,
150+
map::NodeImplItem(it) => it.is_fn_like(),
145151
map::NodeExpr(e) => e.is_fn_like(),
146152
_ => false
147153
};

src/librustc_codegen_llvm/back/lto.rs

-14
Original file line numberDiff line numberDiff line change
@@ -759,20 +759,6 @@ impl ThinModule {
759759
cgcx.save_temp_bitcode(&module, "thin-lto-after-pm");
760760
timeline.record("thin-done");
761761

762-
// FIXME: this is a hack around a bug in LLVM right now. Discovered in
763-
// #46910 it was found out that on 32-bit MSVC LLVM will hit a codegen
764-
// error if there's an available_externally function in the LLVM module.
765-
// Typically we don't actually use these functions but ThinLTO makes
766-
// heavy use of them when inlining across modules.
767-
//
768-
// Tracked upstream at https://bugs.llvm.org/show_bug.cgi?id=35736 this
769-
// function call (and its definition on the C++ side of things)
770-
// shouldn't be necessary eventually and we can safetly delete these few
771-
// lines.
772-
llvm::LLVMRustThinLTORemoveAvailableExternally(llmod);
773-
cgcx.save_temp_bitcode(&module, "thin-lto-after-rm-ae");
774-
timeline.record("no-ae");
775-
776762
Ok(module)
777763
}
778764
}

src/librustc_codegen_llvm/builder.rs

+1-18
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use llvm;
1414
use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
1515
use llvm::{Opcode, IntPredicate, RealPredicate, False, OperandBundleDef};
16-
use llvm::{ValueRef, BasicBlockRef, BuilderRef, ModuleRef};
16+
use llvm::{ValueRef, BasicBlockRef, BuilderRef};
1717
use common::*;
1818
use type_::Type;
1919
use value::Value;
@@ -1157,23 +1157,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
11571157
}
11581158
}
11591159

1160-
pub fn trap(&self) {
1161-
unsafe {
1162-
let bb: BasicBlockRef = llvm::LLVMGetInsertBlock(self.llbuilder);
1163-
let fn_: ValueRef = llvm::LLVMGetBasicBlockParent(bb);
1164-
let m: ModuleRef = llvm::LLVMGetGlobalParent(fn_);
1165-
let p = "llvm.trap\0".as_ptr();
1166-
let t: ValueRef = llvm::LLVMGetNamedFunction(m, p as *const _);
1167-
assert!((t as isize != 0));
1168-
let args: &[ValueRef] = &[];
1169-
self.count_insn("trap");
1170-
llvm::LLVMRustBuildCall(self.llbuilder, t,
1171-
args.as_ptr(), args.len() as c_uint,
1172-
ptr::null_mut(),
1173-
noname());
1174-
}
1175-
}
1176-
11771160
pub fn landing_pad(&self, ty: Type, pers_fn: ValueRef,
11781161
num_clauses: usize) -> ValueRef {
11791162
self.count_insn("landingpad");

src/librustc_llvm/ffi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,6 @@ extern "C" {
17911791
CU1: *mut *mut c_void,
17921792
CU2: *mut *mut c_void);
17931793
pub fn LLVMRustThinLTOPatchDICompileUnit(M: ModuleRef, CU: *mut c_void);
1794-
pub fn LLVMRustThinLTORemoveAvailableExternally(M: ModuleRef);
17951794

17961795
pub fn LLVMRustLinkerNew(M: ModuleRef) -> LinkerRef;
17971796
pub fn LLVMRustLinkerAdd(linker: LinkerRef,

src/libsyntax/ext/expand.rs

+17
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,13 @@ impl Invocation {
240240
InvocationKind::Derive { ref path, .. } => path.span,
241241
}
242242
}
243+
244+
pub fn attr_id(&self) -> Option<ast::AttrId> {
245+
match self.kind {
246+
InvocationKind::Attr { attr: Some(ref attr), .. } => Some(attr.id),
247+
_ => None,
248+
}
249+
}
243250
}
244251

245252
pub struct MacroExpander<'a, 'b:'a> {
@@ -331,10 +338,20 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
331338

332339
let scope =
333340
if self.monotonic { invoc.expansion_data.mark } else { orig_expansion_data.mark };
341+
let attr_id_before = invoc.attr_id();
334342
let ext = match self.cx.resolver.resolve_invoc(&mut invoc, scope, force) {
335343
Ok(ext) => Some(ext),
336344
Err(Determinacy::Determined) => None,
337345
Err(Determinacy::Undetermined) => {
346+
// Sometimes attributes which we thought were invocations
347+
// end up being custom attributes for custom derives. If
348+
// that's the case our `invoc` will have changed out from
349+
// under us. If this is the case we're making progress so we
350+
// want to flag it as such, and we test this by looking if
351+
// the `attr_id()` method has been changing over time.
352+
if invoc.attr_id() != attr_id_before {
353+
progress = true;
354+
}
338355
undetermined_invocations.push(invoc);
339356
continue
340357
}

src/rustllvm/PassWrapper.cpp

-14
Original file line numberDiff line numberDiff line change
@@ -1228,15 +1228,6 @@ LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod, DICompileUnit *Unit) {
12281228
MD->addOperand(Unit);
12291229
}
12301230

1231-
extern "C" void
1232-
LLVMRustThinLTORemoveAvailableExternally(LLVMModuleRef Mod) {
1233-
Module *M = unwrap(Mod);
1234-
for (Function &F : M->functions()) {
1235-
if (F.hasAvailableExternallyLinkage())
1236-
F.deleteBody();
1237-
}
1238-
}
1239-
12401231
#else
12411232

12421233
extern "C" bool
@@ -1328,9 +1319,4 @@ LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod) {
13281319
report_fatal_error("ThinLTO not available");
13291320
}
13301321

1331-
extern "C" void
1332-
LLVMRustThinLTORemoveAvailableExternally(LLVMModuleRef Mod) {
1333-
report_fatal_error("ThinLTO not available");
1334-
}
1335-
13361322
#endif // LLVM_VERSION_GE(4, 0)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// no-prefer-dynamic
12+
13+
#![crate_type = "proc-macro"]
14+
15+
extern crate proc_macro;
16+
17+
use proc_macro::*;
18+
19+
#[proc_macro_derive(A, attributes(b))]
20+
pub fn foo(_x: TokenStream) -> TokenStream {
21+
TokenStream::new()
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:derive-two-attrs.rs
12+
13+
#![feature(use_extern_macros)]
14+
15+
extern crate derive_two_attrs as foo;
16+
17+
use foo::A;
18+
19+
#[derive(A)]
20+
#[b]
21+
#[b]
22+
struct B;
23+
24+
fn main() {}

src/test/run-pass/const-block.rs

-10
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ static BLOCK_FN: fn(usize) -> usize = { foo::<usize> };
3939

4040
static BLOCK_ENUM_CONSTRUCTOR: fn(usize) -> Option<usize> = { Some };
4141

42-
// FIXME #13972
43-
// static BLOCK_UNSAFE_SAFE_PTR: &'static isize = unsafe { &*(0xdeadbeef as *const isize) };
44-
// static BLOCK_UNSAFE_SAFE_PTR_2: &'static isize = unsafe {
45-
// const X: *const isize = 0xdeadbeef as *const isize;
46-
// &*X
47-
// };
48-
4942
pub fn main() {
5043
assert_eq!(BLOCK_INTEGRAL, 1);
5144
assert_eq!(BLOCK_EXPLICIT_UNIT, ());
@@ -58,7 +51,4 @@ pub fn main() {
5851
assert_eq!(BLOCK_FN_INFERRED(300), 300);
5952
assert_eq!(BLOCK_FN(300), 300);
6053
assert_eq!(BLOCK_ENUM_CONSTRUCTOR(200), Some(200));
61-
// FIXME #13972
62-
// assert_eq!(BLOCK_UNSAFE_SAFE_PTR as *const isize as usize, 0xdeadbeef);
63-
// assert_eq!(BLOCK_UNSAFE_SAFE_PTR_2 as *const isize as usize, 0xdeadbeef);
6454
}

src/test/run-pass/sepcomp-lib-lto.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// aux-build:sepcomp_lib.rs
1515
// compile-flags: -C lto -g
1616
// no-prefer-dynamic
17-
// ignore-android FIXME #18800
1817

1918
extern crate sepcomp_lib;
2019
use sepcomp_lib::a::one;

0 commit comments

Comments
 (0)