Skip to content

Commit 5f71c22

Browse files
committed
Rollup merge of #21373 - angst7:pointer_doc_1, r=steveklabnik
Updated incorrect error messages, and removed explicit return statements from example code.
2 parents 3364d41 + 9293607 commit 5f71c22

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/doc/trpl/pointers.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ println!("{}", x + z);
8787
This gives us an error:
8888

8989
```text
90-
hello.rs:6:24: 6:25 error: mismatched types: expected `i32` but found `&i32` (expected i32 but found &-ptr)
90+
hello.rs:6:24: 6:25 error: mismatched types: expected `_`, found `&_` (expected integral variable, found &-ptr)
9191
hello.rs:6 println!("{}", x + z);
9292
^
9393
```
@@ -305,7 +305,7 @@ References are immutable by default:
305305
let x = 5;
306306
let y = &x;
307307
308-
*y = 5; // error: cannot assign to immutable dereference of `&`-pointer `*y`
308+
*y = 5; // error: cannot assign to immutable borrowed content `*y`
309309
```
310310

311311
They can be made mutable with `mut`, but only if its referent is also mutable.
@@ -668,7 +668,7 @@ struct BigStruct {
668668
}
669669
670670
fn foo(x: Box<BigStruct>) -> Box<BigStruct> {
671-
return Box::new(*x);
671+
Box::new(*x)
672672
}
673673
674674
fn main() {
@@ -696,7 +696,7 @@ struct BigStruct {
696696
}
697697
698698
fn foo(x: Box<BigStruct>) -> BigStruct {
699-
return *x;
699+
*x
700700
}
701701
702702
fn main() {

0 commit comments

Comments
 (0)