From 6ea6e62075f21642bfd94b00bf641ea3fe4208c5 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Mar 2019 11:03:19 +0100 Subject: [PATCH 01/20] Update jemalloc-sys to version 0.3.0 --- src/rustc/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rustc/Cargo.toml b/src/rustc/Cargo.toml index e601a1f82377f..997d139383798 100644 --- a/src/rustc/Cargo.toml +++ b/src/rustc/Cargo.toml @@ -17,7 +17,7 @@ rustc_driver = { path = "../librustc_driver" } rustc_codegen_ssa = { path = "../librustc_codegen_ssa" } [dependencies.jemalloc-sys] -version = '0.1.8' +version = '0.3.0' optional = true features = ['unprefixed_malloc_on_supported_platforms'] From b73886d9477f62b5b56439880f64b6d392589753 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Mar 2019 11:29:21 +0100 Subject: [PATCH 02/20] Update Cargo.lock --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec1cda96b99a6..188cfe73491be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1195,7 +1195,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)", @@ -2066,7 +2066,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)", ] @@ -2088,7 +2088,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]] @@ -2113,7 +2113,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]] @@ -2492,7 +2492,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", @@ -4086,7 +4086,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" From c728ae0fd1fe1bfc98598f345fa3a290094390d3 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Wed, 27 Mar 2019 10:37:01 +0900 Subject: [PATCH 03/20] Update rustfmt to 1.2.0 --- Cargo.lock | 10 +++++----- src/tools/rustfmt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7fd39bd1f6eb6..5fdf277ac0a1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2066,7 +2066,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)", ] @@ -2088,7 +2088,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]] @@ -2113,7 +2113,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]] @@ -2252,7 +2252,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)", @@ -3048,7 +3048,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)", diff --git a/src/tools/rustfmt b/src/tools/rustfmt index 1427e4c20ba5c..09940a70d0a9f 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit 1427e4c20ba5cdc80a338347585c9de71a0dea4d +Subproject commit 09940a70d0a9fabfb4985426aa7d66ca1875c65e From d59b46fd49022c1396e203d942103d3483840adf Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Wed, 27 Mar 2019 16:08:47 +0900 Subject: [PATCH 04/20] Add a test --- src/test/run-pass/no-core-2.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/test/run-pass/no-core-2.rs diff --git a/src/test/run-pass/no-core-2.rs b/src/test/run-pass/no-core-2.rs new file mode 100644 index 0000000000000..e09f8f6b7a87c --- /dev/null +++ b/src/test/run-pass/no-core-2.rs @@ -0,0 +1,18 @@ +#![allow(dead_code, unused_imports)] +#![feature(no_core)] +#![no_core] +// edition:2018 + +extern crate std; +extern crate core; +use core::{prelude::v1::*, *}; + +fn foo() { + for _ in &[()] {} +} + +fn bar() -> Option<()> { + None? +} + +fn main() {} From 4d648ce1b936de167260ed4d11f8c3d2f6462ff0 Mon Sep 17 00:00:00 2001 From: hgallagher1993 Date: Wed, 27 Mar 2019 13:13:09 -0400 Subject: [PATCH 05/20] Better diagnostic for binary operation on BoxedValues --- src/librustc_typeck/check/op.rs | 6 +- src/test/ui/autoderef-full-lval.stderr | 12 ++- src/test/ui/binary-op-on-double-ref.stderr | 6 +- src/test/ui/binop/binop-bitxor-str.stderr | 6 +- src/test/ui/binop/binop-mul-bool.stderr | 6 +- src/test/ui/binop/binop-typeck.stderr | 6 +- ...-span-PartialEq-enum-struct-variant.stderr | 6 ++ .../derives-span-PartialEq-enum.stderr | 6 ++ .../derives-span-PartialEq-struct.stderr | 6 ++ ...derives-span-PartialEq-tuple-struct.stderr | 6 ++ ...eriving-no-inner-impl-error-message.stderr | 6 ++ src/test/ui/fn/fn-compare-mismatch.stderr | 6 +- src/test/ui/for/for-loop-type-error.stderr | 6 +- src/test/ui/issues/issue-14915.stderr | 6 +- src/test/ui/issues/issue-24363.stderr | 6 +- src/test/ui/issues/issue-28837.stderr | 90 ++++++++++++------- src/test/ui/issues/issue-31076.stderr | 12 ++- src/test/ui/issues/issue-35668.stderr | 6 +- src/test/ui/issues/issue-3820.stderr | 6 +- src/test/ui/issues/issue-40610.stderr | 6 +- src/test/ui/issues/issue-41394.stderr | 6 +- src/test/ui/issues/issue-47377.stderr | 8 +- src/test/ui/issues/issue-47380.stderr | 8 +- ...quire-parens-for-chained-comparison.stderr | 6 +- src/test/ui/pattern/pattern-tyvar-2.stderr | 6 +- src/test/ui/span/issue-39018.stderr | 22 +++-- .../ui/str/str-concat-on-double-ref.stderr | 6 +- .../trait-resolution-in-overloaded-op.stderr | 6 +- .../type/type-check/missing_trait_impl.stderr | 6 +- src/test/ui/vec/vec-res-add.stderr | 6 +- 30 files changed, 211 insertions(+), 85 deletions(-) diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 9d883b22214f7..f8212659f020c 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -327,10 +327,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { err.emit(); } IsAssign::No => { - let mut err = struct_span_err!(self.tcx.sess, expr.span, E0369, + let mut err = struct_span_err!(self.tcx.sess, op.span, E0369, "binary operation `{}` cannot be applied to type `{}`", op.node.as_str(), lhs_ty); + + err.span_label(lhs_expr.span, lhs_ty.to_string()); + err.span_label(rhs_expr.span, rhs_ty.to_string()); + let mut suggested_deref = false; if let Ref(_, mut rty, _) = lhs_ty.sty { if { diff --git a/src/test/ui/autoderef-full-lval.stderr b/src/test/ui/autoderef-full-lval.stderr index b92259b69df8e..c9f3e8b2e26c5 100644 --- a/src/test/ui/autoderef-full-lval.stderr +++ b/src/test/ui/autoderef-full-lval.stderr @@ -1,16 +1,20 @@ error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box` - --> $DIR/autoderef-full-lval.rs:15:20 + --> $DIR/autoderef-full-lval.rs:15:24 | LL | let z: isize = a.x + b.y; - | ^^^^^^^^^ + | --- ^ --- std::boxed::Box + | | + | std::boxed::Box | = note: an implementation of `std::ops::Add` might be missing for `std::boxed::Box` error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box` - --> $DIR/autoderef-full-lval.rs:21:25 + --> $DIR/autoderef-full-lval.rs:21:33 | LL | let answer: isize = forty.a + two.a; - | ^^^^^^^^^^^^^^^ + | ------- ^ ----- std::boxed::Box + | | + | std::boxed::Box | = note: an implementation of `std::ops::Add` might be missing for `std::boxed::Box` diff --git a/src/test/ui/binary-op-on-double-ref.stderr b/src/test/ui/binary-op-on-double-ref.stderr index f298902e3ff12..d036f06a8c7d0 100644 --- a/src/test/ui/binary-op-on-double-ref.stderr +++ b/src/test/ui/binary-op-on-double-ref.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `%` cannot be applied to type `&&{integer}` - --> $DIR/binary-op-on-double-ref.rs:4:9 + --> $DIR/binary-op-on-double-ref.rs:4:11 | LL | x % 2 == 0 - | ^^^^^ + | - ^ - {integer} + | | + | &&{integer} | = help: `%` can be used on '{integer}', you can dereference `x`: `*x` diff --git a/src/test/ui/binop/binop-bitxor-str.stderr b/src/test/ui/binop/binop-bitxor-str.stderr index 4404fde9200c8..9e8992235edd1 100644 --- a/src/test/ui/binop/binop-bitxor-str.stderr +++ b/src/test/ui/binop/binop-bitxor-str.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `^` cannot be applied to type `std::string::String` - --> $DIR/binop-bitxor-str.rs:3:21 + --> $DIR/binop-bitxor-str.rs:3:37 | LL | fn main() { let x = "a".to_string() ^ "b".to_string(); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | --------------- ^ --------------- std::string::String + | | + | std::string::String | = note: an implementation of `std::ops::BitXor` might be missing for `std::string::String` diff --git a/src/test/ui/binop/binop-mul-bool.stderr b/src/test/ui/binop/binop-mul-bool.stderr index 194181b9c11c3..92e14bccccd58 100644 --- a/src/test/ui/binop/binop-mul-bool.stderr +++ b/src/test/ui/binop/binop-mul-bool.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `*` cannot be applied to type `bool` - --> $DIR/binop-mul-bool.rs:3:21 + --> $DIR/binop-mul-bool.rs:3:26 | LL | fn main() { let x = true * false; } - | ^^^^^^^^^^^^ + | ---- ^ ----- bool + | | + | bool | = note: an implementation of `std::ops::Mul` might be missing for `bool` diff --git a/src/test/ui/binop/binop-typeck.stderr b/src/test/ui/binop/binop-typeck.stderr index 928e836c0b51e..d33cff313e7f9 100644 --- a/src/test/ui/binop/binop-typeck.stderr +++ b/src/test/ui/binop/binop-typeck.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `+` cannot be applied to type `bool` - --> $DIR/binop-typeck.rs:6:13 + --> $DIR/binop-typeck.rs:6:15 | LL | let z = x + y; - | ^^^^^ + | - ^ - {integer} + | | + | bool | = note: an implementation of `std::ops::Add` might be missing for `bool` diff --git a/src/test/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr index ed5468cc4dac2..673f23d29eb78 100644 --- a/src/test/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr @@ -3,6 +3,9 @@ error[E0369]: binary operation `==` cannot be applied to type `Error` | LL | x: Error | ^^^^^^^^ + | | + | Error + | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` @@ -11,6 +14,9 @@ error[E0369]: binary operation `!=` cannot be applied to type `Error` | LL | x: Error | ^^^^^^^^ + | | + | Error + | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` diff --git a/src/test/ui/derives/derives-span-PartialEq-enum.stderr b/src/test/ui/derives/derives-span-PartialEq-enum.stderr index 06a88c03f58af..6ab18b45b7387 100644 --- a/src/test/ui/derives/derives-span-PartialEq-enum.stderr +++ b/src/test/ui/derives/derives-span-PartialEq-enum.stderr @@ -3,6 +3,9 @@ error[E0369]: binary operation `==` cannot be applied to type `Error` | LL | Error | ^^^^^ + | | + | Error + | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` @@ -11,6 +14,9 @@ error[E0369]: binary operation `!=` cannot be applied to type `Error` | LL | Error | ^^^^^ + | | + | Error + | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` diff --git a/src/test/ui/derives/derives-span-PartialEq-struct.stderr b/src/test/ui/derives/derives-span-PartialEq-struct.stderr index b8481048361e5..bdd12942b4710 100644 --- a/src/test/ui/derives/derives-span-PartialEq-struct.stderr +++ b/src/test/ui/derives/derives-span-PartialEq-struct.stderr @@ -3,6 +3,9 @@ error[E0369]: binary operation `==` cannot be applied to type `Error` | LL | x: Error | ^^^^^^^^ + | | + | Error + | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` @@ -11,6 +14,9 @@ error[E0369]: binary operation `!=` cannot be applied to type `Error` | LL | x: Error | ^^^^^^^^ + | | + | Error + | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` diff --git a/src/test/ui/derives/derives-span-PartialEq-tuple-struct.stderr b/src/test/ui/derives/derives-span-PartialEq-tuple-struct.stderr index 4398d25212550..9f60b2ea8166b 100644 --- a/src/test/ui/derives/derives-span-PartialEq-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-PartialEq-tuple-struct.stderr @@ -3,6 +3,9 @@ error[E0369]: binary operation `==` cannot be applied to type `Error` | LL | Error | ^^^^^ + | | + | Error + | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` @@ -11,6 +14,9 @@ error[E0369]: binary operation `!=` cannot be applied to type `Error` | LL | Error | ^^^^^ + | | + | Error + | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` diff --git a/src/test/ui/derives/deriving-no-inner-impl-error-message.stderr b/src/test/ui/derives/deriving-no-inner-impl-error-message.stderr index 3206eecbe30e4..4baf27c520c59 100644 --- a/src/test/ui/derives/deriving-no-inner-impl-error-message.stderr +++ b/src/test/ui/derives/deriving-no-inner-impl-error-message.stderr @@ -3,6 +3,9 @@ error[E0369]: binary operation `==` cannot be applied to type `NoCloneOrEq` | LL | x: NoCloneOrEq | ^^^^^^^^^^^^^^ + | | + | NoCloneOrEq + | NoCloneOrEq | = note: an implementation of `std::cmp::PartialEq` might be missing for `NoCloneOrEq` @@ -11,6 +14,9 @@ error[E0369]: binary operation `!=` cannot be applied to type `NoCloneOrEq` | LL | x: NoCloneOrEq | ^^^^^^^^^^^^^^ + | | + | NoCloneOrEq + | NoCloneOrEq | = note: an implementation of `std::cmp::PartialEq` might be missing for `NoCloneOrEq` diff --git a/src/test/ui/fn/fn-compare-mismatch.stderr b/src/test/ui/fn/fn-compare-mismatch.stderr index 54dae525ffd0e..07b93d9aae7ed 100644 --- a/src/test/ui/fn/fn-compare-mismatch.stderr +++ b/src/test/ui/fn/fn-compare-mismatch.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `==` cannot be applied to type `fn() {main::f}` - --> $DIR/fn-compare-mismatch.rs:4:13 + --> $DIR/fn-compare-mismatch.rs:4:15 | LL | let x = f == g; - | ^^^^^^ + | - ^^ - fn() {main::g} + | | + | fn() {main::f} | = note: an implementation of `std::cmp::PartialEq` might be missing for `fn() {main::f}` diff --git a/src/test/ui/for/for-loop-type-error.stderr b/src/test/ui/for/for-loop-type-error.stderr index f1c1d0a538876..588e7a0ed339e 100644 --- a/src/test/ui/for/for-loop-type-error.stderr +++ b/src/test/ui/for/for-loop-type-error.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `+` cannot be applied to type `()` - --> $DIR/for-loop-type-error.rs:2:13 + --> $DIR/for-loop-type-error.rs:2:16 | LL | let x = () + (); - | ^^^^^^^ + | -- ^ -- () + | | + | () | = note: an implementation of `std::ops::Add` might be missing for `()` diff --git a/src/test/ui/issues/issue-14915.stderr b/src/test/ui/issues/issue-14915.stderr index 411d7a3455238..e8de44320da9c 100644 --- a/src/test/ui/issues/issue-14915.stderr +++ b/src/test/ui/issues/issue-14915.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box` - --> $DIR/issue-14915.rs:6:20 + --> $DIR/issue-14915.rs:6:22 | LL | println!("{}", x + 1); - | ^^^^^ + | - ^ - {integer} + | | + | std::boxed::Box | = note: an implementation of `std::ops::Add` might be missing for `std::boxed::Box` diff --git a/src/test/ui/issues/issue-24363.stderr b/src/test/ui/issues/issue-24363.stderr index 3399856d3f9a7..6f269ba764c5d 100644 --- a/src/test/ui/issues/issue-24363.stderr +++ b/src/test/ui/issues/issue-24363.stderr @@ -5,10 +5,12 @@ LL | 1.create_a_type_error[ | ^^^^^^^^^^^^^^^^^^^ error[E0369]: binary operation `+` cannot be applied to type `()` - --> $DIR/issue-24363.rs:3:9 + --> $DIR/issue-24363.rs:3:11 | LL | ()+() - | ^^^^^ + | --^-- () + | | + | () | = note: an implementation of `std::ops::Add` might be missing for `()` diff --git a/src/test/ui/issues/issue-28837.stderr b/src/test/ui/issues/issue-28837.stderr index aeb25ce12867e..ac2a9f2203d5a 100644 --- a/src/test/ui/issues/issue-28837.stderr +++ b/src/test/ui/issues/issue-28837.stderr @@ -1,120 +1,150 @@ error[E0369]: binary operation `+` cannot be applied to type `A` - --> $DIR/issue-28837.rs:6:5 + --> $DIR/issue-28837.rs:6:7 | LL | a + a; - | ^^^^^ + | - ^ - A + | | + | A | = note: an implementation of `std::ops::Add` might be missing for `A` error[E0369]: binary operation `-` cannot be applied to type `A` - --> $DIR/issue-28837.rs:8:5 + --> $DIR/issue-28837.rs:8:7 | LL | a - a; - | ^^^^^ + | - ^ - A + | | + | A | = note: an implementation of `std::ops::Sub` might be missing for `A` error[E0369]: binary operation `*` cannot be applied to type `A` - --> $DIR/issue-28837.rs:10:5 + --> $DIR/issue-28837.rs:10:7 | LL | a * a; - | ^^^^^ + | - ^ - A + | | + | A | = note: an implementation of `std::ops::Mul` might be missing for `A` error[E0369]: binary operation `/` cannot be applied to type `A` - --> $DIR/issue-28837.rs:12:5 + --> $DIR/issue-28837.rs:12:7 | LL | a / a; - | ^^^^^ + | - ^ - A + | | + | A | = note: an implementation of `std::ops::Div` might be missing for `A` error[E0369]: binary operation `%` cannot be applied to type `A` - --> $DIR/issue-28837.rs:14:5 + --> $DIR/issue-28837.rs:14:7 | LL | a % a; - | ^^^^^ + | - ^ - A + | | + | A | = note: an implementation of `std::ops::Rem` might be missing for `A` error[E0369]: binary operation `&` cannot be applied to type `A` - --> $DIR/issue-28837.rs:16:5 + --> $DIR/issue-28837.rs:16:7 | LL | a & a; - | ^^^^^ + | - ^ - A + | | + | A | = note: an implementation of `std::ops::BitAnd` might be missing for `A` error[E0369]: binary operation `|` cannot be applied to type `A` - --> $DIR/issue-28837.rs:18:5 + --> $DIR/issue-28837.rs:18:7 | LL | a | a; - | ^^^^^ + | - ^ - A + | | + | A | = note: an implementation of `std::ops::BitOr` might be missing for `A` error[E0369]: binary operation `<<` cannot be applied to type `A` - --> $DIR/issue-28837.rs:20:5 + --> $DIR/issue-28837.rs:20:7 | LL | a << a; - | ^^^^^^ + | - ^^ - A + | | + | A | = note: an implementation of `std::ops::Shl` might be missing for `A` error[E0369]: binary operation `>>` cannot be applied to type `A` - --> $DIR/issue-28837.rs:22:5 + --> $DIR/issue-28837.rs:22:7 | LL | a >> a; - | ^^^^^^ + | - ^^ - A + | | + | A | = note: an implementation of `std::ops::Shr` might be missing for `A` error[E0369]: binary operation `==` cannot be applied to type `A` - --> $DIR/issue-28837.rs:24:5 + --> $DIR/issue-28837.rs:24:7 | LL | a == a; - | ^^^^^^ + | - ^^ - A + | | + | A | = note: an implementation of `std::cmp::PartialEq` might be missing for `A` error[E0369]: binary operation `!=` cannot be applied to type `A` - --> $DIR/issue-28837.rs:26:5 + --> $DIR/issue-28837.rs:26:7 | LL | a != a; - | ^^^^^^ + | - ^^ - A + | | + | A | = note: an implementation of `std::cmp::PartialEq` might be missing for `A` error[E0369]: binary operation `<` cannot be applied to type `A` - --> $DIR/issue-28837.rs:28:5 + --> $DIR/issue-28837.rs:28:7 | LL | a < a; - | ^^^^^ + | - ^ - A + | | + | A | = note: an implementation of `std::cmp::PartialOrd` might be missing for `A` error[E0369]: binary operation `<=` cannot be applied to type `A` - --> $DIR/issue-28837.rs:30:5 + --> $DIR/issue-28837.rs:30:7 | LL | a <= a; - | ^^^^^^ + | - ^^ - A + | | + | A | = note: an implementation of `std::cmp::PartialOrd` might be missing for `A` error[E0369]: binary operation `>` cannot be applied to type `A` - --> $DIR/issue-28837.rs:32:5 + --> $DIR/issue-28837.rs:32:7 | LL | a > a; - | ^^^^^ + | - ^ - A + | | + | A | = note: an implementation of `std::cmp::PartialOrd` might be missing for `A` error[E0369]: binary operation `>=` cannot be applied to type `A` - --> $DIR/issue-28837.rs:34:5 + --> $DIR/issue-28837.rs:34:7 | LL | a >= a; - | ^^^^^^ + | - ^^ - A + | | + | A | = note: an implementation of `std::cmp::PartialOrd` might be missing for `A` diff --git a/src/test/ui/issues/issue-31076.stderr b/src/test/ui/issues/issue-31076.stderr index 3a13f02d9f45f..60a3be1c36b75 100644 --- a/src/test/ui/issues/issue-31076.stderr +++ b/src/test/ui/issues/issue-31076.stderr @@ -1,16 +1,20 @@ error[E0369]: binary operation `+` cannot be applied to type `{integer}` - --> $DIR/issue-31076.rs:13:13 + --> $DIR/issue-31076.rs:13:15 | LL | let x = 5 + 6; - | ^^^^^ + | - ^ - {integer} + | | + | {integer} | = note: an implementation of `std::ops::Add` might be missing for `{integer}` error[E0369]: binary operation `+` cannot be applied to type `i32` - --> $DIR/issue-31076.rs:15:13 + --> $DIR/issue-31076.rs:15:18 | LL | let y = 5i32 + 6i32; - | ^^^^^^^^^^^ + | ---- ^ ---- i32 + | | + | i32 | = note: an implementation of `std::ops::Add` might be missing for `i32` diff --git a/src/test/ui/issues/issue-35668.stderr b/src/test/ui/issues/issue-35668.stderr index 08ce2faff10ab..59ca874bd2018 100644 --- a/src/test/ui/issues/issue-35668.stderr +++ b/src/test/ui/issues/issue-35668.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `*` cannot be applied to type `&T` - --> $DIR/issue-35668.rs:2:22 + --> $DIR/issue-35668.rs:2:23 | LL | a.iter().map(|a| a*a) - | ^^^ + | -^- &T + | | + | &T | = note: an implementation of `std::ops::Mul` might be missing for `&T` diff --git a/src/test/ui/issues/issue-3820.stderr b/src/test/ui/issues/issue-3820.stderr index b4af9c2d27dbe..35eceb3b3c637 100644 --- a/src/test/ui/issues/issue-3820.stderr +++ b/src/test/ui/issues/issue-3820.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `*` cannot be applied to type `Thing` - --> $DIR/issue-3820.rs:14:13 + --> $DIR/issue-3820.rs:14:15 | LL | let w = u * 3; - | ^^^^^ + | - ^ - {integer} + | | + | Thing | = note: an implementation of `std::ops::Mul` might be missing for `Thing` diff --git a/src/test/ui/issues/issue-40610.stderr b/src/test/ui/issues/issue-40610.stderr index f441d65b91e43..9d5775919296d 100644 --- a/src/test/ui/issues/issue-40610.stderr +++ b/src/test/ui/issues/issue-40610.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `+` cannot be applied to type `()` - --> $DIR/issue-40610.rs:4:5 + --> $DIR/issue-40610.rs:4:8 | LL | () + f(&[1.0]); - | ^^^^^^^^^^^^^^ + | -- ^ --------- () + | | + | () | = note: an implementation of `std::ops::Add` might be missing for `()` diff --git a/src/test/ui/issues/issue-41394.stderr b/src/test/ui/issues/issue-41394.stderr index bc5c6e798e868..5de5889d8172d 100644 --- a/src/test/ui/issues/issue-41394.stderr +++ b/src/test/ui/issues/issue-41394.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `+` cannot be applied to type `&str` - --> $DIR/issue-41394.rs:2:9 + --> $DIR/issue-41394.rs:2:12 | LL | A = "" + 1 - | ^^^^^^ + | -- ^ - {integer} + | | + | &str | = note: an implementation of `std::ops::Add` might be missing for `&str` diff --git a/src/test/ui/issues/issue-47377.stderr b/src/test/ui/issues/issue-47377.stderr index 1e945727746e9..f782ad42fcbbf 100644 --- a/src/test/ui/issues/issue-47377.stderr +++ b/src/test/ui/issues/issue-47377.stderr @@ -1,8 +1,12 @@ error[E0369]: binary operation `+` cannot be applied to type `&str` - --> $DIR/issue-47377.rs:4:12 + --> $DIR/issue-47377.rs:4:14 | LL | let _a = b + ", World!"; - | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings + | --^----------- + | | | + | | &str + | &str + | `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | LL | let _a = b.to_owned() + ", World!"; diff --git a/src/test/ui/issues/issue-47380.stderr b/src/test/ui/issues/issue-47380.stderr index 84c5df3ca897b..753892c97e7c6 100644 --- a/src/test/ui/issues/issue-47380.stderr +++ b/src/test/ui/issues/issue-47380.stderr @@ -1,8 +1,12 @@ error[E0369]: binary operation `+` cannot be applied to type `&str` - --> $DIR/issue-47380.rs:3:33 + --> $DIR/issue-47380.rs:3:35 | LL | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; - | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings + | --^----------- + | | | + | | &str + | &str + | `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | LL | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!"; diff --git a/src/test/ui/parser/require-parens-for-chained-comparison.stderr b/src/test/ui/parser/require-parens-for-chained-comparison.stderr index 4597b14321513..8899b0d43cd8b 100644 --- a/src/test/ui/parser/require-parens-for-chained-comparison.stderr +++ b/src/test/ui/parser/require-parens-for-chained-comparison.stderr @@ -38,10 +38,12 @@ LL | false == 0 < 2; found type `{integer}` error[E0369]: binary operation `<` cannot be applied to type `fn() {f::<_>}` - --> $DIR/require-parens-for-chained-comparison.rs:13:5 + --> $DIR/require-parens-for-chained-comparison.rs:13:6 | LL | f(); - | ^^^ + | -^- X + | | + | fn() {f::<_>} | = note: an implementation of `std::cmp::PartialOrd` might be missing for `fn() {f::<_>}` diff --git a/src/test/ui/pattern/pattern-tyvar-2.stderr b/src/test/ui/pattern/pattern-tyvar-2.stderr index 5218dd916a575..7c6ae499cbb07 100644 --- a/src/test/ui/pattern/pattern-tyvar-2.stderr +++ b/src/test/ui/pattern/pattern-tyvar-2.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `*` cannot be applied to type `std::vec::Vec` - --> $DIR/pattern-tyvar-2.rs:3:69 + --> $DIR/pattern-tyvar-2.rs:3:71 | LL | fn foo(t: Bar) -> isize { match t { Bar::T1(_, Some(x)) => { return x * 3; } _ => { panic!(); } } } - | ^^^^^ + | - ^ - {integer} + | | + | std::vec::Vec | = note: an implementation of `std::ops::Mul` might be missing for `std::vec::Vec` diff --git a/src/test/ui/span/issue-39018.stderr b/src/test/ui/span/issue-39018.stderr index 00f1b11df19e2..6e4754839875e 100644 --- a/src/test/ui/span/issue-39018.stderr +++ b/src/test/ui/span/issue-39018.stderr @@ -1,26 +1,36 @@ error[E0369]: binary operation `+` cannot be applied to type `&str` - --> $DIR/issue-39018.rs:2:13 + --> $DIR/issue-39018.rs:2:22 | LL | let x = "Hello " + "World!"; - | ^^^^^^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings + | ---------^--------- + | | | + | | &str + | &str + | `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | LL | let x = "Hello ".to_owned() + "World!"; | ^^^^^^^^^^^^^^^^^^^ error[E0369]: binary operation `+` cannot be applied to type `World` - --> $DIR/issue-39018.rs:8:13 + --> $DIR/issue-39018.rs:8:26 | LL | let y = World::Hello + World::Goodbye; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ------------ ^ -------------- World + | | + | World | = note: an implementation of `std::ops::Add` might be missing for `World` error[E0369]: binary operation `+` cannot be applied to type `&str` - --> $DIR/issue-39018.rs:11:13 + --> $DIR/issue-39018.rs:11:22 | LL | let x = "Hello " + "World!".to_owned(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `+` can't be used to concatenate a `&str` with a `String` + | ---------^-------------------- + | | | + | | std::string::String + | &str + | `+` can't be used to concatenate a `&str` with a `String` help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | LL | let x = "Hello ".to_owned() + &"World!".to_owned(); diff --git a/src/test/ui/str/str-concat-on-double-ref.stderr b/src/test/ui/str/str-concat-on-double-ref.stderr index a67db1936f07e..61ebcfdefc316 100644 --- a/src/test/ui/str/str-concat-on-double-ref.stderr +++ b/src/test/ui/str/str-concat-on-double-ref.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `+` cannot be applied to type `&std::string::String` - --> $DIR/str-concat-on-double-ref.rs:4:13 + --> $DIR/str-concat-on-double-ref.rs:4:15 | LL | let c = a + b; - | ^^^^^ + | - ^ - &str + | | + | &std::string::String | = note: an implementation of `std::ops::Add` might be missing for `&std::string::String` diff --git a/src/test/ui/traits/trait-resolution-in-overloaded-op.stderr b/src/test/ui/traits/trait-resolution-in-overloaded-op.stderr index 3b10632b818c7..d11562e2a001b 100644 --- a/src/test/ui/traits/trait-resolution-in-overloaded-op.stderr +++ b/src/test/ui/traits/trait-resolution-in-overloaded-op.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `*` cannot be applied to type `&T` - --> $DIR/trait-resolution-in-overloaded-op.rs:8:5 + --> $DIR/trait-resolution-in-overloaded-op.rs:8:7 | LL | a * b - | ^^^^^ + | - ^ - f64 + | | + | &T | = note: an implementation of `std::ops::Mul` might be missing for `&T` diff --git a/src/test/ui/type/type-check/missing_trait_impl.stderr b/src/test/ui/type/type-check/missing_trait_impl.stderr index 69b531d0c846e..b0e3c35c70567 100644 --- a/src/test/ui/type/type-check/missing_trait_impl.stderr +++ b/src/test/ui/type/type-check/missing_trait_impl.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `+` cannot be applied to type `T` - --> $DIR/missing_trait_impl.rs:5:13 + --> $DIR/missing_trait_impl.rs:5:15 | LL | let z = x + y; - | ^^^^^ + | - ^ - T + | | + | T | = note: `T` might need a bound for `std::ops::Add` diff --git a/src/test/ui/vec/vec-res-add.stderr b/src/test/ui/vec/vec-res-add.stderr index 39552697631db..78b70f09e9005 100644 --- a/src/test/ui/vec/vec-res-add.stderr +++ b/src/test/ui/vec/vec-res-add.stderr @@ -1,8 +1,10 @@ error[E0369]: binary operation `+` cannot be applied to type `std::vec::Vec` - --> $DIR/vec-res-add.rs:16:13 + --> $DIR/vec-res-add.rs:16:15 | LL | let k = i + j; - | ^^^^^ + | - ^ - std::vec::Vec + | | + | std::vec::Vec | = note: an implementation of `std::ops::Add` might be missing for `std::vec::Vec` From 5113e73e81945ab5bedce96d635845932302afd4 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 22 Mar 2019 08:52:45 -0700 Subject: [PATCH 06/20] Update books --- src/bootstrap/builder.rs | 1 + src/bootstrap/test.rs | 1 + src/ci/docker/x86_64-gnu-tools/checktools.sh | 2 ++ src/doc/book | 2 +- src/doc/edition-guide | 2 +- src/doc/embedded-book | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- src/doc/unstable-book/src/language-features/plugin.md | 6 +++--- 9 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index f93f3e72f83e7..7107797216a07 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -402,6 +402,7 @@ impl<'a> Builder<'a> { test::UnstableBook, test::RustcBook, test::EmbeddedBook, + test::EditionGuide, test::Rustfmt, test::Miri, test::Clippy, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index bbe1872d3958d..4c0f6bac4da9c 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1421,6 +1421,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)] diff --git a/src/ci/docker/x86_64-gnu-tools/checktools.sh b/src/ci/docker/x86_64-gnu-tools/checktools.sh index 97e6ee25ec7a0..af0198705a2fe 100755 --- a/src/ci/docker/x86_64-gnu-tools/checktools.sh +++ b/src/ci/docker/x86_64-gnu-tools/checktools.sh @@ -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 \ @@ -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 diff --git a/src/doc/book b/src/doc/book index 9cffbeabec3bc..b93ec30bbc7b1 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 9cffbeabec3bcec42d09432bfe7705125c848889 +Subproject commit b93ec30bbc7b1b5c2f44223249ab359bed2ed5a6 diff --git a/src/doc/edition-guide b/src/doc/edition-guide index aa0022c875907..b56ddb1154845 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit aa0022c875907886cae8f3ef8e9ebf6e2a5e728d +Subproject commit b56ddb11548450a6df4edd1ed571b2bc304eb9e6 diff --git a/src/doc/embedded-book b/src/doc/embedded-book index 9e656ead82bfe..07fd3880ea087 160000 --- a/src/doc/embedded-book +++ b/src/doc/embedded-book @@ -1 +1 @@ -Subproject commit 9e656ead82bfe869493dec82653a52e27fa6a05c +Subproject commit 07fd3880ea0874d82b1d9ed30ad3427ec98b4e8a diff --git a/src/doc/reference b/src/doc/reference index 41493ffce5d0e..27ad493a10364 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 41493ffce5d0e17d54eaf5ec9a995054e2b9aece +Subproject commit 27ad493a10364e907ec476e2ad61e8a1614b57e1 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 2ce92beabb912..f68ef3d0f4959 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 2ce92beabb912d417a7314d6da83ac9b50dc2afb +Subproject commit f68ef3d0f4959f6a7d92a08d9994b117f0f4d32d diff --git a/src/doc/unstable-book/src/language-features/plugin.md b/src/doc/unstable-book/src/language-features/plugin.md index cab350381d2bd..49fe7c9e994fe 100644 --- a/src/doc/unstable-book/src/language-features/plugin.md +++ b/src/doc/unstable-book/src/language-features/plugin.md @@ -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). @@ -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`. @@ -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. From b3011dd711ea8bf4bcb04d96aff814863eff3973 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 28 Mar 2019 01:45:50 +0000 Subject: [PATCH 07/20] Visit ItemKind::Impl for dead code lint --- src/librustc/middle/dead.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index f12367a89bbf3..cd1fa8763c3c7 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -172,6 +172,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { | hir::ItemKind::Ty(..) | hir::ItemKind::Static(..) | hir::ItemKind::Existential(..) + | hir::ItemKind::Impl(..) | hir::ItemKind::Const(..) => { intravisit::walk_item(self, &item); } From 40db5756b435d2e67a834475833f4752486672e0 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 28 Mar 2019 01:47:39 +0000 Subject: [PATCH 08/20] Add a regression test for #47131 --- src/test/ui/dead-code-impl.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/test/ui/dead-code-impl.rs diff --git a/src/test/ui/dead-code-impl.rs b/src/test/ui/dead-code-impl.rs new file mode 100644 index 0000000000000..84829c98e5739 --- /dev/null +++ b/src/test/ui/dead-code-impl.rs @@ -0,0 +1,17 @@ +// run-pass + +#![deny(dead_code)] + +pub struct GenericFoo(T); + +type Foo = GenericFoo; + +impl Foo { + fn bar(self) -> u8 { + 0 + } +} + +fn main() { + println!("{}", GenericFoo(0).bar()); +} From 0acb7867c21bca6e3ba53e88ef895c2ed2d833a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 27 Mar 2019 17:04:58 -0700 Subject: [PATCH 09/20] Do not suggest borrowing when the span comes from a macro --- src/librustc_typeck/check/demand.rs | 7 ++++--- src/test/ui/span/coerce-suggestions.stderr | 5 +---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index b1a249d821bec..302c093d12fab 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -10,7 +10,7 @@ use rustc::hir::Node; use rustc::hir::{Item, ItemKind, print}; use rustc::ty::{self, Ty, AssociatedItem}; use rustc::ty::adjustment::AllowTwoPhase; -use errors::{Applicability, DiagnosticBuilder, SourceMapper}; +use errors::{Applicability, DiagnosticBuilder}; use super::method::probe; @@ -271,9 +271,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expected: Ty<'tcx>) -> Option<(Span, &'static str, String)> { let cm = self.sess().source_map(); - // Use the callsite's span if this is a macro call. #41858 - let sp = cm.call_span_if_macro(expr.span); + let sp = expr.span; if !cm.span_to_filename(sp).is_real() { + // Ignore if span is from within a macro #41858, #58298. We previously used the macro + // call span, but that breaks down when the type error comes from multiple calls down. return None; } diff --git a/src/test/ui/span/coerce-suggestions.stderr b/src/test/ui/span/coerce-suggestions.stderr index cda500c3f5dbe..996d80a07e058 100644 --- a/src/test/ui/span/coerce-suggestions.stderr +++ b/src/test/ui/span/coerce-suggestions.stderr @@ -50,10 +50,7 @@ error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:21:9 | LL | s = format!("foo"); - | ^^^^^^^^^^^^^^ - | | - | expected mutable reference, found struct `std::string::String` - | help: consider mutably borrowing here: `&mut format!("foo")` + | ^^^^^^^^^^^^^^ expected mutable reference, found struct `std::string::String` | = note: expected type `&mut std::string::String` found type `std::string::String` From 925ca49cf12ef9ce328eb7ad66e63c4c86b02460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 27 Mar 2019 17:05:35 -0700 Subject: [PATCH 10/20] Add test --- ...-suggest-deref-inside-macro-issue-58298.rs | 14 +++++++++++++ ...gest-deref-inside-macro-issue-58298.stderr | 21 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.rs create mode 100644 src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr diff --git a/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.rs b/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.rs new file mode 100644 index 0000000000000..bf2d105f63fb5 --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.rs @@ -0,0 +1,14 @@ +fn warn(_: &str) {} + +macro_rules! intrinsic_match { + ($intrinsic:expr) => { + warn(format!("unsupported intrinsic {}", $intrinsic)); + //^~ ERROR mismatched types + }; +} + +fn main() { + intrinsic_match! { + "abc" + }; +} diff --git a/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr b/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr new file mode 100644 index 0000000000000..75a08904e69b9 --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/dont-suggest-deref-inside-macro-issue-58298.rs:10:5 + | +LL | intrinsic_match! { + | _____^ + | |_____| + | || +LL | || "abc" +LL | || }; + | || ^ + | ||______| + | |_______expected &str, found struct `std::string::String` + | in this macro invocation + | + = note: expected type `&str` + found type `std::string::String` + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. From 326ec800b952749d0afc90be0604dc0332d70324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 27 Mar 2019 19:26:47 -0700 Subject: [PATCH 11/20] Account for fully overlapping multiline annotations When two multiline span labels point at the same span, we special case the output to avoid weird behavior: ``` foo( _____^ |_____| || bar, || ); || ^ ||______| |______foo baz ``` instead showing ``` foo( _____^ | bar, | ); | ^ | | |______foo baz ``` --- src/librustc_errors/emitter.rs | 53 ++++++++++++---- src/librustc_errors/snippet.rs | 7 +++ src/libsyntax/test_snippet.rs | 60 +++++++++++++++++++ ...-suggest-deref-inside-macro-issue-58298.rs | 2 +- ...gest-deref-inside-macro-issue-58298.stderr | 19 +++--- 5 files changed, 116 insertions(+), 25 deletions(-) diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index e9f269b6e2410..c3ee1db8d3056 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -243,6 +243,7 @@ impl EmitterWriter { end_col: hi.col_display, is_primary: span_label.is_primary, label: span_label.label.clone(), + overlaps: false, }; multiline_annotations.push((lo.file.clone(), ml.clone())); AnnotationType::Multiline(ml) @@ -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); } } } @@ -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 = true; } else { break; } @@ -289,17 +289,44 @@ 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 { + // 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()); + 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 { + 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; diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index 0c62ff0ff89b2..60ee0c2572761 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -18,6 +18,7 @@ pub struct MultilineAnnotation { pub end_col: usize, pub is_primary: bool, pub label: Option, + pub overlaps: bool, } impl MultilineAnnotation { @@ -25,6 +26,12 @@ impl MultilineAnnotation { 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, diff --git a/src/libsyntax/test_snippet.rs b/src/libsyntax/test_snippet.rs index 2b3d18835d543..86910ffd894c4 100644 --- a/src/libsyntax/test_snippet.rs +++ b/src/libsyntax/test_snippet.rs @@ -374,6 +374,66 @@ error: foo "#); } +#[test] +fn triple_exact_overlap() { + test_harness(r#" +fn foo() { + X0 Y0 Z0 + X1 Y1 Z1 + X2 Y2 Z2 +} +"#, + vec![ + SpanLabel { + start: Position { + string: "X0", + count: 1, + }, + end: Position { + string: "X2", + count: 1, + }, + label: "`X` is a good letter", + }, + SpanLabel { + start: Position { + string: "X0", + count: 1, + }, + end: Position { + string: "X2", + count: 1, + }, + label: "`Y` is a good letter too", + }, + SpanLabel { + start: Position { + string: "X0", + count: 1, + }, + end: Position { + string: "X2", + count: 1, + }, + label: "`Z` label", + }, + ], + r#" +error: foo + --> test.rs:3:3 + | +3 | / X0 Y0 Z0 +4 | | X1 Y1 Z1 +5 | | X2 Y2 Z2 + | | ^ + | | | + | | `X` is a good letter + | |____`Y` is a good letter too + | `Z` label + +"#); +} + #[test] fn minimum_depth() { test_harness(r#" diff --git a/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.rs b/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.rs index bf2d105f63fb5..ef1c09d218058 100644 --- a/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.rs +++ b/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.rs @@ -3,7 +3,7 @@ fn warn(_: &str) {} macro_rules! intrinsic_match { ($intrinsic:expr) => { warn(format!("unsupported intrinsic {}", $intrinsic)); - //^~ ERROR mismatched types + //~^ ERROR mismatched types }; } diff --git a/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr b/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr index 75a08904e69b9..bc7a7247a1283 100644 --- a/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr +++ b/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr @@ -1,16 +1,13 @@ error[E0308]: mismatched types - --> $DIR/dont-suggest-deref-inside-macro-issue-58298.rs:10:5 + --> $DIR/dont-suggest-deref-inside-macro-issue-58298.rs:11:5 | -LL | intrinsic_match! { - | _____^ - | |_____| - | || -LL | || "abc" -LL | || }; - | || ^ - | ||______| - | |_______expected &str, found struct `std::string::String` - | in this macro invocation +LL | / intrinsic_match! { +LL | | "abc" +LL | | }; + | | ^ + | | | + | |______expected &str, found struct `std::string::String` + | in this macro invocation | = note: expected type `&str` found type `std::string::String` From 81402db50176974e413fdc430d5ca42b35ad28f8 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Mar 2019 10:13:08 +0100 Subject: [PATCH 12/20] Update stdsimd --- src/stdsimd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stdsimd b/src/stdsimd index 359845eb7cae8..12bdc2ed6b326 160000 --- a/src/stdsimd +++ b/src/stdsimd @@ -1 +1 @@ -Subproject commit 359845eb7cae85799dc2ec81f2fb05da0aa6276d +Subproject commit 12bdc2ed6b32653866d02b42f0885d9cd8bd295e From 7a5c82d579b9ad80e5ddf0459ab160d2a96079f5 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 28 Mar 2019 10:23:15 -0700 Subject: [PATCH 13/20] Add edition-guide to toolstate. Also, add me to reference, alercah has taken a step back from involvement. --- src/tools/publish_toolstate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/publish_toolstate.py b/src/tools/publish_toolstate.py index f2a585e627307..93d7aa5c1ecb4 100755 --- a/src/tools/publish_toolstate.py +++ b/src/tools/publish_toolstate.py @@ -20,12 +20,13 @@ 'rustfmt': '@nrc @topecongiro', 'book': '@carols10cents @steveklabnik', 'nomicon': '@frewsxcv @Gankro', - 'reference': '@steveklabnik @Havvy @matthewjasper @alercah', + 'reference': '@steveklabnik @Havvy @matthewjasper @ehuss', 'rust-by-example': '@steveklabnik @marioidival @projektir', 'embedded-book': ( '@adamgreig @andre-richter @jamesmunns @korken89 ' '@ryankurte @thejpster @therealprof' ), + 'edition-guide': '@ehuss @Centril @steveklabnik', } REPOS = { @@ -38,6 +39,7 @@ 'reference': 'https://github.com/rust-lang-nursery/reference', 'rust-by-example': 'https://github.com/rust-lang/rust-by-example', 'embedded-book': 'https://github.com/rust-embedded/book', + 'edition-guide': 'https://github.com/rust-lang-nursery/edition-guide', } From 4644c3a6aa0ff0ad394175a029f5531728ecff31 Mon Sep 17 00:00:00 2001 From: hgallagher1993 Date: Thu, 28 Mar 2019 13:54:29 -0400 Subject: [PATCH 14/20] Add check for when left and right overlap and change span for explanation to point at operator --- src/librustc_typeck/check/op.rs | 13 ++++++++----- ...erives-span-PartialEq-enum-struct-variant.stderr | 6 ------ .../ui/derives/derives-span-PartialEq-enum.stderr | 6 ------ .../ui/derives/derives-span-PartialEq-struct.stderr | 6 ------ .../derives-span-PartialEq-tuple-struct.stderr | 6 ------ .../deriving-no-inner-impl-error-message.stderr | 6 ------ src/test/ui/issues/issue-47377.stderr | 7 +++---- src/test/ui/issues/issue-47380.stderr | 7 +++---- src/test/ui/span/issue-39018.stderr | 7 +++---- 9 files changed, 17 insertions(+), 47 deletions(-) diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index f8212659f020c..d6932094dddb6 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -306,7 +306,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(missing_trait) = missing_trait { if op.node == hir::BinOpKind::Add && self.check_str_addition(expr, lhs_expr, rhs_expr, lhs_ty, - rhs_ty, &mut err, true) { + rhs_ty, &mut err, true, op) { // This has nothing here because it means we did string // concatenation (e.g., "Hello " += "World!"). This means // we don't want the note in the else clause to be emitted @@ -332,8 +332,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { op.node.as_str(), lhs_ty); - err.span_label(lhs_expr.span, lhs_ty.to_string()); - err.span_label(rhs_expr.span, rhs_ty.to_string()); + if !lhs_expr.span.eq(&rhs_expr.span) { + err.span_label(lhs_expr.span, lhs_ty.to_string()); + err.span_label(rhs_expr.span, rhs_ty.to_string()); + } let mut suggested_deref = false; if let Ref(_, mut rty, _) = lhs_ty.sty { @@ -384,7 +386,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(missing_trait) = missing_trait { if op.node == hir::BinOpKind::Add && self.check_str_addition(expr, lhs_expr, rhs_expr, lhs_ty, - rhs_ty, &mut err, false) { + rhs_ty, &mut err, false, op) { // This has nothing here because it means we did string // concatenation (e.g., "Hello " + "World!"). This means // we don't want the note in the else clause to be emitted @@ -422,6 +424,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { rhs_ty: Ty<'tcx>, err: &mut errors::DiagnosticBuilder<'_>, is_assign: bool, + op: hir::BinOp, ) -> bool { let source_map = self.tcx.sess.source_map(); let msg = "`to_owned()` can be used to create an owned `String` \ @@ -435,7 +438,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { (&Ref(_, l_ty, _), &Ref(_, r_ty, _)) if l_ty.sty == Str && r_ty.sty == Str => { if !is_assign { - err.span_label(expr.span, + err.span_label(op.span, "`+` can't be used to concatenate two `&str` strings"); match source_map.span_to_snippet(lhs_expr.span) { Ok(lstring) => err.span_suggestion( diff --git a/src/test/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr index 673f23d29eb78..ed5468cc4dac2 100644 --- a/src/test/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr @@ -3,9 +3,6 @@ error[E0369]: binary operation `==` cannot be applied to type `Error` | LL | x: Error | ^^^^^^^^ - | | - | Error - | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` @@ -14,9 +11,6 @@ error[E0369]: binary operation `!=` cannot be applied to type `Error` | LL | x: Error | ^^^^^^^^ - | | - | Error - | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` diff --git a/src/test/ui/derives/derives-span-PartialEq-enum.stderr b/src/test/ui/derives/derives-span-PartialEq-enum.stderr index 6ab18b45b7387..06a88c03f58af 100644 --- a/src/test/ui/derives/derives-span-PartialEq-enum.stderr +++ b/src/test/ui/derives/derives-span-PartialEq-enum.stderr @@ -3,9 +3,6 @@ error[E0369]: binary operation `==` cannot be applied to type `Error` | LL | Error | ^^^^^ - | | - | Error - | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` @@ -14,9 +11,6 @@ error[E0369]: binary operation `!=` cannot be applied to type `Error` | LL | Error | ^^^^^ - | | - | Error - | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` diff --git a/src/test/ui/derives/derives-span-PartialEq-struct.stderr b/src/test/ui/derives/derives-span-PartialEq-struct.stderr index bdd12942b4710..b8481048361e5 100644 --- a/src/test/ui/derives/derives-span-PartialEq-struct.stderr +++ b/src/test/ui/derives/derives-span-PartialEq-struct.stderr @@ -3,9 +3,6 @@ error[E0369]: binary operation `==` cannot be applied to type `Error` | LL | x: Error | ^^^^^^^^ - | | - | Error - | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` @@ -14,9 +11,6 @@ error[E0369]: binary operation `!=` cannot be applied to type `Error` | LL | x: Error | ^^^^^^^^ - | | - | Error - | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` diff --git a/src/test/ui/derives/derives-span-PartialEq-tuple-struct.stderr b/src/test/ui/derives/derives-span-PartialEq-tuple-struct.stderr index 9f60b2ea8166b..4398d25212550 100644 --- a/src/test/ui/derives/derives-span-PartialEq-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-PartialEq-tuple-struct.stderr @@ -3,9 +3,6 @@ error[E0369]: binary operation `==` cannot be applied to type `Error` | LL | Error | ^^^^^ - | | - | Error - | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` @@ -14,9 +11,6 @@ error[E0369]: binary operation `!=` cannot be applied to type `Error` | LL | Error | ^^^^^ - | | - | Error - | Error | = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` diff --git a/src/test/ui/derives/deriving-no-inner-impl-error-message.stderr b/src/test/ui/derives/deriving-no-inner-impl-error-message.stderr index 4baf27c520c59..3206eecbe30e4 100644 --- a/src/test/ui/derives/deriving-no-inner-impl-error-message.stderr +++ b/src/test/ui/derives/deriving-no-inner-impl-error-message.stderr @@ -3,9 +3,6 @@ error[E0369]: binary operation `==` cannot be applied to type `NoCloneOrEq` | LL | x: NoCloneOrEq | ^^^^^^^^^^^^^^ - | | - | NoCloneOrEq - | NoCloneOrEq | = note: an implementation of `std::cmp::PartialEq` might be missing for `NoCloneOrEq` @@ -14,9 +11,6 @@ error[E0369]: binary operation `!=` cannot be applied to type `NoCloneOrEq` | LL | x: NoCloneOrEq | ^^^^^^^^^^^^^^ - | | - | NoCloneOrEq - | NoCloneOrEq | = note: an implementation of `std::cmp::PartialEq` might be missing for `NoCloneOrEq` diff --git a/src/test/ui/issues/issue-47377.stderr b/src/test/ui/issues/issue-47377.stderr index f782ad42fcbbf..88466131e3144 100644 --- a/src/test/ui/issues/issue-47377.stderr +++ b/src/test/ui/issues/issue-47377.stderr @@ -2,11 +2,10 @@ error[E0369]: binary operation `+` cannot be applied to type `&str` --> $DIR/issue-47377.rs:4:14 | LL | let _a = b + ", World!"; - | --^----------- - | | | - | | &str + | - ^ ---------- &str + | | | + | | `+` can't be used to concatenate two `&str` strings | &str - | `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | LL | let _a = b.to_owned() + ", World!"; diff --git a/src/test/ui/issues/issue-47380.stderr b/src/test/ui/issues/issue-47380.stderr index 753892c97e7c6..d69101eab4c46 100644 --- a/src/test/ui/issues/issue-47380.stderr +++ b/src/test/ui/issues/issue-47380.stderr @@ -2,11 +2,10 @@ error[E0369]: binary operation `+` cannot be applied to type `&str` --> $DIR/issue-47380.rs:3:35 | LL | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; - | --^----------- - | | | - | | &str + | - ^ ---------- &str + | | | + | | `+` can't be used to concatenate two `&str` strings | &str - | `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | LL | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!"; diff --git a/src/test/ui/span/issue-39018.stderr b/src/test/ui/span/issue-39018.stderr index 6e4754839875e..a5b91f090d2c0 100644 --- a/src/test/ui/span/issue-39018.stderr +++ b/src/test/ui/span/issue-39018.stderr @@ -2,11 +2,10 @@ error[E0369]: binary operation `+` cannot be applied to type `&str` --> $DIR/issue-39018.rs:2:22 | LL | let x = "Hello " + "World!"; - | ---------^--------- - | | | - | | &str + | -------- ^ -------- &str + | | | + | | `+` can't be used to concatenate two `&str` strings | &str - | `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | LL | let x = "Hello ".to_owned() + "World!"; From 8cdfad91539dea8c9ec7d22c08f40e42e25e6ff0 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 28 Mar 2019 23:33:17 +0000 Subject: [PATCH 15/20] Walk all items for dead_code lint by default --- src/librustc/middle/dead.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index cd1fa8763c3c7..dd080d9ee2644 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -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, ..) => { @@ -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()); } @@ -166,17 +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::Impl(..) - | hir::ItemKind::Const(..) => { + hir::ItemKind::ForeignMod(..) => {} + _ => { intravisit::walk_item(self, &item); } - _ => () } } Node::TraitItem(trait_item) => { @@ -188,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; From 44813dfcb68c670f6ff8b7d79cea5f75b9f02ab9 Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 29 Mar 2019 00:28:07 +0000 Subject: [PATCH 16/20] Rename `type_parameters` to `generics` and so on --- src/librustc/hir/intravisit.rs | 16 ++++++++-------- src/librustc_mir/monomorphize/collector.rs | 4 ++-- src/librustc_save_analysis/dump_visitor.rs | 4 ++-- src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/check/wfcheck.rs | 4 ++-- src/librustc_typeck/collect.rs | 2 +- ...params.rs => constrained_generic_params.rs} | 2 +- src/librustc_typeck/impl_wf_check.rs | 4 ++-- src/librustc_typeck/lib.rs | 2 +- src/libsyntax/visit.rs | 18 +++++++++--------- 10 files changed, 29 insertions(+), 29 deletions(-) rename src/librustc_typeck/{constrained_type_params.rs => constrained_generic_params.rs} (99%) diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index bce528189ad1e..ba756f7e8f5ea 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -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); diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 0ad6962cc4ac5..0e8ab2ba2a5a2 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -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 } @@ -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) } diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 263f5acb662fc..7d4002525942b 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -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, typ: &'l ast::Ty, impl_items: &'l [ast::ImplItem], @@ -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)); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index ec4fc2a3bfb88..7f3c52271711d 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2550,7 +2550,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Neither if self.type_var_diverges(ty) => self.tcx.mk_diverging_default(), Neither => return false, }; - debug!("default_type_parameters: defaulting `{:?}` to `{:?}`", ty, fallback); + debug!("fallback_if_possible: defaulting `{:?}` to `{:?}`", ty, fallback); self.demand_eqtype(syntax_pos::DUMMY_SP, ty, fallback); true } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 0675feade53ef..920270b5473cf 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -1,5 +1,5 @@ use crate::check::{Inherited, FnCtxt}; -use crate::constrained_type_params::{identify_constrained_type_params, Parameter}; +use crate::constrained_generic_params::{identify_constrained_generic_params, Parameter}; use crate::hir::def_id::DefId; use rustc::traits::{self, ObligationCauseCode}; @@ -941,7 +941,7 @@ fn check_variances_for_type_defn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, .map(|(index, _)| Parameter(index as u32)) .collect(); - identify_constrained_type_params(tcx, + identify_constrained_generic_params(tcx, &ty_predicates, None, &mut constrained_parameters); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 8960c9acafa6e..5edb8c92a3bbc 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -15,7 +15,7 @@ //! crate as a kind of pass. This should eventually be factored away. use crate::astconv::{AstConv, Bounds}; -use crate::constrained_type_params as ctp; +use crate::constrained_generic_params as ctp; use crate::check::intrinsic::intrisic_operation_unsafety; use crate::lint; use crate::middle::lang_items::SizedTraitLangItem; diff --git a/src/librustc_typeck/constrained_type_params.rs b/src/librustc_typeck/constrained_generic_params.rs similarity index 99% rename from src/librustc_typeck/constrained_type_params.rs rename to src/librustc_typeck/constrained_generic_params.rs index c8687f5e455fd..18bf66ceb3501 100644 --- a/src/librustc_typeck/constrained_type_params.rs +++ b/src/librustc_typeck/constrained_generic_params.rs @@ -86,7 +86,7 @@ impl<'tcx> TypeVisitor<'tcx> for ParameterCollector { } } -pub fn identify_constrained_type_params<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, +pub fn identify_constrained_generic_params<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, predicates: &ty::GenericPredicates<'tcx>, impl_trait_ref: Option>, input_parameters: &mut FxHashSet) diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index 5677f2c94d8e2..2b72f43d36f72 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -8,7 +8,7 @@ //! specialization errors. These things can (and probably should) be //! fixed, but for the moment it's easier to do these checks early. -use crate::constrained_type_params as ctp; +use crate::constrained_generic_params as ctp; use rustc::hir; use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::def_id::DefId; @@ -103,7 +103,7 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let impl_trait_ref = tcx.impl_trait_ref(impl_def_id); let mut input_parameters = ctp::parameters_for_impl(impl_self_ty, impl_trait_ref); - ctp::identify_constrained_type_params( + ctp::identify_constrained_generic_params( tcx, &impl_predicates, impl_trait_ref, &mut input_parameters); // Disallow unconstrained lifetimes, but only if they appear in assoc types. diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 3ddc18284b302..cc90044573ce5 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -88,7 +88,7 @@ mod check; mod check_unused; mod coherence; mod collect; -mod constrained_type_params; +mod constrained_generic_params; mod structured_errors; mod impl_wf_check; mod namespace; diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 6b3a30ccb54b7..0f98885fb4ec3 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -244,24 +244,24 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { walk_list!(visitor, visit_foreign_item, &foreign_module.items); } ItemKind::GlobalAsm(ref ga) => visitor.visit_global_asm(ga), - ItemKind::Ty(ref typ, ref type_parameters) => { + ItemKind::Ty(ref typ, ref generics) => { visitor.visit_ty(typ); - visitor.visit_generics(type_parameters) + visitor.visit_generics(generics) } - ItemKind::Existential(ref bounds, ref type_parameters) => { + ItemKind::Existential(ref bounds, ref generics) => { walk_list!(visitor, visit_param_bound, bounds); - visitor.visit_generics(type_parameters) + visitor.visit_generics(generics) } - ItemKind::Enum(ref enum_definition, ref type_parameters) => { - visitor.visit_generics(type_parameters); - visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span) + ItemKind::Enum(ref enum_definition, ref generics) => { + visitor.visit_generics(generics); + visitor.visit_enum_def(enum_definition, generics, item.id, item.span) } ItemKind::Impl(_, _, _, - ref type_parameters, + ref generics, ref opt_trait_reference, ref typ, ref impl_items) => { - 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, impl_items); From e13e9a5d636116455aab6940d27bbc1b450aa003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 28 Mar 2019 20:03:13 -0700 Subject: [PATCH 17/20] review comments --- src/librustc_errors/emitter.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index c3ee1db8d3056..d2c9db2db79cf 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -243,7 +243,7 @@ impl EmitterWriter { end_col: hi.col_display, is_primary: span_label.is_primary, label: span_label.label.clone(), - overlaps: false, + overlaps_exactly: false, }; multiline_annotations.push((lo.file.clone(), ml.clone())); AnnotationType::Multiline(ml) @@ -277,7 +277,7 @@ impl EmitterWriter { { a.increase_depth(); } else if ann.same_span(a) && &ann != a { - a.overlaps = true; + a.overlaps_exactly = true; } else { break; } @@ -290,7 +290,7 @@ impl EmitterWriter { max_depth = ann.depth; } let mut end_ann = ann.as_end(); - if !ann.overlaps { + if !ann.overlaps_exactly { // avoid output like // // | foo( From 8fad69c2001ebe78d67e193f05969bb6f681b109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 28 Mar 2019 20:18:50 -0700 Subject: [PATCH 18/20] Add comemnts clarifying logic --- src/librustc_errors/emitter.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index d2c9db2db79cf..98db0097c7457 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -314,8 +314,13 @@ impl EmitterWriter { // | |______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 { From b5690c2cb86afc48e958e0d58ff1916c75f65b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 28 Mar 2019 20:19:50 -0700 Subject: [PATCH 19/20] Fix MultilineAnnotation field name --- src/librustc_errors/snippet.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index 60ee0c2572761..a0af604026d4a 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -18,7 +18,7 @@ pub struct MultilineAnnotation { pub end_col: usize, pub is_primary: bool, pub label: Option, - pub overlaps: bool, + pub overlaps_exactly: bool, } impl MultilineAnnotation { From 362d2439bdd221b0efa4f0d28bb51bfde0ea9484 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 29 Mar 2019 13:54:50 +0900 Subject: [PATCH 20/20] Fix error in Rust 2018 + no_core environment --- src/librustc_resolve/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index f48cfa0b1479f..ab3d87fafdac7 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -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())