Skip to content

Commit fb7ed15

Browse files
committed
fixed all reviews
1 parent f31c93c commit fb7ed15

File tree

6 files changed

+27
-22
lines changed

6 files changed

+27
-22
lines changed

tests/ui/autoref-autoderef/autoderef-box-no-add.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,32 @@
22
//!
33
//! This test ensures that `Box<isize>` fields in structs (`Clam` and `Fish`) are not
44
//! automatically dereferenced to `isize` during addition operations, as `Box<isize>`
5-
//! does not implement the `Add` trait. Attempts to add `Box<isize>` values should
6-
//! result in a compile error.
5+
//! does not implement the `Add` trait.
76
87
struct Clam {
98
x: Box<isize>,
109
y: Box<isize>,
1110
}
1211

13-
14-
1512
struct Fish {
1613
a: Box<isize>,
1714
}
1815

1916
fn main() {
20-
let a: Clam = Clam{ x: Box::new(1), y: Box::new(2) };
21-
let b: Clam = Clam{ x: Box::new(10), y: Box::new(20) };
17+
let a: Clam = Clam {
18+
x: Box::new(1),
19+
y: Box::new(2),
20+
};
21+
let b: Clam = Clam {
22+
x: Box::new(10),
23+
y: Box::new(20),
24+
};
2225
let z: isize = a.x + b.y;
2326
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
2427
println!("{}", z);
2528
assert_eq!(z, 21);
26-
let forty: Fish = Fish{ a: Box::new(40) };
27-
let two: Fish = Fish{ a: Box::new(2) };
29+
let forty: Fish = Fish { a: Box::new(40) };
30+
let two: Fish = Fish { a: Box::new(2) };
2831
let answer: isize = forty.a + two.a;
2932
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
3033
println!("{}", answer);

tests/ui/autoref-autoderef/autoderef-box-no-add.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0369]: cannot add `Box<isize>` to `Box<isize>`
2-
--> $DIR/autoderef-box-no-add.rs:22:24
2+
--> $DIR/autoderef-box-no-add.rs:25:24
33
|
44
LL | let z: isize = a.x + b.y;
55
| --- ^ --- Box<isize>
@@ -13,7 +13,7 @@ note: the foreign item type `Box<isize>` doesn't implement `Add`
1313
= note: not implement `Add`
1414

1515
error[E0369]: cannot add `Box<isize>` to `Box<isize>`
16-
--> $DIR/autoderef-box-no-add.rs:28:33
16+
--> $DIR/autoderef-box-no-add.rs:31:33
1717
|
1818
LL | let answer: isize = forty.a + two.a;
1919
| ------- ^ ----- Box<isize>

tests/ui/functions-closures/bare-fn-implements-fn-mut.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
//! Tests that bare functions implement the `FnMut` trait correctly.
1+
//! Tests that bare functions implement the `FnMut` trait.
2+
//!
3+
//! See <https://github.com/rust-lang/rust/issues/15448>.
24
35
//@ run-pass
46

tests/ui/methods/no-auto-borrow-vec-to-slice.rs renamed to tests/ui/methods/vec-autoderef-autoref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//! Tests that method resolution does not automatically borrow `Vec`
2-
//! to a slice or add extra references.
1+
//! Test that method resolution does not autoderef `Vec`
2+
//! into a slice or perform additional autorefs.
33
44
fn main() {
55
let mut a = vec![0];

tests/ui/methods/no-auto-borrow-vec-to-slice.stderr renamed to tests/ui/methods/vec-autoderef-autoref.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
error[E0599]: no method named `test_mut` found for struct `Vec<{integer}>` in the current scope
2-
--> $DIR/no-auto-borrow-vec-to-slice.rs:6:7
2+
--> $DIR/vec-autoderef-autoref.rs:6:7
33
|
44
LL | a.test_mut();
55
| ^^^^^^^^
66
|
77
= help: items from traits can only be used if the trait is implemented and in scope
88
note: `MyIter` defines an item `test_mut`, perhaps you need to implement it
9-
--> $DIR/no-auto-borrow-vec-to-slice.rs:13:1
9+
--> $DIR/vec-autoderef-autoref.rs:13:1
1010
|
1111
LL | trait MyIter {
1212
| ^^^^^^^^^^^^
1313
help: there is a method `get_mut` with a similar name, but with different arguments
1414
--> $SRC_DIR/core/src/slice/mod.rs:LL:COL
1515

1616
error[E0599]: no method named `test` found for struct `Vec<{integer}>` in the current scope
17-
--> $DIR/no-auto-borrow-vec-to-slice.rs:7:7
17+
--> $DIR/vec-autoderef-autoref.rs:7:7
1818
|
1919
LL | a.test();
2020
| ^^^^ method not found in `Vec<{integer}>`
2121
|
2222
= help: items from traits can only be used if the trait is implemented and in scope
2323
note: `MyIter` defines an item `test`, perhaps you need to implement it
24-
--> $DIR/no-auto-borrow-vec-to-slice.rs:13:1
24+
--> $DIR/vec-autoderef-autoref.rs:13:1
2525
|
2626
LL | trait MyIter {
2727
| ^^^^^^^^^^^^
2828

2929
error[E0599]: no method named `test` found for array `[{integer}; 1]` in the current scope
30-
--> $DIR/no-auto-borrow-vec-to-slice.rs:9:11
30+
--> $DIR/vec-autoderef-autoref.rs:9:11
3131
|
3232
LL | ([1]).test();
3333
| ^^^^ method not found in `[{integer}; 1]`
3434
|
3535
= help: items from traits can only be used if the trait is implemented and in scope
3636
note: `MyIter` defines an item `test`, perhaps you need to implement it
37-
--> $DIR/no-auto-borrow-vec-to-slice.rs:13:1
37+
--> $DIR/vec-autoderef-autoref.rs:13:1
3838
|
3939
LL | trait MyIter {
4040
| ^^^^^^^^^^^^
4141

4242
error[E0599]: no method named `test` found for reference `&[{integer}; 1]` in the current scope
43-
--> $DIR/no-auto-borrow-vec-to-slice.rs:10:12
43+
--> $DIR/vec-autoderef-autoref.rs:10:12
4444
|
4545
LL | (&[1]).test();
4646
| ^^^^ method not found in `&[{integer}; 1]`
4747
|
4848
= help: items from traits can only be used if the trait is implemented and in scope
4949
note: `MyIter` defines an item `test`, perhaps you need to implement it
50-
--> $DIR/no-auto-borrow-vec-to-slice.rs:13:1
50+
--> $DIR/vec-autoderef-autoref.rs:13:1
5151
|
5252
LL | trait MyIter {
5353
| ^^^^^^^^^^^^

tests/ui/str/str-static-literal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Tests that `&'static str` literals are correctly typed and usable.
1+
//! Check that a bare string literal is typed as a `&'static str` and is usable.
22
33
//@ run-pass
44

0 commit comments

Comments
 (0)