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 10 pull requests #46395

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e457cbd
Use suggestions instead of notes ref mismatches
estebank Nov 25, 2017
f9bbcf9
Update compiler-builtins and use it the 128-bit lowering MIR test
scottmcm Nov 25, 2017
c80fee2
Remove the unneeded #![feature(lang_items)]s
scottmcm Nov 27, 2017
235de09
make coercions to `!` in unreachable code a hard error
arielb1 Nov 8, 2017
677381a
On type mismatch error highlight `&` when type matches
estebank Nov 28, 2017
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
dfa6c25
Fix hygiene bug.
jseyfried Nov 28, 2017
89dc8ae
incr.comp.: Remove an unnecessary HIR access which enables hashing sp…
michaelwoerister Nov 29, 2017
02808f1
Include lifetime on highlighted ref type mismatch
estebank Nov 29, 2017
b444843
rustdoc: Fix issues with cross-crate inlined associated items
ollie27 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
8ae7017
Rollup merge of #45880 - arielb1:never-coerce, r=nikomatsakis
Nov 30, 2017
bcfab94
Rollup merge of #46256 - estebank:suggest-deref, r=arielb1
Nov 30, 2017
b54f43a
Rollup merge of #46280 - tamird:remove-old-refs, r=alexcrichton
Nov 30, 2017
be51c4d
Rollup merge of #46290 - scottmcm:i128-from-compiler-builtins, r=nagisa
Nov 30, 2017
cfb8e76
Rollup merge of #46343 - jseyfried:fix_hygiene_bug, r=nrc
Nov 30, 2017
f40088a
Rollup merge of #46349 - estebank:highlight-ref, r=arielb1
Nov 30, 2017
e5d4a7a
Rollup merge of #46368 - michaelwoerister:incr-comp-type-debuginfo-sp…
Nov 30, 2017
8f05a4d
Rollup merge of #46384 - ollie27:rustdoc_inline_assoc, r=QuietMisdreavus
Nov 30, 2017
82b773c
Rollup merge of #46385 - alexcrichton:fix-cargo-book, r=Mark-Simulacrum
Nov 30, 2017
06bfd29
Rollup merge of #46386 - Aaron1011:fix_rustdoc_log, r=Mark-Simulacrum
Nov 30, 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
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/libcompiler_builtins
2 changes: 1 addition & 1 deletion src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl FromStr for TokenStream {
// notify the expansion info that it is unhygienic
let mark = Mark::fresh(mark);
mark.set_expn_info(expn_info);
let span = call_site.with_ctxt(SyntaxContext::empty().apply_mark(mark));
let span = call_site.with_ctxt(call_site.ctxt().apply_mark(mark));
let stream = parse::parse_stream_from_source_str(name, src, sess, Some(span));
Ok(__internal::token_stream_wrap(stream))
})
Expand Down
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");
}
3 changes: 2 additions & 1 deletion src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ impl Definitions {
self.node_to_def_index.insert(node_id, index);
}

