Skip to content

Commit 962e564

Browse files
committed
Bless tests and fixing warnings
1 parent 54aab38 commit 962e564

24 files changed

+33
-24
lines changed

library/alloc/src/fmt.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//! Some examples of the [`format!`] extension are:
1313
//!
1414
//! ```
15+
//! # #![allow(unused_must_use)]
1516
//! format!("Hello"); // => "Hello"
1617
//! format!("Hello, {}!", "world"); // => "Hello, world!"
1718
//! format!("The number is {}", 1); // => "The number is 1"
@@ -44,7 +45,7 @@
4445
//! the iterator advances. This leads to behavior like this:
4546
//!
4647
//! ```
47-
//! format!("{1} {} {0} {}", 1, 2); // => "2 1 1 2"
48+
//! println!("{1} {} {0} {}", 1, 2); // => "2 1 1 2"
4849
//! ```
4950
//!
5051
//! The internal iterator over the argument has not been advanced by the time
@@ -71,6 +72,7 @@
7172
//! For example, the following [`format!`] expressions all use named argument:
7273
//!
7374
//! ```
75+
//! # #![allow(unused_must_use)]
7476
//! format!("{argument}", argument = "test"); // => "test"
7577
//! format!("{name} {}", 1, name = 2); // => "2 1"
7678
//! format!("{a} {c} {b}", a="a", b='b', c=3); // => "a 3 b"

library/alloc/src/macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ macro_rules! vec {
9595
/// # Examples
9696
///
9797
/// ```
98+
/// # #![allow(unused_must_use)]
9899
/// format!("test");
99100
/// format!("hello {}", "world!");
100101
/// format!("x = {}, y = {y}", 10, y = 30);

library/alloc/src/str.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ impl str {
487487
/// A panic upon overflow:
488488
///
489489
/// ```should_panic
490+
/// # #![allow(unused_must_use)]
490491
/// // this will panic at runtime
491492
/// "0123456789abcdef".repeat(usize::MAX);
492493
/// ```

library/alloc/src/string.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ impl String {
950950
/// # Examples
951951
///
952952
/// ```
953+
/// # #![allow(unused_must_use)]
953954
/// #![feature(try_reserve)]
954955
/// use std::collections::TryReserveError;
955956
///
@@ -988,6 +989,7 @@ impl String {
988989
/// # Examples
989990
///
990991
/// ```
992+
/// # #![allow(unused_must_use)]
991993
/// #![feature(try_reserve)]
992994
/// use std::collections::TryReserveError;
993995
///

library/core/tests/fmt/builders.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ mod debug_map {
446446
}
447447
}
448448

449-
format!("{:?}", Foo);
449+
println!("{:?}", Foo);
450450
}
451451

452452
#[test]
@@ -460,7 +460,7 @@ mod debug_map {
460460
}
461461
}
462462

463-
format!("{:?}", Foo);
463+
println!("{:?}", Foo);
464464
}
465465

466466
#[test]
@@ -474,7 +474,7 @@ mod debug_map {
474474
}
475475
}
476476

477-
format!("{:?}", Foo);
477+
println!("{:?}", Foo);
478478
}
479479
}
480480

library/core/tests/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ fn test_unwrap_panic1() {
139139
#[should_panic]
140140
fn test_unwrap_panic2() {
141141
let x: Option<String> = None;
142-
x.unwrap();
142+
drop(x.unwrap());
143143
}
144144

145145
#[test]

src/librustdoc/formats/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ impl DocFolder for Cache {
472472
});
473473

