From cabcd99476060b4e293f3031dafe7d84a557768d Mon Sep 17 00:00:00 2001 From: BO41 Date: Wed, 2 Oct 2019 17:55:06 +0200 Subject: [PATCH 01/29] Mention keyword closing policy --- CONTRIBUTING.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4daaa986a2dc2..d796dc1803240 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -129,6 +129,12 @@ the master branch to your feature branch. Also, please make sure that fixup commits are squashed into other related commits with meaningful commit messages. +GitHub allows [closing issues using keywords][closing-keywords]. This features +should be used to keep the issue tracker tidy. But in pull requests only. Please +do not add this to your commit message. + +[closing-keywords]: https://help.github.com/en/articles/closing-issues-using-keywords + Please make sure your pull request is in compliance with Rust's style guidelines by running From 59ce359c8f5f6f9a373ca5be82a3b96527b38b9e Mon Sep 17 00:00:00 2001 From: BO41 Date: Wed, 2 Oct 2019 21:31:00 +0000 Subject: [PATCH 02/29] Fix typo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d796dc1803240..caf003d183aff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -129,7 +129,7 @@ the master branch to your feature branch. Also, please make sure that fixup commits are squashed into other related commits with meaningful commit messages. -GitHub allows [closing issues using keywords][closing-keywords]. This features +GitHub allows [closing issues using keywords][closing-keywords]. This feature should be used to keep the issue tracker tidy. But in pull requests only. Please do not add this to your commit message. From 77f0aaf0d0a92feb068999d6b14f60dcf325b0c1 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Sat, 12 Oct 2019 20:53:11 +0200 Subject: [PATCH 03/29] Add more coherence tests --- .../ui/coherence/impl-foreign-for-foreign.rs | 17 +++++++++++ .../coherence/impl-foreign-for-foreign.stderr | 12 ++++++++ .../impl-foreign-for-foreign[foreign].rs | 25 ++++++++++++++++ .../impl-foreign-for-foreign[foreign].stderr | 30 +++++++++++++++++++ .../impl-foreign-for-foreign[local].rs | 16 ++++++++++ .../impl-foreign-for-fundamental[foreign].rs | 21 +++++++++++++ ...pl-foreign-for-fundamental[foreign].stderr | 21 +++++++++++++ .../impl-foreign-for-fundamental[local].rs | 17 +++++++++++ .../ui/coherence/impl-foreign-for-local.rs | 15 ++++++++++ ...reign[fundemental[foreign]]-for-foreign.rs | 26 ++++++++++++++++ ...n[fundemental[foreign]]-for-foreign.stderr | 30 +++++++++++++++++++ ...foreign[fundemental[local]]-for-foreign.rs | 18 +++++++++++ .../impl[t]-foreign-for-(local, t).rs | 17 +++++++++++ .../impl[t]-foreign-for-(local, t).stderr | 12 ++++++++ .../impl[t]-foreign-for-foreign[t].rs | 23 ++++++++++++++ .../impl[t]-foreign-for-foreign[t].stderr | 21 +++++++++++++ .../impl[t]-foreign-for-fundamental[t].rs | 17 +++++++++++ .../impl[t]-foreign-for-fundamental[t].stderr | 11 +++++++ ...eign[fundemental[local]]-for-foreign[t].rs | 17 +++++++++++ .../impl[t]-foreign[local]-for-foreign[t].rs | 17 +++++++++++ ...eign[local]-for-fundamental[foreign[t]].rs | 19 ++++++++++++ 21 files changed, 402 insertions(+) create mode 100644 src/test/ui/coherence/impl-foreign-for-foreign.rs create mode 100644 src/test/ui/coherence/impl-foreign-for-foreign.stderr create mode 100644 src/test/ui/coherence/impl-foreign-for-foreign[foreign].rs create mode 100644 src/test/ui/coherence/impl-foreign-for-foreign[foreign].stderr create mode 100644 src/test/ui/coherence/impl-foreign-for-foreign[local].rs create mode 100644 src/test/ui/coherence/impl-foreign-for-fundamental[foreign].rs create mode 100644 src/test/ui/coherence/impl-foreign-for-fundamental[foreign].stderr create mode 100644 src/test/ui/coherence/impl-foreign-for-fundamental[local].rs create mode 100644 src/test/ui/coherence/impl-foreign-for-local.rs create mode 100644 src/test/ui/coherence/impl-foreign[fundemental[foreign]]-for-foreign.rs create mode 100644 src/test/ui/coherence/impl-foreign[fundemental[foreign]]-for-foreign.stderr create mode 100644 src/test/ui/coherence/impl-foreign[fundemental[local]]-for-foreign.rs create mode 100644 src/test/ui/coherence/impl[t]-foreign-for-(local, t).rs create mode 100644 src/test/ui/coherence/impl[t]-foreign-for-(local, t).stderr create mode 100644 src/test/ui/coherence/impl[t]-foreign-for-foreign[t].rs create mode 100644 src/test/ui/coherence/impl[t]-foreign-for-foreign[t].stderr create mode 100644 src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].rs create mode 100644 src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr create mode 100644 src/test/ui/coherence/impl[t]-foreign[fundemental[local]]-for-foreign[t].rs create mode 100644 src/test/ui/coherence/impl[t]-foreign[local]-for-foreign[t].rs create mode 100644 src/test/ui/coherence/impl[t]-foreign[local]-for-fundamental[foreign[t]].rs diff --git a/src/test/ui/coherence/impl-foreign-for-foreign.rs b/src/test/ui/coherence/impl-foreign-for-foreign.rs new file mode 100644 index 0000000000000..de0b66a35eb01 --- /dev/null +++ b/src/test/ui/coherence/impl-foreign-for-foreign.rs @@ -0,0 +1,17 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local; + +impl Remote for i32 { + //~^ ERROR only traits defined in the current crate + // | can be implemented for arbitrary types [E0117] +} + +fn main() {} diff --git a/src/test/ui/coherence/impl-foreign-for-foreign.stderr b/src/test/ui/coherence/impl-foreign-for-foreign.stderr new file mode 100644 index 0000000000000..b03a75a77c346 --- /dev/null +++ b/src/test/ui/coherence/impl-foreign-for-foreign.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/impl-foreign-for-foreign.rs:12:1 + | +LL | impl Remote for i32 { + | ^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference only types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/impl-foreign-for-foreign[foreign].rs b/src/test/ui/coherence/impl-foreign-for-foreign[foreign].rs new file mode 100644 index 0000000000000..5146263d99114 --- /dev/null +++ b/src/test/ui/coherence/impl-foreign-for-foreign[foreign].rs @@ -0,0 +1,25 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local; + +impl Remote1> for i32 { + //~^ ERROR only traits defined in the current crate + // | can be implemented for arbitrary types [E0117] +} +impl Remote1> for f64 { + //~^ ERROR only traits defined in the current crate + // | can be implemented for arbitrary types [E0117] +} +impl Remote1> for f32 { + //~^ ERROR only traits defined in the current crate + // | can be implemented for arbitrary types [E0117] +} + +fn main() {} diff --git a/src/test/ui/coherence/impl-foreign-for-foreign[foreign].stderr b/src/test/ui/coherence/impl-foreign-for-foreign[foreign].stderr new file mode 100644 index 0000000000000..bfaec790b20a6 --- /dev/null +++ b/src/test/ui/coherence/impl-foreign-for-foreign[foreign].stderr @@ -0,0 +1,30 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/impl-foreign-for-foreign[foreign].rs:12:1 + | +LL | impl Remote1> for i32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference only types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/impl-foreign-for-foreign[foreign].rs:16:1 + | +LL | impl Remote1> for f64 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference only types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/impl-foreign-for-foreign[foreign].rs:20:1 + | +LL | impl Remote1> for f32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference only types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/impl-foreign-for-foreign[local].rs b/src/test/ui/coherence/impl-foreign-for-foreign[local].rs new file mode 100644 index 0000000000000..050769dcf4ce8 --- /dev/null +++ b/src/test/ui/coherence/impl-foreign-for-foreign[local].rs @@ -0,0 +1,16 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs +// check-pass + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local(Rc); + +impl Remote1> for i32 {} +impl Remote1> for f32 {} + +fn main() {} diff --git a/src/test/ui/coherence/impl-foreign-for-fundamental[foreign].rs b/src/test/ui/coherence/impl-foreign-for-fundamental[foreign].rs new file mode 100644 index 0000000000000..03b11edf98b41 --- /dev/null +++ b/src/test/ui/coherence/impl-foreign-for-fundamental[foreign].rs @@ -0,0 +1,21 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local; + +impl Remote for Box { + //~^ ERROR only traits defined in the current crate + // | can be implemented for arbitrary types [E0117] +} +impl Remote for Box> { + //~^ ERROR only traits defined in the current crate + // | can be implemented for arbitrary types [E0117] +} + +fn main() {} diff --git a/src/test/ui/coherence/impl-foreign-for-fundamental[foreign].stderr b/src/test/ui/coherence/impl-foreign-for-fundamental[foreign].stderr new file mode 100644 index 0000000000000..2ce4921cf938f --- /dev/null +++ b/src/test/ui/coherence/impl-foreign-for-fundamental[foreign].stderr @@ -0,0 +1,21 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/impl-foreign-for-fundamental[foreign].rs:12:1 + | +LL | impl Remote for Box { + | ^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference only types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/impl-foreign-for-fundamental[foreign].rs:16:1 + | +LL | impl Remote for Box> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference only types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/impl-foreign-for-fundamental[local].rs b/src/test/ui/coherence/impl-foreign-for-fundamental[local].rs new file mode 100644 index 0000000000000..ae03ce6a440dc --- /dev/null +++ b/src/test/ui/coherence/impl-foreign-for-fundamental[local].rs @@ -0,0 +1,17 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs +// check-pass + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local; +struct Local1(Rc); + +impl Remote for Box {} +impl Remote for Box> {} + +fn main() {} diff --git a/src/test/ui/coherence/impl-foreign-for-local.rs b/src/test/ui/coherence/impl-foreign-for-local.rs new file mode 100644 index 0000000000000..c9dddeba18dc5 --- /dev/null +++ b/src/test/ui/coherence/impl-foreign-for-local.rs @@ -0,0 +1,15 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs +// check-pass + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local; + +impl Remote for Local {} + +fn main() {} diff --git a/src/test/ui/coherence/impl-foreign[fundemental[foreign]]-for-foreign.rs b/src/test/ui/coherence/impl-foreign[fundemental[foreign]]-for-foreign.rs new file mode 100644 index 0000000000000..06efb6c2ad75e --- /dev/null +++ b/src/test/ui/coherence/impl-foreign[fundemental[foreign]]-for-foreign.rs @@ -0,0 +1,26 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local; +struct Local1(Rc); + +impl Remote1> for i32 { + //~^ ERROR only traits defined in the current crate + // | can be implemented for arbitrary types [E0117] +} +impl Remote1>> for f64 { + //~^ ERROR only traits defined in the current crate + // | can be implemented for arbitrary types [E0117] +} +impl Remote1>> for f32 { + //~^ ERROR only traits defined in the current crate + // | can be implemented for arbitrary types [E0117] +} + +fn main() {} diff --git a/src/test/ui/coherence/impl-foreign[fundemental[foreign]]-for-foreign.stderr b/src/test/ui/coherence/impl-foreign[fundemental[foreign]]-for-foreign.stderr new file mode 100644 index 0000000000000..bf2361a1718af --- /dev/null +++ b/src/test/ui/coherence/impl-foreign[fundemental[foreign]]-for-foreign.stderr @@ -0,0 +1,30 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/impl-foreign[fundemental[foreign]]-for-foreign.rs:13:1 + | +LL | impl Remote1> for i32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference only types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/impl-foreign[fundemental[foreign]]-for-foreign.rs:17:1 + | +LL | impl Remote1>> for f64 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference only types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/impl-foreign[fundemental[foreign]]-for-foreign.rs:21:1 + | +LL | impl Remote1>> for f32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference only types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/impl-foreign[fundemental[local]]-for-foreign.rs b/src/test/ui/coherence/impl-foreign[fundemental[local]]-for-foreign.rs new file mode 100644 index 0000000000000..d47e0a36a5659 --- /dev/null +++ b/src/test/ui/coherence/impl-foreign[fundemental[local]]-for-foreign.rs @@ -0,0 +1,18 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs +// check-pass + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local; +struct Local1(Rc); + +impl Remote1> for i32 {} +impl Remote1>> for f64 {} +impl Remote1>> for f32 {} + +fn main() {} diff --git a/src/test/ui/coherence/impl[t]-foreign-for-(local, t).rs b/src/test/ui/coherence/impl[t]-foreign-for-(local, t).rs new file mode 100644 index 0000000000000..850b6f85d0ed7 --- /dev/null +++ b/src/test/ui/coherence/impl[t]-foreign-for-(local, t).rs @@ -0,0 +1,17 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local; + +impl Remote for (Local, T) { + //~^ ERROR only traits defined in the current crate + // | can be implemented for arbitrary types [E0117] +} + +fn main() {} diff --git a/src/test/ui/coherence/impl[t]-foreign-for-(local, t).stderr b/src/test/ui/coherence/impl[t]-foreign-for-(local, t).stderr new file mode 100644 index 0000000000000..ff0b9d6d0da9a --- /dev/null +++ b/src/test/ui/coherence/impl[t]-foreign-for-(local, t).stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/impl[t]-foreign-for-(local, t).rs:12:1 + | +LL | impl Remote for (Local, T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference only types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/impl[t]-foreign-for-foreign[t].rs b/src/test/ui/coherence/impl[t]-foreign-for-foreign[t].rs new file mode 100644 index 0000000000000..db7a2ae8076a3 --- /dev/null +++ b/src/test/ui/coherence/impl[t]-foreign-for-foreign[t].rs @@ -0,0 +1,23 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; +use std::sync::Arc; + +struct Local; + +impl Remote for Rc { + //~^ ERROR only traits defined in the current crate + // | can be implemented for arbitrary types [E0117] +} + +impl Remote for Arc { + //~^ ERROR only traits defined in the current crate + // | can be implemented for arbitrary types [E0117] +} + +fn main() {} diff --git a/src/test/ui/coherence/impl[t]-foreign-for-foreign[t].stderr b/src/test/ui/coherence/impl[t]-foreign-for-foreign[t].stderr new file mode 100644 index 0000000000000..d7ffcaf76f9a2 --- /dev/null +++ b/src/test/ui/coherence/impl[t]-foreign-for-foreign[t].stderr @@ -0,0 +1,21 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/impl[t]-foreign-for-foreign[t].rs:13:1 + | +LL | impl Remote for Rc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference only types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/impl[t]-foreign-for-foreign[t].rs:18:1 + | +LL | impl Remote for Arc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference only types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].rs b/src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].rs new file mode 100644 index 0000000000000..4cc19e1a526ca --- /dev/null +++ b/src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].rs @@ -0,0 +1,17 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local; + +impl Remote for Box { + //~^ ERROR type parameter `T` must be used as the type parameter for + // | some local type (e.g., `MyStruct`) +} + +fn main() {} diff --git a/src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr b/src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr new file mode 100644 index 0000000000000..20ce11ef9759e --- /dev/null +++ b/src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) + --> $DIR/impl[t]-foreign-for-fundamental[t].rs:12:1 + | +LL | impl Remote for Box { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/coherence/impl[t]-foreign[fundemental[local]]-for-foreign[t].rs b/src/test/ui/coherence/impl[t]-foreign[fundemental[local]]-for-foreign[t].rs new file mode 100644 index 0000000000000..914680f191ac9 --- /dev/null +++ b/src/test/ui/coherence/impl[t]-foreign[fundemental[local]]-for-foreign[t].rs @@ -0,0 +1,17 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs +// check-pass + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local; +struct Local1(Rc); + +impl Remote1> for Rc {} +impl Remote1>> for Rc {} + +fn main() {} diff --git a/src/test/ui/coherence/impl[t]-foreign[local]-for-foreign[t].rs b/src/test/ui/coherence/impl[t]-foreign[local]-for-foreign[t].rs new file mode 100644 index 0000000000000..1e84ff40c6227 --- /dev/null +++ b/src/test/ui/coherence/impl[t]-foreign[local]-for-foreign[t].rs @@ -0,0 +1,17 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs +// check-pass + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local; +struct Local1(Rc); + +impl Remote1 for Rc {} +impl Remote1> for Rc {} + +fn main() {} diff --git a/src/test/ui/coherence/impl[t]-foreign[local]-for-fundamental[foreign[t]].rs b/src/test/ui/coherence/impl[t]-foreign[local]-for-fundamental[foreign[t]].rs new file mode 100644 index 0000000000000..ea6aa101d209c --- /dev/null +++ b/src/test/ui/coherence/impl[t]-foreign[local]-for-fundamental[foreign[t]].rs @@ -0,0 +1,19 @@ +#![feature(re_rebalance_coherence)] + +// compile-flags:--crate-name=test +// aux-build:coherence_lib.rs +// check-pass + +extern crate coherence_lib as lib; +use lib::*; +use std::rc::Rc; + +struct Local; +struct Local1(Rc); + +impl Remote1 for Box> {} +impl Remote1> for Box> {} +impl Remote1> for Box> {} +impl Remote1>> for Box> {} + +fn main() {} From b9bca1800219b908049a5cfb7cafc0322439f9a8 Mon Sep 17 00:00:00 2001 From: Lucas Henry Date: Thu, 17 Oct 2019 19:15:42 +0200 Subject: [PATCH 04/29] Replaced warn attibute by deny --- .../lint/unused_parens_json_suggestion.fixed | 5 +- .../ui/lint/unused_parens_json_suggestion.rs | 5 +- .../lint/unused_parens_json_suggestion.stderr | 50 +++++++++++-------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/test/ui/lint/unused_parens_json_suggestion.fixed b/src/test/ui/lint/unused_parens_json_suggestion.fixed index 427407119102c..7a2d9ecdc3623 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.fixed +++ b/src/test/ui/lint/unused_parens_json_suggestion.fixed @@ -1,5 +1,4 @@ // compile-flags: --error-format pretty-json -Zunstable-options -// build-pass (FIXME(62277): could be check-pass?) // run-rustfix // The output for humans should just highlight the whole span without showing @@ -8,13 +7,13 @@ // stripping away any starting or ending parenthesis characters—hence this // test of the JSON error format. -#![warn(unused_parens)] +#![deny(unused_parens)] #![allow(unreachable_code)] fn main() { // We want to suggest the properly-balanced expression `1 / (2 + 3)`, not // the malformed `1 / (2 + 3` - let _a = 1 / (2 + 3); + let _a = 1 / (2 + 3); //~ERROR unused parentheses wrap expression f(); } diff --git a/src/test/ui/lint/unused_parens_json_suggestion.rs b/src/test/ui/lint/unused_parens_json_suggestion.rs index 87192503986c4..bfc649ad99c9a 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.rs +++ b/src/test/ui/lint/unused_parens_json_suggestion.rs @@ -1,5 +1,4 @@ // compile-flags: --error-format pretty-json -Zunstable-options -// build-pass (FIXME(62277): could be check-pass?) // run-rustfix // The output for humans should just highlight the whole span without showing @@ -8,13 +7,13 @@ // stripping away any starting or ending parenthesis characters—hence this // test of the JSON error format. -#![warn(unused_parens)] +#![deny(unused_parens)] #![allow(unreachable_code)] fn main() { // We want to suggest the properly-balanced expression `1 / (2 + 3)`, not // the malformed `1 / (2 + 3` - let _a = (1 / (2 + 3)); + let _a = (1 / (2 + 3)); //~ERROR unused parentheses wrap expression f(); } diff --git a/src/test/ui/lint/unused_parens_json_suggestion.stderr b/src/test/ui/lint/unused_parens_json_suggestion.stderr index 256c7555c908b..54baade36e6ae 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.stderr +++ b/src/test/ui/lint/unused_parens_json_suggestion.stderr @@ -4,20 +4,20 @@ "code": "unused_parens", "explanation": null }, - "level": "warning", + "level": "error", "spans": [ { "file_name": "$DIR/unused_parens_json_suggestion.rs", - "byte_start": 654, - "byte_end": 667, - "line_start": 17, - "line_end": 17, + "byte_start": 603, + "byte_end": 616, + "line_start": 16, + "line_end": 16, "column_start": 14, "column_end": 27, "is_primary": true, "text": [ { - "text": " let _a = (1 / (2 + 3));", + "text": " let _a = (1 / (2 + 3)); "highlight_start": 14, "highlight_end": 27 } @@ -36,16 +36,16 @@ "spans": [ { "file_name": "$DIR/unused_parens_json_suggestion.rs", - "byte_start": 472, - "byte_end": 485, - "line_start": 11, - "line_end": 11, + "byte_start": 421, + "byte_end": 434, + "line_start": 10, + "line_end": 10, "column_start": 9, "column_end": 22, "is_primary": true, "text": [ { - "text": "#![warn(unused_parens)]", + "text": "#![deny(unused_parens)]", "highlight_start": 9, "highlight_end": 22 } @@ -66,16 +66,16 @@ "spans": [ { "file_name": "$DIR/unused_parens_json_suggestion.rs", - "byte_start": 654, - "byte_end": 667, - "line_start": 17, - "line_end": 17, + "byte_start": 603, + "byte_end": 616, + "line_start": 16, + "line_end": 16, "column_start": 14, "column_end": 27, "is_primary": true, "text": [ { - "text": " let _a = (1 / (2 + 3));", + "text": " let _a = (1 / (2 + 3)); "highlight_start": 14, "highlight_end": 27 } @@ -90,17 +90,27 @@ "rendered": null } ], - "rendered": "warning: unnecessary parentheses around assigned value - --> $DIR/unused_parens_json_suggestion.rs:17:14 + "rendered": "error: unnecessary parentheses around assigned value + --> $DIR/unused_parens_json_suggestion.rs:16:14 | LL | let _a = (1 / (2 + 3)); | ^^^^^^^^^^^^^ help: remove these parentheses | note: lint level defined here - --> $DIR/unused_parens_json_suggestion.rs:11:9 + --> $DIR/unused_parens_json_suggestion.rs:10:9 | -LL | #![warn(unused_parens)] +LL | #![deny(unused_parens)] | ^^^^^^^^^^^^^ " } +{ + "message": "aborting due to previous error", + "code": null, + "level": "error", + "spans": [], + "children": [], + "rendered": "error: aborting due to previous error + +" +} From 43b5dcaabb527126830f721318037bb270e21d4a Mon Sep 17 00:00:00 2001 From: Lucas Henry Date: Thu, 17 Oct 2019 19:27:55 +0200 Subject: [PATCH 05/29] Replaced warn attribute by deny --- .../lint/unused_parens_json_suggestion.fixed | 2 +- .../ui/lint/unused_parens_json_suggestion.rs | 2 +- ...unused_parens_remove_json_suggestion.fixed | 19 +- .../unused_parens_remove_json_suggestion.rs | 19 +- ...nused_parens_remove_json_suggestion.stderr | 254 +++++++++--------- 5 files changed, 152 insertions(+), 144 deletions(-) diff --git a/src/test/ui/lint/unused_parens_json_suggestion.fixed b/src/test/ui/lint/unused_parens_json_suggestion.fixed index 7a2d9ecdc3623..5408a7cab7faa 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.fixed +++ b/src/test/ui/lint/unused_parens_json_suggestion.fixed @@ -13,7 +13,7 @@ fn main() { // We want to suggest the properly-balanced expression `1 / (2 + 3)`, not // the malformed `1 / (2 + 3` - let _a = 1 / (2 + 3); //~ERROR unused parentheses wrap expression + let _a = 1 / (2 + 3); //~ERROR f(); } diff --git a/src/test/ui/lint/unused_parens_json_suggestion.rs b/src/test/ui/lint/unused_parens_json_suggestion.rs index bfc649ad99c9a..ca421523ccd35 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.rs +++ b/src/test/ui/lint/unused_parens_json_suggestion.rs @@ -13,7 +13,7 @@ fn main() { // We want to suggest the properly-balanced expression `1 / (2 + 3)`, not // the malformed `1 / (2 + 3` - let _a = (1 / (2 + 3)); //~ERROR unused parentheses wrap expression + let _a = (1 / (2 + 3)); //~ERROR f(); } diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed b/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed index 2459eb1ac5cb8..d63abfc8e50de 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed @@ -1,5 +1,4 @@ // compile-flags: --error-format pretty-json -Zunstable-options -// build-pass // run-rustfix // The output for humans should just highlight the whole span without showing @@ -8,14 +7,14 @@ // stripping away any starting or ending parenthesis characters—hence this // test of the JSON error format. -#![warn(unused_parens)] +#![deny(unused_parens)] #![allow(unreachable_code)] fn main() { let _b = false; - if _b { + if _b { //~ ERROR println!("hello"); } @@ -26,29 +25,29 @@ fn main() { fn f() -> bool { let c = false; - if c { + if c { //~ ERROR println!("next"); } - if c { + if c { //~ ERROR println!("prev"); } while false && true { - if c { + if c { //~ ERROR println!("norm"); } } - while true && false { - for _ in 0 .. 3 { + while true && false { //~ ERROR + for _ in 0 .. 3 { //~ ERROR println!("e~") } } - for _ in 0 .. 3 { - while true && false { + for _ in 0 .. 3 { //~ ERROR + while true && false { //~ ERROR println!("e~") } } diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.rs b/src/test/ui/lint/unused_parens_remove_json_suggestion.rs index 0e9869b67d590..1af352df78d78 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.rs +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.rs @@ -1,5 +1,4 @@ // compile-flags: --error-format pretty-json -Zunstable-options -// build-pass // run-rustfix // The output for humans should just highlight the whole span without showing @@ -8,14 +7,14 @@ // stripping away any starting or ending parenthesis characters—hence this // test of the JSON error format. -#![warn(unused_parens)] +#![deny(unused_parens)] #![allow(unreachable_code)] fn main() { let _b = false; - if (_b) { + if (_b) { //~ ERROR println!("hello"); } @@ -26,29 +25,29 @@ fn main() { fn f() -> bool { let c = false; - if(c) { + if(c) { //~ ERROR println!("next"); } - if (c){ + if (c){ //~ ERROR println!("prev"); } while (false && true){ - if (c) { + if (c) { //~ ERROR println!("norm"); } } - while(true && false) { - for _ in (0 .. 3){ + while(true && false) { //~ ERROR + for _ in (0 .. 3){ //~ ERROR println!("e~") } } - for _ in (0 .. 3) { - while (true && false) { + for _ in (0 .. 3) { //~ ERROR + while (true && false) { //~ ERROR println!("e~") } } diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr b/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr index b4eab200dd016..3665d94cca204 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr @@ -4,20 +4,20 @@ "code": "unused_parens", "explanation": null }, - "level": "warning", + "level": "error", "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 521, - "byte_end": 525, - "line_start": 18, - "line_end": 18, + "byte_start": 507, + "byte_end": 511, + "line_start": 17, + "line_end": 17, "column_start": 8, "column_end": 12, "is_primary": true, "text": [ { - "text": " if (_b) {", + "text": " if (_b) { "highlight_start": 8, "highlight_end": 12 } @@ -36,16 +36,16 @@ "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 435, - "byte_end": 448, - "line_start": 11, - "line_end": 11, + "byte_start": 421, + "byte_end": 434, + "line_start": 10, + "line_end": 10, "column_start": 9, "column_end": 22, "is_primary": true, "text": [ { - "text": "#![warn(unused_parens)]", + "text": "#![deny(unused_parens)]", "highlight_start": 9, "highlight_end": 22 } @@ -66,16 +66,16 @@ "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 521, - "byte_end": 525, - "line_start": 18, - "line_end": 18, + "byte_start": 507, + "byte_end": 511, + "line_start": 17, + "line_end": 17, "column_start": 8, "column_end": 12, "is_primary": true, "text": [ { - "text": " if (_b) {", + "text": " if (_b) { "highlight_start": 8, "highlight_end": 12 } @@ -90,16 +90,16 @@ "rendered": null } ], - "rendered": "warning: unnecessary parentheses around `if` condition - --> $DIR/unused_parens_remove_json_suggestion.rs:18:8 + "rendered": "error: unnecessary parentheses around `if` condition + --> $DIR/unused_parens_remove_json_suggestion.rs:17:8 | LL | if (_b) { | ^^^^ help: remove these parentheses | note: lint level defined here - --> $DIR/unused_parens_remove_json_suggestion.rs:11:9 + --> $DIR/unused_parens_remove_json_suggestion.rs:10:9 | -LL | #![warn(unused_parens)] +LL | #![deny(unused_parens)] | ^^^^^^^^^^^^^ " @@ -110,20 +110,20 @@ LL | #![warn(unused_parens)] "code": "unused_parens", "explanation": null }, - "level": "warning", + "level": "error", "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 618, - "byte_end": 621, - "line_start": 29, - "line_end": 29, + "byte_start": 614, + "byte_end": 617, + "line_start": 28, + "line_end": 28, "column_start": 7, "column_end": 10, "is_primary": true, "text": [ { - "text": " if(c) {", + "text": " if(c) { "highlight_start": 7, "highlight_end": 10 } @@ -142,16 +142,16 @@ LL | #![warn(unused_parens)] "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 618, - "byte_end": 621, - "line_start": 29, - "line_end": 29, + "byte_start": 614, + "byte_end": 617, + "line_start": 28, + "line_end": 28, "column_start": 7, "column_end": 10, "is_primary": true, "text": [ { - "text": " if(c) {", + "text": " if(c) { "highlight_start": 7, "highlight_end": 10 } @@ -166,8 +166,8 @@ LL | #![warn(unused_parens)] "rendered": null } ], - "rendered": "warning: unnecessary parentheses around `if` condition - --> $DIR/unused_parens_remove_json_suggestion.rs:29:7 + "rendered": "error: unnecessary parentheses around `if` condition + --> $DIR/unused_parens_remove_json_suggestion.rs:28:7 | LL | if(c) { | ^^^ help: remove these parentheses @@ -180,20 +180,20 @@ LL | if(c) { "code": "unused_parens", "explanation": null }, - "level": "warning", + "level": "error", "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 664, - "byte_end": 667, - "line_start": 33, - "line_end": 33, + "byte_start": 670, + "byte_end": 673, + "line_start": 32, + "line_end": 32, "column_start": 8, "column_end": 11, "is_primary": true, "text": [ { - "text": " if (c){", + "text": " if (c){ "highlight_start": 8, "highlight_end": 11 } @@ -212,16 +212,16 @@ LL | if(c) { "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 664, - "byte_end": 667, - "line_start": 33, - "line_end": 33, + "byte_start": 670, + "byte_end": 673, + "line_start": 32, + "line_end": 32, "column_start": 8, "column_end": 11, "is_primary": true, "text": [ { - "text": " if (c){", + "text": " if (c){ "highlight_start": 8, "highlight_end": 11 } @@ -236,8 +236,8 @@ LL | if(c) { "rendered": null } ], - "rendered": "warning: unnecessary parentheses around `if` condition - --> $DIR/unused_parens_remove_json_suggestion.rs:33:8 + "rendered": "error: unnecessary parentheses around `if` condition + --> $DIR/unused_parens_remove_json_suggestion.rs:32:8 | LL | if (c){ | ^^^ help: remove these parentheses @@ -250,14 +250,14 @@ LL | if (c){ "code": "unused_parens", "explanation": null }, - "level": "warning", + "level": "error", "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 712, - "byte_end": 727, - "line_start": 37, - "line_end": 37, + "byte_start": 728, + "byte_end": 743, + "line_start": 36, + "line_end": 36, "column_start": 11, "column_end": 26, "is_primary": true, @@ -282,10 +282,10 @@ LL | if (c){ "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 712, - "byte_end": 727, - "line_start": 37, - "line_end": 37, + "byte_start": 728, + "byte_end": 743, + "line_start": 36, + "line_end": 36, "column_start": 11, "column_end": 26, "is_primary": true, @@ -306,8 +306,8 @@ LL | if (c){ "rendered": null } ], - "rendered": "warning: unnecessary parentheses around `while` condition - --> $DIR/unused_parens_remove_json_suggestion.rs:37:11 + "rendered": "error: unnecessary parentheses around `while` condition + --> $DIR/unused_parens_remove_json_suggestion.rs:36:11 | LL | while (false && true){ | ^^^^^^^^^^^^^^^ help: remove these parentheses @@ -320,20 +320,20 @@ LL | while (false && true){ "code": "unused_parens", "explanation": null }, - "level": "warning", + "level": "error", "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 740, - "byte_end": 743, - "line_start": 38, - "line_end": 38, + "byte_start": 756, + "byte_end": 759, + "line_start": 37, + "line_end": 37, "column_start": 12, "column_end": 15, "is_primary": true, "text": [ { - "text": " if (c) {", + "text": " if (c) { "highlight_start": 12, "highlight_end": 15 } @@ -352,16 +352,16 @@ LL | while (false && true){ "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 740, - "byte_end": 743, - "line_start": 38, - "line_end": 38, + "byte_start": 756, + "byte_end": 759, + "line_start": 37, + "line_end": 37, "column_start": 12, "column_end": 15, "is_primary": true, "text": [ { - "text": " if (c) {", + "text": " if (c) { "highlight_start": 12, "highlight_end": 15 } @@ -376,8 +376,8 @@ LL | while (false && true){ "rendered": null } ], - "rendered": "warning: unnecessary parentheses around `if` condition - --> $DIR/unused_parens_remove_json_suggestion.rs:38:12 + "rendered": "error: unnecessary parentheses around `if` condition + --> $DIR/unused_parens_remove_json_suggestion.rs:37:12 | LL | if (c) { | ^^^ help: remove these parentheses @@ -390,20 +390,20 @@ LL | if (c) { "code": "unused_parens", "explanation": null }, - "level": "warning", + "level": "error", "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 803, - "byte_end": 818, - "line_start": 44, - "line_end": 44, + "byte_start": 829, + "byte_end": 844, + "line_start": 43, + "line_end": 43, "column_start": 10, "column_end": 25, "is_primary": true, "text": [ { - "text": " while(true && false) {", + "text": " while(true && false) { "highlight_start": 10, "highlight_end": 25 } @@ -422,16 +422,16 @@ LL | if (c) { "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 803, - "byte_end": 818, - "line_start": 44, - "line_end": 44, + "byte_start": 829, + "byte_end": 844, + "line_start": 43, + "line_end": 43, "column_start": 10, "column_end": 25, "is_primary": true, "text": [ { - "text": " while(true && false) {", + "text": " while(true && false) { "highlight_start": 10, "highlight_end": 25 } @@ -446,8 +446,8 @@ LL | if (c) { "rendered": null } ], - "rendered": "warning: unnecessary parentheses around `while` condition - --> $DIR/unused_parens_remove_json_suggestion.rs:44:10 + "rendered": "error: unnecessary parentheses around `while` condition + --> $DIR/unused_parens_remove_json_suggestion.rs:43:10 | LL | while(true && false) { | ^^^^^^^^^^^^^^^ help: remove these parentheses @@ -460,20 +460,20 @@ LL | while(true && false) { "code": "unused_parens", "explanation": null }, - "level": "warning", + "level": "error", "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 838, - "byte_end": 846, - "line_start": 45, - "line_end": 45, + "byte_start": 874, + "byte_end": 882, + "line_start": 44, + "line_end": 44, "column_start": 18, "column_end": 26, "is_primary": true, "text": [ { - "text": " for _ in (0 .. 3){", + "text": " for _ in (0 .. 3){ "highlight_start": 18, "highlight_end": 26 } @@ -492,16 +492,16 @@ LL | while(true && false) { "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 838, - "byte_end": 846, - "line_start": 45, - "line_end": 45, + "byte_start": 874, + "byte_end": 882, + "line_start": 44, + "line_end": 44, "column_start": 18, "column_end": 26, "is_primary": true, "text": [ { - "text": " for _ in (0 .. 3){", + "text": " for _ in (0 .. 3){ "highlight_start": 18, "highlight_end": 26 } @@ -516,8 +516,8 @@ LL | while(true && false) { "rendered": null } ], - "rendered": "warning: unnecessary parentheses around `for` head expression - --> $DIR/unused_parens_remove_json_suggestion.rs:45:18 + "rendered": "error: unnecessary parentheses around `for` head expression + --> $DIR/unused_parens_remove_json_suggestion.rs:44:18 | LL | for _ in (0 .. 3){ | ^^^^^^^^ help: remove these parentheses @@ -530,20 +530,20 @@ LL | for _ in (0 .. 3){ "code": "unused_parens", "explanation": null }, - "level": "warning", + "level": "error", "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 905, - "byte_end": 913, - "line_start": 50, - "line_end": 50, + "byte_start": 951, + "byte_end": 959, + "line_start": 49, + "line_end": 49, "column_start": 14, "column_end": 22, "is_primary": true, "text": [ { - "text": " for _ in (0 .. 3) {", + "text": " for _ in (0 .. 3) { "highlight_start": 14, "highlight_end": 22 } @@ -562,16 +562,16 @@ LL | for _ in (0 .. 3){ "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 905, - "byte_end": 913, - "line_start": 50, - "line_end": 50, + "byte_start": 951, + "byte_end": 959, + "line_start": 49, + "line_end": 49, "column_start": 14, "column_end": 22, "is_primary": true, "text": [ { - "text": " for _ in (0 .. 3) {", + "text": " for _ in (0 .. 3) { "highlight_start": 14, "highlight_end": 22 } @@ -586,8 +586,8 @@ LL | for _ in (0 .. 3){ "rendered": null } ], - "rendered": "warning: unnecessary parentheses around `for` head expression - --> $DIR/unused_parens_remove_json_suggestion.rs:50:14 + "rendered": "error: unnecessary parentheses around `for` head expression + --> $DIR/unused_parens_remove_json_suggestion.rs:49:14 | LL | for _ in (0 .. 3) { | ^^^^^^^^ help: remove these parentheses @@ -600,20 +600,20 @@ LL | for _ in (0 .. 3) { "code": "unused_parens", "explanation": null }, - "level": "warning", + "level": "error", "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 930, - "byte_end": 945, - "line_start": 51, - "line_end": 51, + "byte_start": 986, + "byte_end": 1001, + "line_start": 50, + "line_end": 50, "column_start": 15, "column_end": 30, "is_primary": true, "text": [ { - "text": " while (true && false) {", + "text": " while (true && false) { "highlight_start": 15, "highlight_end": 30 } @@ -632,16 +632,16 @@ LL | for _ in (0 .. 3) { "spans": [ { "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 930, - "byte_end": 945, - "line_start": 51, - "line_end": 51, + "byte_start": 986, + "byte_end": 1001, + "line_start": 50, + "line_end": 50, "column_start": 15, "column_end": 30, "is_primary": true, "text": [ { - "text": " while (true && false) {", + "text": " while (true && false) { "highlight_start": 15, "highlight_end": 30 } @@ -656,11 +656,21 @@ LL | for _ in (0 .. 3) { "rendered": null } ], - "rendered": "warning: unnecessary parentheses around `while` condition - --> $DIR/unused_parens_remove_json_suggestion.rs:51:15 + "rendered": "error: unnecessary parentheses around `while` condition + --> $DIR/unused_parens_remove_json_suggestion.rs:50:15 | LL | while (true && false) { | ^^^^^^^^^^^^^^^ help: remove these parentheses " } +{ + "message": "aborting due to 9 previous errors", + "code": null, + "level": "error", + "spans": [], + "children": [], + "rendered": "error: aborting due to 9 previous errors + +" +} From 46a44668b2e9a25b0e6fe8c805a76325a3c49810 Mon Sep 17 00:00:00 2001 From: Lucas Henry Date: Thu, 17 Oct 2019 19:31:37 +0200 Subject: [PATCH 06/29] Replaced pretty-json error-format with only json --- ...unused_parens_remove_json_suggestion.fixed | 2 +- .../unused_parens_remove_json_suggestion.rs | 2 +- ...nused_parens_remove_json_suggestion.stderr | 644 +----------------- 3 files changed, 22 insertions(+), 626 deletions(-) diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed b/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed index d63abfc8e50de..4497a159f64d7 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed @@ -1,4 +1,4 @@ -// compile-flags: --error-format pretty-json -Zunstable-options +// compile-flags: --error-format json -Zunstable-options // run-rustfix // The output for humans should just highlight the whole span without showing diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.rs b/src/test/ui/lint/unused_parens_remove_json_suggestion.rs index 1af352df78d78..22539b34bce17 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.rs +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.rs @@ -1,4 +1,4 @@ -// compile-flags: --error-format pretty-json -Zunstable-options +// compile-flags: --error-format json -Zunstable-options // run-rustfix // The output for humans should just highlight the whole span without showing diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr b/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr index 3665d94cca204..6901ac09f9917 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr @@ -1,96 +1,4 @@ -{ - "message": "unnecessary parentheses around `if` condition", - "code": { - "code": "unused_parens", - "explanation": null - }, - "level": "error", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 507, - "byte_end": 511, - "line_start": 17, - "line_end": 17, - "column_start": 8, - "column_end": 12, - "is_primary": true, - "text": [ - { - "text": " if (_b) { - "highlight_start": 8, - "highlight_end": 12 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], - "children": [ - { - "message": "lint level defined here", - "code": null, - "level": "note", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 421, - "byte_end": 434, - "line_start": 10, - "line_end": 10, - "column_start": 9, - "column_end": 22, - "is_primary": true, - "text": [ - { - "text": "#![deny(unused_parens)]", - "highlight_start": 9, - "highlight_end": 22 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], - "children": [], - "rendered": null - }, - { - "message": "remove these parentheses", - "code": null, - "level": "help", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 507, - "byte_end": 511, - "line_start": 17, - "line_end": 17, - "column_start": 8, - "column_end": 12, - "is_primary": true, - "text": [ - { - "text": " if (_b) { - "highlight_start": 8, - "highlight_end": 12 - } - ], - "label": null, - "suggested_replacement": "_b", - "suggestion_applicability": "MachineApplicable", - "expansion": null - } - ], - "children": [], - "rendered": null - } - ], - "rendered": "error: unnecessary parentheses around `if` condition +{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":500,"byte_end":504,"line_start":17,"line_end":17,"column_start":8,"column_end":12,"is_primary":true,"text":[{"text":" if (_b) { --> $DIR/unused_parens_remove_json_suggestion.rs:17:8 | LL | if (_b) { @@ -102,575 +10,63 @@ note: lint level defined here LL | #![deny(unused_parens)] | ^^^^^^^^^^^^^ -" -} -{ - "message": "unnecessary parentheses around `if` condition", - "code": { - "code": "unused_parens", - "explanation": null - }, - "level": "error", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 614, - "byte_end": 617, - "line_start": 28, - "line_end": 28, - "column_start": 7, - "column_end": 10, - "is_primary": true, - "text": [ - { - "text": " if(c) { - "highlight_start": 7, - "highlight_end": 10 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], - "children": [ - { - "message": "remove these parentheses", - "code": null, - "level": "help", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 614, - "byte_end": 617, - "line_start": 28, - "line_end": 28, - "column_start": 7, - "column_end": 10, - "is_primary": true, - "text": [ - { - "text": " if(c) { - "highlight_start": 7, - "highlight_end": 10 - } - ], - "label": null, - "suggested_replacement": " c", - "suggestion_applicability": "MachineApplicable", - "expansion": null - } - ], - "children": [], - "rendered": null - } - ], - "rendered": "error: unnecessary parentheses around `if` condition +"} +{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":607,"byte_end":610,"line_start":28,"line_end":28,"column_start":7,"column_end":10,"is_primary":true,"text":[{"text":" if(c) { --> $DIR/unused_parens_remove_json_suggestion.rs:28:7 | LL | if(c) { | ^^^ help: remove these parentheses -" -} -{ - "message": "unnecessary parentheses around `if` condition", - "code": { - "code": "unused_parens", - "explanation": null - }, - "level": "error", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 670, - "byte_end": 673, - "line_start": 32, - "line_end": 32, - "column_start": 8, - "column_end": 11, - "is_primary": true, - "text": [ - { - "text": " if (c){ - "highlight_start": 8, - "highlight_end": 11 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], - "children": [ - { - "message": "remove these parentheses", - "code": null, - "level": "help", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 670, - "byte_end": 673, - "line_start": 32, - "line_end": 32, - "column_start": 8, - "column_end": 11, - "is_primary": true, - "text": [ - { - "text": " if (c){ - "highlight_start": 8, - "highlight_end": 11 - } - ], - "label": null, - "suggested_replacement": "c ", - "suggestion_applicability": "MachineApplicable", - "expansion": null - } - ], - "children": [], - "rendered": null - } - ], - "rendered": "error: unnecessary parentheses around `if` condition +"} +{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":663,"byte_end":666,"line_start":32,"line_end":32,"column_start":8,"column_end":11,"is_primary":true,"text":[{"text":" if (c){ --> $DIR/unused_parens_remove_json_suggestion.rs:32:8 | LL | if (c){ | ^^^ help: remove these parentheses -" -} -{ - "message": "unnecessary parentheses around `while` condition", - "code": { - "code": "unused_parens", - "explanation": null - }, - "level": "error", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 728, - "byte_end": 743, - "line_start": 36, - "line_end": 36, - "column_start": 11, - "column_end": 26, - "is_primary": true, - "text": [ - { - "text": " while (false && true){", - "highlight_start": 11, - "highlight_end": 26 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], - "children": [ - { - "message": "remove these parentheses", - "code": null, - "level": "help", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 728, - "byte_end": 743, - "line_start": 36, - "line_end": 36, - "column_start": 11, - "column_end": 26, - "is_primary": true, - "text": [ - { - "text": " while (false && true){", - "highlight_start": 11, - "highlight_end": 26 - } - ], - "label": null, - "suggested_replacement": "false && true ", - "suggestion_applicability": "MachineApplicable", - "expansion": null - } - ], - "children": [], - "rendered": null - } - ], - "rendered": "error: unnecessary parentheses around `while` condition +"} +{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":721,"byte_end":736,"line_start":36,"line_end":36,"column_start":11,"column_end":26,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":11,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"remove these parentheses","code":null,"level":"help","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":721,"byte_end":736,"line_start":36,"line_end":36,"column_start":11,"column_end":26,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":11,"highlight_end":26}],"label":null,"suggested_replacement":"false && true ","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error: unnecessary parentheses around `while` condition --> $DIR/unused_parens_remove_json_suggestion.rs:36:11 | LL | while (false && true){ | ^^^^^^^^^^^^^^^ help: remove these parentheses -" -} -{ - "message": "unnecessary parentheses around `if` condition", - "code": { - "code": "unused_parens", - "explanation": null - }, - "level": "error", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 756, - "byte_end": 759, - "line_start": 37, - "line_end": 37, - "column_start": 12, - "column_end": 15, - "is_primary": true, - "text": [ - { - "text": " if (c) { - "highlight_start": 12, - "highlight_end": 15 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], - "children": [ - { - "message": "remove these parentheses", - "code": null, - "level": "help", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 756, - "byte_end": 759, - "line_start": 37, - "line_end": 37, - "column_start": 12, - "column_end": 15, - "is_primary": true, - "text": [ - { - "text": " if (c) { - "highlight_start": 12, - "highlight_end": 15 - } - ], - "label": null, - "suggested_replacement": "c", - "suggestion_applicability": "MachineApplicable", - "expansion": null - } - ], - "children": [], - "rendered": null - } - ], - "rendered": "error: unnecessary parentheses around `if` condition +"} +{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":749,"byte_end":752,"line_start":37,"line_end":37,"column_start":12,"column_end":15,"is_primary":true,"text":[{"text":" if (c) { --> $DIR/unused_parens_remove_json_suggestion.rs:37:12 | LL | if (c) { | ^^^ help: remove these parentheses -" -} -{ - "message": "unnecessary parentheses around `while` condition", - "code": { - "code": "unused_parens", - "explanation": null - }, - "level": "error", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 829, - "byte_end": 844, - "line_start": 43, - "line_end": 43, - "column_start": 10, - "column_end": 25, - "is_primary": true, - "text": [ - { - "text": " while(true && false) { - "highlight_start": 10, - "highlight_end": 25 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], - "children": [ - { - "message": "remove these parentheses", - "code": null, - "level": "help", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 829, - "byte_end": 844, - "line_start": 43, - "line_end": 43, - "column_start": 10, - "column_end": 25, - "is_primary": true, - "text": [ - { - "text": " while(true && false) { - "highlight_start": 10, - "highlight_end": 25 - } - ], - "label": null, - "suggested_replacement": " true && false", - "suggestion_applicability": "MachineApplicable", - "expansion": null - } - ], - "children": [], - "rendered": null - } - ], - "rendered": "error: unnecessary parentheses around `while` condition +"} +{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":822,"byte_end":837,"line_start":43,"line_end":43,"column_start":10,"column_end":25,"is_primary":true,"text":[{"text":" while(true && false) { --> $DIR/unused_parens_remove_json_suggestion.rs:43:10 | LL | while(true && false) { | ^^^^^^^^^^^^^^^ help: remove these parentheses -" -} -{ - "message": "unnecessary parentheses around `for` head expression", - "code": { - "code": "unused_parens", - "explanation": null - }, - "level": "error", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 874, - "byte_end": 882, - "line_start": 44, - "line_end": 44, - "column_start": 18, - "column_end": 26, - "is_primary": true, - "text": [ - { - "text": " for _ in (0 .. 3){ - "highlight_start": 18, - "highlight_end": 26 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], - "children": [ - { - "message": "remove these parentheses", - "code": null, - "level": "help", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 874, - "byte_end": 882, - "line_start": 44, - "line_end": 44, - "column_start": 18, - "column_end": 26, - "is_primary": true, - "text": [ - { - "text": " for _ in (0 .. 3){ - "highlight_start": 18, - "highlight_end": 26 - } - ], - "label": null, - "suggested_replacement": "0 .. 3 ", - "suggestion_applicability": "MachineApplicable", - "expansion": null - } - ], - "children": [], - "rendered": null - } - ], - "rendered": "error: unnecessary parentheses around `for` head expression +"} +{"message":"unnecessary parentheses around `for` head expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":867,"byte_end":875,"line_start":44,"line_end":44,"column_start":18,"column_end":26,"is_primary":true,"text":[{"text":" for _ in (0 .. 3){ --> $DIR/unused_parens_remove_json_suggestion.rs:44:18 | LL | for _ in (0 .. 3){ | ^^^^^^^^ help: remove these parentheses -" -} -{ - "message": "unnecessary parentheses around `for` head expression", - "code": { - "code": "unused_parens", - "explanation": null - }, - "level": "error", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 951, - "byte_end": 959, - "line_start": 49, - "line_end": 49, - "column_start": 14, - "column_end": 22, - "is_primary": true, - "text": [ - { - "text": " for _ in (0 .. 3) { - "highlight_start": 14, - "highlight_end": 22 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], - "children": [ - { - "message": "remove these parentheses", - "code": null, - "level": "help", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 951, - "byte_end": 959, - "line_start": 49, - "line_end": 49, - "column_start": 14, - "column_end": 22, - "is_primary": true, - "text": [ - { - "text": " for _ in (0 .. 3) { - "highlight_start": 14, - "highlight_end": 22 - } - ], - "label": null, - "suggested_replacement": "0 .. 3", - "suggestion_applicability": "MachineApplicable", - "expansion": null - } - ], - "children": [], - "rendered": null - } - ], - "rendered": "error: unnecessary parentheses around `for` head expression +"} +{"message":"unnecessary parentheses around `for` head expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":944,"byte_end":952,"line_start":49,"line_end":49,"column_start":14,"column_end":22,"is_primary":true,"text":[{"text":" for _ in (0 .. 3) { --> $DIR/unused_parens_remove_json_suggestion.rs:49:14 | LL | for _ in (0 .. 3) { | ^^^^^^^^ help: remove these parentheses -" -} -{ - "message": "unnecessary parentheses around `while` condition", - "code": { - "code": "unused_parens", - "explanation": null - }, - "level": "error", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 986, - "byte_end": 1001, - "line_start": 50, - "line_end": 50, - "column_start": 15, - "column_end": 30, - "is_primary": true, - "text": [ - { - "text": " while (true && false) { - "highlight_start": 15, - "highlight_end": 30 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], - "children": [ - { - "message": "remove these parentheses", - "code": null, - "level": "help", - "spans": [ - { - "file_name": "$DIR/unused_parens_remove_json_suggestion.rs", - "byte_start": 986, - "byte_end": 1001, - "line_start": 50, - "line_end": 50, - "column_start": 15, - "column_end": 30, - "is_primary": true, - "text": [ - { - "text": " while (true && false) { - "highlight_start": 15, - "highlight_end": 30 - } - ], - "label": null, - "suggested_replacement": "true && false", - "suggestion_applicability": "MachineApplicable", - "expansion": null - } - ], - "children": [], - "rendered": null - } - ], - "rendered": "error: unnecessary parentheses around `while` condition +"} +{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":979,"byte_end":994,"line_start":50,"line_end":50,"column_start":15,"column_end":30,"is_primary":true,"text":[{"text":" while (true && false) { --> $DIR/unused_parens_remove_json_suggestion.rs:50:15 | LL | while (true && false) { | ^^^^^^^^^^^^^^^ help: remove these parentheses -" -} -{ - "message": "aborting due to 9 previous errors", - "code": null, - "level": "error", - "spans": [], - "children": [], - "rendered": "error: aborting due to 9 previous errors +"} +{"message":"aborting due to 9 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 9 previous errors -" -} +"} From a1387e352f36ae6cd80ee25e01a4a6de2aedef45 Mon Sep 17 00:00:00 2001 From: Lucas Henry Date: Thu, 17 Oct 2019 19:32:04 +0200 Subject: [PATCH 07/29] Replaced pretty-json error-format with only json --- .../lint/unused_parens_json_suggestion.fixed | 2 +- .../ui/lint/unused_parens_json_suggestion.rs | 2 +- .../lint/unused_parens_json_suggestion.stderr | 108 +----------------- 3 files changed, 6 insertions(+), 106 deletions(-) diff --git a/src/test/ui/lint/unused_parens_json_suggestion.fixed b/src/test/ui/lint/unused_parens_json_suggestion.fixed index 5408a7cab7faa..757ad933a1f70 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.fixed +++ b/src/test/ui/lint/unused_parens_json_suggestion.fixed @@ -1,4 +1,4 @@ -// compile-flags: --error-format pretty-json -Zunstable-options +// compile-flags: --error-format json -Zunstable-options // run-rustfix // The output for humans should just highlight the whole span without showing diff --git a/src/test/ui/lint/unused_parens_json_suggestion.rs b/src/test/ui/lint/unused_parens_json_suggestion.rs index ca421523ccd35..173cd55545027 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.rs +++ b/src/test/ui/lint/unused_parens_json_suggestion.rs @@ -1,4 +1,4 @@ -// compile-flags: --error-format pretty-json -Zunstable-options +// compile-flags: --error-format json -Zunstable-options // run-rustfix // The output for humans should just highlight the whole span without showing diff --git a/src/test/ui/lint/unused_parens_json_suggestion.stderr b/src/test/ui/lint/unused_parens_json_suggestion.stderr index 54baade36e6ae..c503c100808db 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.stderr +++ b/src/test/ui/lint/unused_parens_json_suggestion.stderr @@ -1,96 +1,4 @@ -{ - "message": "unnecessary parentheses around assigned value", - "code": { - "code": "unused_parens", - "explanation": null - }, - "level": "error", - "spans": [ - { - "file_name": "$DIR/unused_parens_json_suggestion.rs", - "byte_start": 603, - "byte_end": 616, - "line_start": 16, - "line_end": 16, - "column_start": 14, - "column_end": 27, - "is_primary": true, - "text": [ - { - "text": " let _a = (1 / (2 + 3)); - "highlight_start": 14, - "highlight_end": 27 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], - "children": [ - { - "message": "lint level defined here", - "code": null, - "level": "note", - "spans": [ - { - "file_name": "$DIR/unused_parens_json_suggestion.rs", - "byte_start": 421, - "byte_end": 434, - "line_start": 10, - "line_end": 10, - "column_start": 9, - "column_end": 22, - "is_primary": true, - "text": [ - { - "text": "#![deny(unused_parens)]", - "highlight_start": 9, - "highlight_end": 22 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], - "children": [], - "rendered": null - }, - { - "message": "remove these parentheses", - "code": null, - "level": "help", - "spans": [ - { - "file_name": "$DIR/unused_parens_json_suggestion.rs", - "byte_start": 603, - "byte_end": 616, - "line_start": 16, - "line_end": 16, - "column_start": 14, - "column_end": 27, - "is_primary": true, - "text": [ - { - "text": " let _a = (1 / (2 + 3)); - "highlight_start": 14, - "highlight_end": 27 - } - ], - "label": null, - "suggested_replacement": "1 / (2 + 3)", - "suggestion_applicability": "MachineApplicable", - "expansion": null - } - ], - "children": [], - "rendered": null - } - ], - "rendered": "error: unnecessary parentheses around assigned value +{"message":"unnecessary parentheses around assigned value","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":596,"byte_end":609,"line_start":16,"line_end":16,"column_start":14,"column_end":27,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3)); --> $DIR/unused_parens_json_suggestion.rs:16:14 | LL | let _a = (1 / (2 + 3)); @@ -102,15 +10,7 @@ note: lint level defined here LL | #![deny(unused_parens)] | ^^^^^^^^^^^^^ -" -} -{ - "message": "aborting due to previous error", - "code": null, - "level": "error", - "spans": [], - "children": [], - "rendered": "error: aborting due to previous error +"} +{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error -" -} +"} From 95d98af806f78d9cbe3975b633d5341394a155ad Mon Sep 17 00:00:00 2001 From: Lucas Henry Date: Fri, 18 Oct 2019 13:21:39 +0200 Subject: [PATCH 08/29] Added text after error messages --- .../ui/lint/unused_parens_json_suggestion.fixed | 2 +- .../ui/lint/unused_parens_json_suggestion.rs | 2 +- .../unused_parens_remove_json_suggestion.fixed | 16 ++++++++-------- .../lint/unused_parens_remove_json_suggestion.rs | 16 ++++++++-------- .../unused_parens_remove_json_suggestion.stderr | 16 ++++++++-------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/test/ui/lint/unused_parens_json_suggestion.fixed b/src/test/ui/lint/unused_parens_json_suggestion.fixed index 757ad933a1f70..15ee19755bffc 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.fixed +++ b/src/test/ui/lint/unused_parens_json_suggestion.fixed @@ -13,7 +13,7 @@ fn main() { // We want to suggest the properly-balanced expression `1 / (2 + 3)`, not // the malformed `1 / (2 + 3` - let _a = 1 / (2 + 3); //~ERROR + let _a = 1 / (2 + 3); //~ERROR unnecessary parentheses f(); } diff --git a/src/test/ui/lint/unused_parens_json_suggestion.rs b/src/test/ui/lint/unused_parens_json_suggestion.rs index 173cd55545027..d72df21e09ae2 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.rs +++ b/src/test/ui/lint/unused_parens_json_suggestion.rs @@ -13,7 +13,7 @@ fn main() { // We want to suggest the properly-balanced expression `1 / (2 + 3)`, not // the malformed `1 / (2 + 3` - let _a = (1 / (2 + 3)); //~ERROR + let _a = (1 / (2 + 3)); //~ERROR unnecessary parentheses f(); } diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed b/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed index 4497a159f64d7..1d891d328dd5a 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed @@ -14,7 +14,7 @@ fn main() { let _b = false; - if _b { //~ ERROR + if _b { //~ ERROR unnecessary parentheses println!("hello"); } @@ -25,29 +25,29 @@ fn main() { fn f() -> bool { let c = false; - if c { //~ ERROR + if c { //~ ERROR unnecessary parentheses println!("next"); } - if c { //~ ERROR + if c { //~ ERROR unnecessary parentheses println!("prev"); } while false && true { - if c { //~ ERROR + if c { //~ ERROR unnecessary parentheses println!("norm"); } } - while true && false { //~ ERROR - for _ in 0 .. 3 { //~ ERROR + while true && false { //~ ERROR unnecessary parentheses + for _ in 0 .. 3 { //~ ERROR unnecessary parentheses println!("e~") } } - for _ in 0 .. 3 { //~ ERROR - while true && false { //~ ERROR + for _ in 0 .. 3 { //~ ERROR unnecessary parentheses + while true && false { //~ ERROR unnecessary parentheses println!("e~") } } diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.rs b/src/test/ui/lint/unused_parens_remove_json_suggestion.rs index 22539b34bce17..494cd18450630 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.rs +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.rs @@ -14,7 +14,7 @@ fn main() { let _b = false; - if (_b) { //~ ERROR + if (_b) { //~ ERROR unnecessary parentheses println!("hello"); } @@ -25,29 +25,29 @@ fn main() { fn f() -> bool { let c = false; - if(c) { //~ ERROR + if(c) { //~ ERROR unnecessary parentheses println!("next"); } - if (c){ //~ ERROR + if (c){ //~ ERROR unnecessary parentheses println!("prev"); } while (false && true){ - if (c) { //~ ERROR + if (c) { //~ ERROR unnecessary parentheses println!("norm"); } } - while(true && false) { //~ ERROR - for _ in (0 .. 3){ //~ ERROR + while(true && false) { //~ ERROR unnecessary parentheses + for _ in (0 .. 3){ //~ ERROR unnecessary parentheses println!("e~") } } - for _ in (0 .. 3) { //~ ERROR - while (true && false) { //~ ERROR + for _ in (0 .. 3) { //~ ERROR unnecessary parentheses + while (true && false) { //~ ERROR unnecessary parentheses println!("e~") } } diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr b/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr index 6901ac09f9917..873f105435e08 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr @@ -11,56 +11,56 @@ LL | #![deny(unused_parens)] | ^^^^^^^^^^^^^ "} -{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":607,"byte_end":610,"line_start":28,"line_end":28,"column_start":7,"column_end":10,"is_primary":true,"text":[{"text":" if(c) { +{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":631,"byte_end":634,"line_start":28,"line_end":28,"column_start":7,"column_end":10,"is_primary":true,"text":[{"text":" if(c) { --> $DIR/unused_parens_remove_json_suggestion.rs:28:7 | LL | if(c) { | ^^^ help: remove these parentheses "} -{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":663,"byte_end":666,"line_start":32,"line_end":32,"column_start":8,"column_end":11,"is_primary":true,"text":[{"text":" if (c){ +{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":711,"byte_end":714,"line_start":32,"line_end":32,"column_start":8,"column_end":11,"is_primary":true,"text":[{"text":" if (c){ --> $DIR/unused_parens_remove_json_suggestion.rs:32:8 | LL | if (c){ | ^^^ help: remove these parentheses "} -{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":721,"byte_end":736,"line_start":36,"line_end":36,"column_start":11,"column_end":26,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":11,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"remove these parentheses","code":null,"level":"help","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":721,"byte_end":736,"line_start":36,"line_end":36,"column_start":11,"column_end":26,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":11,"highlight_end":26}],"label":null,"suggested_replacement":"false && true ","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error: unnecessary parentheses around `while` condition +{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":793,"byte_end":808,"line_start":36,"line_end":36,"column_start":11,"column_end":26,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":11,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"remove these parentheses","code":null,"level":"help","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":793,"byte_end":808,"line_start":36,"line_end":36,"column_start":11,"column_end":26,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":11,"highlight_end":26}],"label":null,"suggested_replacement":"false && true ","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error: unnecessary parentheses around `while` condition --> $DIR/unused_parens_remove_json_suggestion.rs:36:11 | LL | while (false && true){ | ^^^^^^^^^^^^^^^ help: remove these parentheses "} -{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":749,"byte_end":752,"line_start":37,"line_end":37,"column_start":12,"column_end":15,"is_primary":true,"text":[{"text":" if (c) { +{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":821,"byte_end":824,"line_start":37,"line_end":37,"column_start":12,"column_end":15,"is_primary":true,"text":[{"text":" if (c) { --> $DIR/unused_parens_remove_json_suggestion.rs:37:12 | LL | if (c) { | ^^^ help: remove these parentheses "} -{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":822,"byte_end":837,"line_start":43,"line_end":43,"column_start":10,"column_end":25,"is_primary":true,"text":[{"text":" while(true && false) { +{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":918,"byte_end":933,"line_start":43,"line_end":43,"column_start":10,"column_end":25,"is_primary":true,"text":[{"text":" while(true && false) { --> $DIR/unused_parens_remove_json_suggestion.rs:43:10 | LL | while(true && false) { | ^^^^^^^^^^^^^^^ help: remove these parentheses "} -{"message":"unnecessary parentheses around `for` head expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":867,"byte_end":875,"line_start":44,"line_end":44,"column_start":18,"column_end":26,"is_primary":true,"text":[{"text":" for _ in (0 .. 3){ +{"message":"unnecessary parentheses around `for` head expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":987,"byte_end":995,"line_start":44,"line_end":44,"column_start":18,"column_end":26,"is_primary":true,"text":[{"text":" for _ in (0 .. 3){ --> $DIR/unused_parens_remove_json_suggestion.rs:44:18 | LL | for _ in (0 .. 3){ | ^^^^^^^^ help: remove these parentheses "} -{"message":"unnecessary parentheses around `for` head expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":944,"byte_end":952,"line_start":49,"line_end":49,"column_start":14,"column_end":22,"is_primary":true,"text":[{"text":" for _ in (0 .. 3) { +{"message":"unnecessary parentheses around `for` head expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":1088,"byte_end":1096,"line_start":49,"line_end":49,"column_start":14,"column_end":22,"is_primary":true,"text":[{"text":" for _ in (0 .. 3) { --> $DIR/unused_parens_remove_json_suggestion.rs:49:14 | LL | for _ in (0 .. 3) { | ^^^^^^^^ help: remove these parentheses "} -{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":979,"byte_end":994,"line_start":50,"line_end":50,"column_start":15,"column_end":30,"is_primary":true,"text":[{"text":" while (true && false) { +{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":1147,"byte_end":1162,"line_start":50,"line_end":50,"column_start":15,"column_end":30,"is_primary":true,"text":[{"text":" while (true && false) { --> $DIR/unused_parens_remove_json_suggestion.rs:50:15 | LL | while (true && false) { From 1c85b45117ad2cb7979f8f6580be965227f9241f Mon Sep 17 00:00:00 2001 From: BO41 Date: Fri, 18 Oct 2019 16:55:08 +0000 Subject: [PATCH 09/29] Apply suggested wording to better describe the situation --- CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index caf003d183aff..add4338771e45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -130,8 +130,10 @@ Also, please make sure that fixup commits are squashed into other related commits with meaningful commit messages. GitHub allows [closing issues using keywords][closing-keywords]. This feature -should be used to keep the issue tracker tidy. But in pull requests only. Please -do not add this to your commit message. +should be used to keep the issue tracker tidy. However, it is generally preferred +to put the "closes #123" text in the PR description rather than the issue commit; +particularly during rebasing, citing the issue number in the commit can "spam" +the issue in question. [closing-keywords]: https://help.github.com/en/articles/closing-issues-using-keywords From 7e17ea37b72efd42153604a28977a8482ceef6f8 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Sat, 19 Oct 2019 16:02:21 +0200 Subject: [PATCH 10/29] Fix test paths --- .../coherence/impl[t]-foreign-for-(local, t).rs | 17 ----------------- .../impl[t]-foreign-for-(local, t).stderr | 12 ------------ 2 files changed, 29 deletions(-) delete mode 100644 src/test/ui/coherence/impl[t]-foreign-for-(local, t).rs delete mode 100644 src/test/ui/coherence/impl[t]-foreign-for-(local, t).stderr diff --git a/src/test/ui/coherence/impl[t]-foreign-for-(local, t).rs b/src/test/ui/coherence/impl[t]-foreign-for-(local, t).rs deleted file mode 100644 index 850b6f85d0ed7..0000000000000 --- a/src/test/ui/coherence/impl[t]-foreign-for-(local, t).rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(re_rebalance_coherence)] - -// compile-flags:--crate-name=test -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::*; -use std::rc::Rc; - -struct Local; - -impl Remote for (Local, T) { - //~^ ERROR only traits defined in the current crate - // | can be implemented for arbitrary types [E0117] -} - -fn main() {} diff --git a/src/test/ui/coherence/impl[t]-foreign-for-(local, t).stderr b/src/test/ui/coherence/impl[t]-foreign-for-(local, t).stderr deleted file mode 100644 index ff0b9d6d0da9a..0000000000000 --- a/src/test/ui/coherence/impl[t]-foreign-for-(local, t).stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/impl[t]-foreign-for-(local, t).rs:12:1 - | -LL | impl Remote for (Local, T) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference only types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0117`. From 1e2b711d308be714e6211c125b1a33ac1247f866 Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Sun, 20 Oct 2019 06:31:27 +0000 Subject: [PATCH 11/29] fix WASI sleep impl --- src/libstd/sys/wasi/thread.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libstd/sys/wasi/thread.rs b/src/libstd/sys/wasi/thread.rs index 28a504f197974..6ce41420284e5 100644 --- a/src/libstd/sys/wasi/thread.rs +++ b/src/libstd/sys/wasi/thread.rs @@ -31,10 +31,10 @@ impl Thread { let nanos = dur.as_nanos(); assert!(nanos <= u64::max_value() as u128); - const CLOCK_ID: wasi::Userdata = 0x0123_45678; + const USERDATA: wasi::Userdata = 0x0123_45678; let clock = wasi::raw::__wasi_subscription_u_clock_t { - identifier: CLOCK_ID, + identifier: 0, clock_id: wasi::CLOCK_MONOTONIC, timeout: nanos as u64, precision: 0, @@ -42,7 +42,7 @@ impl Thread { }; let in_ = [wasi::Subscription { - userdata: 0, + userdata: USERDATA, type_: wasi::EVENTTYPE_CLOCK, u: wasi::raw::__wasi_subscription_u { clock: clock }, }]; @@ -53,7 +53,7 @@ impl Thread { }; match (res, event) { (Ok(1), wasi::Event { - userdata: CLOCK_ID, + userdata: USERDATA, error: 0, type_: wasi::EVENTTYPE_CLOCK, .. From 429f91c9e68d6c15f7a6cedb3c8e9e300fa71da1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 19 Oct 2019 11:21:52 +0200 Subject: [PATCH 12/29] Add long error explanation for E0588 --- src/librustc_typeck/error_codes.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs index ef08e8d4f0b7a..892919cbf2073 100644 --- a/src/librustc_typeck/error_codes.rs +++ b/src/librustc_typeck/error_codes.rs @@ -3891,6 +3891,33 @@ details. [issue #33685]: https://github.com/rust-lang/rust/issues/33685 "##, +E0588: r##" +A type with `packed` representation hint has a field with `align` +representation hint. + +Erroneous code example: + +```compile_fail,E0588 +#[repr(align(16))] +struct Aligned(i32); + +#[repr(packed)] // error! +struct Packed(Aligned); +``` + +Just like you can't have both `align` and `packed` representation hints on a +same type, a `packed` type can't contain another type with the `align` +representation hint. However, you can do the opposite: + +``` +#[repr(packed)] +struct Packed(i32); + +#[repr(align(16))] // ok! +struct Aligned(Packed); +``` +"##, + E0592: r##" This error occurs when you defined methods or associated functions with same name. @@ -5043,7 +5070,6 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC. // E0564, // only named lifetimes are allowed in `impl Trait`, // but `{}` was found in the type `{}` E0587, // type has conflicting packed and align representation hints - E0588, // packed type cannot transitively contain a `[repr(align)]` type // E0611, // merged into E0616 // E0612, // merged into E0609 // E0613, // Removed (merged with E0609) From 2541d49601ad4fd311d28d9ae7a7ce947879d839 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 19 Oct 2019 11:22:17 +0200 Subject: [PATCH 13/29] Update ui tests --- src/test/ui/repr/repr-packed-contains-align.stderr | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/ui/repr/repr-packed-contains-align.stderr b/src/test/ui/repr/repr-packed-contains-align.stderr index 219516d8abc48..df001d6b5f2a4 100644 --- a/src/test/ui/repr/repr-packed-contains-align.stderr +++ b/src/test/ui/repr/repr-packed-contains-align.stderr @@ -56,3 +56,4 @@ LL | | } error: aborting due to 8 previous errors +For more information about this error, try `rustc --explain E0588`. From 87744841c81377b1f195ff171fb23c9ae3d40303 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 21 Oct 2019 11:36:52 +0200 Subject: [PATCH 14/29] Add option to disable keyboard shortcuts in docs --- src/librustdoc/html/render.rs | 1 + src/librustdoc/html/static/main.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 72a72e892814a..414c3137376a9 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1241,6 +1241,7 @@ fn settings(root_path: &str, suffix: &str) -> String { ("go-to-only-result", "Directly go to item in search if there is only one result", false), ("line-numbers", "Show line numbers on code examples", false), + ("disable-shortcuts", "Disable keyboard shortcuts", false), ]; format!( "

\ diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 17a940cc4c9f8..f0104c9156ded 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -79,6 +79,7 @@ function getSearchElement() { "derive", "traitalias"]; + var disableShortcuts = getCurrentValue("rustdoc-disable-shortcuts") !== "true"; var search_input = getSearchInput(); // On the search screen, so you remain on the last tab you opened. @@ -294,7 +295,7 @@ function getSearchElement() { function handleShortcut(ev) { // Don't interfere with browser shortcuts - if (ev.ctrlKey || ev.altKey || ev.metaKey) { + if (ev.ctrlKey || ev.altKey || ev.metaKey || disableShortcuts === true) { return; } From cde60e82a079f0d900b35d5f41101111bbe56d7b Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 22 Oct 2019 08:48:01 +0900 Subject: [PATCH 15/29] Add long error explanation for E0728 --- src/librustc/error_codes.rs | 73 ++++++++++++++++++- .../incorrect-syntax-suggestions.stderr | 3 +- .../ui/async-await/issues/issue-51719.stderr | 1 + .../ui/async-await/issues/issue-51751.stderr | 1 + .../async-await/issues/issue-62009-1.stderr | 3 +- .../async-await/issues/issue-62009-2.stderr | 1 + .../issues/non-async-enclosing-span.stderr | 1 + 7 files changed, 78 insertions(+), 5 deletions(-) diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index 3d501cacf6f4c..bc66beab86262 100644 --- a/src/librustc/error_codes.rs +++ b/src/librustc/error_codes.rs @@ -2045,8 +2045,8 @@ so that a generator can then be constructed: async fn bar() -> () {} async fn foo() { - bar::().await; - // ^^^^^^^^ specify type explicitly + bar::().await; + // ^^^^^^^^ specify type explicitly } ``` "##, @@ -2126,6 +2126,74 @@ static X: u32 = 42; ``` "##, +E0728: r##" +`await` has been used outside `async` function or block. + +Erroneous code examples: + +```edition2018,compile_fail,E0728 +# use std::pin::Pin; +# use std::future::Future; +# use std::task::{Context, Poll}; + +# struct WakeOnceThenComplete(bool); + +# fn wake_and_yield_once() -> WakeOnceThenComplete { +# WakeOnceThenComplete(false) +# } + +# impl Future for WakeOnceThenComplete { +# type Output = (); +# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { +# if self.0 { +# Poll::Ready(()) +# } else { +# cx.waker().wake_by_ref(); +# self.0 = true; +# Poll::Pending +# } +# } +# } + +fn foo() { + wake_and_yield_once().await // `await` is used outside `async` context +} +``` + +`await` is used to suspend the current computation until the given +future is ready to produce a value. So it is legal only within +an async context, like an `async fn` or an `async` block. + +```edition2018 +# use std::pin::Pin; +# use std::future::Future; +# use std::task::{Context, Poll}; + +# struct WakeOnceThenComplete(bool); + +# fn wake_and_yield_once() -> WakeOnceThenComplete { +# WakeOnceThenComplete(false) +# } + +# impl Future for WakeOnceThenComplete { +# type Output = (); +# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { +# if self.0 { +# Poll::Ready(()) +# } else { +# cx.waker().wake_by_ref(); +# self.0 = true; +# Poll::Pending +# } +# } +# } + +async fn foo() { + wake_and_yield_once().await // `await` is used within `async` context +} +``` +"##, + E0734: r##" A stability attribute has been used outside of the standard library. @@ -2218,6 +2286,5 @@ See [RFC 2091] for details on this and other limitations. // E0702, // replaced with a generic attribute input check E0726, // non-explicit (not `'_`) elided lifetime in unsupported position E0727, // `async` generators are not yet supported - E0728, // `await` must be in an `async` function or block E0739, // invalid track_caller application/syntax } diff --git a/src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr b/src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr index 7caa9f26bc2f8..4b5e2d59e38c9 100644 --- a/src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr +++ b/src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr @@ -244,4 +244,5 @@ LL | let _ = await bar()?; error: aborting due to 35 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0728. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/async-await/issues/issue-51719.stderr b/src/test/ui/async-await/issues/issue-51719.stderr index 6c3c8889da7ce..5b9adb253d968 100644 --- a/src/test/ui/async-await/issues/issue-51719.stderr +++ b/src/test/ui/async-await/issues/issue-51719.stderr @@ -8,3 +8,4 @@ LL | let _gen = || foo().await; error: aborting due to previous error +For more information about this error, try `rustc --explain E0728`. diff --git a/src/test/ui/async-await/issues/issue-51751.stderr b/src/test/ui/async-await/issues/issue-51751.stderr index e50c78534f852..f120bd119c540 100644 --- a/src/test/ui/async-await/issues/issue-51751.stderr +++ b/src/test/ui/async-await/issues/issue-51751.stderr @@ -9,3 +9,4 @@ LL | let finished = result.await; error: aborting due to previous error +For more information about this error, try `rustc --explain E0728`. diff --git a/src/test/ui/async-await/issues/issue-62009-1.stderr b/src/test/ui/async-await/issues/issue-62009-1.stderr index f63eaa4c48a97..538430290d299 100644 --- a/src/test/ui/async-await/issues/issue-62009-1.stderr +++ b/src/test/ui/async-await/issues/issue-62009-1.stderr @@ -40,4 +40,5 @@ LL | F: Future error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0728. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/async-await/issues/issue-62009-2.stderr b/src/test/ui/async-await/issues/issue-62009-2.stderr index 79b6803263eec..47b74b5574fea 100644 --- a/src/test/ui/async-await/issues/issue-62009-2.stderr +++ b/src/test/ui/async-await/issues/issue-62009-2.stderr @@ -8,3 +8,4 @@ LL | (async || 2333)().await; error: aborting due to previous error +For more information about this error, try `rustc --explain E0728`. diff --git a/src/test/ui/async-await/issues/non-async-enclosing-span.stderr b/src/test/ui/async-await/issues/non-async-enclosing-span.stderr index 49ebf414c550b..f826a86f08985 100644 --- a/src/test/ui/async-await/issues/non-async-enclosing-span.stderr +++ b/src/test/ui/async-await/issues/non-async-enclosing-span.stderr @@ -9,3 +9,4 @@ LL | let y = do_the_thing().await; error: aborting due to previous error +For more information about this error, try `rustc --explain E0728`. From 4fcc784c9ad6748ab9a5754e75c38281d4e7a249 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 22 Oct 2019 09:00:01 +0900 Subject: [PATCH 16/29] Apply suggestions --- src/librustc/error_codes.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index bc66beab86262..4ee3445235ee9 100644 --- a/src/librustc/error_codes.rs +++ b/src/librustc/error_codes.rs @@ -2135,13 +2135,13 @@ Erroneous code examples: # use std::pin::Pin; # use std::future::Future; # use std::task::{Context, Poll}; - +# # struct WakeOnceThenComplete(bool); - +# # fn wake_and_yield_once() -> WakeOnceThenComplete { # WakeOnceThenComplete(false) # } - +# # impl Future for WakeOnceThenComplete { # type Output = (); # fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { @@ -2154,7 +2154,7 @@ Erroneous code examples: # } # } # } - +# fn foo() { wake_and_yield_once().await // `await` is used outside `async` context } @@ -2168,13 +2168,13 @@ an async context, like an `async fn` or an `async` block. # use std::pin::Pin; # use std::future::Future; # use std::task::{Context, Poll}; - +# # struct WakeOnceThenComplete(bool); - +# # fn wake_and_yield_once() -> WakeOnceThenComplete { # WakeOnceThenComplete(false) # } - +# # impl Future for WakeOnceThenComplete { # type Output = (); # fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { @@ -2187,9 +2187,16 @@ an async context, like an `async fn` or an `async` block. # } # } # } - +# async fn foo() { - wake_and_yield_once().await // `await` is used within `async` context + wake_and_yield_once().await // `await` is used within `async` function +} + +fn bar(x: u8) -> impl Future { + async move { + wake_and_yield_once().await; // `await` is used within `async` block + x + } } ``` "##, From 3f1af9056d8b2bf7b90a657503cd03f8c0c2b538 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 21 Oct 2019 17:29:40 -0700 Subject: [PATCH 17/29] Code cleanups following up on #65576. This makes a few code cleanups to follow up on the review comments in https://github.com/rust-lang/rust/pull/65576. --- src/librustc_codegen_ssa/base.rs | 37 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index f4f3dd4d2d295..e8ffe868231a6 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -406,6 +406,8 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &' rust_main_def_id: DefId, use_start_lang_item: bool, ) { + // The entry function is either `int main(void)` or `int main(int argc, char **argv)`, + // depending on whether the target needs `argc` and `argv` to be passed in. let llfty = if cx.sess().target.target.options.main_needs_argc_argv { cx.type_func(&[cx.type_int(), cx.type_ptr_to(cx.type_i8p())], cx.type_int()) } else { @@ -440,19 +442,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &' bx.insert_reference_to_gdb_debug_scripts_section_global(); - let (arg_argc, arg_argv) = if cx.sess().target.target.options.main_needs_argc_argv { - // Params from native main() used as args for rust start function - let param_argc = bx.get_param(0); - let param_argv = bx.get_param(1); - let arg_argc = bx.intcast(param_argc, cx.type_isize(), true); - let arg_argv = param_argv; - (arg_argc, arg_argv) - } else { - // The Rust start function doesn't need argc and argv, so just pass zeros. - let arg_argc = bx.const_int(cx.type_int(), 0); - let arg_argv = bx.const_null(cx.type_ptr_to(cx.type_i8p())); - (arg_argc, arg_argv) - }; + let (arg_argc, arg_argv) = get_argc_argv(cx, &mut bx); let (start_fn, args) = if use_start_lang_item { let start_def_id = cx.tcx().require_lang_item(StartFnLangItem, None); @@ -477,6 +467,27 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &' } } +/// Obtain the `argc` and `argv` values to pass to the rust start function. +fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( + cx: &'a Bx::CodegenCx, + bx: &mut Bx +) -> (Bx::Value, Bx::Value) +{ + if cx.sess().target.target.options.main_needs_argc_argv { + // Params from native `main()` used as args for rust start function + let param_argc = bx.get_param(0); + let param_argv = bx.get_param(1); + let arg_argc = bx.intcast(param_argc, cx.type_isize(), true); + let arg_argv = param_argv; + (arg_argc, arg_argv) + } else { + // The Rust start function doesn't need `argc` and `argv`, so just pass zeros. + let arg_argc = bx.const_int(cx.type_int(), 0); + let arg_argv = bx.const_null(cx.type_ptr_to(cx.type_i8p())); + (arg_argc, arg_argv) + } +} + pub const CODEGEN_WORKER_ID: usize = ::std::usize::MAX; pub fn codegen_crate( From 40f92b3b0595984f40aafd70ec4a5b9a3bdde47a Mon Sep 17 00:00:00 2001 From: yjhmelody <465402634@qq.com> Date: Tue, 22 Oct 2019 12:25:14 +0800 Subject: [PATCH 18/29] refactor maybe_append --- src/libsyntax/parse/parser.rs | 7 ------- src/libsyntax/parse/parser/item.rs | 10 ++++++++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9cb410a8ae318..d4d2f42446bec 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -86,13 +86,6 @@ macro_rules! maybe_recover_from_interpolated_ty_qpath { } } -fn maybe_append(mut lhs: Vec, mut rhs: Option>) -> Vec { - if let Some(ref mut rhs) = rhs { - lhs.append(rhs); - } - lhs -} - #[derive(Debug, Clone, Copy, PartialEq)] enum PrevTokenKind { DocComment, diff --git a/src/libsyntax/parse/parser/item.rs b/src/libsyntax/parse/parser/item.rs index 0acfd1450d819..73bd80e2a21f7 100644 --- a/src/libsyntax/parse/parser/item.rs +++ b/src/libsyntax/parse/parser/item.rs @@ -10,7 +10,6 @@ use crate::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, use crate::ast::{Ty, TyKind, Generics, GenericBounds, TraitRef, EnumDef, VariantData, StructField}; use crate::ast::{Mac, MacDelimiter, Block, BindingMode, FnDecl, MethodSig, SelfKind, Param}; use crate::parse::token; -use crate::parse::parser::maybe_append; use crate::tokenstream::{TokenTree, TokenStream}; use crate::symbol::{kw, sym}; use crate::source_map::{self, respan, Span}; @@ -416,10 +415,17 @@ impl<'a> Parser<'a> { ) -> PResult<'a, Option>> { let (ident, item, extra_attrs) = info; let span = lo.to(self.prev_span); - let attrs = maybe_append(attrs, extra_attrs); + let attrs = Self::maybe_append(attrs, extra_attrs); Ok(Some(self.mk_item(span, ident, item, vis, attrs))) } + fn maybe_append(mut lhs: Vec, mut rhs: Option>) -> Vec { + if let Some(ref mut rhs) = rhs { + lhs.append(rhs); + } + lhs + } + /// This is the fall-through for parsing items. fn parse_macro_use_or_failure( &mut self, From a239c8dfb29c20f29fc3b30959f654d41fb0dd7f Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 22 Oct 2019 17:00:47 +0900 Subject: [PATCH 19/29] Add test for issue-41366 --- src/test/ui/closures/issue-41366.rs | 13 +++++++++++++ src/test/ui/closures/issue-41366.stderr | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/test/ui/closures/issue-41366.rs create mode 100644 src/test/ui/closures/issue-41366.stderr diff --git a/src/test/ui/closures/issue-41366.rs b/src/test/ui/closures/issue-41366.rs new file mode 100644 index 0000000000000..5cae0e76d1acb --- /dev/null +++ b/src/test/ui/closures/issue-41366.rs @@ -0,0 +1,13 @@ +trait T<'x> { + type V; +} + +impl<'g> T<'g> for u32 { + type V = u16; +} + +fn main() { + (&|_|()) as &dyn for<'x> Fn(>::V); + //~^ ERROR: type mismatch in closure arguments + //~| ERROR: type mismatch resolving +} diff --git a/src/test/ui/closures/issue-41366.stderr b/src/test/ui/closures/issue-41366.stderr new file mode 100644 index 0000000000000..91d26efbc4f35 --- /dev/null +++ b/src/test/ui/closures/issue-41366.stderr @@ -0,0 +1,22 @@ +error[E0631]: type mismatch in closure arguments + --> $DIR/issue-41366.rs:10:5 + | +LL | (&|_|()) as &dyn for<'x> Fn(>::V); + | ^^-----^ + | | | + | | found signature of `fn(_) -> _` + | expected signature of `for<'x> fn(>::V) -> _` + | + = note: required for the cast to the object type `dyn for<'x> std::ops::Fn(>::V)` + +error[E0271]: type mismatch resolving `for<'x> <[closure@$DIR/issue-41366.rs:10:7: 10:12] as std::ops::FnOnce<(>::V,)>>::Output == ()` + --> $DIR/issue-41366.rs:10:5 + | +LL | (&|_|()) as &dyn for<'x> Fn(>::V); + | ^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime + | + = note: required for the cast to the object type `dyn for<'x> std::ops::Fn(>::V)` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0271`. From dd0f98bc3ebc08cd0bcff7e682b9aff9038921cd Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 22 Oct 2019 17:01:06 +0900 Subject: [PATCH 20/29] Add test for issue-51431 --- src/test/ui/asm/issue-51431.rs | 10 ++++++++++ src/test/ui/asm/issue-51431.stderr | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/test/ui/asm/issue-51431.rs create mode 100644 src/test/ui/asm/issue-51431.stderr diff --git a/src/test/ui/asm/issue-51431.rs b/src/test/ui/asm/issue-51431.rs new file mode 100644 index 0000000000000..d29c31fafc286 --- /dev/null +++ b/src/test/ui/asm/issue-51431.rs @@ -0,0 +1,10 @@ +// ignore-emscripten no asm! support + +#![feature(asm)] + +fn main() { + unsafe { + asm! {"mov $0,$1"::"0"("bx"),"1"(0x00)} + //~^ ERROR: invalid value for constraint in inline assembly + } +} diff --git a/src/test/ui/asm/issue-51431.stderr b/src/test/ui/asm/issue-51431.stderr new file mode 100644 index 0000000000000..132eea126d642 --- /dev/null +++ b/src/test/ui/asm/issue-51431.stderr @@ -0,0 +1,8 @@ +error[E0669]: invalid value for constraint in inline assembly + --> $DIR/issue-51431.rs:7:32 + | +LL | asm! {"mov $0,$1"::"0"("bx"),"1"(0x00)} + | ^^^^ + +error: aborting due to previous error + From 93fab980e3b6e02deeecf5168cd0f3745c698660 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 22 Oct 2019 17:01:32 +0900 Subject: [PATCH 21/29] Add test for issue-52437 --- src/test/ui/closures/issue-52437.rs | 5 +++++ src/test/ui/closures/issue-52437.stderr | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/test/ui/closures/issue-52437.rs create mode 100644 src/test/ui/closures/issue-52437.stderr diff --git a/src/test/ui/closures/issue-52437.rs b/src/test/ui/closures/issue-52437.rs new file mode 100644 index 0000000000000..6ac5380a5aa23 --- /dev/null +++ b/src/test/ui/closures/issue-52437.rs @@ -0,0 +1,5 @@ +fn main() { + [(); &(&'static: loop { |x| {}; }) as *const _ as usize] + //~^ ERROR: invalid label name `'static` + //~| ERROR: type annotations needed +} diff --git a/src/test/ui/closures/issue-52437.stderr b/src/test/ui/closures/issue-52437.stderr new file mode 100644 index 0000000000000..e76f942e9ba57 --- /dev/null +++ b/src/test/ui/closures/issue-52437.stderr @@ -0,0 +1,15 @@ +error: invalid label name `'static` + --> $DIR/issue-52437.rs:2:13 + | +LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize] + | ^^^^^^^ + +error[E0282]: type annotations needed + --> $DIR/issue-52437.rs:2:30 + | +LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize] + | ^ consider giving this closure parameter a type + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0282`. From 768965a2a65277a59bf6fb8d37ee5fbcfa57dc8c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 22 Oct 2019 10:15:56 +0200 Subject: [PATCH 22/29] bring back some Debug instances for Miri --- src/librustc_mir/interpret/eval_context.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 2ab7c41bb787e..0ff350f0bab24 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -91,7 +91,7 @@ pub struct Frame<'mir, 'tcx, Tag=(), Extra=()> { pub extra: Extra, } -#[derive(Clone, Eq, PartialEq)] +#[derive(Clone, Eq, PartialEq, Debug)] pub enum StackPopCleanup { /// Jump to the next block in the caller, or cause UB if None (that's a function /// that may never return). Also store layout of return place so @@ -113,7 +113,7 @@ pub struct LocalState<'tcx, Tag=(), Id=AllocId> { } /// Current value of a local variable -#[derive(Clone, PartialEq, Eq)] +#[derive(Clone, PartialEq, Eq, Debug)] pub enum LocalValue { /// This local is not currently alive, and cannot be used at all. Dead, From fc5b48514ef6cc74a81686e71b7efe3659fcadb5 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 22 Oct 2019 10:18:38 +0200 Subject: [PATCH 23/29] add comments --- src/librustc_mir/interpret/eval_context.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 0ff350f0bab24..d929e958f05d0 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -91,7 +91,7 @@ pub struct Frame<'mir, 'tcx, Tag=(), Extra=()> { pub extra: Extra, } -#[derive(Clone, Eq, PartialEq, Debug)] +#[derive(Clone, Eq, PartialEq, Debug)] // Miri debug-prints these pub enum StackPopCleanup { /// Jump to the next block in the caller, or cause UB if None (that's a function /// that may never return). Also store layout of return place so @@ -113,7 +113,7 @@ pub struct LocalState<'tcx, Tag=(), Id=AllocId> { } /// Current value of a local variable -#[derive(Clone, PartialEq, Eq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] // Miri debug-prints these pub enum LocalValue { /// This local is not currently alive, and cannot be used at all. Dead, From 7a85c430fb978717ee1433cf5bee756f40544e74 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 22 Oct 2019 17:01:49 +0900 Subject: [PATCH 24/29] Add test for issue-63496 --- src/test/ui/associated-const/issue-63496.rs | 9 ++++++++ .../ui/associated-const/issue-63496.stderr | 21 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/test/ui/associated-const/issue-63496.rs create mode 100644 src/test/ui/associated-const/issue-63496.stderr diff --git a/src/test/ui/associated-const/issue-63496.rs b/src/test/ui/associated-const/issue-63496.rs new file mode 100644 index 0000000000000..311c48b5e48c5 --- /dev/null +++ b/src/test/ui/associated-const/issue-63496.rs @@ -0,0 +1,9 @@ +trait A { + const C: usize; + + fn f() -> ([u8; A::C], [u8; A::C]); + //~^ ERROR: type annotations needed: cannot resolve + //~| ERROR: type annotations needed: cannot resolve +} + +fn main() {} diff --git a/src/test/ui/associated-const/issue-63496.stderr b/src/test/ui/associated-const/issue-63496.stderr new file mode 100644 index 0000000000000..70bb12de1fb72 --- /dev/null +++ b/src/test/ui/associated-const/issue-63496.stderr @@ -0,0 +1,21 @@ +error[E0283]: type annotations needed: cannot resolve `_: A` + --> $DIR/issue-63496.rs:4:21 + | +LL | const C: usize; + | --------------- required by `A::C` +LL | +LL | fn f() -> ([u8; A::C], [u8; A::C]); + | ^^^^ + +error[E0283]: type annotations needed: cannot resolve `_: A` + --> $DIR/issue-63496.rs:4:33 + | +LL | const C: usize; + | --------------- required by `A::C` +LL | +LL | fn f() -> ([u8; A::C], [u8; A::C]); + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0283`. From 07f2f054ec5395536a0daddcb442c4a135fd8927 Mon Sep 17 00:00:00 2001 From: Dylan DPC Date: Tue, 22 Oct 2019 12:07:07 +0200 Subject: [PATCH 25/29] Update error_codes.rs --- src/librustc_typeck/error_codes.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs index 892919cbf2073..9e32356365344 100644 --- a/src/librustc_typeck/error_codes.rs +++ b/src/librustc_typeck/error_codes.rs @@ -194,7 +194,7 @@ a guard. ```compile_fail,E0029 let string = "salutations !"; -// The ordering relation for strings can't be evaluated at compile time, +// The ordering relation for strings cannot be evaluated at compile time, // so this doesn't work: match string { "hello" ..= "world" => {} @@ -348,7 +348,7 @@ fn main() { "##, E0044: r##" -You can't use type or const parameters on foreign items. +You cannot use type or const parameters on foreign items. Example of erroneous code: ```compile_fail,E0044 @@ -788,7 +788,7 @@ fn some_other_func() {} fn some_function() { SOME_CONST = 14; // error : a constant value cannot be changed! 1 = 3; // error : 1 isn't a valid place! - some_other_func() = 4; // error : we can't assign value to a function! + some_other_func() = 4; // error : we cannot assign value to a function! SomeStruct.x = 12; // error : SomeStruct a structure name but it is used // like a variable! } @@ -3905,8 +3905,8 @@ struct Aligned(i32); struct Packed(Aligned); ``` -Just like you can't have both `align` and `packed` representation hints on a -same type, a `packed` type can't contain another type with the `align` +Just like you cannot have both `align` and `packed` representation hints on a +same type, a `packed` type cannot contain another type with the `align` representation hint. However, you can do the opposite: ``` @@ -4326,7 +4326,7 @@ extern { unsafe { printf(::std::ptr::null(), 0f32); - // error: can't pass an `f32` to variadic function, cast to `c_double` + // error: cannot pass an `f32` to variadic function, cast to `c_double` } ``` @@ -5023,7 +5023,7 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC. // E0174, // E0182, // merged into E0229 E0183, -// E0187, // can't infer the kind of the closure +// E0187, // cannot infer the kind of the closure // E0188, // can not cast an immutable reference to a mutable pointer // E0189, // deprecated: can only cast a boxed pointer to a boxed object // E0190, // deprecated: can only cast a &-pointer to an &-object From 66a025378025742a2a867287c4683e1209d15f65 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 22 Oct 2019 12:53:46 +0200 Subject: [PATCH 26/29] self-profiling: Remove module names from some event-ids in codegen backend. --- src/librustc_codegen_ssa/back/write.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index 8bc815f2c622e..762b50f1659cc 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -259,7 +259,7 @@ fn generate_lto_work( needs_thin_lto: Vec<(String, B::ThinBuffer)>, import_only_modules: Vec<(SerializedModule, WorkProduct)> ) -> Vec<(WorkItem, u64)> { - let _prof_timer = cgcx.prof.generic_activity("codegen_run_lto"); + let _prof_timer = cgcx.prof.generic_activity("codegen_generate_lto_work"); let (lto_modules, copy_jobs) = if !needs_fat_lto.is_empty() { assert!(needs_thin_lto.is_empty()); @@ -674,11 +674,11 @@ impl WorkItem { } } - pub fn name(&self) -> String { + fn profiling_event_id(&self) -> &'static str { match *self { - WorkItem::Optimize(ref m) => format!("optimize: {}", m.name), - WorkItem::CopyPostLtoArtifacts(ref m) => format!("copy post LTO artifacts: {}", m.name), - WorkItem::LTO(ref m) => format!("lto: {}", m.name()), + WorkItem::Optimize(_) => "codegen_module_optimize", + WorkItem::CopyPostLtoArtifacts(_) => "codegen_copy_artifacts_from_incr_cache", + WorkItem::LTO(_) => "codegen_module_perform_lto", } } } @@ -1587,7 +1587,7 @@ fn spawn_work( // as a diagnostic was already sent off to the main thread - just // surface that there was an error in this worker. bomb.result = { - let _prof_timer = cgcx.prof.generic_activity(&work.name()); + let _prof_timer = cgcx.prof.generic_activity(work.profiling_event_id()); execute_work_item(&cgcx, work).ok() }; }); From a1f65895a071885141061590e24022eacec6e858 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 22 Oct 2019 21:10:51 +0900 Subject: [PATCH 27/29] Add link to async/await --- src/librustc/error_codes.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index 4ee3445235ee9..122ae4a6cf66f 100644 --- a/src/librustc/error_codes.rs +++ b/src/librustc/error_codes.rs @@ -2127,7 +2127,7 @@ static X: u32 = 42; "##, E0728: r##" -`await` has been used outside `async` function or block. +[`await`] has been used outside [`async`] function or block. Erroneous code examples: @@ -2160,9 +2160,9 @@ fn foo() { } ``` -`await` is used to suspend the current computation until the given +[`await`] is used to suspend the current computation until the given future is ready to produce a value. So it is legal only within -an async context, like an `async fn` or an `async` block. +an [`async`] context, like an `async fn` or an `async` block. ```edition2018 # use std::pin::Pin; @@ -2199,6 +2199,9 @@ fn bar(x: u8) -> impl Future { } } ``` + +[`async`]: https://doc.rust-lang.org/std/keyword.async.html +[`await`]: https://doc.rust-lang.org/std/keyword.await.html "##, E0734: r##" From de3fd021f5eef7b3c2fad795920e542798104d1d Mon Sep 17 00:00:00 2001 From: togiberlin Date: Wed, 4 Sep 2019 14:53:47 +0200 Subject: [PATCH 28/29] Target-feature documented as unsafe. rustc book and rustc -C help have been modified. --- src/doc/rustc/src/SUMMARY.md | 1 + src/doc/rustc/src/codegen-options/index.md | 2 ++ src/doc/rustc/src/command-line-arguments.md | 2 +- src/doc/rustc/src/targets/index.md | 6 ++++++ src/doc/rustc/src/targets/known-issues.md | 13 +++++++++++++ src/librustc/session/config.rs | 3 ++- 6 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 src/doc/rustc/src/targets/known-issues.md diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index d5564fd798f39..b603c7b231e68 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -14,6 +14,7 @@ - [Targets](targets/index.md) - [Built-in Targets](targets/built-in.md) - [Custom Targets](targets/custom.md) + - [Known Issues](targets/known-issues.md) - [Profile-guided Optimization](profile-guided-optimization.md) - [Linker-plugin based LTO](linker-plugin-lto.md) - [Contributing to `rustc`](contributing.md) diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index e73fd43f19a51..f5d5f2089d7e7 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -61,6 +61,8 @@ enabling or disabling a feature. To see the valid options and an example of use, run `rustc --print target-features`. +Using this flag is unsafe and might result in [undefined runtime behavior](../targets/known-issues.md). + ## passes This flag can be used to add extra LLVM passes to the compilation. diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md index b2cc65c11fd2c..bdb3c5196585e 100644 --- a/src/doc/rustc/src/command-line-arguments.md +++ b/src/doc/rustc/src/command-line-arguments.md @@ -145,7 +145,7 @@ of print values are: target CPU may be selected with the `-C target-cpu=val` flag. - `target-features` — List of available target features for the current target. Target features may be enabled with the `-C target-feature=val` - flag. + flag. This flag is unsafe. See [known issues](targets/known-issues.md) for more details. - `relocation-models` — List of relocation models. Relocation models may be selected with the `-C relocation-model=val` flag. - `code-models` — List of code models. Code models may be selected with the diff --git a/src/doc/rustc/src/targets/index.md b/src/doc/rustc/src/targets/index.md index 3d63d072befe0..5859df83f645b 100644 --- a/src/doc/rustc/src/targets/index.md +++ b/src/doc/rustc/src/targets/index.md @@ -11,3 +11,9 @@ To compile to a particular target, use the `--target` flag: ```bash $ rustc src/main.rs --target=wasm32-unknown-unknown ``` +## Target Features +`x86`, and `ARMv8` are two popular CPU architectures. Their instruction sets form a common baseline across most CPUs. However, some CPUs extend these with custom instruction sets, e.g. vector (`AVX`), bitwise manipulation (`BMI`) or cryptographic (`AES`). + +Developers, who know on which CPUs their compiled code is going to run can choose to add (or remove) CPU specific instruction sets via the `-C target-feature=val` flag. + +Please note, that this flag is generally considered as unsafe. More details can be found in [this section](known-issues.md). diff --git a/src/doc/rustc/src/targets/known-issues.md b/src/doc/rustc/src/targets/known-issues.md new file mode 100644 index 0000000000000..89fd8ea6d32e9 --- /dev/null +++ b/src/doc/rustc/src/targets/known-issues.md @@ -0,0 +1,13 @@ +# Known Issues +This section informs you about known "gotchas". Keep in mind, that this section is (and always will be) incomplete. For suggestions and amendments, feel free to [contribute](../contributing.md) to this guide. + +## Target Features +Most target-feature problems arise, when mixing code that have the target-feature _enabled_ with code that have it _disabled_. If you want to avoid undefined behavior, it is recommended to build _all code_ (including the standard library and imported crates) with a common set of target-features. + +By default, compiling your code with the `-C target-feature` flag will not recompile the entire standard library and/or imported crates with matching target features. Therefore, target features are generally considered as unsafe. Using `#[target_feature]` on individual functions makes the function unsafe. + +Examples: + +| Target-Feature | Issue | Seen on | Description | Details | +| -------------- | ----- | ------- | ----------- | ------- | +| `+soft-float`
and
`-sse` | Segfaults and ABI mismatches | `x86` and `x86-64` | The `x86` and `x86_64` architecture uses SSE registers (aka `xmm`) for floating point operations. Using software emulated floats ("soft-floats") disables usage of `xmm` registers, but parts of Rust's core libraries (e.g. `std::f32` or `std::f64`) are compiled without soft-floats and expect parameters to be passed in `xmm` registers. This leads to ABI mismatches.

