diff options
| author | kennytm <kennytm@gmail.com> | 2018-04-04 11:07:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-04 11:07:16 +0200 |
| commit | 6c8b8091fc73f5cec88d838d32fa165f54ac4ead (patch) | |
| tree | b31e0adf063c09a9ebe9a17ecf25c41c8689d7c6 /src/liballoc/vec.rs | |
| parent | f4f13883e5f888d36681b4390bc07fdb1e4eb7e0 (diff) | |
| parent | fb7deda27419eae61da3cbf5a5b1b4f51ae16d04 (diff) | |
| download | rust-6c8b8091fc73f5cec88d838d32fa165f54ac4ead.tar.gz rust-6c8b8091fc73f5cec88d838d32fa165f54ac4ead.zip | |
Rollup merge of #49533 - scottmcm:more-must-use, r=nikomatsakis
Add #[must_use] to a few standard library methods
Chosen to start a precedent of using it on ones that are potentially-expensive and where using it for side effects is particularly discouraged.
Discuss :)
```rust
warning: unused return value of `std::iter::Iterator::collect` which must be used: if you really need to exhaust the iterator, consider `.for_each(drop)` instead
--> $DIR/fn_must_use_stdlib.rs:19:5
|
LL | "1 2 3".split_whitespace().collect::<Vec<_>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused return value of `std::borrow::ToOwned::to_owned` which must be used: cloning is often expensive and is not expected to have side effects
--> $DIR/fn_must_use_stdlib.rs:21:5
|
LL | "hello".to_owned();
| ^^^^^^^^^^^^^^^^^^^
warning: unused return value of `std::clone::Clone::clone` which must be used: cloning is often expensive and is not expected to have side effects
--> $DIR/fn_must_use_stdlib.rs:23:5
|
LL | String::from("world").clone();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
cc https://github.com/rust-lang/rust/issues/48926
Diffstat (limited to 'src/liballoc/vec.rs')
0 files changed, 0 insertions, 0 deletions
