Skip to content

Commit 6eb935a

Browse files
committed
Auto merge of rust-lang#11826 - kpreid:typo, r=Alexendoo
Fix typos in recent lint documentation. Fixes typos and markup errors, and also makes the examples more realistic by hiding the `;`s so as not to visibly be discarding the computed value. Affected lints: * `redundant_as_str` * `unnecessary_map_on_constructor` changelog: none
2 parents e8e9510 + b3f4a90 commit 6eb935a

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

clippy_lints/src/methods/mod.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -3609,7 +3609,7 @@ declare_clippy_lint! {
36093609

36103610
declare_clippy_lint! {
36113611
/// ### What it does
3612-
/// Checks for usage of `as_str()` on a `String`` chained with a method available on the `String` itself.
3612+
/// Checks for usage of `as_str()` on a `String` chained with a method available on the `String` itself.
36133613
///
36143614
/// ### Why is this bad?
36153615
/// The `as_str()` conversion is pointless and can be removed for simplicity and cleanliness.
@@ -3618,14 +3618,16 @@ declare_clippy_lint! {
36183618
/// ```no_run
36193619
/// # #![allow(unused)]
36203620
/// let owned_string = "This is a string".to_owned();
3621-
/// owned_string.as_str().as_bytes();
3621+
/// owned_string.as_str().as_bytes()
3622+
/// # ;
36223623
/// ```
36233624
///
36243625
/// Use instead:
36253626
/// ```no_run
36263627
/// # #![allow(unused)]
36273628
/// let owned_string = "This is a string".to_owned();
3628-
/// owned_string.as_bytes();
3629+
/// owned_string.as_bytes()
3630+
/// # ;
36293631
/// ```
36303632
#[clippy::version = "1.74.0"]
36313633
pub REDUNDANT_AS_STR,

clippy_lints/src/unnecessary_map_on_constructor.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@ use rustc_span::sym;
99

1010
declare_clippy_lint! {
1111
/// ### What it does
12-
/// Suggest removing the use of a map (or map_err) method when an Option or Result is being constructed.
12+
/// Suggests removing the use of a `map()` (or `map_err()`) method when an `Option` or `Result`
13+
/// is being constructed.
1314
///
1415
/// ### Why is this bad?
15-
/// It introduces unnecessary complexity. In this case the function can be used directly and
16-
/// construct the Option or Result from the output.
16+
/// It introduces unnecessary complexity. Instead, the function can be called before
17+
/// constructing the `Option` or `Result` from its return value.
1718
///
1819
/// ### Example
1920
/// ```no_run
20-
/// Some(4).map(i32::swap_bytes);
21+
/// Some(4).map(i32::swap_bytes)
22+
/// # ;
2123
/// ```
2224
/// Use instead:
2325
/// ```no_run
24-
/// Some(i32::swap_bytes(4));
26+
/// Some(i32::swap_bytes(4))
27+
/// # ;
2528
/// ```
2629
#[clippy::version = "1.74.0"]
2730
pub UNNECESSARY_MAP_ON_CONSTRUCTOR,

0 commit comments

Comments
 (0)