Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 13 pull requests #46430

Merged
merged 30 commits into from
Dec 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
658ea38
rustc_llvm: remove stale references
tamird Nov 26, 2017
9067d97
rustc_llvm: use cc::Build::define
tamird Nov 26, 2017
94d02b8
*: strip calls to cc::Build::compile
tamird Nov 26, 2017
c00ba79
Invert colors in important traits tooltip
GuillaumeGomez Nov 29, 2017
326eb79
rustbuild: Fix a typo with the Cargo book
alexcrichton Nov 29, 2017
21228a8
Remove librustdoc dependency on env_logger
Aaron1011 Nov 29, 2017
91a4106
Fix rustoc item summaries that are headers
chrisduerr Nov 29, 2017
2544b9f
Update Cargo to Wed Nov 29 15:19:05 2017 +0000
SimonSapin Nov 29, 2017
5a00b7c
make coercions to `!` in unreachable code a hard error
arielb1 Nov 8, 2017
666bb90
wasm: Update LLVM to fix a test
alexcrichton Nov 29, 2017
780f4ed
incr.comp.: Make traits::VTable encodable and decodable.
michaelwoerister Nov 30, 2017
4e74eb5
rustc: Filter out bogus extern crate warnings
alexcrichton Nov 30, 2017
ccef969
NetBSD: add sysctl backend for std::env::current_exe
jakllsch Nov 29, 2017
ec337b6
Show hidden items with rustdoc's document-private
chrisduerr Nov 30, 2017
1df13c0
Hide trait impl with private trait type parameter
chrisduerr Nov 30, 2017
5f47c7f
Fix htmldocck naming
chrisduerr Nov 30, 2017
f2df1f5
build_helper: destination file can't be up to date when not exists
Dec 1, 2017
95f465d
Rollup merge of #45880 - arielb1:never-coerce, r=nikomatsakis
kennytm Dec 1, 2017
263eb4d
Rollup merge of #46280 - tamird:remove-old-refs, r=alexcrichton
kennytm Dec 1, 2017
9493d4b
Rollup merge of #46373 - jakllsch:netbsd-kern_proc_pathname, r=kennytm
kennytm Dec 1, 2017
613da5c
Rollup merge of #46376 - SimonSapin:cargoup, r=kennytm
kennytm Dec 1, 2017
2341f6c
Rollup merge of #46385 - alexcrichton:fix-cargo-book, r=Mark-Simulacrum
kennytm Dec 1, 2017
ae24366
Rollup merge of #46386 - Aaron1011:fix_rustdoc_log, r=Mark-Simulacrum
kennytm Dec 1, 2017
bc8e8fa
Rollup merge of #46387 - chrisduerr:master, r=QuietMisdreavus
kennytm Dec 1, 2017
edaec07
Rollup merge of #46392 - GuillaumeGomez:fix-tooltip, r=QuietMisdreavus
kennytm Dec 1, 2017
b86a47f
Rollup merge of #46400 - michaelwoerister:vtable-encodable, r=eddyb
kennytm Dec 1, 2017
bd5a4af
Rollup merge of #46401 - alexcrichton:wasm-tests, r=arielb1
kennytm Dec 1, 2017
3f99b7c
Rollup merge of #46405 - alexcrichton:fix-rustdoc, r=estebank
kennytm Dec 1, 2017
662f902
Rollup merge of #46412 - chrisduerr:issue-46380, r=QuietMisdreavus
kennytm Dec 1, 2017
5617477
Rollup merge of #46421 - mnd:fix-build-for-guix, r=alexcrichton
kennytm Dec 1, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ config.stamp
keywords.md
lexer.ml
src/etc/dl
src/librustc_llvm/llvmdeps.rs
tmp.*.rs
version.md
version.ml
Expand Down
1 change: 0 additions & 1 deletion src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl Step for CargoBook {

let target = self.target;
let name = self.name;
let src = PathBuf::from("src/tools/cargo/src/doc/book");
let src = build.src.join("src/tools/cargo/src/doc/book");

let out = build.doc_out(target);
t!(fs::create_dir_all(&out));
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl Step for TestHelpers {
.warnings(false)
.debug(false)
.file(build.src.join("src/rt/rust_test_helpers.c"))
.compile("librust_test_helpers.a");
.compile("rust_test_helpers");
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/build_helper/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ pub fn mtime(path: &Path) -> FileTime {
///
/// Uses last-modified time checks to verify this.
pub fn up_to_date(src: &Path, dst: &Path) -> bool {
if !dst.exists() {
return false;
}
let threshold = mtime(dst);
let meta = match fs::metadata(src) {
Ok(meta) => meta,
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc_jemalloc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ fn main() {
cc::Build::new()
.flag("-fvisibility=hidden")
.file("pthread_atfork_dummy.c")
.compile("libpthread_atfork_dummy.a");
.compile("pthread_atfork_dummy");
}
}
2 changes: 1 addition & 1 deletion src/libprofiler_builtins/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ fn main() {
cfg.file(Path::new("../libcompiler_builtins/compiler-rt/lib/profile").join(src));
}

cfg.compile("libprofiler-rt.a");
cfg.compile("profiler-rt");
}
9 changes: 8 additions & 1 deletion src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ declare_lint! {
"detect mut variables which don't need to be mutable"
}

declare_lint! {
pub COERCE_NEVER,
Deny,
"detect coercion to !"
}

/// Does nothing as a lint pass, but registers some `Lint`s
/// which are used by other parts of the compiler.
#[derive(Copy, Clone)]
Expand Down Expand Up @@ -263,7 +269,8 @@ impl LintPass for HardwiredLints {
LATE_BOUND_LIFETIME_ARGUMENTS,
DEPRECATED,
UNUSED_UNSAFE,
UNUSED_MUT
UNUSED_MUT,
COERCE_NEVER
)
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
/// ### The type parameter `N`
///
/// See explanation on `VtableImplData`.
#[derive(Clone)]
#[derive(Clone, RustcEncodable, RustcDecodable)]
pub enum Vtable<'tcx, N> {
/// Vtable identifying a particular impl.
VtableImpl(VtableImplData<'tcx, N>),
Expand Down Expand Up @@ -327,14 +327,14 @@ pub enum Vtable<'tcx, N> {
/// is `Obligation`, as one might expect. During trans, however, this
/// is `()`, because trans only requires a shallow resolution of an
/// impl, and nested obligations are satisfied later.
#[derive(Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
pub struct VtableImplData<'tcx, N> {
pub impl_def_id: DefId,
pub substs: &'tcx Substs<'tcx>,
pub nested: Vec<N>
}

#[derive(Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
pub struct VtableGeneratorData<'tcx, N> {
pub closure_def_id: DefId,
pub substs: ty::ClosureSubsts<'tcx>,
Expand All @@ -343,7 +343,7 @@ pub struct VtableGeneratorData<'tcx, N> {
pub nested: Vec<N>
}

#[derive(Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
pub struct VtableClosureData<'tcx, N> {
pub closure_def_id: DefId,
pub substs: ty::ClosureSubsts<'tcx>,
Expand All @@ -352,20 +352,20 @@ pub struct VtableClosureData<'tcx, N> {
pub nested: Vec<N>
}

#[derive(Clone)]
#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct VtableAutoImplData<N> {
pub trait_def_id: DefId,
pub nested: Vec<N>
}

