Skip to content

Commit 7051754

Browse files
committed
Auto merge of #46430 - kennytm:rollup, r=kennytm
Rollup of 13 pull requests - Successful merges: #45880, #46280, #46373, #46376, #46385, #46386, #46387, #46392, #46400, #46401, #46405, #46412, #46421 - Failed merges:
2 parents bb42071 + 5617477 commit 7051754

File tree

34 files changed

+219
-49
lines changed

34 files changed

+219
-49
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ config.stamp
9595
keywords.md
9696
lexer.ml
9797
src/etc/dl
98-
src/librustc_llvm/llvmdeps.rs
9998
tmp.*.rs
10099
version.md
101100
version.ml

src/Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl Step for CargoBook {
159159

160160
let target = self.target;
161161
let name = self.name;
162-
let src = PathBuf::from("src/tools/cargo/src/doc/book");
162+
let src = build.src.join("src/tools/cargo/src/doc/book");
163163

164164
let out = build.doc_out(target);
165165
t!(fs::create_dir_all(&out));

src/bootstrap/native.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl Step for TestHelpers {
316316
.warnings(false)
317317
.debug(false)
318318
.file(build.src.join("src/rt/rust_test_helpers.c"))
319-
.compile("librust_test_helpers.a");
319+
.compile("rust_test_helpers");
320320
}
321321
}
322322

src/build_helper/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ pub fn mtime(path: &Path) -> FileTime {
190190
///
191191
/// Uses last-modified time checks to verify this.
192192
pub fn up_to_date(src: &Path, dst: &Path) -> bool {
193+
if !dst.exists() {
194+
return false;
195+
}
193196
let threshold = mtime(dst);
194197
let meta = match fs::metadata(src) {
195198
Ok(meta) => meta,

src/liballoc_jemalloc/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,6 @@ fn main() {
140140
cc::Build::new()
141141
.flag("-fvisibility=hidden")
142142
.file("pthread_atfork_dummy.c")
143-
.compile("libpthread_atfork_dummy.a");
143+
.compile("pthread_atfork_dummy");
144144
}
145145
}

src/libprofiler_builtins/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ fn main() {
5656
cfg.file(Path::new("../libcompiler_builtins/compiler-rt/lib/profile").join(src));
5757
}
5858

59-
cfg.compile("libprofiler-rt.a");
59+
cfg.compile("profiler-rt");
6060
}

src/librustc/lint/builtin.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ declare_lint! {
222222
"detect mut variables which don't need to be mutable"
223223
}
224224

225+
declare_lint! {
226+
pub COERCE_NEVER,
227+
Deny,
228+
"detect coercion to !"
229+
}
230+
225231
/// Does nothing as a lint pass, but registers some `Lint`s
226232
/// which are used by other parts of the compiler.
227233
#[derive(Copy, Clone)]
@@ -263,7 +269,8 @@ impl LintPass for HardwiredLints {
263269
LATE_BOUND_LIFETIME_ARGUMENTS,
264270
DEPRECATED,
265271
UNUSED_UNSAFE,
266-
UNUSED_MUT
272+
UNUSED_MUT,
273+
COERCE_NEVER
267274
)
268275
}
269276
}

src/librustc/traits/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
282282
/// ### The type parameter `N`
283283
///
284284
/// See explanation on `VtableImplData`.
285-
#[derive(Clone)]
285+
#[derive(Clone, RustcEncodable, RustcDecodable)]
286286
pub enum Vtable<'tcx, N> {
287287
/// Vtable identifying a particular impl.
288288
VtableImpl(VtableImplData<'tcx, N>),
@@ -327,14 +327,14 @@ pub enum Vtable<'tcx, N> {
327327
/// is `Obligation`, as one might expect. During trans, however, this
328328
/// is `()`, because trans only requires a shallow resolution of an
329329
/// impl, and nested obligations are satisfied later.
330-
#[derive(Clone, PartialEq, Eq)]
330+
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
331331
pub struct VtableImplData<'tcx, N> {
332332
pub impl_def_id: DefId,
333333
pub substs: &'tcx Substs<'tcx>,
334334
pub nested: Vec<N>
335335
}
336336