474474
if pushed {
475-
self.stack.pop().expect("stack already empty");
475+
let _ = self.stack.pop().expect("stack already empty");
476476
}
477477
if parent_pushed {
478478
self.parent_stack.pop().expect("parent stack already empty");

src/test/ui/block-result/consider-removing-last-semi.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub fn f() -> String { //~ ERROR mismatched types
55
"bla".to_string()
66
}
77

8+
#[allow(unused_must_use)]
89
pub fn g() -> String { //~ ERROR mismatched types
910
"this won't work".to_string();
1011
"removeme".to_string()

src/test/ui/block-result/consider-removing-last-semi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub fn f() -> String { //~ ERROR mismatched types
55
"bla".to_string();
66
}
77

8+
#[allow(unused_must_use)]
89
pub fn g() -> String { //~ ERROR mismatched types
910
"this won't work".to_string();
1011
"removeme".to_string();

src/test/ui/block-result/consider-removing-last-semi.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | "bla".to_string();
1010
| - help: consider removing this semicolon
1111

1212
error[E0308]: mismatched types
13-
--> $DIR/consider-removing-last-semi.rs:8:15
13+
--> $DIR/consider-removing-last-semi.rs:9:15
1414
|
1515
LL | pub fn g() -> String {
1616
| - ^^^^^^ expected struct `std::string::String`, found `()`

src/test/ui/deriving/deriving-in-fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ pub fn main() {
66
}
77

88
let f = Foo { foo: 10 };
9-
format!("{:?}", f);
9+
println!("{:?}", f);
1010
}

src/test/ui/issues/issue-2063.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ impl ToStr2 for T {
1414
}
1515

1616
#[allow(dead_code)]
17-
fn new_t(x: T) {
18-
x.my_to_string();
17+
fn new_t(x: T) -> String {
18+
x.my_to_string()
1919
}
2020

2121
fn main() {

src/test/ui/issues/issue-20676.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ use std::fmt;
88

99
fn main() {
1010
let a: &dyn fmt::Debug = &1;
11-
format!("{:?}", a);
11+
println!("{:?}", a);
1212
}

src/test/ui/istr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fn test_stack_assign() {
1111
assert!((s != u));
1212
}
1313

14+
#[allow(unused_must_use)]
1415
fn test_heap_lit() { "a big string".to_string(); }
1516

1617
fn test_heap_assign() {

src/test/ui/nll/issue-61424.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
fn main() {
66
let x; //~ ERROR: variable does not need to be mutable
77
x = String::new();
8-
dbg!(x);
8+
let _ = dbg!(x);
99
}

src/test/ui/nll/issue-61424.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
fn main() {
66
let mut x; //~ ERROR: variable does not need to be mutable
77
x = String::new();
8-
dbg!(x);
8+
let _ = dbg!(x);
99
}

src/test/ui/overloaded/overloaded-deref-count.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn main() {
6464

6565
// Immutable deref used for calling a method taking &self. (The
6666
// typechecker is smarter now about doing this.)
67-
(*n).to_string();
67+
let _ = (*n).to_string();
6868
assert_eq!(n.counts(), (3, 3));
6969

7070
// Mutable deref used for calling a method taking &mut self.

src/tools/clippy/src/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ pub fn main() {
348348
// for example `clippy-driver --rustc --version` will print the rustc version that clippy-driver
349349
// uses
350350
if let Some(pos) = orig_args.iter().position(|arg| arg == "--rustc") {
351-
orig_args.remove(pos);
351+
drop(orig_args.remove(pos));
352352
orig_args[0] = "rustc".to_string();
353353

354354
// if we call "rustc", we need to pass --sysroot here as well
@@ -372,7 +372,7 @@ pub fn main() {
372372

373373
if wrapper_mode {
374374
// we still want to be able to invoke it normally though
375-
orig_args.remove(1);
375+
drop(orig_args.remove(1));
376376
}
377377

378378
if !wrapper_mode && (orig_args.iter().any(|a| a == "--help" || a == "-h") || orig_args.len() == 1) {

src/tools/clippy/tests/ui/format.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22

3-
#![allow(clippy::print_literal, clippy::redundant_clone)]
3+
#![allow(unused_must_use, clippy::print_literal, clippy::redundant_clone)]
44
#![warn(clippy::useless_format)]
55

66
struct Foo(pub String);

src/tools/clippy/tests/ui/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22

3-
#![allow(clippy::print_literal, clippy::redundant_clone)]
3+
#![allow(unused_must_use, clippy::print_literal, clippy::redundant_clone)]
44
#![warn(clippy::useless_format)]
55

66
struct Foo(pub String);

src/tools/clippy/tests/ui/question_mark.fixed

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ impl MoveStruct {
9494
}
9595

9696
fn func() -> Option<i32> {
97-
fn f() -> Option<String> {
98-
Some(String::new())
97+
fn f() -> Option<u32> {
98+
Some(42)
9999
}
100100

101101
f()?;

src/tools/clippy/tests/ui/question_mark.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ impl MoveStruct {
122122
}
123123

124124
fn func() -> Option<i32> {
125-
fn f() -> Option<String> {
126-
Some(String::new())
125+
fn f() -> Option<u32> {
126+
Some(42)
127127
}
128128

129129
if f().is_none() {

src/tools/clippy/tests/ui/redundant_clone.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn main() {
4848

4949
with_branch(Alpha, true);
5050
cannot_double_move(Alpha);
51-
cannot_move_from_type_with_drop();
51+
drop(cannot_move_from_type_with_drop());
5252
borrower_propagation();
5353
not_consumed();
5454
issue_5405();

src/tools/clippy/tests/ui/redundant_clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn main() {
4848

4949
with_branch(Alpha, true);
5050
cannot_double_move(Alpha);
51-
cannot_move_from_type_with_drop();
51+
drop(cannot_move_from_type_with_drop());
5252
borrower_propagation();
5353
not_consumed();
5454
issue_5405();

0 commit comments

Comments
 (0)