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 9 pull requests #59522

Merged
merged 29 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6ea6e62
Update jemalloc-sys to version 0.3.0
gnzlbg Mar 26, 2019
b73886d
Update Cargo.lock
gnzlbg Mar 26, 2019
c728ae0
Update rustfmt to 1.2.0
topecongiro Mar 27, 2019
d59b46f
Add a test
taiki-e Mar 27, 2019
4d648ce
Better diagnostic for binary operation on BoxedValues
hgallagher1993 Mar 27, 2019
5113e73
Update books
ehuss Mar 22, 2019
b3011dd
Visit ItemKind::Impl for dead code lint
varkor Mar 28, 2019
40db575
Add a regression test for #47131
varkor Mar 28, 2019
0acb786
Do not suggest borrowing when the span comes from a macro
estebank Mar 28, 2019
925ca49
Add test
estebank Mar 28, 2019
326ec80
Account for fully overlapping multiline annotations
estebank Mar 28, 2019
81402db
Update stdsimd
gnzlbg Mar 28, 2019
7a5c82d
Add edition-guide to toolstate.
ehuss Mar 28, 2019
4644c3a
Add check for when left and right overlap and change span for explana…
hgallagher1993 Mar 28, 2019
8cdfad9
Walk all items for dead_code lint by default
varkor Mar 28, 2019
44813df
Rename `type_parameters` to `generics` and so on
varkor Mar 29, 2019
e13e9a5
review comments
estebank Mar 29, 2019
8fad69c
Add comemnts clarifying logic
estebank Mar 29, 2019
b5690c2
Fix MultilineAnnotation field name
estebank Mar 29, 2019
362d243
Fix error in Rust 2018 + no_core environment
taiki-e Mar 29, 2019
972a8ce
Rollup merge of #59366 - ehuss:update-books, r=QuietMisdreavus
Centril Mar 29, 2019
8e0855b
Rollup merge of #59436 - gnzlbg:update_jemalloc, r=alexcrichton
Centril Mar 29, 2019
38af98e
Rollup merge of #59454 - topecongiro:rustfmt-1.2.0, r=nrc
Centril Mar 29, 2019
647d09f
Rollup merge of #59462 - taiki-e:no-core, r=petrochenkov
Centril Mar 29, 2019
fda2066
Rollup merge of #59467 - hgallagher1993:local_branch, r=estebank
Centril Mar 29, 2019
c105f34
Rollup merge of #59473 - estebank:borrow-sugg-inside-macro, r=davidtwco
Centril Mar 29, 2019
ee17267
Rollup merge of #59480 - gnzlbg:us, r=alexcrichton
Centril Mar 29, 2019
4aacc49
Rollup merge of #59486 - varkor:dead-code-impl, r=sanxiyn
Centril Mar 29, 2019
99e886d
Rollup merge of #59510 - varkor:rename-type_parameters, r=eddyb
Centril Mar 29, 2019
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
16 changes: 8 additions & 8 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "jemalloc-sys"
version = "0.1.8"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -2074,7 +2074,7 @@ name = "rand_chacha"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]