if expansion.is_modern() {
let expansion = expansion.modern();
if expansion != Mark::root() {
self.expansions.insert(index, expansion);
}

Expand Down
20 changes: 9 additions & 11 deletions src/librustc/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,13 +884,13 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for hir::Item {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'gcx>,
hasher: &mut StableHasher<W>) {
let (is_const, hash_spans) = match self.node {
let is_const = match self.node {
hir::ItemStatic(..) |
hir::ItemConst(..) => {
(true, hcx.hash_spans())
true
}
hir::ItemFn(_, _, constness, ..) => {
(constness == hir::Constness::Const, hcx.hash_spans())
constness == hir::Constness::Const
}
hir::ItemUse(..) |
hir::ItemExternCrate(..) |
Expand All @@ -904,7 +904,7 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for hir::Item {
hir::ItemEnum(..) |
hir::ItemStruct(..) |
hir::ItemUnion(..) => {
(false, false)
false
}
};

Expand All @@ -919,13 +919,11 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for hir::Item {
} = *self;

hcx.hash_hir_item_like(attrs, is_const, |hcx| {
hcx.while_hashing_spans(hash_spans, |hcx| {
name.hash_stable(hcx, hasher);
attrs.hash_stable(hcx, hasher);
node.hash_stable(hcx, hasher);
vis.hash_stable(hcx, hasher);
span.hash_stable(hcx, hasher);
});
name.hash_stable(hcx, hasher);
attrs.hash_stable(hcx, hasher);
node.hash_stable(hcx, hasher);
vis.hash_stable(hcx, hasher);
span.hash_stable(hcx, hasher);
});
}
}
Expand Down
56 changes: 56 additions & 0 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,39 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
fn cmp(&self, t1: Ty<'tcx>, t2: Ty<'tcx>)
-> (DiagnosticStyledString, DiagnosticStyledString)
{
fn equals<'tcx>(a: &Ty<'tcx>, b: &Ty<'tcx>) -> bool {
match (&a.sty, &b.sty) {
(a, b) if *a == *b => true,
(&ty::TyInt(_), &ty::TyInfer(ty::InferTy::IntVar(_))) |
(&ty::TyInfer(ty::InferTy::IntVar(_)), &ty::TyInt(_)) |
(&ty::TyInfer(ty::InferTy::IntVar(_)), &ty::TyInfer(ty::InferTy::IntVar(_))) |
(&ty::TyFloat(_), &ty::TyInfer(ty::InferTy::FloatVar(_))) |
(&ty::TyInfer(ty::InferTy::FloatVar(_)), &ty::TyFloat(_)) |
(&ty::TyInfer(ty::InferTy::FloatVar(_)),
&ty::TyInfer(ty::InferTy::FloatVar(_))) => true,
_ => false,
}
}

fn push_ty_ref<'tcx>(r: &ty::Region<'tcx>,
tnm: &ty::TypeAndMut<'tcx>,
s: &mut DiagnosticStyledString) {
let r = &format!("{}", r);
s.push_highlighted(format!("&{}{}{}",
r,
if r == "" {
""
} else {
" "
},
if tnm.mutbl == hir::MutMutable {
"mut "
} else {
""
}));
s.push_normal(format!("{}", tnm.ty));
}

match (&t1.sty, &t2.sty) {
(&ty::TyAdt(def1, sub1), &ty::TyAdt(def2, sub2)) => {
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
Expand Down Expand Up @@ -672,6 +705,29 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
DiagnosticStyledString::highlighted(format!("{}", t2)))
}
}

// When finding T != &T, hightlight only the borrow
(&ty::TyRef(r1, ref tnm1), _) if equals(&tnm1.ty, &t2) => {
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
push_ty_ref(&r1, tnm1, &mut values.0);
values.1.push_normal(format!("{}", t2));
values
}
(_, &ty::TyRef(r2, ref tnm2)) if equals(&t1, &tnm2.ty) => {
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
values.0.push_normal(format!("{}", t1));
push_ty_ref(&r2, tnm2, &mut values.1);
values
}

// When encountering &T != &mut T, highlight only the borrow
(&ty::TyRef(r1, ref tnm1), &ty::TyRef(r2, ref tnm2)) if equals(&tnm1.ty, &tnm2.ty) => {
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
push_ty_ref(&r1, tnm1, &mut values.0);
push_ty_ref(&r2, tnm2, &mut values.1);
values
}

_ => {
if t1 == t2 {
// The two types are the same, elide and don't highlight.
Expand Down
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
4 changes: 1 addition & 3 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2302,9 +2302,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}

pub fn item_name(self, id: DefId) -> InternedString {
if let Some(id) = self.hir.as_local_node_id(id) {
self.hir.name(id).as_str()
} else if id.index == CRATE_DEF_INDEX {
if id.index == CRATE_DEF_INDEX {
self.original_crate_name(id.krate).as_str()
} else {
let def_key = self.def_key(id);
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/42869>",
},

]);

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
13 changes: 11 additions & 2 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,15 @@ impl<'a> Resolver<'a> {
}
}

fn macro_def(&self, mut ctxt: SyntaxContext) -> DefId {
loop {
match self.macro_defs.get(&ctxt.outer()) {
Some(&def_id) => return def_id,
None => ctxt.remove_mark(),
};
}
}

/// Entry point to crate resolution.
pub fn resolve_crate(&mut self, krate: &Crate) {
ImportResolver { resolver: self }.finalize_imports();
Expand Down Expand Up @@ -1663,7 +1672,7 @@ impl<'a> Resolver<'a> {

module = match self.ribs[ns][i].kind {
ModuleRibKind(module) => module,
MacroDefinition(def) if def == self.macro_defs[&ident.ctxt.outer()] => {
MacroDefinition(def) if def == self.macro_def(ident.ctxt) => {
// If an invocation of this macro created `ident`, give up on `ident`
// and switch to `ident`'s source from the macro definition.
ident.ctxt.remove_mark();
Expand Down Expand Up @@ -1830,7 +1839,7 @@ impl<'a> Resolver<'a> {
// If an invocation of this macro created `ident`, give up on `ident`
// and switch to `ident`'s source from the macro definition.
MacroDefinition(def) => {
if def == self.macro_defs[&ident.ctxt.outer()] {
if def == self.macro_def(ident.ctxt) {
ident.ctxt.remove_mark();
}
}
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
Loading