Skip to content

Commit a11d06b

Browse files
committed
Apply suggestions from code review
1 parent f4ef3fa commit a11d06b

File tree

10 files changed

+15
-27
lines changed

10 files changed

+15
-27
lines changed

library/alloc/src/bstr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ impl Clone for Box<ByteStr> {
624624

625625
#[unstable(feature = "bstr", issue = "134915")]
626626
impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> {
627-
/// Create a `Borrowed` cow from a `ByteStr`.
627+
/// Wrap `ByteStr` in `Cow::Borrowed`.
628628
#[inline]
629629
fn from(s: &'a ByteStr) -> Self {
630630
Cow::Borrowed(s)
@@ -633,7 +633,7 @@ impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> {
633633

634634
#[unstable(feature = "bstr", issue = "134915")]
635635
impl From<Box<[u8]>> for Box<ByteStr> {
636-
/// Create a `Box<[u8]>` from `Box<ByteStr>`s raw.
636+
/// Move the bytes from `Box<ByteStr>` to `Box<[u8]>`, this does not allocate new memory.
637637
#[inline]
638638
fn from(s: Box<[u8]>) -> Box<ByteStr> {
639639
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.

library/core/src/array/mod.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,24 +178,12 @@ impl Error for TryFromSliceError {
178178

179179
#[stable(feature = "try_from_slice_error", since = "1.36.0")]
180180
impl From<Infallible> for TryFromSliceError {
181-
/// Match `Infallible` into `TryFromSliceError`.
181+
/// Convert `Infallible` into an error that can happen.
182182
fn from(x: Infallible) -> TryFromSliceError {
183183
match x {}
184184
}
185185
}
186186

187-
#[unstable(feature = "never_type", issue = "35121")]
188-
impl From<!> for TryFromSliceError {
189-
/// Match `!` into `TryFromSliceError`.
190-
#[inline]
191-
fn from(never: !) -> TryFromSliceError {
192-
// Match rather than coerce to make sure that code like
193-
// `From<Infallible> for TryFromSliceError` above will keep working
194-
// when `Infallible` becomes an alias to `!`.
195-
match never {}
196-
}
197-
}
198-
199187
#[stable(feature = "rust1", since = "1.0.0")]
200188
impl<T, const N: usize> AsRef<[T]> for [T; N] {
201189
#[inline]

library/core/src/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub enum Alignment {
3636
#[doc(hidden)]
3737
#[unstable(feature = "fmt_internals", reason = "internal to standard library", issue = "none")]
3838
impl From<rt::Alignment> for Option<Alignment> {
39-
/// Match the `Alignment` to the `Some` equivalent, `Unknown` matches `None`.
39+
/// Match the `rt::Alignment` to the `Some` equivalent, `Unknown` matches `None`.
4040
fn from(value: rt::Alignment) -> Self {
4141
match value {
4242
rt::Alignment::Left => Some(Alignment::Left),

library/core/src/num/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl Error for TryFromIntError {
2727

2828
#[stable(feature = "try_from", since = "1.34.0")]
2929
impl From<Infallible> for TryFromIntError {
30-
/// Match `Infallible` into `TryFromIntError`.
30+
/// Convert `Infallible` into an error that can happen.
3131
#[inline]
3232
fn from(x: Infallible) -> TryFromIntError {
3333
match x {}
@@ -36,7 +36,7 @@ impl From<Infallible> for TryFromIntError {
3636

3737
#[unstable(feature = "never_type", issue = "35121")]
3838
impl From<!> for TryFromIntError {
39-
/// Match `!` into `TryFromIntError`.
39+
/// Convert `!` into an error that can happen.
4040
#[inline]
4141
fn from(never: !) -> TryFromIntError {
4242
// Match rather than coerce to make sure that code like

library/core/src/num/nonzero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl<T> From<NonZero<T>> for T
290290
where
291291
T: ZeroablePrimitive,
292292
{
293-
/// Get the inner num of `NonZero`.
293+
/// Returns the contained value as a primitive type.
294294
#[inline]
295295
fn from(nonzero: NonZero<T>) -> Self {
296296
// Call `get` method to keep range information.

library/core/src/ptr/alignment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl TryFrom<usize> for Alignment {
189189

190190
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
191191
impl From<Alignment> for NonZero<usize> {
192-
/// `Alignment` is non zero so the inner enum value is returned
192+
/// `Alignment` is non zero so the inner value is returned
193193
#[inline]
194194
fn from(align: Alignment) -> NonZero<usize> {
195195
align.as_nonzero()
@@ -198,7 +198,7 @@ impl From<Alignment> for NonZero<usize> {
198198

199199
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
200200
impl From<Alignment> for usize {
201-
/// `Alignment` is unsined so the inner enum value is returned
201+
/// `Alignment` is unsined so the inner value is returned
202202
#[inline]
203203
fn from(align: Alignment) -> usize {
204204
align.as_usize()

library/proc_macro/src/bridge/rpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ impl From<PanicMessage> for Box<dyn Any + Send> {
269269
/// Return the inner wrapped in `Box`.
270270
///
271271
/// ## Cost
272-
/// Allocates a new `Box` on the heep
272+
/// Allocates a new `Box` on the heap
273273
fn from(val: PanicMessage) -> Self {
274274
match val {
275275
PanicMessage::StaticStr(s) => Box::new(s),

library/std/src/sys/pal/windows/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl From<&OsStr> for EnvKey {
140140
/// Uses `EnvKey::From<OsString>` to convert the `&OsStr`.
141141
///
142142
/// ## Cost
143-
/// Converts `&OsStr` to `OsString` which does a heep allocation
143+
/// Converts `&OsStr` to `OsString` which does a heap allocation
144144
fn from(k: &OsStr) -> Self {
145145
Self::from(k.to_os_string())
146146
}

src/tools/clippy/clippy_lints/src/attrs/mixed_attributes_style.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl From<&AttrKind> for SimpleAttrKind {
1919
/// if it's a `DocComment` then `Doc` is returned with no conversion.
2020
///
2121
/// ## Cost
22-
/// If `AttrKind` is `DocComment` it's free, however if it's `Normal` their is heep allocation
22+
/// If `AttrKind` is `DocComment` it's free, however if it's `Normal` their is heap allocation
2323
fn from(value: &AttrKind) -> Self {
2424
match value {
2525
AttrKind::Normal(attr) => {

tests/ui/try-block/try-block-bad-type.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ LL | Err("")?;
77
| this can't be annotated with `?` because it has type `Result<_, &str>`
88
|
99
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
10-
= help: the following other types implement trait `From<T>`:
11-
`TryFromSliceError` implements `From<!>`
12-
`TryFromSliceError` implements `From<Infallible>`
10+
= help: the trait `From<&str>` is not implemented for `TryFromSliceError`
11+
but trait `From<Infallible>` is implemented for it
12+
= help: for that trait implementation, expected `Infallible`, found `&str`
1313

1414
error[E0271]: type mismatch resolving `<Result<i32, i32> as Try>::Output == &str`
1515
--> $DIR/try-block-bad-type.rs:12:9

0 commit comments

Comments
 (0)