Skip to content

Commit 7b3d14c

Browse files
authored
Rollup merge of rust-lang#136923 - samueltardieu:push-vxxqvqwspssv, r=davidtwco
Lint `#[must_use]` attributes applied to methods in trait impls The `#[must_use]` attribute has no effect when applied to methods in trait implementations. This PR adds it to the unused `#[must_use]` lint, and cleans the extra attributes in portable-simd and Clippy.
2 parents 105431d + 8676bc8 commit 7b3d14c

File tree

6 files changed

+0
-25
lines changed

6 files changed

+0
-25
lines changed

Diff for: portable-simd/crates/core_simd/src/masks.rs

-13
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ where
401401
LaneCount<N>: SupportedLaneCount,
402402
{
403403
#[inline]
404-
#[must_use = "method returns a defaulted mask with all elements set to false (0)"]
405404
fn default() -> Self {
406405
Self::splat(false)
407406
}
@@ -413,7 +412,6 @@ where
413412
LaneCount<N>: SupportedLaneCount,
414413
{
415414
#[inline]
416-
#[must_use = "method returns a new bool and does not mutate the original value"]
417415
fn eq(&self, other: &Self) -> bool {
418416
self.0 == other.0
419417
}
@@ -425,7 +423,6 @@ where
425423
LaneCount<N>: SupportedLaneCount,
426424
{
427425
#[inline]
428-
#[must_use = "method returns a new Ordering and does not mutate the original value"]
429426
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
430427
self.0.partial_cmp(&other.0)
431428
}
@@ -451,7 +448,6 @@ where
451448
{
452449
type Output = Self;
453450
#[inline]
454-
#[must_use = "method returns a new mask and does not mutate the original value"]
455451
fn bitand(self, rhs: Self) -> Self {
456452
Self(self.0 & rhs.0)
457453
}
@@ -464,7 +460,6 @@ where
464460
{
465461
type Output = Self;
466462
#[inline]
467-
#[must_use = "method returns a new mask and does not mutate the original value"]
468463
fn bitand(self, rhs: bool) -> Self {
469464
self & Self::splat(rhs)
470465
}
@@ -477,7 +472,6 @@ where
477472
{
478473
type Output = Mask<T, N>;
479474
#[inline]
480-
#[must_use = "method returns a new mask and does not mutate the original value"]
481475
fn bitand(self, rhs: Mask<T, N>) -> Mask<T, N> {
482476
Mask::splat(self) & rhs
483477
}
@@ -490,7 +484,6 @@ where
490484
{
491485
type Output = Self;
492486
#[inline]
493-
#[must_use = "method returns a new mask and does not mutate the original value"]
494487
fn bitor(self, rhs: Self) -> Self {
495488
Self(self.0 | rhs.0)
496489
}
@@ -503,7 +496,6 @@ where
503496
{
504497
type Output = Self;
505498
#[inline]
506-
#[must_use = "method returns a new mask and does not mutate the original value"]
507499
fn bitor(self, rhs: bool) -> Self {
508500
self | Self::splat(rhs)
509501
}
@@ -516,7 +508,6 @@ where
516508
{
517509
type Output = Mask<T, N>;
518510
#[inline]
519-
#[must_use = "method returns a new mask and does not mutate the original value"]
520511
fn bitor(self, rhs: Mask<T, N>) -> Mask<T, N> {
521512
Mask::splat(self) | rhs
522513
}
@@ -529,7 +520,6 @@ where
529520
{
530521
type Output = Self;
531522
#[inline]
532-
#[must_use = "method returns a new mask and does not mutate the original value"]
533523
fn bitxor(self, rhs: Self) -> Self::Output {
534524
Self(self.0 ^ rhs.0)
535525
}
@@ -542,7 +532,6 @@ where
542532
{
543533
type Output = Self;
544534
#[inline]
545-
#[must_use = "method returns a new mask and does not mutate the original value"]
546535
fn bitxor(self, rhs: bool) -> Self::Output {
547536
self ^ Self::splat(rhs)
548537
}
@@ -555,7 +544,6 @@ where
555544
{
556545
type Output = Mask<T, N>;
557546
#[inline]
558-
#[must_use = "method returns a new mask and does not mutate the original value"]
559547
fn bitxor(self, rhs: Mask<T, N>) -> Self::Output {
560548
Mask::splat(self) ^ rhs
561549
}
@@ -568,7 +556,6 @@ where
568556
{
569557
type Output = Mask<T, N>;
570558
#[inline]
571-
#[must_use = "method returns a new mask and does not mutate the original value"]
572559
fn not(self) -> Self::Output {
573560
Self(!self.0)
574561
}

Diff for: portable-simd/crates/core_simd/src/masks/full_masks.rs

-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ where
2121
LaneCount<N>: SupportedLaneCount,
2222
{
2323
#[inline]
24-
#[must_use = "method returns a new mask and does not mutate the original value"]
2524
fn clone(&self) -> Self {
2625
*self
2726
}
@@ -252,7 +251,6 @@ where
252251
{
253252
type Output = Self;
254253
#[inline]
255-
#[must_use = "method returns a new mask and does not mutate the original value"]
256254
fn bitand(self, rhs: Self) -> Self {
257255
// Safety: `self` is an integer vector
258256
unsafe { Self(core::intrinsics::simd::simd_and(self.0, rhs.0)) }
@@ -266,7 +264,6 @@ where
266264
{
267265
type Output = Self;
268266
#[inline]
269-
#[must_use = "method returns a new mask and does not mutate the original value"]
270267
fn bitor(self, rhs: Self) -> Self {
271268
// Safety: `self` is an integer vector
272269
unsafe { Self(core::intrinsics::simd::simd_or(self.0, rhs.0)) }
@@ -280,7 +277,6 @@ where
280277
{
281278
type Output = Self;
282279
#[inline]
283-
#[must_use = "method returns a new mask and does not mutate the original value"]
284280
fn bitxor(self, rhs: Self) -> Self {
285281
// Safety: `self` is an integer vector
286282
unsafe { Self(core::intrinsics::simd::simd_xor(self.0, rhs.0)) }
@@ -294,7 +290,6 @@ where
294290
{
295291
type Output = Self;
296292
#[inline]
297-
#[must_use = "method returns a new mask and does not mutate the original value"]
298293
fn not(self) -> Self::Output {
299294
Self::splat(true) ^ self
300295
}

Diff for: portable-simd/crates/core_simd/src/ops.rs

-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ macro_rules! for_base_types {
135135
type Output = $out;
136136

137137
#[inline]
138-
#[must_use = "operator returns a new vector without mutating the inputs"]
139138
// TODO: only useful for int Div::div, but we hope that this
140139
// will essentially always get inlined anyway.
141140
#[track_caller]

Diff for: portable-simd/crates/core_simd/src/ops/deref.rs

-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ macro_rules! deref_lhs {
1818
type Output = Simd<T, N>;
1919

2020
#[inline]
21-
#[must_use = "operator returns a new vector without mutating the inputs"]
2221
fn $call(self, rhs: $simd) -> Self::Output {
2322
(*self).$call(rhs)
2423
}
@@ -39,7 +38,6 @@ macro_rules! deref_rhs {
3938
type Output = Simd<T, N>;
4039

4140
#[inline]
42-
#[must_use = "operator returns a new vector without mutating the inputs"]
4341
fn $call(self, rhs: &$simd) -> Self::Output {
4442
self.$call(*rhs)
4543
}
@@ -71,7 +69,6 @@ macro_rules! deref_ops {
7169
type Output = $simd;
7270

7371
#[inline]
74-
#[must_use = "operator returns a new vector without mutating the inputs"]
7572
fn $call(self, rhs: &'rhs $simd) -> Self::Output {
7673
(*self).$call(*rhs)
7774
}

Diff for: portable-simd/crates/core_simd/src/ops/unary.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ macro_rules! neg {
1111
type Output = Self;
1212

1313
#[inline]
14-
#[must_use = "operator returns a new vector without mutating the input"]
1514
fn neg(self) -> Self::Output {
1615
// Safety: `self` is a signed vector
1716
unsafe { core::intrinsics::simd::simd_neg(self) }
@@ -46,7 +45,6 @@ macro_rules! not {
4645
type Output = Self;
4746

4847
#[inline]
49-
#[must_use = "operator returns a new vector without mutating the input"]
5048
fn not(self) -> Self::Output {
5149
self ^ (Simd::splat(!(0 as $scalar)))
5250
}

Diff for: portable-simd/crates/core_simd/src/simd/num/float.rs

-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ macro_rules! impl_trait {
371371
}
372372

373373
#[inline]
374-
#[must_use = "method returns a new mask and does not mutate the original value"]
375374
fn is_normal(self) -> Self::Mask {
376375
!(self.abs().simd_eq(Self::splat(0.0)) | self.is_nan() | self.is_subnormal() | self.is_infinite())
377376
}

0 commit comments

Comments
 (0)