Skip to content

Commit 8d370ec

Browse files
committed
Auto merge of #47225 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 5 pull requests - Successful merges: #46987, #47165, #47173, #47202, #47216 - Failed merges:
2 parents b98fd52 + 35d1555 commit 8d370ec

File tree

9 files changed

+45
-66
lines changed

9 files changed

+45
-66
lines changed

src/librustc_llvm/ffi.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,6 @@ extern "C" {
538538
/// See llvm::LLVMTypeKind::getTypeID.
539539
pub fn LLVMRustGetTypeKind(Ty: TypeRef) -> TypeKind;
540540

541-
/// See llvm::Value::getContext
542-
pub fn LLVMRustGetValueContext(V: ValueRef) -> ContextRef;
543-
544541
// Operations on integer types
545542
pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
546543
pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
@@ -812,13 +809,12 @@ extern "C" {
812809
Bundle: OperandBundleDefRef,
813810
Name: *const c_char)
814811
-> ValueRef;
815-
pub fn LLVMRustBuildLandingPad(B: BuilderRef,
816-
Ty: TypeRef,
817-
PersFn: ValueRef,
818-
NumClauses: c_uint,
819-
Name: *const c_char,
820-
F: ValueRef)
821-
-> ValueRef;
812+
pub fn LLVMBuildLandingPad(B: BuilderRef,
813+
Ty: TypeRef,
814+
PersFn: ValueRef,
815+
NumClauses: c_uint,
816+
Name: *const c_char)
817+
-> ValueRef;
822818
pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
823819
pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
824820

src/librustc_trans/builder.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1012,12 +1012,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10121012
}
10131013

10141014
pub fn landing_pad(&self, ty: Type, pers_fn: ValueRef,
1015-
num_clauses: usize,
1016-
llfn: ValueRef) -> ValueRef {
1015+
num_clauses: usize) -> ValueRef {
10171016
self.count_insn("landingpad");
10181017
unsafe {
1019-
llvm::LLVMRustBuildLandingPad(self.llbuilder, ty.to_ref(), pers_fn,
1020-
num_clauses as c_uint, noname(), llfn)
1018+
llvm::LLVMBuildLandingPad(self.llbuilder, ty.to_ref(), pers_fn,
1019+
num_clauses as c_uint, noname())
10211020
}
10221021
}
10231022

src/librustc_trans/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ fn trans_gnu_try<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
925925
// rust_try ignores the selector.
926926
let lpad_ty = Type::struct_(ccx, &[Type::i8p(ccx), Type::i32(ccx)],
927927
false);
928-
let vals = catch.landing_pad(lpad_ty, bcx.ccx.eh_personality(), 1, catch.llfn());
928+
let vals = catch.landing_pad(lpad_ty, bcx.ccx.eh_personality(), 1);
929929
catch.add_clause(vals, C_null(Type::i8p(ccx)));
930930
let ptr = catch.extract_value(vals, 0);
931931
let ptr_align = bcx.tcx().data_layout.pointer_align;

src/librustc_trans/mir/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
753753

754754
let llpersonality = self.ccx.eh_personality();
755755
let llretty = self.landing_pad_type();
756-
let lp = bcx.landing_pad(llretty, llpersonality, 1, self.llfn);
756+
let lp = bcx.landing_pad(llretty, llpersonality, 1);
757757
bcx.set_cleanup(lp);
758758

759759
let slot = self.get_personality_slot(&bcx);

src/librustdoc/html/static/main.js

+4
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,10 @@
11321132
e.preventDefault();
11331133
} else if (e.which === 16) { // shift
11341134
// Does nothing, it's just to avoid losing "focus" on the highlighted element.
1135+
} else if (e.which === 27) { // escape
1136+
removeClass(actives[currentTab][0], 'highlighted');
1137+
document.getElementsByClassName('search-input')[0].value = '';
1138+
defocusSearchBar();
11351139
} else if (actives[currentTab].length > 0) {
11361140
removeClass(actives[currentTab][0], 'highlighted');
11371141
}