337-
#[derive(Clone, PartialEq, Eq)]
337+
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
338338
pub struct VtableGeneratorData<'tcx, N> {
339339
pub closure_def_id: DefId,
340340
pub substs: ty::ClosureSubsts<'tcx>,
@@ -343,7 +343,7 @@ pub struct VtableGeneratorData<'tcx, N> {
343343
pub nested: Vec<N>
344344
}
345345

346-
#[derive(Clone, PartialEq, Eq)]
346+
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
347347
pub struct VtableClosureData<'tcx, N> {
348348
pub closure_def_id: DefId,
349349
pub substs: ty::ClosureSubsts<'tcx>,
@@ -352,20 +352,20 @@ pub struct VtableClosureData<'tcx, N> {
352352
pub nested: Vec<N>
353353
}
354354

355-
#[derive(Clone)]
355+
#[derive(Clone, RustcEncodable, RustcDecodable)]
356356
pub struct VtableAutoImplData<N> {
357357
pub trait_def_id: DefId,
358358
pub nested: Vec<N>
359359
}
360360

361-
#[derive(Clone)]
361+
#[derive(Clone, RustcEncodable, RustcDecodable)]
362362
pub struct VtableBuiltinData<N> {
363363
pub nested: Vec<N>
364364
}
365365

366366
/// A vtable for some object-safe trait `Foo` automatically derived
367367
/// for the object type `Foo`.
368-
#[derive(PartialEq,Eq,Clone)]
368+
#[derive(PartialEq, Eq, Clone, RustcEncodable, RustcDecodable)]
369369
pub struct VtableObjectData<'tcx, N> {
370370
/// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
371371
pub upcast_trait_ref: ty::PolyTraitRef<'tcx>,
@@ -378,7 +378,7 @@ pub struct VtableObjectData<'tcx, N> {
378378
pub nested: Vec<N>,
379379
}
380380

381-
#[derive(Clone, PartialEq, Eq)]
381+
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
382382
pub struct VtableFnPointerData<'tcx, N> {
383383
pub fn_ty: Ty<'tcx>,
384384
pub nested: Vec<N>

src/librustc_lint/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
247247
id: LintId::of(SAFE_PACKED_BORROWS),
248248
reference: "issue #46043 <https://github.com/rust-lang/rust/issues/46043>",
249249
},
250+
FutureIncompatibleInfo {
251+
id: LintId::of(COERCE_NEVER),
252+
reference: "issue #46325 <https://github.com/rust-lang/rust/issues/46325>",
253+
},
250254

251255
]);
252256

src/librustc_llvm/build.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ fn main() {
154154
}
155155

156156
for component in &components {
157-
let mut flag = String::from("-DLLVM_COMPONENT_");
157+
let mut flag = String::from("LLVM_COMPONENT_");
158158
flag.push_str(&component.to_uppercase());
159-
cfg.flag(&flag);
159+
cfg.define(&flag, None);
160160
}
161161

162162
if env::var_os("LLVM_RUSTLLVM").is_some() {
163-
cfg.flag("-DLLVM_RUSTLLVM");
163+
cfg.define("LLVM_RUSTLLVM", None);
164164
}
165165