Attempting to compile with disabled SSE causes the same error, too. | [#63466](https://github.com/rust-lang/rust/issues/63466) | diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 2446d4f4788df..33b9ddaa62230 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1149,7 +1149,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options, target_cpu: Option = (None, parse_opt_string, [TRACKED], "select target processor (`rustc --print target-cpus` for details)"), target_feature: String = (String::new(), parse_string, [TRACKED], - "target specific attributes (`rustc --print target-features` for details)"), + "target specific attributes. (`rustc --print target-features` for details). \ + This feature is unsafe."), passes: Vec = (Vec::new(), parse_list, [TRACKED], "a list of extra LLVM passes to run (space separated)"), llvm_args: Vec = (Vec::new(), parse_list, [TRACKED], From 8497f793d57d9d29432f31601068f7face3179c4 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Tue, 22 Oct 2019 20:14:34 +0300 Subject: [PATCH 29/29] Add missing space in librustdoc --- src/librustdoc/doctree.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index 0dc094ae329fb..bbc00147ee14e 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -59,7 +59,7 @@ impl Module<'hir> { fns : Vec::new(), mods : Vec::new(), typedefs : Vec::new(), - opaque_tys : Vec::new(), + opaque_tys : Vec::new(), statics : Vec::new(), constants : Vec::new(), traits : Vec::new(),