src/libstd/env.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,11 @@ pub fn temp_dir() -> PathBuf {
571571

572572
/// Returns the full filesystem path of the current running executable.
573573
///
574-
/// The path returned is not necessarily a "real path" of the executable as
575-
/// there may be intermediate symlinks.
574+
/// # Platform-specific behavior
575+
///
576+
/// If the executable was invoked through a symbolic link, some platforms will
577+
/// return the path of the symbolic link and other platforms will return the
578+
/// path of the symbolic link’s target.
576579
///
577580
/// # Errors
578581
///
@@ -599,24 +602,24 @@ pub fn temp_dir() -> PathBuf {
599602
/// Ok("/home/alex/foo")
600603
/// ```
601604
///
602-
/// And you make a symbolic link of the program:
605+
/// And you make a hard link of the program:
603606
///
604607
/// ```bash
605608
/// $ ln foo bar
606609
/// ```
607610
///
608-
/// When you run it, you won't get the original executable, you'll get the
609-
/// symlink:
611+
/// When you run it, you wont get the path of the original executable, you’ll
612+
/// get the path of the hard link:
610613
///
611614
/// ```bash
612615
/// $ ./bar
613616
/// Ok("/home/alex/bar")
614617
/// ```
615618
///
616619
/// This sort of behavior has been known to [lead to privilege escalation] when
617-
/// used incorrectly, for example.
620+
/// used incorrectly.
618621
///
619-
/// [lead to privilege escalation]: http://securityvulns.com/Wdocument183.html
622+
/// [lead to privilege escalation]: https://securityvulns.com/Wdocument183.html
620623
///
621624
/// # Examples
622625
///
@@ -625,7 +628,7 @@ pub fn temp_dir() -> PathBuf {
625628
///
626629
/// match env::current_exe() {
627630
/// Ok(exe_path) => println!("Path of this executable is: {}",
628-
/// exe_path.display()),
631+
/// exe_path.display()),
629632
/// Err(e) => println!("failed to get current exe path: {}", e),
630633
/// };
631634
/// ```

src/libstd/io/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ pub trait Read {
601601
read_to_end(self, buf)
602602
}
603603

604-
/// Read all bytes until EOF in this source, placing them into `buf`.
604+
/// Read all bytes until EOF in this source, appending them to `buf`.
605605
///
606606
/// If successful, this function returns the number of bytes which were read
607607
/// and appended to `buf`.

src/libstd/sys/unix/args.rs

+16-23
Original file line numberDiff line numberDiff line change
@@ -69,57 +69,50 @@ impl DoubleEndedIterator for Args {
6969
target_os = "fuchsia"))]
7070
mod imp {
7171
use os::unix::prelude::*;
72-
use mem;
72+
use ptr;
7373
use ffi::{CStr, OsString};
7474
use marker::PhantomData;
7575
use libc;
7676
use super::Args;
7777

7878
use sys_common::mutex::Mutex;
7979

80-
static mut GLOBAL_ARGS_PTR: usize = 0;
80+
static mut ARGC: isize = 0;
81+
static mut ARGV: *const *const u8 = ptr::null();
8182
static LOCK: Mutex = Mutex::new();
8283

8384
pub unsafe fn init(argc: isize, argv: *const *const u8) {
84-
let args = (0..argc).map(|i| {
85-
CStr::from_ptr(*argv.offset(i) as *const libc::c_char).to_bytes().to_vec()
86-
}).collect();
87-
8885
LOCK.lock();
89-
let ptr = get_global_ptr();
90-
assert!((*ptr).is_none());
91-
(*ptr) = Some(box args);
86+
ARGC = argc;
87+
ARGV = argv;
9288
LOCK.unlock();
9389
}
9490

9591
pub unsafe fn cleanup() {
9692
LOCK.lock();
97-
*get_global_ptr() = None;
93+
ARGC = 0;
94+
ARGV = ptr::null();
9895
LOCK.unlock();
9996
}
10097

10198
pub fn args() -> Args {
102-
let bytes = clone().unwrap_or(Vec::new());
103-
let v: Vec<OsString> = bytes.into_iter().map(|v| {
104-
OsStringExt::from_vec(v)
105-
}).collect();
106-
Args { iter: v.into_iter(), _dont_send_or_sync_me: PhantomData }
99+
Args {
100+
iter: clone().into_iter(),
101+
_dont_send_or_sync_me: PhantomData
102+
}
107103
}
108104

109-
fn clone() -> Option<Vec<Vec<u8>>> {
105+
fn clone() -> Vec<OsString> {
110106
unsafe {
111107
LOCK.lock();
112-
let ptr = get_global_ptr();
113-
let ret = (*ptr).as_ref().map(|s| (**s).clone());
108+
let ret = (0..ARGC).map(|i| {
109+
let cstr = CStr::from_ptr(*ARGV.offset(i) as *const libc::c_char);
110+
OsStringExt::from_vec(cstr.to_bytes().to_vec())
111+
}).collect();
114112
LOCK.unlock();
115113
return ret
116114
}
117115
}
118-
119-
fn get_global_ptr() -> *mut Option<Box<Vec<Vec<u8>>>> {
120-
unsafe { mem::transmute(&GLOBAL_ARGS_PTR) }
121-
}
122-
123116
}
124117

125118
#[cfg(any(target_os = "macos",

src/rustllvm/RustWrapper.cpp

+2-18
Original file line numberDiff line numberDiff line change
@@ -1144,13 +1144,6 @@ extern "C" void LLVMRustWriteSMDiagnosticToString(LLVMSMDiagnosticRef D,
11441144
unwrap(D)->print("", OS);
11451145
}
11461146

1147-
extern "C" LLVMValueRef
1148-
LLVMRustBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
1149-
LLVMValueRef PersFn, unsigned NumClauses,
1150-
const char *Name, LLVMValueRef F) {
1151-
return LLVMBuildLandingPad(B, Ty, PersFn, NumClauses, Name);
1152-
}
1153-
11541147
extern "C" LLVMValueRef LLVMRustBuildCleanupPad(LLVMBuilderRef B,
11551148
LLVMValueRef ParentPad,
11561149
unsigned ArgCount,
@@ -1355,10 +1348,6 @@ extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *hig
13551348
return true;
13561349
}
13571350

1358-
extern "C" LLVMContextRef LLVMRustGetValueContext(LLVMValueRef V) {
1359-
return wrap(&unwrap(V)->getContext());
1360-
}
1361-
13621351
enum class LLVMRustVisibility {
13631352
Default = 0,
13641353
Hidden = 1,
@@ -1439,11 +1428,6 @@ LLVMRustModuleBufferLen(const LLVMRustModuleBuffer *Buffer) {
14391428

14401429
extern "C" uint64_t
14411430
LLVMRustModuleCost(LLVMModuleRef M) {
1442-
Module &Mod = *unwrap(M);
1443-
uint64_t cost = 0;
1444-
for (auto &F : Mod.functions()) {
1445-
(void)F;
1446-
cost += 1;
1447-
}
1448-
return cost;
1431+
auto f = unwrap(M)->functions();
1432+
return std::distance(std::begin(f), std::end(f));
14491433
}

0 commit comments

Comments
 (0)