166166
build_helper::rerun_if_changed_anything_in_dir(Path::new("../rustllvm"));
@@ -169,7 +169,7 @@ fn main() {
169169
.file("../rustllvm/ArchiveWrapper.cpp")
170170
.cpp(true)
171171
.cpp_link_stdlib(None) // we handle this below
172-
.compile("librustllvm.a");
172+
.compile("rustllvm");
173173

174174
let (llvm_kind, llvm_link_arg) = detect_llvm_link(major, minor, &llvm_config);
175175

src/librustc_llvm/ffi.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -505,17 +505,13 @@ pub mod debuginfo {
505505

506506
pub enum ModuleBuffer {}
507507

508-
// Link to our native llvm bindings (things that we need to use the C++ api
509-
// for) and because llvm is written in C++ we need to link against libstdc++
510-
//
511-
// You'll probably notice that there is an omission of all LLVM libraries
512-
// from this location. This is because the set of LLVM libraries that we
513-
// link to is mostly defined by LLVM, and the `llvm-config` tool is used to
514-
// figure out the exact set of libraries. To do this, the build system
515-
// generates an llvmdeps.rs file next to this one which will be
516-
// automatically updated whenever LLVM is updated to include an up-to-date
517-
// set of the libraries we need to link to LLVM for.
518-
#[link(name = "rustllvm", kind = "static")] // not quite true but good enough
508+
// This annotation is primarily needed for MSVC where attributes like
509+
// dllimport/dllexport are applied and need to be correct for everything to
510+
// link successfully. The #[link] annotation here says "these symbols are
511+
// included statically" which means that they're all exported with dllexport
512+
// and from the rustc_llvm dynamic library. Otherwise the rustc_trans dynamic
513+
// library would not be able to access these symbols.
514+
#[link(name = "rustllvm", kind = "static")]
519515
extern "C" {
520516
// Create and destroy contexts.
521517
pub fn LLVMContextCreate() -> ContextRef;

src/librustc_typeck/check/coercion.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ use rustc::hir;
6666
use rustc::hir::def_id::DefId;
6767
use rustc::infer::{Coercion, InferResult, InferOk};
6868
use rustc::infer::type_variable::TypeVariableOrigin;
69+
use rustc::lint;
6970
use rustc::traits::{self, ObligationCause, ObligationCauseCode};
7071
use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow};
7172
use rustc::ty::{self, LvaluePreference, TypeAndMut,
@@ -754,7 +755,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
754755
// type, but only if the source expression diverges.
755756
if target.is_never() && expr_diverges.always() {
756757
debug!("permit coercion to `!` because expr diverges");
757-
return Ok(target);
758+
if self.can_eq(self.param_env, source, target).is_err() {
759+
self.tcx.lint_node(
760+
lint::builtin::COERCE_NEVER,
761+
expr.id,
762+
expr.span,
763+
&format!("cannot coerce `{}` to !", source)
764+
);
765+
return Ok(target);
766+
}
758767
}
759768

760769
let cause = self.cause(expr.span, ObligationCauseCode::ExprAssignable);

src/librustc_typeck/check_unused.rs

+19
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,25 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
7575
tcx.hir.krate().visit_all_item_likes(&mut visitor);
7676

7777
for &(def_id, span) in tcx.maybe_unused_extern_crates(LOCAL_CRATE).iter() {
78+
// The `def_id` here actually was calculated during resolution (at least
79+
// at the time of this writing) and is being shipped to us via a side
80+
// channel of the tcx. There may have been extra expansion phases,
81+
// however, which ended up removing the `def_id` *after* expansion such
82+
// as the `ReplaceBodyWithLoop` pass (which is a bit of a hack, but hey)
83+
//
84+
// As a result we need to verify that `def_id` is indeed still valid for
85+
// our AST and actually present in the HIR map. If it's not there then
86+
// there's safely nothing to warn about, and otherwise we carry on with
87+
// our execution.
88+
//
89+
// Note that if we carry through to the `extern_mod_stmt_cnum` query
90+
// below it'll cause a panic because `def_id` is actually bogus at this
91+
// point in time otherwise.
92+
if let Some(id) = tcx.hir.as_local_node_id(def_id) {
93+
if tcx.hir.find(id).is_none() {
94+
continue
95+
}
96+
}
7897
let cnum = tcx.extern_mod_stmt_cnum(def_id).unwrap();
7998
if tcx.is_compiler_builtins(cnum) {
8099
continue

src/librustdoc/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ path = "lib.rs"
1111
doctest = false
1212

1313
[dependencies]
14-
env_logger = { version = "0.4", default-features = false }
1514
log = "0.3"
1615
pulldown-cmark = { version = "0.1.0", default-features = false }
1716
html-diff = "0.0.5"

src/librustdoc/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fn main() {
2727
.warnings(false)
2828
.include(src_dir)
2929
.warnings(false)
30-
.compile("libhoedown.a");
30+
.compile("hoedown");
3131
}
3232

src/librustdoc/html/render.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,9 @@ fn full_path(cx: &Context, item: &clean::Item) -> String {
18191819

18201820
fn shorter<'a>(s: Option<&'a str>) -> String {
18211821
match s {
1822-
Some(s) => s.lines().take_while(|line|{
1822+
Some(s) => s.lines()
1823+
.skip_while(|s| s.chars().all(|c| c.is_whitespace()))
1824+
.take_while(|line|{
18231825
(*line).chars().any(|chr|{
18241826
!chr.is_whitespace()
18251827
})

src/librustdoc/html/static/rustdoc.css

+6
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,12 @@ span.since {
920920
border-color: transparent black transparent transparent;
921921
}
922922

923+
.important-traits .tooltip .tooltiptext {
924+
background-color: white;
925+
color: black;
926+
border: 1px solid #000;
927+
}
928+
923929
pre.rust {
924930
position: relative;
925931
}

src/librustdoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
470470
default_passes = false;
471471

472472
passes = vec![
473-
String::from("strip-hidden"),
474473
String::from("collapse-docs"),
475474
String::from("unindent-comments"),
476475
];

src/librustdoc/passes/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ impl<'a> fold::DocFolder for ImplStripper<'a> {
184184
return None;
185185
}
186186
}
187+
if let Some(generics) = imp.trait_.as_ref().and_then(|t| t.generics()) {
188+
for typaram in generics {
189+
if let Some(did) = typaram.def_id() {
190+
if did.is_local() && !self.retained.contains(&did) {
191+
return None;
192+
}
193+
}
194+
}
195+
}
187196
}
188197
self.fold_item_recur(i)
189198
}

src/libstd/sys/unix/os.rs

+28-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,34 @@ pub fn current_exe() -> io::Result<PathBuf> {
223223

224224
#[cfg(target_os = "netbsd")]
225225
pub fn current_exe() -> io::Result<PathBuf> {
226-
::fs::read_link("/proc/curproc/exe")
226+
fn sysctl() -> io::Result<PathBuf> {
227+
unsafe {
228+
let mib = [libc::CTL_KERN, libc::KERN_PROC_ARGS, -1, libc::KERN_PROC_PATHNAME];
229+
let mut path_len: usize = 0;
230+
cvt(libc::sysctl(mib.as_ptr(), mib.len() as ::libc::c_uint,
231+
ptr::null_mut(), &mut path_len,
232+
ptr::null(), 0))?;
233+
if path_len <= 1 {
234+
return Err(io::Error::new(io::ErrorKind::Other,
235+
"KERN_PROC_PATHNAME sysctl returned zero-length string"))
236+
}
237+
let mut path: Vec<u8> = Vec::with_capacity(path_len);
238+
cvt(libc::sysctl(mib.as_ptr(), mib.len() as ::libc::c_uint,
239+
path.as_ptr() as *mut libc::c_void, &mut path_len,
240+
ptr::null(), 0))?;
241+
path.set_len(path_len - 1); // chop off NUL
242+
Ok(PathBuf::from(OsString::from_vec(path)))
243+
}
244+
}
245+
fn procfs() -> io::Result<PathBuf> {
246+
let curproc_exe = path::Path::new("/proc/curproc/exe");
247+
if curproc_exe.is_file() {
248+
return ::fs::read_link(curproc_exe);
249+
}
250+
Err(io::Error::new(io::ErrorKind::Other,
251+
"/proc/curproc/exe doesn't point to regular file."))
252+
}
253+
sysctl().or_else(|_| procfs())
227254
}
228255

229256
#[cfg(any(target_os = "bitrig", target_os = "openbsd"))]

src/test/compile-fail/coerce-to-bang-cast.rs

+3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212

1313
fn foo(x: usize, y: !, z: usize) { }
1414

15+
#[deny(coerce_never)]
1516
fn cast_a() {
1617
let y = {return; 22} as !;
18+
//~^ ERROR cannot coerce `i32` to !
19+
//~| hard error
1720
}
1821

1922
fn cast_b() {

0 commit comments

Comments
 (0)