#[derive(Clone)]
#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct VtableBuiltinData<N> {
pub nested: Vec<N>
}

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

#[derive(Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
pub struct VtableFnPointerData<'tcx, N> {
pub fn_ty: Ty<'tcx>,
pub nested: Vec<N>
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
id: LintId::of(SAFE_PACKED_BORROWS),
reference: "issue #46043 <https://github.com/rust-lang/rust/issues/46043>",
},
FutureIncompatibleInfo {
id: LintId::of(COERCE_NEVER),
reference: "issue #46325 <https://github.com/rust-lang/rust/issues/46325>",
},

]);

Expand Down
8 changes: 4 additions & 4 deletions src/librustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ fn main() {
}

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

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

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

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

Expand Down
18 changes: 7 additions & 11 deletions src/librustc_llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,17 +505,13 @@ pub mod debuginfo {

pub enum ModuleBuffer {}

// Link to our native llvm bindings (things that we need to use the C++ api
// for) and because llvm is written in C++ we need to link against libstdc++
//
// You'll probably notice that there is an omission of all LLVM libraries
// from this location. This is because the set of LLVM libraries that we
// link to is mostly defined by LLVM, and the `llvm-config` tool is used to
// figure out the exact set of libraries. To do this, the build system
// generates an llvmdeps.rs file next to this one which will be
// automatically updated whenever LLVM is updated to include an up-to-date
// set of the libraries we need to link to LLVM for.
#[link(name = "rustllvm", kind = "static")] // not quite true but good enough
// This annotation is primarily needed for MSVC where attributes like
// dllimport/dllexport are applied and need to be correct for everything to
// link successfully. The #[link] annotation here says "these symbols are
// included statically" which means that they're all exported with dllexport
// and from the rustc_llvm dynamic library. Otherwise the rustc_trans dynamic
// library would not be able to access these symbols.
#[link(name = "rustllvm", kind = "static")]
extern "C" {
// Create and destroy contexts.
pub fn LLVMContextCreate() -> ContextRef;
Expand Down
11 changes: 10 additions & 1 deletion src/librustc_typeck/check/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ use rustc::hir;
use rustc::hir::def_id::DefId;
use rustc::infer::{Coercion, InferResult, InferOk};
use rustc::infer::type_variable::TypeVariableOrigin;
use rustc::lint;
use rustc::traits::{self, ObligationCause, ObligationCauseCode};
use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow};
use rustc::ty::{self, LvaluePreference, TypeAndMut,
Expand Down Expand Up @@ -754,7 +755,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// type, but only if the source expression diverges.
if target.is_never() && expr_diverges.always() {
debug!("permit coercion to `!` because expr diverges");
return Ok(target);
if self.can_eq(self.param_env, source, target).is_err() {
self.tcx.lint_node(
lint::builtin::COERCE_NEVER,
expr.id,
expr.span,
&format!("cannot coerce `{}` to !", source)
);
return Ok(target);
}
}

let cause = self.cause(expr.span, ObligationCauseCode::ExprAssignable);
Expand Down
19 changes: 19 additions & 0 deletions src/librustc_typeck/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
tcx.hir.krate().visit_all_item_likes(&mut visitor);

for &(def_id, span) in tcx.maybe_unused_extern_crates(LOCAL_CRATE).iter() {
// The `def_id` here actually was calculated during resolution (at least
// at the time of this writing) and is being shipped to us via a side
// channel of the tcx. There may have been extra expansion phases,
// however, which ended up removing the `def_id` *after* expansion such
// as the `ReplaceBodyWithLoop` pass (which is a bit of a hack, but hey)
//
// As a result we need to verify that `def_id` is indeed still valid for
// our AST and actually present in the HIR map. If it's not there then
// there's safely nothing to warn about, and otherwise we carry on with
// our execution.
//
// Note that if we carry through to the `extern_mod_stmt_cnum` query
// below it'll cause a panic because `def_id` is actually bogus at this
// point in time otherwise.
if let Some(id) = tcx.hir.as_local_node_id(def_id) {
if tcx.hir.find(id).is_none() {
continue
}
}
let cnum = tcx.extern_mod_stmt_cnum(def_id).unwrap();
if tcx.is_compiler_builtins(cnum) {
continue
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ path = "lib.rs"
doctest = false

[dependencies]
env_logger = { version = "0.4", default-features = false }
log = "0.3"
pulldown-cmark = { version = "0.1.0", default-features = false }
html-diff = "0.0.5"
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ fn main() {
.warnings(false)
.include(src_dir)
.warnings(false)
.compile("libhoedown.a");
.compile("hoedown");
}

4 changes: 3 additions & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,9 @@ fn full_path(cx: &Context, item: &clean::Item) -> String {

fn shorter<'a>(s: Option<&'a str>) -> String {
match s {
Some(s) => s.lines().take_while(|line|{
Some(s) => s.lines()
.skip_while(|s| s.chars().all(|c| c.is_whitespace()))
.take_while(|line|{
(*line).chars().any(|chr|{
!chr.is_whitespace()
})
Expand Down
6 changes: 6 additions & 0 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,12 @@ span.since {
border-color: transparent black transparent transparent;
}

.important-traits .tooltip .tooltiptext {
background-color: white;
color: black;
border: 1px solid #000;
}

pre.rust {
position: relative;
}
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
default_passes = false;

passes = vec![
String::from("strip-hidden"),
String::from("collapse-docs"),
String::from("unindent-comments"),
];
Expand Down
9 changes: 9 additions & 0 deletions src/librustdoc/passes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ impl<'a> fold::DocFolder for ImplStripper<'a> {
return None;
}
}
if let Some(generics) = imp.trait_.as_ref().and_then(|t| t.generics()) {
for typaram in generics {
if let Some(did) = typaram.def_id() {
if did.is_local() && !self.retained.contains(&did) {
return None;
}
}
}
}
}
self.fold_item_recur(i)
}
Expand Down
29 changes: 28 additions & 1 deletion src/libstd/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,34 @@ pub fn current_exe() -> io::Result<PathBuf> {

#[cfg(target_os = "netbsd")]
pub fn current_exe() -> io::Result<PathBuf> {
::fs::read_link("/proc/curproc/exe")
fn sysctl() -> io::Result<PathBuf> {
unsafe {
let mib = [libc::CTL_KERN, libc::KERN_PROC_ARGS, -1, libc::KERN_PROC_PATHNAME];
let mut path_len: usize = 0;
cvt(libc::sysctl(mib.as_ptr(), mib.len() as ::libc::c_uint,
ptr::null_mut(), &mut path_len,
ptr::null(), 0))?;
if path_len <= 1 {
return Err(io::Error::new(io::ErrorKind::Other,
"KERN_PROC_PATHNAME sysctl returned zero-length string"))
}
let mut path: Vec<u8> = Vec::with_capacity(path_len);
cvt(libc::sysctl(mib.as_ptr(), mib.len() as ::libc::c_uint,
path.as_ptr() as *mut libc::c_void, &mut path_len,
ptr::null(), 0))?;
path.set_len(path_len - 1); // chop off NUL
Ok(PathBuf::from(OsString::from_vec(path)))
}
}
fn procfs() -> io::Result<PathBuf> {
let curproc_exe = path::Path::new("/proc/curproc/exe");
if curproc_exe.is_file() {
return ::fs::read_link(curproc_exe);
}
Err(io::Error::new(io::ErrorKind::Other,
"/proc/curproc/exe doesn't point to regular file."))
}
sysctl().or_else(|_| procfs())
}

#[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
Expand Down
3 changes: 3 additions & 0 deletions src/test/compile-fail/coerce-to-bang-cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@

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

#[deny(coerce_never)]
fn cast_a() {
let y = {return; 22} as !;
//~^ ERROR cannot coerce `i32` to !
//~| hard error
}

fn cast_b() {
Expand Down
Loading