Skip to content

Commit d920dfc

Browse files
committed
Auto merge of #59522 - Centril:rollup, r=Centril
Rollup of 9 pull requests Successful merges: - #59366 (Update books) - #59436 (Update jemalloc-sys to version 0.3.0) - #59454 (Update rustfmt to 1.2.0) - #59462 (Fix error in Rust 2018 + no_core environment) - #59467 (Better diagnostic for binary operation on BoxedValues) - #59473 (Do not emit incorrect borrow suggestion involving macros and fix overlapping multiline spans) - #59480 (Update stdsimd) - #59486 (Visit `ImplItem` in `dead_code` lint) - #59510 (Rename `type_parameters` to `generics` and so on) Failed merges: - #59516 (Update cargo) r? @ghost
2 parents 2002b4b + 99e886d commit d920dfc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+435
-166
lines changed

Cargo.lock

+8-8
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
12031203

12041204
[[package]]
12051205
name = "jemalloc-sys"
1206-
version = "0.1.8"
1206+
version = "0.3.0"
12071207
source = "registry+https://github.com/rust-lang/crates.io-index"
12081208
dependencies = [
12091209
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2074,7 +2074,7 @@ name = "rand_chacha"
20742074
version = "0.1.0"
20752075
source = "registry+https://github.com/rust-lang/crates.io-index"
20762076
dependencies = [
2077-
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
2077+
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
20782078
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
20792079
]
20802080

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

21022102
[[package]]
@@ -2121,7 +2121,7 @@ name = "rand_xorshift"
21212121
version = "0.1.0"
21222122
source = "registry+https://github.com/rust-lang/crates.io-index"
21232123
dependencies = [
2124-
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
2124+
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
21252125
]
21262126

21272127
[[package]]
@@ -2260,7 +2260,7 @@ dependencies = [
22602260
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
22612261
"rustc-workspace-hack 1.0.0",
22622262
"rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
2263-
"rustfmt-nightly 1.1.0",
2263+
"rustfmt-nightly 1.2.0",
22642264
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
22652265
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
22662266
"serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2500,7 +2500,7 @@ dependencies = [
25002500
name = "rustc-main"
25012501
version = "0.0.0"
25022502
dependencies = [
2503-
"jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
2503+
"jemalloc-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
25042504
"rustc_codegen_ssa 0.0.0",
25052505
"rustc_driver 0.0.0",
25062506
"rustc_target 0.0.0",
@@ -3056,7 +3056,7 @@ dependencies = [
30563056

30573057
[[package]]
30583058
name = "rustfmt-nightly"
3059-
version = "1.1.0"
3059+
version = "1.2.0"
30603060
dependencies = [
30613061
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
30623062
"bytecount 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4096,7 +4096,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
40964096
"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
40974097
"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358"
40984098
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
4099-
"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae"
4099+
"checksum jemalloc-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7bef0d4ce37578dfd80b466e3d8324bd9de788e249f1accebb0c472ea4b52bdc"
41004100
"checksum jobserver 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "dd80e58f77e0cdea53ba96acc5e04479e5ffc5d869626a6beafe50fed867eace"
41014101
"checksum json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9ad0485404155f45cce53a40d4b2d6ac356418300daed05273d9e26f91c390be"
41024102
"checksum jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a5152c3fda235dfd68341b3edf4121bc4428642c93acbd6de88c26bf95fc5d7"

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ impl<'a> Builder<'a> {
402402
test::UnstableBook,
403403
test::RustcBook,
404404
test::EmbeddedBook,
405+
test::EditionGuide,
405406
test::Rustfmt,
406407
test::Miri,
407408
test::Clippy,

src/bootstrap/test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,7 @@ test_book!(
14251425
EmbeddedBook, "src/doc/embedded-book", "embedded-book", default=false;
14261426
TheBook, "src/doc/book", "book", default=false;
14271427
UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;
1428+
EditionGuide, "src/doc/edition-guide", "edition-guide", default=false;
14281429
);
14291430

14301431
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

src/ci/docker/x86_64-gnu-tools/checktools.sh

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ python2.7 "$X_PY" test --no-fail-fast \
2424
src/doc/reference \
2525
src/doc/rust-by-example \
2626
src/doc/embedded-book \
27+
src/doc/edition-guide \
2728
src/tools/clippy \
2829
src/tools/rls \
2930
src/tools/rustfmt \
@@ -73,6 +74,7 @@ status_check() {
7374
check_dispatch $1 beta nomicon src/doc/nomicon
7475
check_dispatch $1 beta reference src/doc/reference
7576
check_dispatch $1 beta rust-by-example src/doc/rust-by-example
77+
check_dispatch $1 beta edition-guide src/doc/edition-guide
7678
check_dispatch $1 beta rls src/tools/rls
7779
check_dispatch $1 beta rustfmt src/tools/rustfmt
7880
check_dispatch $1 beta clippy-driver src/tools/clippy

src/doc/edition-guide

src/doc/reference

src/doc/unstable-book/src/language-features/plugin.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ The advantages over a simple `fn(&str) -> u32` are:
130130
a way to define new literal syntax for any data type.
131131

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

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

255255
Lints defined by plugins are controlled by the usual [attributes and compiler
256-
flags](../reference/attributes.html#lint-check-attributes), e.g.
256+
flags](../reference/attributes/diagnostics.html#lint-check-attributes), e.g.
257257
`#[allow(test_lint)]` or `-A test-lint`. These identifiers are derived from the
258258
first argument to `declare_lint!`, with appropriate case and punctuation
259259
conversion.

src/librustc/hir/intravisit.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -485,30 +485,30 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
485485
ItemKind::GlobalAsm(_) => {
486486
visitor.visit_id(item.hir_id);
487487
}
488-
ItemKind::Ty(ref typ, ref type_parameters) => {
488+
ItemKind::Ty(ref ty, ref generics) => {
489489
visitor.visit_id(item.hir_id);
490-
visitor.visit_ty(typ);
491-
visitor.visit_generics(type_parameters)
490+
visitor.visit_ty(ty);
491+
visitor.visit_generics(generics)
492492
}
493493
ItemKind::Existential(ExistTy { ref generics, ref bounds, impl_trait_fn: _ }) => {
494494
visitor.visit_id(item.hir_id);
495495
walk_generics(visitor, generics);
496496
walk_list!(visitor, visit_param_bound, bounds);
497497
}
498-
ItemKind::Enum(ref enum_definition, ref type_parameters) => {
499-
visitor.visit_generics(type_parameters);
498+
ItemKind::Enum(ref enum_definition, ref generics) => {
499+
visitor.visit_generics(generics);
500500
// `visit_enum_def()` takes care of visiting the `Item`'s `HirId`.
501-
visitor.visit_enum_def(enum_definition, type_parameters, item.hir_id, item.span)
501+
visitor.visit_enum_def(enum_definition, generics, item.hir_id, item.span)
502502
}
503503
ItemKind::Impl(
504504
..,
505-
ref type_parameters,
505+
ref generics,
506506
ref opt_trait_reference,
507507
ref typ,
508508
ref impl_item_refs
509509
) => {
510510
visitor.visit_id(item.hir_id);
511-
visitor.visit_generics(type_parameters);
511+
visitor.visit_generics(generics);
512512
walk_list!(visitor, visit_trait_ref, opt_trait_reference);
513513
visitor.visit_ty(typ);
514514
walk_list!(visitor, visit_impl_item_ref, impl_item_refs);

src/librustc/middle/dead.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
7373
Def::Const(_) | Def::AssociatedConst(..) | Def::TyAlias(_) => {
7474
self.check_def_id(def.def_id());
7575
}
76-
_ if self.in_pat => (),
76+
_ if self.in_pat => {},
7777
Def::PrimTy(..) | Def::SelfTy(..) | Def::SelfCtor(..) |
7878
Def::Local(..) | Def::Upvar(..) => {}
7979
Def::Ctor(ctor_def_id, CtorOf::Variant, ..) => {
@@ -91,6 +91,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
9191
self.check_def_id(variant_id);
9292
}
9393
}
94+
Def::ToolMod | Def::NonMacroAttr(..) | Def::Err => {}
9495
_ => {
9596
self.check_def_id(def.def_id());
9697
}
@@ -166,16 +167,13 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
166167
}
167168
hir::ItemKind::Enum(..) => {
168169
self.inherited_pub_visibility = item.vis.node.is_pub();
170+
169171
intravisit::walk_item(self, &item);
170172
}
171-
hir::ItemKind::Fn(..)
172-
| hir::ItemKind::Ty(..)
173-
| hir::ItemKind::Static(..)
174-
| hir::ItemKind::Existential(..)
175-
| hir::ItemKind::Const(..) => {
173+
hir::ItemKind::ForeignMod(..) => {}
174+
_ => {
176175
intravisit::walk_item(self, &item);
177176
}
178-
_ => ()
179177
}
180178
}
181179
Node::TraitItem(trait_item) => {
@@ -187,7 +185,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
187185
Node::ForeignItem(foreign_item) => {
188186
intravisit::walk_foreign_item(self, &foreign_item);
189187
}
190-
_ => ()
188+
_ => {}
191189
}
192190
self.repr_has_repr_c = had_repr_c;
193191
self.inherited_pub_visibility = had_inherited_pub_visibility;

src/librustc_errors/emitter.rs

+45-13
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ impl EmitterWriter {
243243
end_col: hi.col_display,
244244
is_primary: span_label.is_primary,
245245
label: span_label.label.clone(),
246+
overlaps_exactly: false,
246247
};
247248
multiline_annotations.push((lo.file.clone(), ml.clone()));
248249
AnnotationType::Multiline(ml)
@@ -258,10 +259,7 @@ impl EmitterWriter {
258259
};
259260

260261
if !ann.is_multiline() {
261-
add_annotation_to_file(&mut output,
262-
lo.file,
263-
lo.line,
264-
ann);
262+
add_annotation_to_file(&mut output, lo.file, lo.line, ann);
265263
}
266264
}
267265
}
@@ -274,10 +272,12 @@ impl EmitterWriter {
274272
let ref mut a = item.1;
275273
// Move all other multiline annotations overlapping with this one
276274
// one level to the right.
277-
if &ann != a &&
275+
if !(ann.same_span(a)) &&
278276
num_overlap(ann.line_start, ann.line_end, a.line_start, a.line_end, true)
279277
{
280278
a.increase_depth();
279+
} else if ann.same_span(a) && &ann != a {
280+
a.overlaps_exactly = true;
281281
} else {
282282
break;
283283
}
@@ -289,17 +289,49 @@ impl EmitterWriter {
289289
if ann.depth > max_depth {
290290
max_depth = ann.depth;
291291
}
292-
add_annotation_to_file(&mut output, file.clone(), ann.line_start, ann.as_start());
293-
let middle = min(ann.line_start + 4, ann.line_end);
294-
for line in ann.line_start + 1..middle {
295-
add_annotation_to_file(&mut output, file.clone(), line, ann.as_line());
296-
}
297-
if middle < ann.line_end - 1 {
298-
for line in ann.line_end - 1..ann.line_end {
292+
let mut end_ann = ann.as_end();
293+
if !ann.overlaps_exactly {
294+
// avoid output like
295+
//
296+
// | foo(
297+
// | _____^
298+
// | |_____|
299+
// | || bar,
300+
// | || );
301+
// | || ^
302+
// | ||______|
303+
// | |______foo
304+
// | baz
305+
//
306+
// and instead get
307+
//
308+
// | foo(
309+
// | _____^
310+
// | | bar,
311+
// | | );
312+
// | | ^
313+
// | | |
314+
// | |______foo
315+
// | baz
316+
add_annotation_to_file(&mut output, file.clone(), ann.line_start, ann.as_start());
317+
// 4 is the minimum vertical length of a multiline span when presented: two lines
318+
// of code and two lines of underline. This is not true for the special case where
319+
// the beginning doesn't have an underline, but the current logic seems to be
320+
// working correctly.
321+
let middle = min(ann.line_start + 4, ann.line_end);
322+
for line in ann.line_start + 1..middle {
323+
// Every `|` that joins the beginning of the span (`___^`) to the end (`|__^`).
299324
add_annotation_to_file(&mut output, file.clone(), line, ann.as_line());
300325
}
326+
if middle < ann.line_end - 1 {
327+
for line in ann.line_end - 1..ann.line_end {
328+
add_annotation_to_file(&mut output, file.clone(), line, ann.as_line());
329+
}
330+
}
331+
} else {
332+
end_ann.annotation_type = AnnotationType::Singleline;
301333
}
302-
add_annotation_to_file(&mut output, file, ann.line_end, ann.as_end());
334+
add_annotation_to_file(&mut output, file, ann.line_end, end_ann);
303335
}
304336
for file_vec in output.iter_mut() {
305337
file_vec.multiline_depth = max_depth;

src/librustc_errors/snippet.rs

+7
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ pub struct MultilineAnnotation {
1818
pub end_col: usize,
1919
pub is_primary: bool,
2020
pub label: Option<String>,
21+
pub overlaps_exactly: bool,
2122
}
2223

2324
impl MultilineAnnotation {
2425
pub fn increase_depth(&mut self) {
2526
self.depth += 1;
2627
}
2728

29+
/// Compare two `MultilineAnnotation`s considering only the `Span` they cover.
30+
pub fn same_span(&self, other: &MultilineAnnotation) -> bool {
31+
self.line_start == other.line_start && self.line_end == other.line_end
32+
&& self.start_col == other.start_col && self.end_col == other.end_col
33+
}
34+
2835
pub fn as_start(&self) -> Annotation {
2936
Annotation {
3037
start_col: self.start_col,

src/librustc_mir/monomorphize/collector.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
10401040

10411041
impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
10421042
fn is_root(&self, def_id: DefId) -> bool {
1043-
!item_has_type_parameters(self.tcx, def_id) && match self.mode {
1043+
!item_requires_monomorphization(self.tcx, def_id) && match self.mode {
10441044
MonoItemCollectionMode::Eager => {
10451045
true
10461046
}
@@ -1101,7 +1101,7 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
11011101
}
11021102
}
11031103

1104-
fn item_has_type_parameters<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
1104+
fn item_requires_monomorphization<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
11051105
let generics = tcx.generics_of(def_id);
11061106
generics.requires_monomorphization(tcx)
11071107
}

src/librustc_resolve/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,12 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
16971697
components: &[&str],
16981698
is_value: bool
16991699
) -> hir::Path {
1700-
let segments = iter::once(keywords::PathRoot.ident())
1700+
let root = if crate_root.is_some() {
1701+
keywords::PathRoot
1702+
} else {
1703+
keywords::Crate
1704+
};
1705+
let segments = iter::once(root.ident())
17011706
.chain(
17021707
crate_root.into_iter()
17031708
.chain(components.iter().cloned())

src/librustc_save_analysis/dump_visitor.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
659659
fn process_impl(
660660
&mut self,
661661
item: &'l ast::Item,
662-
type_parameters: &'l ast::Generics,
662+
generics: &'l ast::Generics,
663663
trait_ref: &'l Option<ast::TraitRef>,
664664
typ: &'l ast::Ty,
665665
impl_items: &'l [ast::ImplItem],
@@ -678,7 +678,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
678678
if let &Some(ref trait_ref) = trait_ref {
679679
self.process_path(trait_ref.ref_id, &trait_ref.path);
680680
}
681-
self.process_generic_params(type_parameters, "", item.id);
681+
self.process_generic_params(generics, "", item.id);
682682
for impl_item in impl_items {
683683
let map = &self.tcx.hir();
684684
self.process_impl_item(impl_item, map.local_def_id(item.id));

0 commit comments

Comments
 (0)