From 949f0d9c72e901a001acd9c82bca6339be3b6b0e Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 29 Jun 2018 16:55:26 +0200 Subject: [PATCH 1/8] Fix badly mangled lint message for neg-cmp-op-on-partial-ord --- clippy_lints/src/neg_cmp_op_on_partial_ord.rs | 16 ++++++++-------- tests/ui/booleans.rs | 2 +- tests/ui/neg_cmp_op_on_partial_ord.rs | 4 ++-- tests/ui/neg_cmp_op_on_partial_ord.stderr | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs index 013bab69d798..cae88263111f 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -4,20 +4,20 @@ use rustc::lint::*; use crate::utils::{self, paths, span_lint, in_external_macro}; /// **What it does:** -/// Checks for the usage of negated comparision operators on types which only implement +/// Checks for the usage of negated comparison operators on types which only implement /// `PartialOrd` (e.g. `f64`). /// /// **Why is this bad?** /// These operators make it easy to forget that the underlying types actually allow not only three -/// potential Orderings (Less, Equal, Greater) but also a forth one (Uncomparable). Escpeccially if -/// the operator based comparision result is negated it is easy to miss that fact. +/// potential Orderings (Less, Equal, Greater) but also a forth one (Uncomparable). This is +/// especially easy to miss if the operator based comparison result is negated. /// /// **Known problems:** None. /// /// **Example:** /// /// ```rust -/// use core::cmp::Ordering; +/// use std::cmp::Ordering; /// /// // Bad /// let a = 1.0; @@ -37,7 +37,7 @@ use crate::utils::{self, paths, span_lint, in_external_macro}; declare_clippy_lint! { pub NEG_CMP_OP_ON_PARTIAL_ORD, complexity, - "The use of negated comparision operators on partially orded types may produce confusing code." + "The use of negated comparison operators on partially ordered types may produce confusing code." } pub struct NoNegCompOpForPartialOrd; @@ -83,10 +83,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NoNegCompOpForPartialOrd { cx, NEG_CMP_OP_ON_PARTIAL_ORD, expr.span, - "The use of negated comparision operators on partially orded \ + "The use of negated comparison operators on partially ordered \ types produces code that is hard to read and refactor. Please \ - consider to use the `partial_cmp` instead, to make it clear \ - that the two values could be incomparable." + consider using the `partial_cmp` method instead, to make it \ + clear that the two values could be incomparable." ) } } diff --git a/tests/ui/booleans.rs b/tests/ui/booleans.rs index 9daf15d378cc..fc16c12af28a 100644 --- a/tests/ui/booleans.rs +++ b/tests/ui/booleans.rs @@ -116,7 +116,7 @@ fn warn_for_built_in_methods_with_negation() { } #[allow(neg_cmp_op_on_partial_ord)] -fn dont_warn_for_negated_partial_ord_comparision() { +fn dont_warn_for_negated_partial_ord_comparison() { let a: f64 = unimplemented!(); let b: f64 = unimplemented!(); let _ = !(a < b); diff --git a/tests/ui/neg_cmp_op_on_partial_ord.rs b/tests/ui/neg_cmp_op_on_partial_ord.rs index 483972bb41b3..e739908bc282 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.rs +++ b/tests/ui/neg_cmp_op_on_partial_ord.rs @@ -59,9 +59,9 @@ fn main() { // Issue 2856: False positive on assert!() // - // The macro always negates the result of the given comparision in its + // The macro always negates the result of the given comparison in its // internal check which automatically triggered the lint. As it's an - // external macro there was no chance to do anything about it which lead + // external macro there was no chance to do anything about it which led // to a whitelisting of all external macros. assert!(a_value < another_value); } diff --git a/tests/ui/neg_cmp_op_on_partial_ord.stderr b/tests/ui/neg_cmp_op_on_partial_ord.stderr index 5067ece87050..ccd305611009 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.stderr +++ b/tests/ui/neg_cmp_op_on_partial_ord.stderr @@ -1,4 +1,4 @@ -error: The use of negated comparision operators on partially orded types produces code that is hard to read and refactor. Please consider to use the `partial_cmp` instead, to make it clear that the two values could be incomparable. +error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. --> $DIR/neg_cmp_op_on_partial_ord.rs:17:21 | 17 | let _not_less = !(a_value < another_value); @@ -6,19 +6,19 @@ error: The use of negated comparision operators on partially orded types produce | = note: `-D neg-cmp-op-on-partial-ord` implied by `-D warnings` -error: The use of negated comparision operators on partially orded types produces code that is hard to read and refactor. Please consider to use the `partial_cmp` instead, to make it clear that the two values could be incomparable. +error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. --> $DIR/neg_cmp_op_on_partial_ord.rs:20:30 | 20 | let _not_less_or_equal = !(a_value <= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: The use of negated comparision operators on partially orded types produces code that is hard to read and refactor. Please consider to use the `partial_cmp` instead, to make it clear that the two values could be incomparable. +error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. --> $DIR/neg_cmp_op_on_partial_ord.rs:23:24 | 23 | let _not_greater = !(a_value > another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: The use of negated comparision operators on partially orded types produces code that is hard to read and refactor. Please consider to use the `partial_cmp` instead, to make it clear that the two values could be incomparable. +error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. --> $DIR/neg_cmp_op_on_partial_ord.rs:26:33 | 26 | let _not_greater_or_equal = !(a_value >= another_value); From 26eea10ec170a1cb1ab1db38dbc87d8abc88ac58 Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 21 Jul 2018 18:05:02 +0200 Subject: [PATCH 2/8] Add known problem for redundant_closure lint Documenting https://github.com/rust-lang-nursery/rust-clippy/issues/1439 until it gets fixed. --- clippy_lints/src/eta_reduction.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 7b6623ed29b2..b11bbfcdc2e7 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -15,7 +15,11 @@ pub struct EtaPass; /// **Why is this bad?** Needlessly creating a closure adds code for no benefit /// and gives the optimizer more work. /// -/// **Known problems:** None. +/// **Known problems:** If creating the closure inside the closure has a side- +/// effect then moving the closure creation out will change when that side- +/// effect runs. +/// See https://github.com/rust-lang-nursery/rust-clippy/issues/1439 for more +/// details. /// /// **Example:** /// ```rust From 0961c692fae6164086c9c8e21d9e8de253399d8b Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Mon, 23 Jul 2018 07:29:53 +0200 Subject: [PATCH 3/8] s/wiki/lint list/ --- CHANGELOG.md | 6 +++--- util/update_lints.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34f826527bbe..48585df06031 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -507,7 +507,7 @@ All notable changes to this project will be documented in this file. ## 0.0.74 — 2016-06-07 * Fix bug with `cargo-clippy` JSON parsing * Add the `CLIPPY_DISABLE_DOCS_LINKS` environment variable to deactivate the - “for further information visit *wiki-link*” message. + “for further information visit *lint-link*” message. ## 0.0.73 — 2016-06-05 * Fix false positives in [`useless_let_if_seq`] @@ -612,7 +612,7 @@ All notable changes to this project will be documented in this file. [`AsRef`]: https://doc.rust-lang.org/std/convert/trait.AsRef.html [configuration file]: ./rust-clippy#configuration - + [`absurd_extreme_comparisons`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons [`almost_swapped`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#almost_swapped [`approx_constant`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#approx_constant @@ -894,4 +894,4 @@ All notable changes to this project will be documented in this file. [`zero_prefixed_literal`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#zero_prefixed_literal [`zero_ptr`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#zero_ptr [`zero_width_space`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#zero_width_space - + diff --git a/util/update_lints.py b/util/update_lints.py index 6ee14cfcb125..70d49f940eeb 100755 --- a/util/update_lints.py +++ b/util/update_lints.py @@ -192,8 +192,8 @@ def main(print_only=False, check=False): # update the links in the CHANGELOG changed |= replace_region( 'CHANGELOG.md', - "", - "", + "", + "", lambda: ["[`{0}`]: {1}#{0}\n".format(l[1], docs_link) for l in sorted(all_lints + deprecated_lints, key=lambda l: l[1])], From 2665f1066238e46a91ace101b9010e272fc8dfe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 25 Jul 2018 20:02:52 +0200 Subject: [PATCH 4/8] fix a bunch of typos found by codespell --- clippy_lints/src/excessive_precision.rs | 2 +- clippy_lints/src/loops.rs | 2 +- clippy_lints/src/matches.rs | 2 +- clippy_lints/src/neg_cmp_op_on_partial_ord.rs | 2 +- clippy_lints/src/types.rs | 2 +- clippy_lints/src/utils/sugg.rs | 2 +- tests/ui/checked_unwrap.rs | 4 ++-- tests/ui/for_loop.rs | 2 +- tests/ui/infinite_loop.rs | 8 ++++---- tests/ui/matches.stderr | 6 +++--- util/gh-pages/versions.html | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/clippy_lints/src/excessive_precision.rs b/clippy_lints/src/excessive_precision.rs index 28819077f9bc..2c673fdfe3f7 100644 --- a/clippy_lints/src/excessive_precision.rs +++ b/clippy_lints/src/excessive_precision.rs @@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision { } impl ExcessivePrecision { - // None if nothing to lint, Some(suggestion) if lint neccessary + // None if nothing to lint, Some(suggestion) if lint necessary fn check(&self, sym: Symbol, fty: FloatTy) -> Option { let max = max_digits(fty); let sym_str = sym.as_str(); diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index b95bc01c013d..85a9c13ff35c 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -2217,7 +2217,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarCollectorVisitor<'a, 'tcx> { fn visit_expr(&mut self, ex: &'tcx Expr) { match ex.node { ExprKind::Path(_) => self.insert_def_id(ex), - // If there is any fuction/method call… we just stop analysis + // If there is any function/method call… we just stop analysis ExprKind::Call(..) | ExprKind::MethodCall(..) => self.skip = true, _ => walk_expr(self, ex), diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index c7452f0027e9..6bdcd004134e 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -383,7 +383,7 @@ fn check_wild_err_arm(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm]) { arm.pats[0].span, "Err(_) will match all errors, maybe not a good idea", arm.pats[0].span, - "to remove this warning, match each error seperately \ + "to remove this warning, match each error separately \ or use unreachable macro"); } } diff --git a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs index 02007e2de43c..f53e2cb0cce8 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -11,7 +11,7 @@ use crate::utils::{self, paths, span_lint}; /// /// **Why is this bad?** /// These operators make it easy to forget that the underlying types actually allow not only three -/// potential Orderings (Less, Equal, Greater) but also a forth one (Uncomparable). This is +/// potential Orderings (Less, Equal, Greater) but also a fourth one (Uncomparable). This is /// especially easy to miss if the operator based comparison result is negated. /// /// **Known problems:** None. diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index d016afb4908c..7b3f6f20fc74 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -700,7 +700,7 @@ declare_clippy_lint! { /// **What it does:** Checks for casts of a function pointer to a numeric type not enough to store address. /// -/// **Why is this bad?** Casting a function pointer to not eligable type could truncate the address value. +/// **Why is this bad?** Casting a function pointer to not eligible type could truncate the address value. /// /// **Known problems:** None. /// diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index 91fd5ec874af..11187559bf6a 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -334,7 +334,7 @@ pub fn make_assoc(op: AssocOp, lhs: &Sugg<'_>, rhs: &Sugg<'_>) -> Sugg<'static> Sugg::BinOp(op, sugg.into()) } -/// Convinience wrapper arround `make_assoc` and `AssocOp::from_ast_binop`. +/// Convenience wrapper around `make_assoc` and `AssocOp::from_ast_binop`. pub fn make_binop(op: ast::BinOpKind, lhs: &Sugg<'_>, rhs: &Sugg<'_>) -> Sugg<'static> { make_assoc(AssocOp::from_ast_binop(op), lhs, rhs) } diff --git a/tests/ui/checked_unwrap.rs b/tests/ui/checked_unwrap.rs index c3d4b8de08b3..2b5118fa814e 100644 --- a/tests/ui/checked_unwrap.rs +++ b/tests/ui/checked_unwrap.rs @@ -31,11 +31,11 @@ fn main() { if x.is_ok() { x = Err(()); x.unwrap(); // not unnecessary because of mutation of x - // it will always panic but the lint is not smart enoguh to see this (it only checks if conditions). + // it will always panic but the lint is not smart enough to see this (it only checks if conditions). } else { x = Ok(()); x.unwrap_err(); // not unnecessary because of mutation of x - // it will always panic but the lint is not smart enoguh to see this (it only checks if conditions). + // it will always panic but the lint is not smart enough to see this (it only checks if conditions). } } diff --git a/tests/ui/for_loop.rs b/tests/ui/for_loop.rs index e28a8f1e1788..bc0c3172bf06 100644 --- a/tests/ui/for_loop.rs +++ b/tests/ui/for_loop.rs @@ -389,7 +389,7 @@ fn main() { let m: Rc> = Rc::new(HashMap::new()); for (_, v) in &*m { let _v = v; - // Here the `*` is not actually necesarry, but the test tests that we don't + // Here the `*` is not actually necessary, but the test tests that we don't // suggest // `in *m.values()` as we used to } diff --git a/tests/ui/infinite_loop.rs b/tests/ui/infinite_loop.rs index aa4f8b53f6c7..9e801911602c 100644 --- a/tests/ui/infinite_loop.rs +++ b/tests/ui/infinite_loop.rs @@ -9,7 +9,7 @@ fn foob() -> bool { unimplemented!() } #[allow(many_single_char_names)] fn immutable_condition() { - // Should warn when all vars mentionned are immutable + // Should warn when all vars mentioned are immutable let y = 0; while y < 10 { println!("KO - y is immutable"); @@ -69,11 +69,11 @@ fn unused_var() { while i < 3 { j = 3; - println!("KO - i not mentionned"); + println!("KO - i not mentioned"); } while i < 3 && j > 0 { - println!("KO - i and j not mentionned"); + println!("KO - i and j not mentioned"); } while i < 3 { @@ -84,7 +84,7 @@ fn unused_var() { while i < 3 && j > 0 { i = 5; - println!("OK - i in cond and mentionned"); + println!("OK - i in cond and mentioned"); } } diff --git a/tests/ui/matches.stderr b/tests/ui/matches.stderr index 6554b6d34492..5bfc3271c450 100644 --- a/tests/ui/matches.stderr +++ b/tests/ui/matches.stderr @@ -164,7 +164,7 @@ error: Err(_) will match all errors, maybe not a good idea | ^^^^^^ | = note: `-D match-wild-err-arm` implied by `-D warnings` - = note: to remove this warning, match each error seperately or use unreachable macro + = note: to remove this warning, match each error separately or use unreachable macro error: this `match` has identical arm bodies --> $DIR/matches.rs:131:18 @@ -191,7 +191,7 @@ error: Err(_) will match all errors, maybe not a good idea 138 | Err(_) => {panic!()} | ^^^^^^ | - = note: to remove this warning, match each error seperately or use unreachable macro + = note: to remove this warning, match each error separately or use unreachable macro error: this `match` has identical arm bodies --> $DIR/matches.rs:137:18 @@ -217,7 +217,7 @@ error: Err(_) will match all errors, maybe not a good idea 144 | Err(_) => {panic!();} | ^^^^^^ | - = note: to remove this warning, match each error seperately or use unreachable macro + = note: to remove this warning, match each error separately or use unreachable macro error: this `match` has identical arm bodies --> $DIR/matches.rs:143:18 diff --git a/util/gh-pages/versions.html b/util/gh-pages/versions.html index 310a38736910..5678ebec7220 100644 --- a/util/gh-pages/versions.html +++ b/util/gh-pages/versions.html @@ -14,7 +14,7 @@
From bf3f976a4373eb541cf292f341f03ad2b6e6982a Mon Sep 17 00:00:00 2001 From: Thomas Gideon Date: Wed, 25 Jul 2018 17:31:17 -0400 Subject: [PATCH 5/8] Fix regression in print_literal --- clippy_lints/src/write.rs | 32 +++++++++++++++++--------------- tests/ui/print_literal.rs | 1 + tests/ui/write_literal.rs | 1 + 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index a019e23a3014..0b52981bfa58 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -290,22 +290,24 @@ fn check_tts(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) -> Op idx += 1; }, ExprKind::Assign(lhs, rhs) => { - if let ExprKind::Path(_, p) = &lhs.node { - let mut all_simple = true; - let mut seen = false; - for arg in &args { - match arg.position { - | ArgumentImplicitlyIs(_) - | ArgumentIs(_) - => {}, - ArgumentNamed(name) => if *p == name { - seen = true; - all_simple &= arg.format == SIMPLE; - }, + if let ExprKind::Lit(_) = rhs.node { + if let ExprKind::Path(_, p) = &lhs.node { + let mut all_simple = true; + let mut seen = false; + for arg in &args { + match arg.position { + | ArgumentImplicitlyIs(_) + | ArgumentIs(_) + => {}, + ArgumentNamed(name) => if *p == name { + seen = true; + all_simple &= arg.format == SIMPLE; + }, + } + } + if all_simple && seen { + span_lint(cx, lint, rhs.span, "literal with an empty format string"); } - } - if all_simple && seen { - span_lint(cx, lint, rhs.span, "literal with an empty format string"); } } }, diff --git a/tests/ui/print_literal.rs b/tests/ui/print_literal.rs index 272e1c168d3e..620349bab335 100644 --- a/tests/ui/print_literal.rs +++ b/tests/ui/print_literal.rs @@ -8,6 +8,7 @@ fn main() { println!("Hello"); let world = "world"; println!("Hello {}", world); + println!("Hello {world}", world=world); println!("3 in hex is {:X}", 3); println!("2 + 1 = {:.4}", 3); println!("2 + 1 = {:5.4}", 3); diff --git a/tests/ui/write_literal.rs b/tests/ui/write_literal.rs index b09640a18eba..fe1f83a2790c 100644 --- a/tests/ui/write_literal.rs +++ b/tests/ui/write_literal.rs @@ -11,6 +11,7 @@ fn main() { writeln!(&mut v, "Hello"); let world = "world"; writeln!(&mut v, "Hello {}", world); + writeln!(&mut v, "Hello {world}", world); writeln!(&mut v, "3 in hex is {:X}", 3); writeln!(&mut v, "2 + 1 = {:.4}", 3); writeln!(&mut v, "2 + 1 = {:5.4}", 3); From 457b76cedfd542f05813b4fe51feec93235dd223 Mon Sep 17 00:00:00 2001 From: Thomas Gideon Date: Wed, 25 Jul 2018 17:51:04 -0400 Subject: [PATCH 6/8] Update line numbers --- tests/ui/print_literal.stderr | 28 ++++++++++++++-------------- tests/ui/write_literal.stderr | 28 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/ui/print_literal.stderr b/tests/ui/print_literal.stderr index 39e0387cb5ec..eb0940881e94 100644 --- a/tests/ui/print_literal.stderr +++ b/tests/ui/print_literal.stderr @@ -1,7 +1,7 @@ error: literal with an empty format string --> $DIR/print_literal.rs:23:71 | -23 | println!("{} of {:b} people know binary, the other half doesn't", 1, 2); +24 | println!("{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ | = note: `-D print-literal` implied by `-D warnings` @@ -9,79 +9,79 @@ error: literal with an empty format string error: literal with an empty format string --> $DIR/print_literal.rs:24:24 | -24 | print!("Hello {}", "world"); +25 | print!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:25:36 | -25 | println!("Hello {} {}", world, "world"); +26 | println!("Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:26:26 | -26 | println!("Hello {}", "world"); +27 | println!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:27:30 | -27 | println!("10 / 4 is {}", 2.5); +28 | println!("10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string --> $DIR/print_literal.rs:28:28 | -28 | println!("2 + 1 = {}", 3); +29 | println!("2 + 1 = {}", 3); | ^ error: literal with an empty format string --> $DIR/print_literal.rs:33:25 | -33 | println!("{0} {1}", "hello", "world"); +34 | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:33:34 | -33 | println!("{0} {1}", "hello", "world"); +34 | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:34:25 | -34 | println!("{1} {0}", "hello", "world"); +35 | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:34:34 | -34 | println!("{1} {0}", "hello", "world"); +35 | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:37:33 | -37 | println!("{foo} {bar}", foo="hello", bar="world"); +38 | println!("{foo} {bar}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:37:46 | -37 | println!("{foo} {bar}", foo="hello", bar="world"); +38 | println!("{foo} {bar}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:38:33 | -38 | println!("{bar} {foo}", foo="hello", bar="world"); +39 | println!("{bar} {foo}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:38:46 | -38 | println!("{bar} {foo}", foo="hello", bar="world"); +39 | println!("{bar} {foo}", foo="hello", bar="world"); | ^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/write_literal.stderr b/tests/ui/write_literal.stderr index 70855ef81870..83dd70e4c18e 100644 --- a/tests/ui/write_literal.stderr +++ b/tests/ui/write_literal.stderr @@ -1,7 +1,7 @@ error: literal with an empty format string --> $DIR/write_literal.rs:26:79 | -26 | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); +27 | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ | = note: `-D write-literal` implied by `-D warnings` @@ -9,79 +9,79 @@ error: literal with an empty format string error: literal with an empty format string --> $DIR/write_literal.rs:27:32 | -27 | write!(&mut v, "Hello {}", "world"); +28 | write!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:28:44 | -28 | writeln!(&mut v, "Hello {} {}", world, "world"); +29 | writeln!(&mut v, "Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:29:34 | -29 | writeln!(&mut v, "Hello {}", "world"); +30 | writeln!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:30:38 | -30 | writeln!(&mut v, "10 / 4 is {}", 2.5); +31 | writeln!(&mut v, "10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string --> $DIR/write_literal.rs:31:36 | -31 | writeln!(&mut v, "2 + 1 = {}", 3); +32 | writeln!(&mut v, "2 + 1 = {}", 3); | ^ error: literal with an empty format string --> $DIR/write_literal.rs:36:33 | -36 | writeln!(&mut v, "{0} {1}", "hello", "world"); +37 | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:36:42 | -36 | writeln!(&mut v, "{0} {1}", "hello", "world"); +37 | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:37:33 | -37 | writeln!(&mut v, "{1} {0}", "hello", "world"); +38 | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:37:42 | -37 | writeln!(&mut v, "{1} {0}", "hello", "world"); +38 | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:40:41 | -40 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); +41 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:40:54 | -40 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); +41 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:41:41 | -41 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); +42 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:41:54 | -41 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); +42 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); | ^^^^^^^ error: aborting due to 14 previous errors From 5446e73de6d9294c1a7a398a7508f9c44a388500 Mon Sep 17 00:00:00 2001 From: Thomas Gideon Date: Wed, 25 Jul 2018 18:00:19 -0400 Subject: [PATCH 7/8] And the ones annotating the source file name. --- tests/ui/print_literal.stderr | 46 +++++++++++++++++------------------ tests/ui/write_literal.stderr | 46 +++++++++++++++++------------------ 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/tests/ui/print_literal.stderr b/tests/ui/print_literal.stderr index eb0940881e94..cada26c61423 100644 --- a/tests/ui/print_literal.stderr +++ b/tests/ui/print_literal.stderr @@ -1,5 +1,5 @@ error: literal with an empty format string - --> $DIR/print_literal.rs:23:71 + --> $DIR/print_literal.rs:24:71 | 24 | println!("{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ @@ -7,79 +7,79 @@ error: literal with an empty format string = note: `-D print-literal` implied by `-D warnings` error: literal with an empty format string - --> $DIR/print_literal.rs:24:24 + --> $DIR/print_literal.rs:25:24 | 25 | print!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:25:36 + --> $DIR/print_literal.rs:26:36 | 26 | println!("Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:26:26 + --> $DIR/print_literal.rs:27:26 | 27 | println!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:27:30 + --> $DIR/print_literal.rs:28:30 | 28 | println!("10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:28:28 + --> $DIR/print_literal.rs:29:28 | 29 | println!("2 + 1 = {}", 3); | ^ -error: literal with an empty format string - --> $DIR/print_literal.rs:33:25 - | -34 | println!("{0} {1}", "hello", "world"); - | ^^^^^^^ - -error: literal with an empty format string - --> $DIR/print_literal.rs:33:34 - | -34 | println!("{0} {1}", "hello", "world"); - | ^^^^^^^ - error: literal with an empty format string --> $DIR/print_literal.rs:34:25 | -35 | println!("{1} {0}", "hello", "world"); +34 | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:34:34 | +34 | println!("{0} {1}", "hello", "world"); + | ^^^^^^^ + +error: literal with an empty format string + --> $DIR/print_literal.rs:35:25 + | +35 | println!("{1} {0}", "hello", "world"); + | ^^^^^^^ + +error: literal with an empty format string + --> $DIR/print_literal.rs:35:34 + | 35 | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:37:33 + --> $DIR/print_literal.rs:38:33 | 38 | println!("{foo} {bar}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:37:46 + --> $DIR/print_literal.rs:38:46 | 38 | println!("{foo} {bar}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:38:33 + --> $DIR/print_literal.rs:39:33 | 39 | println!("{bar} {foo}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:38:46 + --> $DIR/print_literal.rs:39:46 | 39 | println!("{bar} {foo}", foo="hello", bar="world"); | ^^^^^^^ diff --git a/tests/ui/write_literal.stderr b/tests/ui/write_literal.stderr index 83dd70e4c18e..d2e8ca94ed80 100644 --- a/tests/ui/write_literal.stderr +++ b/tests/ui/write_literal.stderr @@ -1,5 +1,5 @@ error: literal with an empty format string - --> $DIR/write_literal.rs:26:79 + --> $DIR/write_literal.rs:27:79 | 27 | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ @@ -7,79 +7,79 @@ error: literal with an empty format string = note: `-D write-literal` implied by `-D warnings` error: literal with an empty format string - --> $DIR/write_literal.rs:27:32 + --> $DIR/write_literal.rs:28:32 | 28 | write!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:28:44 + --> $DIR/write_literal.rs:29:44 | 29 | writeln!(&mut v, "Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:29:34 + --> $DIR/write_literal.rs:30:34 | 30 | writeln!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:30:38 + --> $DIR/write_literal.rs:31:38 | 31 | writeln!(&mut v, "10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:31:36 + --> $DIR/write_literal.rs:32:36 | 32 | writeln!(&mut v, "2 + 1 = {}", 3); | ^ -error: literal with an empty format string - --> $DIR/write_literal.rs:36:33 - | -37 | writeln!(&mut v, "{0} {1}", "hello", "world"); - | ^^^^^^^ - -error: literal with an empty format string - --> $DIR/write_literal.rs:36:42 - | -37 | writeln!(&mut v, "{0} {1}", "hello", "world"); - | ^^^^^^^ - error: literal with an empty format string --> $DIR/write_literal.rs:37:33 | -38 | writeln!(&mut v, "{1} {0}", "hello", "world"); +37 | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:37:42 | +37 | writeln!(&mut v, "{0} {1}", "hello", "world"); + | ^^^^^^^ + +error: literal with an empty format string + --> $DIR/write_literal.rs:38:33 + | +38 | writeln!(&mut v, "{1} {0}", "hello", "world"); + | ^^^^^^^ + +error: literal with an empty format string + --> $DIR/write_literal.rs:38:42 + | 38 | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:40:41 + --> $DIR/write_literal.rs:41:41 | 41 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:40:54 + --> $DIR/write_literal.rs:41:54 | 41 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:41:41 + --> $DIR/write_literal.rs:42:41 | 42 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:41:54 + --> $DIR/write_literal.rs:42:54 | 42 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); | ^^^^^^^ From 9b11be72c0fbc830291ab02b94470f7e95e84382 Mon Sep 17 00:00:00 2001 From: Thomas Gideon Date: Wed, 25 Jul 2018 18:14:11 -0400 Subject: [PATCH 8/8] Fix copy-paste error --- tests/ui/write_literal.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/write_literal.rs b/tests/ui/write_literal.rs index fe1f83a2790c..48dfcd0ea3e1 100644 --- a/tests/ui/write_literal.rs +++ b/tests/ui/write_literal.rs @@ -11,7 +11,7 @@ fn main() { writeln!(&mut v, "Hello"); let world = "world"; writeln!(&mut v, "Hello {}", world); - writeln!(&mut v, "Hello {world}", world); + writeln!(&mut v, "Hello {world}", world=world); writeln!(&mut v, "3 in hex is {:X}", 3); writeln!(&mut v, "2 + 1 = {:.4}", 3); writeln!(&mut v, "2 + 1 = {:5.4}", 3);