Expand All @@ -2096,7 +2096,7 @@ name = "rand_hc"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand All @@ -2121,7 +2121,7 @@ name = "rand_xorshift"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand Down Expand Up @@ -2260,7 +2260,7 @@ dependencies = [
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-workspace-hack 1.0.0",
"rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustfmt-nightly 1.1.0",
"rustfmt-nightly 1.2.0",
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -2500,7 +2500,7 @@ dependencies = [
name = "rustc-main"
version = "0.0.0"
dependencies = [
"jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"jemalloc-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_codegen_ssa 0.0.0",
"rustc_driver 0.0.0",
"rustc_target 0.0.0",
Expand Down Expand Up @@ -3056,7 +3056,7 @@ dependencies = [

[[package]]
name = "rustfmt-nightly"
version = "1.1.0"
version = "1.2.0"
dependencies = [
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bytecount 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -4096,7 +4096,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358"
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae"
"checksum jemalloc-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7bef0d4ce37578dfd80b466e3d8324bd9de788e249f1accebb0c472ea4b52bdc"
"checksum jobserver 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "dd80e58f77e0cdea53ba96acc5e04479e5ffc5d869626a6beafe50fed867eace"
"checksum json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9ad0485404155f45cce53a40d4b2d6ac356418300daed05273d9e26f91c390be"
"checksum jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a5152c3fda235dfd68341b3edf4121bc4428642c93acbd6de88c26bf95fc5d7"
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ impl<'a> Builder<'a> {
test::UnstableBook,
test::RustcBook,
test::EmbeddedBook,
test::EditionGuide,
test::Rustfmt,
test::Miri,
test::Clippy,
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,7 @@ test_book!(
EmbeddedBook, "src/doc/embedded-book", "embedded-book", default=false;
TheBook, "src/doc/book", "book", default=false;
UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;
EditionGuide, "src/doc/edition-guide", "edition-guide", default=false;
);

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Expand Down
2 changes: 2 additions & 0 deletions src/ci/docker/x86_64-gnu-tools/checktools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ python2.7 "$X_PY" test --no-fail-fast \
src/doc/reference \
src/doc/rust-by-example \
src/doc/embedded-book \
src/doc/edition-guide \
src/tools/clippy \
src/tools/rls \
src/tools/rustfmt \
Expand Down Expand Up @@ -73,6 +74,7 @@ status_check() {
check_dispatch $1 beta nomicon src/doc/nomicon
check_dispatch $1 beta reference src/doc/reference
check_dispatch $1 beta rust-by-example src/doc/rust-by-example
check_dispatch $1 beta edition-guide src/doc/edition-guide
check_dispatch $1 beta rls src/tools/rls
check_dispatch $1 beta rustfmt src/tools/rustfmt
check_dispatch $1 beta clippy-driver src/tools/clippy
Expand Down
2 changes: 1 addition & 1 deletion src/doc/edition-guide
2 changes: 1 addition & 1 deletion src/doc/reference
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
6 changes: 3 additions & 3 deletions src/doc/unstable-book/src/language-features/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ The advantages over a simple `fn(&str) -> u32` are:
a way to define new literal syntax for any data type.

In addition to procedural macros, you can define new
[`derive`](../reference/attributes.html#derive)-like attributes and other kinds
[`derive`](../reference/attributes/derive.html)-like attributes and other kinds
of extensions. See `Registry::register_syntax_extension` and the
`SyntaxExtension` enum. For a more involved macro example, see
[`regex_macros`](https://github.com/rust-lang/regex/blob/master/regex_macros/src/lib.rs).
Expand Down Expand Up @@ -174,7 +174,7 @@ quasiquote as an ordinary plugin library.
# Lint plugins

Plugins can extend [Rust's lint
infrastructure](../reference/attributes.html#lint-check-attributes) with
infrastructure](../reference/attributes/diagnostics.html#lint-check-attributes) with
additional checks for code style, safety, etc. Now let's write a plugin
[`lint_plugin_test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs)
that warns about any item named `lintme`.
Expand Down Expand Up @@ -253,7 +253,7 @@ mostly use the same infrastructure as lint plugins, and provide examples of how
to access type information.

Lints defined by plugins are controlled by the usual [attributes and compiler
flags](../reference/attributes.html#lint-check-attributes), e.g.
flags](../reference/attributes/diagnostics.html#lint-check-attributes), e.g.
`#[allow(test_lint)]` or `-A test-lint`. These identifiers are derived from the
first argument to `declare_lint!`, with appropriate case and punctuation
conversion.
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,30 +485,30 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
ItemKind::GlobalAsm(_) => {
visitor.visit_id(item.hir_id);
}
ItemKind::Ty(ref typ, ref type_parameters) => {
ItemKind::Ty(ref ty, ref generics) => {
visitor.visit_id(item.hir_id);
visitor.visit_ty(typ);
visitor.visit_generics(type_parameters)
visitor.visit_ty(ty);
visitor.visit_generics(generics)
}
ItemKind::Existential(ExistTy { ref generics, ref bounds, impl_trait_fn: _ }) => {
visitor.visit_id(item.hir_id);
walk_generics(visitor, generics);
walk_list!(visitor, visit_param_bound, bounds);
}
ItemKind::Enum(ref enum_definition, ref type_parameters) => {
visitor.visit_generics(type_parameters);
ItemKind::Enum(ref enum_definition, ref generics) => {
visitor.visit_generics(generics);
// `visit_enum_def()` takes care of visiting the `Item`'s `HirId`.
visitor.visit_enum_def(enum_definition, type_parameters, item.hir_id, item.span)
visitor.visit_enum_def(enum_definition, generics, item.hir_id, item.span)
}
ItemKind::Impl(
..,
ref type_parameters,
ref generics,
ref opt_trait_reference,
ref typ,
ref impl_item_refs
) => {
visitor.visit_id(item.hir_id);
visitor.visit_generics(type_parameters);
visitor.visit_generics(generics);
walk_list!(visitor, visit_trait_ref, opt_trait_reference);
visitor.visit_ty(typ);
walk_list!(visitor, visit_impl_item_ref, impl_item_refs);
Expand Down
14 changes: 6 additions & 8 deletions src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
Def::Const(_) | Def::AssociatedConst(..) | Def::TyAlias(_) => {
self.check_def_id(def.def_id());
}
_ if self.in_pat => (),
_ if self.in_pat => {},
Def::PrimTy(..) | Def::SelfTy(..) | Def::SelfCtor(..) |
Def::Local(..) | Def::Upvar(..) => {}
Def::Ctor(ctor_def_id, CtorOf::Variant, ..) => {
Expand All @@ -91,6 +91,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
self.check_def_id(variant_id);
}
}
Def::ToolMod | Def::NonMacroAttr(..) | Def::Err => {}
_ => {
self.check_def_id(def.def_id());
}
Expand Down Expand Up @@ -166,16 +167,13 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
hir::ItemKind::Enum(..) => {
self.inherited_pub_visibility = item.vis.node.is_pub();

intravisit::walk_item(self, &item);
}
hir::ItemKind::Fn(..)
| hir::ItemKind::Ty(..)
| hir::ItemKind::Static(..)
| hir::ItemKind::Existential(..)
| hir::ItemKind::Const(..) => {
hir::ItemKind::ForeignMod(..) => {}
_ => {
intravisit::walk_item(self, &item);
}
_ => ()
}
}
Node::TraitItem(trait_item) => {
Expand All @@ -187,7 +185,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
Node::ForeignItem(foreign_item) => {
intravisit::walk_foreign_item(self, &foreign_item);
}
_ => ()
_ => {}
}
self.repr_has_repr_c = had_repr_c;
self.inherited_pub_visibility = had_inherited_pub_visibility;
Expand Down
58 changes: 45 additions & 13 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ impl EmitterWriter {
end_col: hi.col_display,
is_primary: span_label.is_primary,
label: span_label.label.clone(),
overlaps_exactly: false,
};
multiline_annotations.push((lo.file.clone(), ml.clone()));
AnnotationType::Multiline(ml)
Expand All @@ -258,10 +259,7 @@ impl EmitterWriter {
};

if !ann.is_multiline() {
add_annotation_to_file(&mut output,
lo.file,
lo.line,
ann);
add_annotation_to_file(&mut output, lo.file, lo.line, ann);
}
}
}
Expand All @@ -274,10 +272,12 @@ impl EmitterWriter {
let ref mut a = item.1;
// Move all other multiline annotations overlapping with this one
// one level to the right.
if &ann != a &&
if !(ann.same_span(a)) &&
num_overlap(ann.line_start, ann.line_end, a.line_start, a.line_end, true)
{
a.increase_depth();
} else if ann.same_span(a) && &ann != a {
a.overlaps_exactly = true;
} else {
break;
}
Expand All @@ -289,17 +289,49 @@ impl EmitterWriter {
if ann.depth > max_depth {
max_depth = ann.depth;
}
add_annotation_to_file(&mut output, file.clone(), ann.line_start, ann.as_start());
let middle = min(ann.line_start + 4, ann.line_end);
for line in ann.line_start + 1..middle {
add_annotation_to_file(&mut output, file.clone(), line, ann.as_line());
}
if middle < ann.line_end - 1 {
for line in ann.line_end - 1..ann.line_end {
let mut end_ann = ann.as_end();
if !ann.overlaps_exactly {
// avoid output like
//
// | foo(
// | _____^
// | |_____|
// | || bar,
// | || );
// | || ^
// | ||______|
// | |______foo
// | baz
//
// and instead get
//
// | foo(
// | _____^
// | | bar,
// | | );
// | | ^
// | | |
// | |______foo
// | baz
add_annotation_to_file(&mut output, file.clone(), ann.line_start, ann.as_start());
// 4 is the minimum vertical length of a multiline span when presented: two lines
// of code and two lines of underline. This is not true for the special case where
// the beginning doesn't have an underline, but the current logic seems to be
// working correctly.
let middle = min(ann.line_start + 4, ann.line_end);
for line in ann.line_start + 1..middle {
// Every `|` that joins the beginning of the span (`___^`) to the end (`|__^`).
add_annotation_to_file(&mut output, file.clone(), line, ann.as_line());
}
if middle < ann.line_end - 1 {
for line in ann.line_end - 1..ann.line_end {
add_annotation_to_file(&mut output, file.clone(), line, ann.as_line());
}
}
} else {
end_ann.annotation_type = AnnotationType::Singleline;
}
add_annotation_to_file(&mut output, file, ann.line_end, ann.as_end());
add_annotation_to_file(&mut output, file, ann.line_end, end_ann);
}
for file_vec in output.iter_mut() {
file_vec.multiline_depth = max_depth;
Expand Down
7 changes: 7 additions & 0 deletions src/librustc_errors/snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ pub struct MultilineAnnotation {
pub end_col: usize,
pub is_primary: bool,
pub label: Option<String>,
pub overlaps_exactly: bool,
}

impl MultilineAnnotation {
pub fn increase_depth(&mut self) {
self.depth += 1;
}

/// Compare two `MultilineAnnotation`s considering only the `Span` they cover.
pub fn same_span(&self, other: &MultilineAnnotation) -> bool {
self.line_start == other.line_start && self.line_end == other.line_end
&& self.start_col == other.start_col && self.end_col == other.end_col
}

pub fn as_start(&self) -> Annotation {
Annotation {
start_col: self.start_col,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/monomorphize/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {

impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
fn is_root(&self, def_id: DefId) -> bool {
!item_has_type_parameters(self.tcx, def_id) && match self.mode {
!item_requires_monomorphization(self.tcx, def_id) && match self.mode {
MonoItemCollectionMode::Eager => {
true
}
Expand Down Expand Up @@ -1101,7 +1101,7 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
}
}

fn item_has_type_parameters<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
fn item_requires_monomorphization<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
let generics = tcx.generics_of(def_id);
generics.requires_monomorphization(tcx)
}
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,12 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
components: &[&str],
is_value: bool
) -> hir::Path {
let segments = iter::once(keywords::PathRoot.ident())
let root = if crate_root.is_some() {
keywords::PathRoot
} else {
keywords::Crate
};
let segments = iter::once(root.ident())
.chain(
crate_root.into_iter()
.chain(components.iter().cloned())
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
fn process_impl(
&mut self,
item: &'l ast::Item,
type_parameters: &'l ast::Generics,
generics: &'l ast::Generics,
trait_ref: &'l Option<ast::TraitRef>,
typ: &'l ast::Ty,
impl_items: &'l [ast::ImplItem],
Expand All @@ -678,7 +678,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
if let &Some(ref trait_ref) = trait_ref {
self.process_path(trait_ref.ref_id, &trait_ref.path);
}
self.process_generic_params(type_parameters, "", item.id);
self.process_generic_params(generics, "", item.id);
for impl_item in impl_items {
let map = &self.tcx.hir();
self.process_impl_item(impl_item, map.local_def_id(item.id));
Expand Down
Loading