diff --git a/src/ci/docker/dist-various-1/install-x86_64-redox.sh b/src/ci/docker/dist-various-1/install-x86_64-redox.sh index 339042bb6729..dad979223384 100755 --- a/src/ci/docker/dist-various-1/install-x86_64-redox.sh +++ b/src/ci/docker/dist-various-1/install-x86_64-redox.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -# ignore-tidy-linelength set -ex diff --git a/src/ci/docker/dist-various-2/build-fuchsia-toolchain.sh b/src/ci/docker/dist-various-2/build-fuchsia-toolchain.sh index ef486075ff9d..3b91918288a2 100755 --- a/src/ci/docker/dist-various-2/build-fuchsia-toolchain.sh +++ b/src/ci/docker/dist-various-2/build-fuchsia-toolchain.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -# ignore-tidy-linelength - set -ex source shared.sh diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index c8a4ff7ca61e..f1325f383eed 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -377,6 +377,8 @@ let m = ", $rot_result, "; assert_eq!(n.rotate_left(", $rot, "), m); ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn rotate_left(self, n: u32) -> Self { (self as $UnsignedT).rotate_left(n) as Self @@ -401,6 +403,8 @@ let m = ", $rot_op, "; assert_eq!(n.rotate_right(", $rot, "), m); ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn rotate_right(self, n: u32) -> Self { (self as $UnsignedT).rotate_right(n) as Self @@ -598,6 +602,8 @@ assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(3), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_add(self, rhs: Self) -> Option { let (a, b) = self.overflowing_add(rhs); @@ -620,6 +626,8 @@ assert_eq!((", stringify!($SelfT), "::min_value() + 2).checked_sub(3), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_sub(self, rhs: Self) -> Option { let (a, b) = self.overflowing_sub(rhs); @@ -642,6 +650,8 @@ assert_eq!(", stringify!($SelfT), "::max_value().checked_mul(2), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_mul(self, rhs: Self) -> Option { let (a, b) = self.overflowing_mul(rhs); @@ -665,6 +675,8 @@ assert_eq!((1", stringify!($SelfT), ").checked_div(0), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_div(self, rhs: Self) -> Option { if rhs == 0 || (self == Self::min_value() && rhs == -1) { @@ -691,6 +703,8 @@ assert_eq!(", stringify!($SelfT), "::min_value().checked_div_euclid(-1), None); assert_eq!((1", stringify!($SelfT), ").checked_div_euclid(0), None); ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_div_euclid(self, rhs: Self) -> Option { if rhs == 0 || (self == Self::min_value() && rhs == -1) { @@ -718,6 +732,8 @@ assert_eq!(", stringify!($SelfT), "::MIN.checked_rem(-1), None);", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_rem(self, rhs: Self) -> Option { if rhs == 0 || (self == Self::min_value() && rhs == -1) { @@ -745,6 +761,8 @@ assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(0), None); assert_eq!(", stringify!($SelfT), "::MIN.checked_rem_euclid(-1), None); ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_rem_euclid(self, rhs: Self) -> Option { if rhs == 0 || (self == Self::min_value() && rhs == -1) { @@ -791,6 +809,8 @@ assert_eq!(0x1", stringify!($SelfT), ".checked_shl(129), None);", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_shl(self, rhs: u32) -> Option { let (a, b) = self.overflowing_shl(rhs); @@ -812,6 +832,8 @@ assert_eq!(0x10", stringify!($SelfT), ".checked_shr(128), None);", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_shr(self, rhs: u32) -> Option { let (a, b) = self.overflowing_shr(rhs); @@ -860,6 +882,8 @@ $EndFeature, " ```"), #[stable(feature = "no_panic_pow", since = "1.34.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_pow(self, mut exp: u32) -> Option { let mut base = self; @@ -901,6 +925,8 @@ $EndFeature, " #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_saturating_int_methods")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn saturating_add(self, rhs: Self) -> Self { intrinsics::saturating_add(self, rhs) @@ -924,6 +950,8 @@ $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_saturating_int_methods")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn saturating_sub(self, rhs: Self) -> Self { intrinsics::saturating_sub(self, rhs) @@ -947,6 +975,8 @@ assert_eq!(", stringify!($SelfT), "::MIN.saturating_mul(10), ", stringify!($Self $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn saturating_mul(self, rhs: Self) -> Self { self.checked_mul(rhs).unwrap_or_else(|| { @@ -976,6 +1006,8 @@ assert_eq!(", stringify!($SelfT), "::MIN.saturating_pow(3), ", stringify!($SelfT $EndFeature, " ```"), #[stable(feature = "no_panic_pow", since = "1.34.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn saturating_pow(self, exp: u32) -> Self { match self.checked_pow(exp) { @@ -1001,6 +1033,8 @@ assert_eq!(", stringify!($SelfT), "::max_value().wrapping_add(2), ", stringify!( $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn wrapping_add(self, rhs: Self) -> Self { intrinsics::overflowing_add(self, rhs) @@ -1022,6 +1056,8 @@ stringify!($SelfT), "::max_value());", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn wrapping_sub(self, rhs: Self) -> Self { intrinsics::overflowing_sub(self, rhs) @@ -1042,6 +1078,8 @@ assert_eq!(11i8.wrapping_mul(12), -124);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn wrapping_mul(self, rhs: Self) -> Self { intrinsics::overflowing_mul(self, rhs) @@ -1070,6 +1108,8 @@ assert_eq!((-128i8).wrapping_div(-1), -128);", $EndFeature, " ```"), #[stable(feature = "num_wrapping", since = "1.2.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn wrapping_div(self, rhs: Self) -> Self { self.overflowing_div(rhs).0 @@ -1098,6 +1138,8 @@ assert_eq!(100", stringify!($SelfT), ".wrapping_div_euclid(10), 10); assert_eq!((-128i8).wrapping_div_euclid(-1), -128); ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn wrapping_div_euclid(self, rhs: Self) -> Self { self.overflowing_div_euclid(rhs).0 @@ -1126,6 +1168,8 @@ assert_eq!((-128i8).wrapping_rem(-1), 0);", $EndFeature, " ```"), #[stable(feature = "num_wrapping", since = "1.2.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn wrapping_rem(self, rhs: Self) -> Self { self.overflowing_rem(rhs).0 @@ -1153,6 +1197,8 @@ assert_eq!(100", stringify!($SelfT), ".wrapping_rem_euclid(10), 0); assert_eq!((-128i8).wrapping_rem_euclid(-1), 0); ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn wrapping_rem_euclid(self, rhs: Self) -> Self { self.overflowing_rem_euclid(rhs).0 @@ -1203,6 +1249,8 @@ assert_eq!((-1", stringify!($SelfT), ").wrapping_shl(128), -1);", $EndFeature, " ```"), #[stable(feature = "num_wrapping", since = "1.2.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn wrapping_shl(self, rhs: u32) -> Self { unsafe { @@ -1230,6 +1278,8 @@ assert_eq!((-128i16).wrapping_shr(64), -128);", $EndFeature, " ```"), #[stable(feature = "num_wrapping", since = "1.2.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn wrapping_shr(self, rhs: u32) -> Self { unsafe { @@ -1284,6 +1334,8 @@ assert_eq!(3i8.wrapping_pow(6), -39);", $EndFeature, " ```"), #[stable(feature = "no_panic_pow", since = "1.34.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn wrapping_pow(self, mut exp: u32) -> Self { let mut base = self; @@ -1326,6 +1378,8 @@ assert_eq!(", stringify!($SelfT), "::MAX.overflowing_add(1), (", stringify!($Sel "::MIN, true));", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn overflowing_add(self, rhs: Self) -> (Self, bool) { let (a, b) = intrinsics::add_with_overflow(self as $ActualT, rhs as $ActualT); @@ -1351,6 +1405,8 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_sub(1), (", stringify!($Sel "::MAX, true));", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool) { let (a, b) = intrinsics::sub_with_overflow(self as $ActualT, rhs as $ActualT); @@ -1374,6 +1430,8 @@ assert_eq!(1_000_000_000i32.overflowing_mul(10), (1410065408, true));", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool) { let (a, b) = intrinsics::mul_with_overflow(self as $ActualT, rhs as $ActualT); @@ -1405,6 +1463,8 @@ $EndFeature, " ```"), #[inline] #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] pub fn overflowing_div(self, rhs: Self) -> (Self, bool) { if self == Self::min_value() && rhs == -1 { (self, true) @@ -1438,6 +1498,8 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_div_euclid(-1), (", stringi ```"), #[inline] #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] pub fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) { if self == Self::min_value() && rhs == -1 { (self, true) @@ -1470,6 +1532,8 @@ $EndFeature, " ```"), #[inline] #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] pub fn overflowing_rem(self, rhs: Self) -> (Self, bool) { if self == Self::min_value() && rhs == -1 { (0, true) @@ -1502,6 +1566,8 @@ assert_eq!(5", stringify!($SelfT), ".overflowing_rem_euclid(2), (1, false)); assert_eq!(", stringify!($SelfT), "::MIN.overflowing_rem_euclid(-1), (0, true)); ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool) { if self == Self::min_value() && rhs == -1 { @@ -1555,6 +1621,8 @@ assert_eq!(0x1i32.overflowing_shl(36), (0x10, true));", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool) { (self.wrapping_shl(rhs), (rhs > ($BITS - 1))) @@ -1578,6 +1646,8 @@ assert_eq!(0x10i32.overflowing_shr(36), (0x1, true));", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool) { (self.wrapping_shr(rhs), (rhs > ($BITS - 1))) @@ -1630,6 +1700,8 @@ assert_eq!(3i8.overflowing_pow(5), (-13, true));", $EndFeature, " ```"), #[stable(feature = "no_panic_pow", since = "1.34.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn overflowing_pow(self, mut exp: u32) -> (Self, bool) { let mut base = self; @@ -1677,6 +1749,8 @@ assert_eq!(x.pow(5), 32);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] #[rustc_inherit_overflow_checks] pub fn pow(self, mut exp: u32) -> Self { @@ -1732,6 +1806,8 @@ assert_eq!((-a).div_euclid(b), -2); // -7 >= 4 * -2 assert_eq!((-a).div_euclid(-b), 2); // -7 >= -4 * 2 ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] #[rustc_inherit_overflow_checks] pub fn div_euclid(self, rhs: Self) -> Self { @@ -1770,6 +1846,8 @@ assert_eq!(a.rem_euclid(-b), 3); assert_eq!((-a).rem_euclid(-b), 1); ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] #[rustc_inherit_overflow_checks] pub fn rem_euclid(self, rhs: Self) -> Self { @@ -2277,6 +2355,8 @@ let m = ", $rot_result, "; assert_eq!(n.rotate_left(", $rot, "), m); ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn rotate_left(self, n: u32) -> Self { intrinsics::rotate_left(self, n as $SelfT) @@ -2301,6 +2381,8 @@ let m = ", $rot_op, "; assert_eq!(n.rotate_right(", $rot, "), m); ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn rotate_right(self, n: u32) -> Self { intrinsics::rotate_right(self, n as $SelfT) @@ -2496,6 +2578,8 @@ Basic usage: assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(3), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_add(self, rhs: Self) -> Option { let (a, b) = self.overflowing_add(rhs); @@ -2516,6 +2600,8 @@ Basic usage: assert_eq!(0", stringify!($SelfT), ".checked_sub(1), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_sub(self, rhs: Self) -> Option { let (a, b) = self.overflowing_sub(rhs); @@ -2536,6 +2622,8 @@ Basic usage: assert_eq!(", stringify!($SelfT), "::max_value().checked_mul(2), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_mul(self, rhs: Self) -> Option { let (a, b) = self.overflowing_mul(rhs); @@ -2556,6 +2644,8 @@ Basic usage: assert_eq!(1", stringify!($SelfT), ".checked_div(0), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_div(self, rhs: Self) -> Option { match rhs { @@ -2579,6 +2669,8 @@ assert_eq!(128", stringify!($SelfT), ".checked_div_euclid(2), Some(64)); assert_eq!(1", stringify!($SelfT), ".checked_div_euclid(0), None); ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_div_euclid(self, rhs: Self) -> Option { if rhs == 0 { @@ -2603,6 +2695,8 @@ Basic usage: assert_eq!(5", stringify!($SelfT), ".checked_rem(0), None);", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_rem(self, rhs: Self) -> Option { if rhs == 0 { @@ -2627,6 +2721,8 @@ assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(2), Some(1)); assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(0), None); ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_rem_euclid(self, rhs: Self) -> Option { if rhs == 0 { @@ -2672,6 +2768,8 @@ Basic usage: assert_eq!(0x10", stringify!($SelfT), ".checked_shl(129), None);", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_shl(self, rhs: u32) -> Option { let (a, b) = self.overflowing_shl(rhs); @@ -2692,6 +2790,8 @@ Basic usage: assert_eq!(0x10", stringify!($SelfT), ".checked_shr(129), None);", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_shr(self, rhs: u32) -> Option { let (a, b) = self.overflowing_shr(rhs); @@ -2712,6 +2812,8 @@ Basic usage: assert_eq!(", stringify!($SelfT), "::max_value().checked_pow(2), None);", $EndFeature, " ```"), #[stable(feature = "no_panic_pow", since = "1.34.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn checked_pow(self, mut exp: u32) -> Option { let mut base = self; @@ -2750,6 +2852,8 @@ assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[rustc_const_unstable(feature = "const_saturating_int_methods")] #[inline] pub const fn saturating_add(self, rhs: Self) -> Self { @@ -2770,6 +2874,8 @@ Basic usage: assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[rustc_const_unstable(feature = "const_saturating_int_methods")] #[inline] pub const fn saturating_sub(self, rhs: Self) -> Self { @@ -2793,6 +2899,8 @@ assert_eq!((", stringify!($SelfT), "::MAX).saturating_mul(10), ", stringify!($Se "::MAX);", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn saturating_mul(self, rhs: Self) -> Self { self.checked_mul(rhs).unwrap_or(Self::max_value()) @@ -2815,6 +2923,8 @@ assert_eq!(", stringify!($SelfT), "::MAX.saturating_pow(2), ", stringify!($SelfT $EndFeature, " ```"), #[stable(feature = "no_panic_pow", since = "1.34.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn saturating_pow(self, exp: u32) -> Self { match self.checked_pow(exp) { @@ -2838,6 +2948,8 @@ assert_eq!(200", stringify!($SelfT), ".wrapping_add(", stringify!($SelfT), "::ma $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn wrapping_add(self, rhs: Self) -> Self { intrinsics::overflowing_add(self, rhs) @@ -2858,6 +2970,8 @@ assert_eq!(100", stringify!($SelfT), ".wrapping_sub(", stringify!($SelfT), "::ma $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn wrapping_sub(self, rhs: Self) -> Self { intrinsics::overflowing_sub(self, rhs) @@ -2879,6 +2993,8 @@ $EndFeature, " /// assert_eq!(25u8.wrapping_mul(12), 44); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn wrapping_mul(self, rhs: Self) -> Self { intrinsics::overflowing_mul(self, rhs) @@ -2899,6 +3015,8 @@ Basic usage: ", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_div(10), 10);", $EndFeature, " ```"), #[stable(feature = "num_wrapping", since = "1.2.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn wrapping_div(self, rhs: Self) -> Self { self / rhs @@ -2924,6 +3042,8 @@ Basic usage: assert_eq!(100", stringify!($SelfT), ".wrapping_div_euclid(10), 10); ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn wrapping_div_euclid(self, rhs: Self) -> Self { self / rhs @@ -2946,6 +3066,8 @@ Basic usage: ", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_rem(10), 0);", $EndFeature, " ```"), #[stable(feature = "num_wrapping", since = "1.2.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn wrapping_rem(self, rhs: Self) -> Self { self % rhs @@ -2972,6 +3094,8 @@ Basic usage: assert_eq!(100", stringify!($SelfT), ".wrapping_rem_euclid(10), 0); ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn wrapping_rem_euclid(self, rhs: Self) -> Self { self % rhs @@ -3026,6 +3150,8 @@ Basic usage: assert_eq!(1", stringify!($SelfT), ".wrapping_shl(128), 1);", $EndFeature, " ```"), #[stable(feature = "num_wrapping", since = "1.2.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn wrapping_shl(self, rhs: u32) -> Self { unsafe { @@ -3055,6 +3181,8 @@ Basic usage: assert_eq!(128", stringify!($SelfT), ".wrapping_shr(128), 128);", $EndFeature, " ```"), #[stable(feature = "num_wrapping", since = "1.2.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn wrapping_shr(self, rhs: u32) -> Self { unsafe { @@ -3076,6 +3204,8 @@ Basic usage: assert_eq!(3u8.wrapping_pow(6), 217);", $EndFeature, " ```"), #[stable(feature = "no_panic_pow", since = "1.34.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn wrapping_pow(self, mut exp: u32) -> Self { let mut base = self; @@ -3118,6 +3248,8 @@ assert_eq!(5", stringify!($SelfT), ".overflowing_add(2), (7, false)); assert_eq!(", stringify!($SelfT), "::MAX.overflowing_add(1), (0, true));", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn overflowing_add(self, rhs: Self) -> (Self, bool) { let (a, b) = intrinsics::add_with_overflow(self as $ActualT, rhs as $ActualT); @@ -3144,6 +3276,8 @@ assert_eq!(0", stringify!($SelfT), ".overflowing_sub(1), (", stringify!($SelfT), $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool) { let (a, b) = intrinsics::sub_with_overflow(self as $ActualT, rhs as $ActualT); @@ -3169,6 +3303,8 @@ $EndFeature, " /// assert_eq!(1_000_000_000u32.overflowing_mul(10), (1410065408, true)); /// ``` #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool) { let (a, b) = intrinsics::mul_with_overflow(self as $ActualT, rhs as $ActualT); @@ -3196,6 +3332,8 @@ Basic usage ```"), #[inline] #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] pub fn overflowing_div(self, rhs: Self) -> (Self, bool) { (self / rhs, false) } @@ -3226,6 +3364,8 @@ assert_eq!(5", stringify!($SelfT), ".overflowing_div_euclid(2), (2, false)); ```"), #[inline] #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] pub fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) { (self / rhs, false) } @@ -3252,6 +3392,8 @@ Basic usage ```"), #[inline] #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] pub fn overflowing_rem(self, rhs: Self) -> (Self, bool) { (self % rhs, false) } @@ -3282,6 +3424,8 @@ assert_eq!(5", stringify!($SelfT), ".overflowing_rem_euclid(2), (1, false)); ```"), #[inline] #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] pub fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool) { (self % rhs, false) } @@ -3329,6 +3473,8 @@ Basic usage assert_eq!(0x1", stringify!($SelfT), ".overflowing_shl(132), (0x10, true));", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool) { (self.wrapping_shl(rhs), (rhs > ($BITS - 1))) @@ -3353,6 +3499,8 @@ Basic usage assert_eq!(0x10", stringify!($SelfT), ".overflowing_shr(132), (0x1, true));", $EndFeature, " ```"), #[stable(feature = "wrapping", since = "1.7.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool) { (self.wrapping_shr(rhs), (rhs > ($BITS - 1))) @@ -3374,6 +3522,8 @@ Basic usage: assert_eq!(3u8.overflowing_pow(6), (217, true));", $EndFeature, " ```"), #[stable(feature = "no_panic_pow", since = "1.34.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn overflowing_pow(self, mut exp: u32) -> (Self, bool) { let mut base = self; @@ -3418,6 +3568,8 @@ Basic usage: ", $Feature, "assert_eq!(2", stringify!($SelfT), ".pow(5), 32);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] #[rustc_inherit_overflow_checks] pub fn pow(self, mut exp: u32) -> Self { @@ -3459,6 +3611,8 @@ Basic usage: assert_eq!(7", stringify!($SelfT), ".div_euclid(4), 1); // or any other integer type ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] #[rustc_inherit_overflow_checks] pub fn div_euclid(self, rhs: Self) -> Self { @@ -3483,6 +3637,8 @@ Basic usage: assert_eq!(7", stringify!($SelfT), ".rem_euclid(4), 3); // or any other integer type ```"), #[unstable(feature = "euclidean_division", issue = "49048")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] #[rustc_inherit_overflow_checks] pub fn rem_euclid(self, rhs: Self) -> Self { diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 007eaef74a7a..a0c9e5983a1d 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -58,10 +58,10 @@ impl<'a> FnKind<'a> { } } - pub fn header(&self) -> Option { + pub fn header(&self) -> Option<&FnHeader> { match *self { - FnKind::ItemFn(_, _, header, _, _) => Some(header), - FnKind::Method(_, sig, _, _) => Some(sig.header), + FnKind::ItemFn(_, _, ref header, _, _) => Some(header), + FnKind::Method(_, ref sig, _, _) => Some(&sig.header), FnKind::Closure(_) => None, } } @@ -262,6 +262,9 @@ pub trait Visitor<'v> : Sized { fn visit_pat(&mut self, p: &'v Pat) { walk_pat(self, p) } + fn visit_argument_source(&mut self, s: &'v ArgSource) { + walk_argument_source(self, s) + } fn visit_anon_const(&mut self, c: &'v AnonConst) { walk_anon_const(self, c) } @@ -399,10 +402,17 @@ pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &'v Body) { for argument in &body.arguments { visitor.visit_id(argument.hir_id); visitor.visit_pat(&argument.pat); + visitor.visit_argument_source(&argument.source); } visitor.visit_expr(&body.value); } +pub fn walk_argument_source<'v, V: Visitor<'v>>(visitor: &mut V, source: &'v ArgSource) { + if let ArgSource::AsyncFn(pat) = source { + visitor.visit_pat(pat); + } +} + pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local) { // Intentionally visiting the expr first - the initialization expr // dominates the local's definition. diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 99cae00fafc2..380dee5fcdcc 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -448,10 +448,9 @@ impl<'a> LoweringContext<'a> { impl<'lcx, 'interner> Visitor<'lcx> for MiscCollector<'lcx, 'interner> { fn visit_pat(&mut self, p: &'lcx Pat) { match p.node { - // Doesn't generate a Hir node + // Doesn't generate a HIR node PatKind::Paren(..) => {}, _ => { - if let Some(owner) = self.hir_id_owner { self.lctx.lower_node_id_with_owner(p.id, owner); } @@ -461,6 +460,32 @@ impl<'a> LoweringContext<'a> { visit::walk_pat(self, p) } + fn visit_fn(&mut self, fk: visit::FnKind<'lcx>, fd: &'lcx FnDecl, s: Span, _: NodeId) { + if fk.header().map(|h| h.asyncness.node.is_async()).unwrap_or(false) { + // Don't visit the original pattern for async functions as it will be + // replaced. + for arg in &fd.inputs { + if let ArgSource::AsyncFn(pat) = &arg.source { self.visit_pat(pat); } + self.visit_ty(&arg.ty) + } + self.visit_fn_ret_ty(&fd.output); + + match fk { + visit::FnKind::ItemFn(_, decl, _, body) => { + self.visit_fn_header(decl); + self.visit_block(body) + }, + visit::FnKind::Method(_, sig, _, body) => { + self.visit_fn_header(&sig.header); + self.visit_block(body) + }, + visit::FnKind::Closure(body) => self.visit_expr(body), + } + } else { + visit::walk_fn(self, fk, fd, s) + } + } + fn visit_item(&mut self, item: &'lcx Item) { let hir_id = self.lctx.allocate_hir_id_counter(item.id).hir_id; @@ -784,12 +809,10 @@ impl<'a> LoweringContext<'a> { }) } - fn record_body(&mut self, value: hir::Expr, decl: Option<&FnDecl>) -> hir::BodyId { + fn record_body(&mut self, value: hir::Expr, arguments: HirVec) -> hir::BodyId { let body = hir::Body { - arguments: decl.map_or(hir_vec![], |decl| { - decl.inputs.iter().map(|x| self.lower_arg(x)).collect() - }), is_generator: self.is_generator, + arguments, value, }; let id = body.id(); @@ -1112,11 +1135,10 @@ impl<'a> LoweringContext<'a> { capture_clause: CaptureBy, closure_node_id: NodeId, ret_ty: Option<&Ty>, + span: Span, body: impl FnOnce(&mut LoweringContext<'_>) -> hir::Expr, ) -> hir::ExprKind { let prev_is_generator = mem::replace(&mut self.is_generator, true); - let body_expr = body(self); - let span = body_expr.span; let output = match ret_ty { Some(ty) => FunctionRetTy::Ty(P(ty.clone())), None => FunctionRetTy::Default(span), @@ -1126,7 +1148,11 @@ impl<'a> LoweringContext<'a> { output, c_variadic: false }; - let body_id = self.record_body(body_expr, Some(&decl)); + // Lower the arguments before the body otherwise the body will call `lower_def` expecting + // the argument to have been assigned an id already. + let arguments = self.lower_args(Some(&decl)); + let body_expr = body(self); + let body_id = self.record_body(body_expr, arguments); self.is_generator = prev_is_generator; let capture_clause = self.lower_capture_clause(capture_clause); @@ -1157,8 +1183,9 @@ impl<'a> LoweringContext<'a> { F: FnOnce(&mut LoweringContext<'_>) -> hir::Expr, { let prev = mem::replace(&mut self.is_generator, false); + let arguments = self.lower_args(decl); let result = f(self); - let r = self.record_body(result, decl); + let r = self.record_body(result, arguments); self.is_generator = prev; return r; } @@ -2224,10 +2251,17 @@ impl<'a> LoweringContext<'a> { init: l.init.as_ref().map(|e| P(self.lower_expr(e))), span: l.span, attrs: l.attrs.clone(), - source: hir::LocalSource::Normal, + source: self.lower_local_source(l.source), }, ids) } + fn lower_local_source(&mut self, ls: LocalSource) -> hir::LocalSource { + match ls { + LocalSource::Normal => hir::LocalSource::Normal, + LocalSource::AsyncFn => hir::LocalSource::AsyncFn, + } + } + fn lower_mutability(&mut self, m: Mutability) -> hir::Mutability { match m { Mutability::Mutable => hir::MutMutable, @@ -2235,11 +2269,23 @@ impl<'a> LoweringContext<'a> { } } + fn lower_args(&mut self, decl: Option<&FnDecl>) -> HirVec { + decl.map_or(hir_vec![], |decl| decl.inputs.iter().map(|x| self.lower_arg(x)).collect()) + } + fn lower_arg(&mut self, arg: &Arg) -> hir::Arg { let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(arg.id); hir::Arg { hir_id, pat: self.lower_pat(&arg.pat), + source: self.lower_arg_source(&arg.source), + } + } + + fn lower_arg_source(&mut self, source: &ArgSource) -> hir::ArgSource { + match source { + ArgSource::Normal => hir::ArgSource::Normal, + ArgSource::AsyncFn(pat) => hir::ArgSource::AsyncFn(self.lower_pat(pat)), } } @@ -2993,15 +3039,21 @@ impl<'a> LoweringContext<'a> { fn lower_async_body( &mut self, decl: &FnDecl, - asyncness: IsAsync, + asyncness: &IsAsync, body: &Block, ) -> hir::BodyId { - self.lower_body(Some(decl), |this| { - if let IsAsync::Async { closure_id, .. } = asyncness { + self.lower_body(Some(&decl), |this| { + if let IsAsync::Async { closure_id, ref arguments, .. } = asyncness { + let mut body = body.clone(); + + for a in arguments.iter().rev() { + body.stmts.insert(0, a.stmt.clone()); + } + let async_expr = this.make_async_expr( - CaptureBy::Value, closure_id, None, + CaptureBy::Value, *closure_id, None, body.span, |this| { - let body = this.lower_block(body, false); + let body = this.lower_block(&body, false); this.expr_block(body, ThinVec::new()) }); this.expr(body.span, async_expr, ThinVec::new()) @@ -3060,26 +3112,42 @@ impl<'a> LoweringContext<'a> { value ) } - ItemKind::Fn(ref decl, header, ref generics, ref body) => { + ItemKind::Fn(ref decl, ref header, ref generics, ref body) => { let fn_def_id = self.resolver.definitions().local_def_id(id); self.with_new_scopes(|this| { - // Note: we don't need to change the return type from `T` to - // `impl Future` here because lower_body - // only cares about the input argument patterns in the function - // declaration (decl), not the return types. - let body_id = this.lower_async_body(decl, header.asyncness.node, body); + let mut lower_fn = |decl: &FnDecl| { + // Note: we don't need to change the return type from `T` to + // `impl Future` here because lower_body + // only cares about the input argument patterns in the function + // declaration (decl), not the return types. + let body_id = this.lower_async_body(&decl, &header.asyncness.node, body); - let (generics, fn_decl) = this.add_in_band_defs( - generics, - fn_def_id, - AnonymousLifetimeMode::PassThrough, - |this, idty| this.lower_fn_decl( - decl, - Some((fn_def_id, idty)), - true, - header.asyncness.node.opt_return_id() - ), - ); + let (generics, fn_decl) = this.add_in_band_defs( + generics, + fn_def_id, + AnonymousLifetimeMode::PassThrough, + |this, idty| this.lower_fn_decl( + &decl, + Some((fn_def_id, idty)), + true, + header.asyncness.node.opt_return_id() + ), + ); + + (body_id, generics, fn_decl) + }; + + let (body_id, generics, fn_decl) = if let IsAsync::Async { + arguments, .. + } = &header.asyncness.node { + let mut decl = decl.clone(); + // Replace the arguments of this async function with the generated + // arguments that will be moved into the closure. + decl.inputs = arguments.clone().drain(..).map(|a| a.arg).collect(); + lower_fn(&decl) + } else { + lower_fn(decl) + }; hir::ItemKind::Fn( fn_decl, @@ -3558,15 +3626,33 @@ impl<'a> LoweringContext<'a> { ) } ImplItemKind::Method(ref sig, ref body) => { - let body_id = self.lower_async_body(&sig.decl, sig.header.asyncness.node, body); - let impl_trait_return_allow = !self.is_in_trait_impl; - let (generics, sig) = self.lower_method_sig( - &i.generics, - sig, - impl_item_def_id, - impl_trait_return_allow, - sig.header.asyncness.node.opt_return_id(), - ); + let mut lower_method = |sig: &MethodSig| { + let body_id = self.lower_async_body( + &sig.decl, &sig.header.asyncness.node, body + ); + let impl_trait_return_allow = !self.is_in_trait_impl; + let (generics, sig) = self.lower_method_sig( + &i.generics, + sig, + impl_item_def_id, + impl_trait_return_allow, + sig.header.asyncness.node.opt_return_id(), + ); + (body_id, generics, sig) + }; + + let (body_id, generics, sig) = if let IsAsync::Async { + ref arguments, .. + } = sig.header.asyncness.node { + let mut sig = sig.clone(); + // Replace the arguments of this async function with the generated + // arguments that will be moved into the closure. + sig.decl.inputs = arguments.clone().drain(..).map(|a| a.arg).collect(); + lower_method(&sig) + } else { + lower_method(sig) + }; + (generics, hir::ImplItemKind::Method(sig, body_id)) } ImplItemKind::Type(ref ty) => ( @@ -3760,7 +3846,7 @@ impl<'a> LoweringContext<'a> { impl_trait_return_allow: bool, is_async: Option, ) -> (hir::Generics, hir::MethodSig) { - let header = self.lower_fn_header(sig.header); + let header = self.lower_fn_header(&sig.header); let (generics, decl) = self.add_in_band_defs( generics, fn_def_id, @@ -3782,10 +3868,10 @@ impl<'a> LoweringContext<'a> { } } - fn lower_fn_header(&mut self, h: FnHeader) -> hir::FnHeader { + fn lower_fn_header(&mut self, h: &FnHeader) -> hir::FnHeader { hir::FnHeader { unsafety: self.lower_unsafety(h.unsafety), - asyncness: self.lower_asyncness(h.asyncness.node), + asyncness: self.lower_asyncness(&h.asyncness.node), constness: self.lower_constness(h.constness), abi: h.abi, } @@ -3805,7 +3891,7 @@ impl<'a> LoweringContext<'a> { } } - fn lower_asyncness(&mut self, a: IsAsync) -> hir::IsAsync { + fn lower_asyncness(&mut self, a: &IsAsync) -> hir::IsAsync { match a { IsAsync::Async { .. } => hir::IsAsync::Async, IsAsync::NotAsync => hir::IsAsync::NotAsync, @@ -4110,7 +4196,7 @@ impl<'a> LoweringContext<'a> { hir::MatchSource::Normal, ), ExprKind::Async(capture_clause, closure_node_id, ref block) => { - self.make_async_expr(capture_clause, closure_node_id, None, |this| { + self.make_async_expr(capture_clause, closure_node_id, None, block.span, |this| { this.with_new_scopes(|this| { let block = this.lower_block(block, false); this.expr_block(block, ThinVec::new()) @@ -4118,7 +4204,7 @@ impl<'a> LoweringContext<'a> { }) } ExprKind::Closure( - capture_clause, asyncness, movability, ref decl, ref body, fn_decl_span + capture_clause, ref asyncness, movability, ref decl, ref body, fn_decl_span ) => { if let IsAsync::Async { closure_id, .. } = asyncness { let outer_decl = FnDecl { @@ -4156,7 +4242,7 @@ impl<'a> LoweringContext<'a> { Some(&**ty) } else { None }; let async_body = this.make_async_expr( - capture_clause, closure_id, async_ret_ty, + capture_clause, *closure_id, async_ret_ty, body.span, |this| { this.with_new_scopes(|this| this.lower_expr(body)) }); diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs index 1a3bbc5ecc49..0fa973853221 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -68,16 +68,17 @@ impl<'a> DefCollector<'a> { id: NodeId, name: Name, span: Span, - header: &FnHeader, + header: &'a FnHeader, generics: &'a Generics, decl: &'a FnDecl, body: &'a Block, ) { - let (closure_id, return_impl_trait_id) = match header.asyncness.node { + let (closure_id, return_impl_trait_id, arguments) = match &header.asyncness.node { IsAsync::Async { closure_id, return_impl_trait_id, - } => (closure_id, return_impl_trait_id), + arguments, + } => (closure_id, return_impl_trait_id, arguments), _ => unreachable!(), }; @@ -86,17 +87,31 @@ impl<'a> DefCollector<'a> { let fn_def_data = DefPathData::ValueNs(name.as_interned_str()); let fn_def = self.create_def(id, fn_def_data, ITEM_LIKE_SPACE, span); return self.with_parent(fn_def, |this| { - this.create_def(return_impl_trait_id, DefPathData::ImplTrait, REGULAR_SPACE, span); + this.create_def(*return_impl_trait_id, DefPathData::ImplTrait, REGULAR_SPACE, span); visit::walk_generics(this, generics); - visit::walk_fn_decl(this, decl); - let closure_def = this.create_def(closure_id, - DefPathData::ClosureExpr, - REGULAR_SPACE, - span); + // Walk the generated arguments for the `async fn`. + for a in arguments { + use visit::Visitor; + this.visit_ty(&a.arg.ty); + } + + // We do not invoke `walk_fn_decl` as this will walk the arguments that are being + // replaced. + visit::walk_fn_ret_ty(this, &decl.output); + + let closure_def = this.create_def( + *closure_id, DefPathData::ClosureExpr, REGULAR_SPACE, span, + ); this.with_parent(closure_def, |this| { - visit::walk_block(this, body); + for a in arguments { + use visit::Visitor; + // Walk each of the generated statements before the regular block body. + this.visit_stmt(&a.stmt); + } + + visit::walk_block(this, &body); }) }) } @@ -290,7 +305,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { match expr.node { ExprKind::Mac(..) => return self.visit_macro_invoc(expr.id), - ExprKind::Closure(_, asyncness, ..) => { + ExprKind::Closure(_, ref asyncness, ..) => { let closure_def = self.create_def(expr.id, DefPathData::ClosureExpr, REGULAR_SPACE, @@ -300,7 +315,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { // Async closures desugar to closures inside of closures, so // we must create two defs. if let IsAsync::Async { closure_id, .. } = asyncness { - let async_def = self.create_def(closure_id, + let async_def = self.create_def(*closure_id, DefPathData::ClosureExpr, REGULAR_SPACE, expr.span); diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 630c163bcaf5..f114f0fc2369 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1583,6 +1583,17 @@ pub enum LocalSource { Normal, /// A desugared `for _ in _ { .. }` loop. ForLoopDesugar, + /// When lowering async functions, we create locals within the `async move` so that + /// all arguments are dropped after the future is polled. + /// + /// ```ignore (pseudo-Rust) + /// async fn foo( @ x: Type) { + /// async move { + /// let = x; + /// } + /// } + /// ``` + AsyncFn, } /// Hints at the original code for a `match _ { .. }`. @@ -1883,6 +1894,26 @@ pub struct InlineAsm { pub struct Arg { pub pat: P, pub hir_id: HirId, + pub source: ArgSource, +} + +impl Arg { + /// Returns the pattern representing the original binding for this argument. + pub fn original_pat(&self) -> &P { + match &self.source { + ArgSource::Normal => &self.pat, + ArgSource::AsyncFn(pat) => &pat, + } + } +} + +/// Represents the source of an argument in a function header. +#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] +pub enum ArgSource { + /// Argument as specified by the user. + Normal, + /// Generated argument from `async fn` lowering, contains the original binding pattern. + AsyncFn(P), } /// Represents the header (not the body) of a function declaration. diff --git a/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs b/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs index 86d7a19bc830..944cc8a8b199 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs @@ -86,19 +86,16 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { let sub_is_ret_type = self.is_return_type_anon(scope_def_id_sub, bregion_sub, ty_fndecl_sub); - let span_label_var1 = if let Some(simple_ident) = anon_arg_sup.pat.simple_ident() { - format!(" from `{}`", simple_ident) - } else { - String::new() + let span_label_var1 = match anon_arg_sup.original_pat().simple_ident() { + Some(simple_ident) => format!(" from `{}`", simple_ident), + None => String::new(), }; - let span_label_var2 = if let Some(simple_ident) = anon_arg_sub.pat.simple_ident() { - format!(" into `{}`", simple_ident) - } else { - String::new() + let span_label_var2 = match anon_arg_sub.original_pat().simple_ident() { + Some(simple_ident) => format!(" into `{}`", simple_ident), + None => String::new(), }; - let (span_1, span_2, main_label, span_label) = match (sup_is_ret_type, sub_is_ret_type) { (None, None) => { let (main_label_1, span_label_1) = if ty_sup.hir_id == ty_sub.hir_id { diff --git a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs index 7403a5d7dbb0..2d7587b11b6f 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs @@ -95,13 +95,12 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { } } - let (error_var, span_label_var) = if let Some(simple_ident) = arg.pat.simple_ident() { - ( + let (error_var, span_label_var) = match arg.original_pat().simple_ident() { + Some(simple_ident) => ( format!("the type of `{}`", simple_ident), format!("the type of `{}`", simple_ident), - ) - } else { - ("parameter type".to_owned(), "type".to_owned()) + ), + None => ("parameter type".to_owned(), "type".to_owned()), }; let mut diag = struct_span_err!( diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 747f0a6ae872..f33250343513 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -111,31 +111,31 @@ pub struct InferCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { /// and for error reporting logic to read arbitrary node types. pub in_progress_tables: Option<&'a RefCell>>, - // Cache for projections. This cache is snapshotted along with the - // infcx. - // - // Public so that `traits::project` can use it. + /// Cache for projections. This cache is snapshotted along with the + /// infcx. + /// + /// Public so that `traits::project` can use it. pub projection_cache: RefCell>, - // We instantiate UnificationTable with bounds because the - // types that might instantiate a general type variable have an - // order, represented by its upper and lower bounds. + /// We instantiate `UnificationTable` with `bounds` because the + /// types that might instantiate a general type variable have an + /// order, represented by its upper and lower bounds. pub type_variables: RefCell>, - // Map from integral variable to the kind of integer it represents + /// Map from integral variable to the kind of integer it represents int_unification_table: RefCell>>, - // Map from floating variable to the kind of float it represents + /// Map from floating variable to the kind of float it represents float_unification_table: RefCell>>, - // Tracks the set of region variables and the constraints between - // them. This is initially `Some(_)` but when - // `resolve_regions_and_report_errors` is invoked, this gets set - // to `None` -- further attempts to perform unification etc may - // fail if new region constraints would've been added. + /// Tracks the set of region variables and the constraints between + /// them. This is initially `Some(_)` but when + /// `resolve_regions_and_report_errors` is invoked, this gets set + /// to `None` -- further attempts to perform unification etc may + /// fail if new region constraints would've been added. region_constraints: RefCell>>, - // Once region inference is done, the values for each variable. + /// Once region inference is done, the values for each variable. lexical_region_resolutions: RefCell>>, /// Caches the results of trait selection. This cache is used @@ -145,65 +145,65 @@ pub struct InferCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { /// Caches the results of trait evaluation. pub evaluation_cache: traits::EvaluationCache<'tcx>, - // the set of predicates on which errors have been reported, to - // avoid reporting the same error twice. + /// the set of predicates on which errors have been reported, to + /// avoid reporting the same error twice. pub reported_trait_errors: RefCell>>>, - // When an error occurs, we want to avoid reporting "derived" - // errors that are due to this original failure. Normally, we - // handle this with the `err_count_on_creation` count, which - // basically just tracks how many errors were reported when we - // started type-checking a fn and checks to see if any new errors - // have been reported since then. Not great, but it works. - // - // However, when errors originated in other passes -- notably - // resolve -- this heuristic breaks down. Therefore, we have this - // auxiliary flag that one can set whenever one creates a - // type-error that is due to an error in a prior pass. - // - // Don't read this flag directly, call `is_tainted_by_errors()` - // and `set_tainted_by_errors()`. + /// When an error occurs, we want to avoid reporting "derived" + /// errors that are due to this original failure. Normally, we + /// handle this with the `err_count_on_creation` count, which + /// basically just tracks how many errors were reported when we + /// started type-checking a fn and checks to see if any new errors + /// have been reported since then. Not great, but it works. + /// + /// However, when errors originated in other passes -- notably + /// resolve -- this heuristic breaks down. Therefore, we have this + /// auxiliary flag that one can set whenever one creates a + /// type-error that is due to an error in a prior pass. + /// + /// Don't read this flag directly, call `is_tainted_by_errors()` + /// and `set_tainted_by_errors()`. tainted_by_errors_flag: Cell, - // Track how many errors were reported when this infcx is created. - // If the number of errors increases, that's also a sign (line - // `tained_by_errors`) to avoid reporting certain kinds of errors. + /// Track how many errors were reported when this infcx is created. + /// If the number of errors increases, that's also a sign (line + /// `tained_by_errors`) to avoid reporting certain kinds of errors. err_count_on_creation: usize, - // This flag is true while there is an active snapshot. + /// This flag is true while there is an active snapshot. in_snapshot: Cell, - // A set of constraints that regionck must validate. Each - // constraint has the form `T:'a`, meaning "some type `T` must - // outlive the lifetime 'a". These constraints derive from - // instantiated type parameters. So if you had a struct defined - // like - // - // struct Foo { ... } - // - // then in some expression `let x = Foo { ... }` it will - // instantiate the type parameter `T` with a fresh type `$0`. At - // the same time, it will record a region obligation of - // `$0:'static`. This will get checked later by regionck. (We - // can't generally check these things right away because we have - // to wait until types are resolved.) - // - // These are stored in a map keyed to the id of the innermost - // enclosing fn body / static initializer expression. This is - // because the location where the obligation was incurred can be - // relevant with respect to which sublifetime assumptions are in - // place. The reason that we store under the fn-id, and not - // something more fine-grained, is so that it is easier for - // regionck to be sure that it has found *all* the region - // obligations (otherwise, it's easy to fail to walk to a - // particular node-id). - // - // Before running `resolve_regions_and_report_errors`, the creator - // of the inference context is expected to invoke - // `process_region_obligations` (defined in `self::region_obligations`) - // for each body-id in this map, which will process the - // obligations within. This is expected to be done 'late enough' - // that all type inference variables have been bound and so forth. + /// A set of constraints that regionck must validate. Each + /// constraint has the form `T:'a`, meaning "some type `T` must + /// outlive the lifetime 'a". These constraints derive from + /// instantiated type parameters. So if you had a struct defined + /// like + /// + /// struct Foo { ... } + /// + /// then in some expression `let x = Foo { ... }` it will + /// instantiate the type parameter `T` with a fresh type `$0`. At + /// the same time, it will record a region obligation of + /// `$0:'static`. This will get checked later by regionck. (We + /// can't generally check these things right away because we have + /// to wait until types are resolved.) + /// + /// These are stored in a map keyed to the id of the innermost + /// enclosing fn body / static initializer expression. This is + /// because the location where the obligation was incurred can be + /// relevant with respect to which sublifetime assumptions are in + /// place. The reason that we store under the fn-id, and not + /// something more fine-grained, is so that it is easier for + /// regionck to be sure that it has found *all* the region + /// obligations (otherwise, it's easy to fail to walk to a + /// particular node-id). + /// + /// Before running `resolve_regions_and_report_errors`, the creator + /// of the inference context is expected to invoke + /// `process_region_obligations` (defined in `self::region_obligations`) + /// for each body-id in this map, which will process the + /// obligations within. This is expected to be done 'late enough' + /// that all type inference variables have been bound and so forth. pub region_obligations: RefCell)>>, /// What is the innermost universe we have created? Starts out as @@ -247,85 +247,85 @@ pub struct TypeTrace<'tcx> { /// See `error_reporting` module for more details #[derive(Clone, Debug)] pub enum SubregionOrigin<'tcx> { - // Arose from a subtyping relation + /// Arose from a subtyping relation Subtype(TypeTrace<'tcx>), - // Stack-allocated closures cannot outlive innermost loop - // or function so as to ensure we only require finite stack + /// Stack-allocated closures cannot outlive innermost loop + /// or function so as to ensure we only require finite stack InfStackClosure(Span), - // Invocation of closure must be within its lifetime + /// Invocation of closure must be within its lifetime InvokeClosure(Span), - // Dereference of reference must be within its lifetime + /// Dereference of reference must be within its lifetime DerefPointer(Span), - // Closure bound must not outlive captured free variables + /// Closure bound must not outlive captured free variables FreeVariable(Span, ast::NodeId), - // Index into slice must be within its lifetime + /// Index into slice must be within its lifetime IndexSlice(Span), - // When casting `&'a T` to an `&'b Trait` object, - // relating `'a` to `'b` + /// When casting `&'a T` to an `&'b Trait` object, + /// relating `'a` to `'b` RelateObjectBound(Span), - // Some type parameter was instantiated with the given type, - // and that type must outlive some region. + /// Some type parameter was instantiated with the given type, + /// and that type must outlive some region. RelateParamBound(Span, Ty<'tcx>), - // The given region parameter was instantiated with a region - // that must outlive some other region. + /// The given region parameter was instantiated with a region + /// that must outlive some other region. RelateRegionParamBound(Span), - // A bound placed on type parameters that states that must outlive - // the moment of their instantiation. + /// A bound placed on type parameters that states that must outlive + /// the moment of their instantiation. RelateDefaultParamBound(Span, Ty<'tcx>), - // Creating a pointer `b` to contents of another reference + /// Creating a pointer `b` to contents of another reference Reborrow(Span), - // Creating a pointer `b` to contents of an upvar + /// Creating a pointer `b` to contents of an upvar ReborrowUpvar(Span, ty::UpvarId), - // Data with type `Ty<'tcx>` was borrowed + /// Data with type `Ty<'tcx>` was borrowed DataBorrowed(Ty<'tcx>, Span), - // (&'a &'b T) where a >= b + /// (&'a &'b T) where a >= b ReferenceOutlivesReferent(Ty<'tcx>, Span), - // Type or region parameters must be in scope. + /// Type or region parameters must be in scope. ParameterInScope(ParameterOrigin, Span), - // The type T of an expression E must outlive the lifetime for E. + /// The type T of an expression E must outlive the lifetime for E. ExprTypeIsNotInScope(Ty<'tcx>, Span), - // A `ref b` whose region does not enclose the decl site + /// A `ref b` whose region does not enclose the decl site BindingTypeIsNotValidAtDecl(Span), - // Regions appearing in a method receiver must outlive method call + /// Regions appearing in a method receiver must outlive method call CallRcvr(Span), - // Regions appearing in a function argument must outlive func call + /// Regions appearing in a function argument must outlive func call CallArg(Span), - // Region in return type of invoked fn must enclose call + /// Region in return type of invoked fn must enclose call CallReturn(Span), - // Operands must be in scope + /// Operands must be in scope Operand(Span), - // Region resulting from a `&` expr must enclose the `&` expr + /// Region resulting from a `&` expr must enclose the `&` expr AddrOf(Span), - // An auto-borrow that does not enclose the expr where it occurs + /// An auto-borrow that does not enclose the expr where it occurs AutoBorrow(Span), - // Region constraint arriving from destructor safety + /// Region constraint arriving from destructor safety SafeDestructor(Span), - // Comparing the signature and requirements of an impl method against - // the containing trait. + /// Comparing the signature and requirements of an impl method against + /// the containing trait. CompareImplMethodObligation { span: Span, item_name: ast::Name, @@ -361,35 +361,35 @@ pub enum LateBoundRegionConversionTime { /// See `error_reporting` module for more details #[derive(Copy, Clone, Debug)] pub enum RegionVariableOrigin { - // Region variables created for ill-categorized reasons, - // mostly indicates places in need of refactoring + /// Region variables created for ill-categorized reasons, + /// mostly indicates places in need of refactoring MiscVariable(Span), - // Regions created by a `&P` or `[...]` pattern + /// Regions created by a `&P` or `[...]` pattern PatternRegion(Span), - // Regions created by `&` operator + /// Regions created by `&` operator AddrOfRegion(Span), - // Regions created as part of an autoref of a method receiver + /// Regions created as part of an autoref of a method receiver Autoref(Span), - // Regions created as part of an automatic coercion + /// Regions created as part of an automatic coercion Coercion(Span), - // Region variables created as the values for early-bound regions + /// Region variables created as the values for early-bound regions EarlyBoundRegion(Span, InternedString), - // Region variables created for bound regions - // in a function or method that is called + /// Region variables created for bound regions + /// in a function or method that is called LateBoundRegion(Span, ty::BoundRegion, LateBoundRegionConversionTime), UpvarRegion(ty::UpvarId, Span), BoundRegionInCoherence(ast::Name), - // This origin is used for the inference variables that we create - // during NLL region processing. + /// This origin is used for the inference variables that we create + /// during NLL region processing. NLL(NLLRegionVariableOrigin), } @@ -686,22 +686,22 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } - // Clear the "currently in a snapshot" flag, invoke the closure, - // then restore the flag to its original value. This flag is a - // debugging measure designed to detect cases where we start a - // snapshot, create type variables, and register obligations - // which may involve those type variables in the fulfillment cx, - // potentially leaving "dangling type variables" behind. - // In such cases, an assertion will fail when attempting to - // register obligations, within a snapshot. Very useful, much - // better than grovelling through megabytes of RUST_LOG output. - // - // HOWEVER, in some cases the flag is unhelpful. In particular, we - // sometimes create a "mini-fulfilment-cx" in which we enroll - // obligations. As long as this fulfillment cx is fully drained - // before we return, this is not a problem, as there won't be any - // escaping obligations in the main cx. In those cases, you can - // use this function. + /// Clear the "currently in a snapshot" flag, invoke the closure, + /// then restore the flag to its original value. This flag is a + /// debugging measure designed to detect cases where we start a + /// snapshot, create type variables, and register obligations + /// which may involve those type variables in the fulfillment cx, + /// potentially leaving "dangling type variables" behind. + /// In such cases, an assertion will fail when attempting to + /// register obligations, within a snapshot. Very useful, much + /// better than grovelling through megabytes of `RUST_LOG` output. + /// + /// HOWEVER, in some cases the flag is unhelpful. In particular, we + /// sometimes create a "mini-fulfilment-cx" in which we enroll + /// obligations. As long as this fulfillment cx is fully drained + /// before we return, this is not a problem, as there won't be any + /// escaping obligations in the main cx. In those cases, you can + /// use this function. pub fn save_and_restore_in_snapshot_flag(&self, func: F) -> R where F: FnOnce(&Self) -> R, @@ -828,7 +828,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { r } - // Execute `f` in a snapshot, and commit the bindings it creates + /// Execute `f` in a snapshot, and commit the bindings it creates. pub fn in_snapshot(&self, f: F) -> T where F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> T, @@ -854,9 +854,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { /// Scan the constraints produced since `snapshot` began and returns: /// - /// - None -- if none of them involve "region outlives" constraints - /// - Some(true) -- if there are `'a: 'b` constraints where `'a` or `'b` is a placehodler - /// - Some(false) -- if there are `'a: 'b` constraints but none involve placeholders + /// - `None` -- if none of them involve "region outlives" constraints + /// - `Some(true)` -- if there are `'a: 'b` constraints where `'a` or `'b` is a placeholder + /// - `Some(false)` -- if there are `'a: 'b` constraints but none involve placeholders pub fn region_constraints_added_in_snapshot( &self, snapshot: &CombinedSnapshot<'a, 'tcx>, @@ -1292,19 +1292,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { self.type_variables.borrow_mut().root_var(var) } + /// Where possible, replaces type/int/float variables in + /// `value` with their final value. Note that region variables + /// are unaffected. If a type variable has not been unified, it + /// is left as is. This is an idempotent operation that does + /// not affect inference state in any way and so you can do it + /// at will. pub fn resolve_type_vars_if_possible(&self, value: &T) -> T where T: TypeFoldable<'tcx>, { - /*! - * Where possible, replaces type/int/float variables in - * `value` with their final value. Note that region variables - * are unaffected. If a type variable has not been unified, it - * is left as is. This is an idempotent operation that does - * not affect inference state in any way and so you can do it - * at will. - */ - if !value.needs_infer() { return value.clone(); // avoid duplicated subst-folding } diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 34bf4adffc6b..f5cb4cfa29f5 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -1326,6 +1326,25 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T> run_early_pass!(self, check_mac, mac); } + + fn visit_fn_header(&mut self, header: &'a ast::FnHeader) { + // Unlike in HIR lowering and name resolution, the `AsyncArgument` statements are not added + // to the function body and the arguments do not replace those in the declaration. They are + // still visited manually here so that buffered lints can be emitted. + if let ast::IsAsync::Async { ref arguments, .. } = header.asyncness.node { + for a in arguments { + // Visit the argument.. + self.visit_pat(&a.arg.pat); + if let ast::ArgSource::AsyncFn(pat) = &a.arg.source { + self.visit_pat(pat); + } + self.visit_ty(&a.arg.ty); + + // ..and the statement. + self.visit_stmt(&a.stmt); + } + } + } } struct LateLintPassObjects<'a> { diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 3306bcae2123..814776c21bd2 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -2421,7 +2421,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let help_name = if let Some(body) = parent { let arg = &self.tcx.hir().body(body).arguments[index]; - format!("`{}`", self.tcx.hir().hir_to_pretty_string(arg.pat.hir_id)) + format!("`{}`", self.tcx.hir().hir_to_pretty_string(arg.original_pat().hir_id)) } else { format!("argument {}", index + 1) }; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 56fafacd722b..67be228d232e 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -438,12 +438,12 @@ bitflags! { // FIXME: Rename this to the actual property since it's used for generators too const HAS_TY_CLOSURE = 1 << 9; - // `true` if there are "names" of types and regions and so forth - // that are local to a particular fn + /// `true` if there are "names" of types and regions and so forth + /// that are local to a particular fn const HAS_FREE_LOCAL_NAMES = 1 << 10; - // Present if the type belongs in a local type context. - // Only set for Infer other than Fresh. + /// Present if the type belongs in a local type context. + /// Only set for Infer other than Fresh. const KEEP_IN_LOCAL_TCX = 1 << 11; // Is there a projection that does not involve a bound region? @@ -462,9 +462,9 @@ bitflags! { TypeFlags::HAS_SELF.bits | TypeFlags::HAS_RE_EARLY_BOUND.bits; - // Flags representing the nominal content of a type, - // computed by FlagsComputation. If you add a new nominal - // flag, it should be added here too. + /// Flags representing the nominal content of a type, + /// computed by FlagsComputation. If you add a new nominal + /// flag, it should be added here too. const NOMINAL_FLAGS = TypeFlags::HAS_PARAMS.bits | TypeFlags::HAS_SELF.bits | TypeFlags::HAS_TY_INFER.bits | diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index 3ba2c4cbf6c8..b8ae0430502b 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -439,16 +439,16 @@ struct SubstFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: &'a [Kind<'tcx>], - // The location for which the substitution is performed, if available. + /// The location for which the substitution is performed, if available. span: Option, - // The root type that is being substituted, if available. + /// The root type that is being substituted, if available. root_ty: Option>, - // Depth of type stack + /// Depth of type stack ty_stack_depth: usize, - // Number of region binders we have passed through while doing the substitution + /// Number of region binders we have passed through while doing the substitution binders_passed: u32, } diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs index fe21b19b52a3..f1b8d532eeb7 100644 --- a/src/librustc_codegen_llvm/llvm_util.rs +++ b/src/librustc_codegen_llvm/llvm_util.rs @@ -145,6 +145,7 @@ const X86_WHITELIST: &[(&str, Option<&str>)] = &[ ("bmi1", None), ("bmi2", None), ("cmpxchg16b", Some("cmpxchg16b_target_feature")), + ("f16c", Some("f16c_target_feature")), ("fma", None), ("fxsr", None), ("lzcnt", None), diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index e0b9921ca8d6..2d7f8b1a1aec 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -76,6 +76,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MatchVisitor<'a, 'tcx> { self.check_irrefutable(&loc.pat, match loc.source { hir::LocalSource::Normal => "local binding", hir::LocalSource::ForLoopDesugar => "`for` loop binding", + hir::LocalSource::AsyncFn => "async fn binding", }); // Check legality of move bindings and `@` patterns. diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index a9a604cad8bc..9dd8a7050fd2 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -222,7 +222,7 @@ impl<'a> AstValidator<'a> { } } - fn check_trait_fn_not_async(&self, span: Span, asyncness: IsAsync) { + fn check_trait_fn_not_async(&self, span: Span, asyncness: &IsAsync) { if asyncness.is_async() { struct_span_err!(self.session, span, E0706, "trait fns cannot be declared `async`").emit() @@ -570,7 +570,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { self.invalid_visibility(&impl_item.vis, None); if let ImplItemKind::Method(ref sig, _) = impl_item.node { self.check_trait_fn_not_const(sig.header.constness); - self.check_trait_fn_not_async(impl_item.span, sig.header.asyncness.node); + self.check_trait_fn_not_async(impl_item.span, &sig.header.asyncness.node); } } } @@ -642,7 +642,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { self.no_questions_in_bounds(bounds, "supertraits", true); for trait_item in trait_items { if let TraitItemKind::Method(ref sig, ref block) = trait_item.node { - self.check_trait_fn_not_async(trait_item.span, sig.header.asyncness.node); + self.check_trait_fn_not_async(trait_item.span, &sig.header.asyncness.node); self.check_trait_fn_not_const(sig.header.constness); if block.is_none() { self.check_decl_no_pat(&sig.decl, |span, mut_ident| { diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index edb3efb78a39..57e17eb6878e 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -948,6 +948,16 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> { intravisit::walk_pat(self, pat); } + + fn visit_argument_source(&mut self, s: &'tcx hir::ArgSource) { + match s { + // Don't visit the pattern in `ArgSource::AsyncFn`, it contains a pattern which has + // a `NodeId` w/out a type, as it is only used for getting the name of the original + // pattern for diagnostics where only an `hir::Arg` is present. + hir::ArgSource::AsyncFn(..) => {}, + _ => intravisit::walk_argument_source(self, s), + } + } } //////////////////////////////////////////////////////////////////////////////////////////// @@ -1133,6 +1143,16 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { intravisit::walk_pat(self, pattern); } + fn visit_argument_source(&mut self, s: &'tcx hir::ArgSource) { + match s { + // Don't visit the pattern in `ArgSource::AsyncFn`, it contains a pattern which has + // a `NodeId` w/out a type, as it is only used for getting the name of the original + // pattern for diagnostics where only an `hir::Arg` is present. + hir::ArgSource::AsyncFn(..) => {}, + _ => intravisit::walk_argument_source(self, s), + } + } + fn visit_local(&mut self, local: &'tcx hir::Local) { if let Some(ref init) = local.init { if self.check_expr_pat_type(init.hir_id, init.span) { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 8df83120738c..2ef05f7efeb7 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -817,13 +817,13 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { debug!("(resolving function) entering function"); let (rib_kind, asyncness) = match function_kind { FnKind::ItemFn(_, ref header, ..) => - (FnItemRibKind, header.asyncness.node), + (FnItemRibKind, &header.asyncness.node), FnKind::Method(_, ref sig, _, _) => - (TraitOrImplItemRibKind, sig.header.asyncness.node), + (TraitOrImplItemRibKind, &sig.header.asyncness.node), FnKind::Closure(_) => // Async closures aren't resolved through `visit_fn`-- they're // processed separately - (ClosureRibKind(node_id), IsAsync::NotAsync), + (ClosureRibKind(node_id), &IsAsync::NotAsync), }; // Create a value rib for the function. @@ -834,26 +834,42 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { // Add each argument to the rib. let mut bindings_list = FxHashMap::default(); - for argument in &declaration.inputs { + let mut add_argument = |argument: &ast::Arg| { self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list); - self.visit_ty(&argument.ty); - debug!("(resolving function) recorded argument"); + }; + + // Walk the generated async arguments if this is an `async fn`, otherwise walk the + // normal arguments. + if let IsAsync::Async { ref arguments, .. } = asyncness { + for a in arguments { add_argument(&a.arg); } + } else { + for a in &declaration.inputs { add_argument(a); } } + visit::walk_fn_ret_ty(self, &declaration.output); // Resolve the function body, potentially inside the body of an async closure if let IsAsync::Async { closure_id, .. } = asyncness { - let rib_kind = ClosureRibKind(closure_id); + let rib_kind = ClosureRibKind(*closure_id); self.ribs[ValueNS].push(Rib::new(rib_kind)); self.label_ribs.push(Rib::new(rib_kind)); } match function_kind { - FnKind::ItemFn(.., body) | - FnKind::Method(.., body) => { - self.visit_block(body); + FnKind::ItemFn(.., body) | FnKind::Method(.., body) => { + if let IsAsync::Async { ref arguments, .. } = asyncness { + let mut body = body.clone(); + // Insert the generated statements into the body before attempting to + // resolve names. + for a in arguments { + body.stmts.insert(0, a.stmt.clone()); + } + self.visit_block(&body); + } else { + self.visit_block(body); + } } FnKind::Closure(body) => { self.visit_expr(body); diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 90fe6a60dd77..5ac75d012752 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -374,7 +374,7 @@ impl Sig for ast::Item { Ok(extend_sig(ty, text, defs, vec![])) } - ast::ItemKind::Fn(ref decl, header, ref generics, _) => { + ast::ItemKind::Fn(ref decl, ref header, ref generics, _) => { let mut text = String::new(); if header.constness.node == ast::Constness::Const { text.push_str("const "); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 15190f569655..79477b6fea87 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1005,6 +1005,16 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> { // Don't descend into the bodies of nested closures fn visit_fn(&mut self, _: intravisit::FnKind<'gcx>, _: &'gcx hir::FnDecl, _: hir::BodyId, _: Span, _: hir::HirId) { } + + fn visit_argument_source(&mut self, s: &'gcx hir::ArgSource) { + match s { + // Don't visit the pattern in `ArgSource::AsyncFn`, it contains a pattern which has + // a `NodeId` w/out a type, as it is only used for getting the name of the original + // pattern for diagnostics where only an `hir::Arg` is present. + hir::ArgSource::AsyncFn(..) => {}, + _ => intravisit::walk_argument_source(self, s), + } + } } /// When `check_fn` is invoked on a generator (i.e., a body that diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index d9df4672f147..efff08f66969 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -297,6 +297,16 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> { let ty = self.resolve(&ty, &hir_ty.span); self.write_ty_to_tables(hir_ty.hir_id, ty); } + + fn visit_argument_source(&mut self, s: &'gcx hir::ArgSource) { + match s { + // Don't visit the pattern in `ArgSource::AsyncFn`, it contains a pattern which has + // a `NodeId` w/out a type, as it is only used for getting the name of the original + // pattern for diagnostics where only an `hir::Arg` is present. + hir::ArgSource::AsyncFn(..) => {}, + _ => intravisit::walk_argument_source(self, s), + } + } } impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 586ae6659bb0..4ff16e4a2676 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2017,7 +2017,7 @@ impl<'a> Clean for (&'a [hir::Ty], hir::BodyId) { Arguments { values: self.0.iter().enumerate().map(|(i, ty)| { Argument { - name: name_from_pat(&body.arguments[i].pat), + name: name_from_pat(&body.arguments[i].original_pat()), type_: ty.clean(cx), } }).collect() diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index d91b78c8416b..487c57172d9b 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -930,13 +930,13 @@ themePicker.onblur = handleThemeButtonsBlur; static_files::source_serif_pro::BOLD)?; write(cx.dst.join("SourceSerifPro-It.ttf.woff"), static_files::source_serif_pro::ITALIC)?; - write(cx.dst.join("SourceSerifPro-LICENSE.txt"), + write(cx.dst.join("SourceSerifPro-LICENSE.md"), static_files::source_serif_pro::LICENSE)?; write(cx.dst.join("SourceCodePro-Regular.woff"), static_files::source_code_pro::REGULAR)?; write(cx.dst.join("SourceCodePro-Semibold.woff"), static_files::source_code_pro::SEMIBOLD)?; - write(cx.dst.join("SourceCodePro-LICENSE.txt"), + write(cx.dst.join("SourceCodePro-LICENSE.md"), static_files::source_code_pro::LICENSE)?; write(cx.dst.join("LICENSE-MIT.txt"), static_files::LICENSE_MIT)?; diff --git a/src/librustdoc/html/static/FiraSans-LICENSE.txt b/src/librustdoc/html/static/FiraSans-LICENSE.txt index b4a39671ee94..d444ea92b6f1 100644 --- a/src/librustdoc/html/static/FiraSans-LICENSE.txt +++ b/src/librustdoc/html/static/FiraSans-LICENSE.txt @@ -1,10 +1,5 @@ -Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ -with Reserved Font Name Fira Sans. - -Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ -with Reserved Font Name Fira Mono. - -Copyright (c) 2014, Telefonica S.A. +Digitized data copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A. +with Reserved Font Name < Fira >, This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is copied below, and is also available with a FAQ at: @@ -24,7 +19,7 @@ with others. The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, +fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The diff --git a/src/librustdoc/html/static/FiraSans-Medium.woff b/src/librustdoc/html/static/FiraSans-Medium.woff index 5627227744ae..7d742c5fb7d4 100644 Binary files a/src/librustdoc/html/static/FiraSans-Medium.woff and b/src/librustdoc/html/static/FiraSans-Medium.woff differ diff --git a/src/librustdoc/html/static/FiraSans-Regular.woff b/src/librustdoc/html/static/FiraSans-Regular.woff index 9ff40445bf4a..d8e0363f4e1a 100644 Binary files a/src/librustdoc/html/static/FiraSans-Regular.woff and b/src/librustdoc/html/static/FiraSans-Regular.woff differ diff --git a/src/librustdoc/html/static/SourceCodePro-LICENSE.txt b/src/librustdoc/html/static/SourceCodePro-LICENSE.md similarity index 99% rename from src/librustdoc/html/static/SourceCodePro-LICENSE.txt rename to src/librustdoc/html/static/SourceCodePro-LICENSE.md index 07542572e33b..1177330426de 100644 --- a/src/librustdoc/html/static/SourceCodePro-LICENSE.txt +++ b/src/librustdoc/html/static/SourceCodePro-LICENSE.md @@ -18,7 +18,7 @@ with others. The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, +fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The diff --git a/src/librustdoc/html/static/SourceCodePro-Regular.woff b/src/librustdoc/html/static/SourceCodePro-Regular.woff index 5576670903ae..117c7e5142c3 100644 Binary files a/src/librustdoc/html/static/SourceCodePro-Regular.woff and b/src/librustdoc/html/static/SourceCodePro-Regular.woff differ diff --git a/src/librustdoc/html/static/SourceCodePro-Semibold.woff b/src/librustdoc/html/static/SourceCodePro-Semibold.woff index ca972a11dc42..270873a86a09 100644 Binary files a/src/librustdoc/html/static/SourceCodePro-Semibold.woff and b/src/librustdoc/html/static/SourceCodePro-Semibold.woff differ diff --git a/src/librustdoc/html/static/SourceSerifPro-Bold.ttf.woff b/src/librustdoc/html/static/SourceSerifPro-Bold.ttf.woff index e283dae58de6..ca254318fe9e 100644 Binary files a/src/librustdoc/html/static/SourceSerifPro-Bold.ttf.woff and b/src/librustdoc/html/static/SourceSerifPro-Bold.ttf.woff differ diff --git a/src/librustdoc/html/static/SourceSerifPro-It.ttf.woff b/src/librustdoc/html/static/SourceSerifPro-It.ttf.woff index 4bd621c9bd0b..a287bbe6ed3f 100644 Binary files a/src/librustdoc/html/static/SourceSerifPro-It.ttf.woff and b/src/librustdoc/html/static/SourceSerifPro-It.ttf.woff differ diff --git a/src/librustdoc/html/static/SourceSerifPro-LICENSE.txt b/src/librustdoc/html/static/SourceSerifPro-LICENSE.md similarity index 95% rename from src/librustdoc/html/static/SourceSerifPro-LICENSE.txt rename to src/librustdoc/html/static/SourceSerifPro-LICENSE.md index b77d653ad4f0..22cb755f2f1d 100644 --- a/src/librustdoc/html/static/SourceSerifPro-LICENSE.txt +++ b/src/librustdoc/html/static/SourceSerifPro-LICENSE.md @@ -1,4 +1,4 @@ -Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries. +Copyright 2014-2018 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries. This Font Software is licensed under the SIL Open Font License, Version 1.1. diff --git a/src/librustdoc/html/static/SourceSerifPro-Regular.ttf.woff b/src/librustdoc/html/static/SourceSerifPro-Regular.ttf.woff index 96b36a0ed236..a3d55cfdf255 100644 Binary files a/src/librustdoc/html/static/SourceSerifPro-Regular.ttf.woff and b/src/librustdoc/html/static/SourceSerifPro-Regular.ttf.woff differ diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index a1d8cfacc54a..24fe61e977a1 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -91,7 +91,7 @@ pub mod source_serif_pro { pub static ITALIC: &'static [u8] = include_bytes!("static/SourceSerifPro-It.ttf.woff"); /// The file `SourceSerifPro-LICENSE.txt`, the license text for the Source Serif Pro font. - pub static LICENSE: &'static [u8] = include_bytes!("static/SourceSerifPro-LICENSE.txt"); + pub static LICENSE: &'static [u8] = include_bytes!("static/SourceSerifPro-LICENSE.md"); } /// Files related to the Source Code Pro font. @@ -103,7 +103,7 @@ pub mod source_code_pro { pub static SEMIBOLD: &'static [u8] = include_bytes!("static/SourceCodePro-Semibold.woff"); /// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font. - pub static LICENSE: &'static [u8] = include_bytes!("static/SourceCodePro-LICENSE.txt"); + pub static LICENSE: &'static [u8] = include_bytes!("static/SourceCodePro-LICENSE.md"); } /// Files related to the sidebar in rustdoc sources. diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a5472c622e64..334fcfd74f35 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -888,6 +888,17 @@ pub struct Local { pub id: NodeId, pub span: Span, pub attrs: ThinVec, + /// Origin of this local variable. + pub source: LocalSource, +} + +#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug)] +pub enum LocalSource { + /// Local was parsed from source. + Normal, + /// Within `ast::IsAsync::Async`, a local is generated that will contain the moved arguments + /// of an `async fn`. + AsyncFn, } /// An arm of a 'match'. @@ -1725,6 +1736,16 @@ pub struct Arg { pub ty: P, pub pat: P, pub id: NodeId, + pub source: ArgSource, +} + +/// The source of an argument in a function header. +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] +pub enum ArgSource { + /// Argument as written by the user. + Normal, + /// Argument from `async fn` lowering, contains the original binding pattern. + AsyncFn(P), } /// Alternative representation for `Arg`s describing `self` parameter of methods. @@ -1784,6 +1805,7 @@ impl Arg { }), ty, id: DUMMY_NODE_ID, + source: ArgSource::Normal, }; match eself.node { SelfKind::Explicit(ty, mutbl) => arg(mutbl, ty), @@ -1838,18 +1860,35 @@ pub enum Unsafety { Normal, } -#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] +pub struct AsyncArgument { + /// `__arg0` + pub ident: Ident, + /// `__arg0: ` argument to replace existing function argument `: `. + pub arg: Arg, + /// `let : = __arg0;` statement to be inserted at the start of the block. + pub stmt: Stmt, +} + +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum IsAsync { Async { closure_id: NodeId, return_impl_trait_id: NodeId, + /// This field stores the arguments and statements that are used in HIR lowering to + /// ensure that `async fn` arguments are dropped at the correct time. + /// + /// The argument and statements here are generated at parse time as they are required in + /// both the hir lowering, def collection and name resolution and this stops them needing + /// to be created in each place. + arguments: Vec, }, NotAsync, } impl IsAsync { - pub fn is_async(self) -> bool { - if let IsAsync::Async { .. } = self { + pub fn is_async(&self) -> bool { + if let IsAsync::Async { .. } = *self { true } else { false @@ -1857,12 +1896,12 @@ impl IsAsync { } /// In ths case this is an `async` return, the `NodeId` for the generated `impl Trait` item. - pub fn opt_return_id(self) -> Option { + pub fn opt_return_id(&self) -> Option { match self { IsAsync::Async { return_impl_trait_id, .. - } => Some(return_impl_trait_id), + } => Some(*return_impl_trait_id), IsAsync::NotAsync => None, } } @@ -2202,7 +2241,7 @@ impl Item { /// /// All the information between the visibility and the name of the function is /// included in this struct (e.g., `async unsafe fn` or `const extern "C" fn`). -#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct FnHeader { pub unsafety: Unsafety, pub asyncness: Spanned, diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 614967bdeb44..40dd187ed28a 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -526,6 +526,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { id: ast::DUMMY_NODE_ID, span: sp, attrs: ThinVec::new(), + source: ast::LocalSource::Normal, }); ast::Stmt { id: ast::DUMMY_NODE_ID, @@ -554,6 +555,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { id: ast::DUMMY_NODE_ID, span: sp, attrs: ThinVec::new(), + source: ast::LocalSource::Normal, }); ast::Stmt { id: ast::DUMMY_NODE_ID, @@ -571,6 +573,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { id: ast::DUMMY_NODE_ID, span, attrs: ThinVec::new(), + source: ast::LocalSource::Normal, }); ast::Stmt { id: ast::DUMMY_NODE_ID, @@ -976,7 +979,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ast::Arg { ty, pat: arg_pat, - id: ast::DUMMY_NODE_ID + id: ast::DUMMY_NODE_ID, + source: ast::ArgSource::Normal, } } diff --git a/src/libsyntax/ext/placeholders.rs b/src/libsyntax/ext/placeholders.rs index 3e60dd81a3bc..68cd3c28676f 100644 --- a/src/libsyntax/ext/placeholders.rs +++ b/src/libsyntax/ext/placeholders.rs @@ -102,6 +102,13 @@ impl<'a, 'b> PlaceholderExpander<'a, 'b> { fn remove(&mut self, id: ast::NodeId) -> AstFragment { self.expanded_fragments.remove(&id).unwrap() } + + fn next_id(&mut self, id: &mut ast::NodeId) { + if self.monotonic { + assert_eq!(*id, ast::DUMMY_NODE_ID); + *id = self.cx.resolver.next_node_id() + } + } } impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { @@ -183,9 +190,16 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { noop_visit_block(block, self); for stmt in block.stmts.iter_mut() { - if self.monotonic { - assert_eq!(stmt.id, ast::DUMMY_NODE_ID); - stmt.id = self.cx.resolver.next_node_id(); + self.next_id(&mut stmt.id); + } + } + + fn visit_asyncness(&mut self, a: &mut ast::IsAsync) { + noop_visit_asyncness(a, self); + + if let ast::IsAsync::Async { ref mut arguments, .. } = a { + for argument in arguments.iter_mut() { + self.next_id(&mut argument.stmt.id); } } } diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 784d0049ac51..d3441a2039b1 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -208,6 +208,10 @@ pub trait MutVisitor: Sized { noop_visit_local(l, self); } + fn visit_local_source(&mut self, l: &mut LocalSource) { + noop_visit_local_source(l, self); + } + fn visit_mac(&mut self, _mac: &mut Mac) { panic!("visit_mac disabled by default"); // N.B., see note about macros above. If you really want a visitor that @@ -231,6 +235,10 @@ pub trait MutVisitor: Sized { noop_visit_arg(a, self); } + fn visit_arg_source(&mut self, a: &mut ArgSource) { + noop_visit_arg_source(a, self); + } + fn visit_generics(&mut self, generics: &mut Generics) { noop_visit_generics(generics, self); } @@ -511,13 +519,17 @@ pub fn noop_visit_parenthesized_parameter_data(args: &mut Parenth } pub fn noop_visit_local(local: &mut P, vis: &mut T) { - let Local { id, pat, ty, init, span, attrs } = local.deref_mut(); + let Local { id, pat, ty, init, span, attrs, source } = local.deref_mut(); vis.visit_id(id); vis.visit_pat(pat); visit_opt(ty, |ty| vis.visit_ty(ty)); visit_opt(init, |init| vis.visit_expr(init)); vis.visit_span(span); visit_thin_attrs(attrs, vis); + vis.visit_local_source(source); +} + +pub fn noop_visit_local_source(_local_source: &mut LocalSource, _vis: &mut T) { } pub fn noop_visit_attribute(attr: &mut Attribute, vis: &mut T) { @@ -556,10 +568,18 @@ pub fn noop_visit_meta_item(mi: &mut MetaItem, vis: &mut T) { vis.visit_span(span); } -pub fn noop_visit_arg(Arg { id, pat, ty }: &mut Arg, vis: &mut T) { +pub fn noop_visit_arg(Arg { id, pat, ty, source }: &mut Arg, vis: &mut T) { vis.visit_id(id); vis.visit_pat(pat); vis.visit_ty(ty); + vis.visit_arg_source(source); +} + +pub fn noop_visit_arg_source(source: &mut ArgSource, vis: &mut T) { + match source { + ArgSource::Normal => {}, + ArgSource::AsyncFn(pat) => vis.visit_pat(pat), + } } pub fn noop_visit_tt(tt: &mut TokenTree, vis: &mut T) { @@ -671,9 +691,17 @@ pub fn noop_visit_interpolated(nt: &mut token::Nonterminal, vis: pub fn noop_visit_asyncness(asyncness: &mut IsAsync, vis: &mut T) { match asyncness { - IsAsync::Async { closure_id, return_impl_trait_id } => { + IsAsync::Async { closure_id, return_impl_trait_id, ref mut arguments } => { vis.visit_id(closure_id); vis.visit_id(return_impl_trait_id); + for AsyncArgument { ident, arg, stmt } in arguments.iter_mut() { + vis.visit_ident(ident); + vis.visit_arg(arg); + visit_clobber(stmt, |stmt| { + vis.flat_map_stmt(stmt) + .expect_one("expected visitor to produce exactly one item") + }); + } } IsAsync::NotAsync => {} } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 824192f07392..53dab510ac39 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1,7 +1,7 @@ -use crate::ast::{AngleBracketedArgs, ParenthesizedArgs, AttrStyle, BareFnTy}; +use crate::ast::{AngleBracketedArgs, AsyncArgument, ParenthesizedArgs, AttrStyle, BareFnTy}; use crate::ast::{GenericBound, TraitBoundModifier}; use crate::ast::Unsafety; -use crate::ast::{Mod, AnonConst, Arg, Arm, Guard, Attribute, BindingMode, TraitItemKind}; +use crate::ast::{Mod, AnonConst, Arg, ArgSource, Arm, Guard, Attribute, BindingMode, TraitItemKind}; use crate::ast::Block; use crate::ast::{BlockCheckMode, CaptureBy, Movability}; use crate::ast::{Constness, Crate}; @@ -14,7 +14,7 @@ use crate::ast::{GenericParam, GenericParamKind}; use crate::ast::GenericArg; use crate::ast::{Ident, ImplItem, IsAsync, IsAuto, Item, ItemKind}; use crate::ast::{Label, Lifetime, Lit, LitKind}; -use crate::ast::Local; +use crate::ast::{Local, LocalSource}; use crate::ast::MacStmtStyle; use crate::ast::{Mac, Mac_, MacDelimiter}; use crate::ast::{MutTy, Mutability}; @@ -550,7 +550,7 @@ fn dummy_arg(span: Span) -> Arg { span, id: ast::DUMMY_NODE_ID }; - Arg { ty: P(ty), pat: pat, id: ast::DUMMY_NODE_ID } + Arg { ty: P(ty), pat: pat, id: ast::DUMMY_NODE_ID, source: ast::ArgSource::Normal } } #[derive(Copy, Clone, Debug)] @@ -1517,6 +1517,7 @@ impl<'a> Parser<'a> { IsAsync::Async { closure_id: ast::DUMMY_NODE_ID, return_impl_trait_id: ast::DUMMY_NODE_ID, + arguments: Vec::new(), } } else { IsAsync::NotAsync @@ -1575,7 +1576,7 @@ impl<'a> Parser<'a> { // trait item macro. (keywords::Invalid.ident(), ast::TraitItemKind::Macro(mac), ast::Generics::default()) } else { - let (constness, unsafety, asyncness, abi) = self.parse_fn_front_matter()?; + let (constness, unsafety, mut asyncness, abi) = self.parse_fn_front_matter()?; let ident = self.parse_ident()?; let mut generics = self.parse_generics()?; @@ -1589,6 +1590,7 @@ impl<'a> Parser<'a> { p.parse_arg_general(p.span.rust_2018(), true, false) })?; generics.where_clause = self.parse_where_clause()?; + self.construct_async_arguments(&mut asyncness, &d); let sig = ast::MethodSig { header: FnHeader { @@ -2124,7 +2126,7 @@ impl<'a> Parser<'a> { } }; - Ok(Arg { ty, pat, id: ast::DUMMY_NODE_ID }) + Ok(Arg { ty, pat, id: ast::DUMMY_NODE_ID, source: ast::ArgSource::Normal }) } /// Parses a single function argument. @@ -2147,7 +2149,8 @@ impl<'a> Parser<'a> { Ok(Arg { ty: t, pat, - id: ast::DUMMY_NODE_ID + id: ast::DUMMY_NODE_ID, + source: ast::ArgSource::Normal, }) } @@ -5029,6 +5032,7 @@ impl<'a> Parser<'a> { id: ast::DUMMY_NODE_ID, span: lo.to(hi), attrs, + source: LocalSource::Normal, })) } @@ -6566,7 +6570,7 @@ impl<'a> Parser<'a> { /// Parses an item-position function declaration. fn parse_item_fn(&mut self, unsafety: Unsafety, - asyncness: Spanned, + mut asyncness: Spanned, constness: Spanned, abi: Abi) -> PResult<'a, ItemInfo> { @@ -6575,6 +6579,7 @@ impl<'a> Parser<'a> { let decl = self.parse_fn_decl(allow_c_variadic)?; generics.where_clause = self.parse_where_clause()?; let (inner_attrs, body) = self.parse_inner_attrs_and_block()?; + self.construct_async_arguments(&mut asyncness, &decl); let header = FnHeader { unsafety, asyncness, constness, abi }; Ok((ident, ItemKind::Fn(decl, header, generics, body), Some(inner_attrs))) } @@ -6755,11 +6760,12 @@ impl<'a> Parser<'a> { Ok((keywords::Invalid.ident(), vec![], ast::Generics::default(), ast::ImplItemKind::Macro(mac))) } else { - let (constness, unsafety, asyncness, abi) = self.parse_fn_front_matter()?; + let (constness, unsafety, mut asyncness, abi) = self.parse_fn_front_matter()?; let ident = self.parse_ident()?; let mut generics = self.parse_generics()?; let decl = self.parse_fn_decl_with_self(|p| p.parse_arg())?; generics.where_clause = self.parse_where_clause()?; + self.construct_async_arguments(&mut asyncness, &decl); *at_end = true; let (inner_attrs, body) = self.parse_inner_attrs_and_block()?; let header = ast::FnHeader { abi, unsafety, constness, asyncness }; @@ -8181,6 +8187,7 @@ impl<'a> Parser<'a> { respan(async_span, IsAsync::Async { closure_id: ast::DUMMY_NODE_ID, return_impl_trait_id: ast::DUMMY_NODE_ID, + arguments: Vec::new(), }), respan(fn_span, Constness::NotConst), Abi::Rust)?; @@ -8826,6 +8833,68 @@ impl<'a> Parser<'a> { } } } + + /// When lowering a `async fn` to the HIR, we need to move all of the arguments of the function + /// into the generated closure so that they are dropped when the future is polled and not when + /// it is created. + /// + /// The arguments of the function are replaced in HIR lowering with the arguments created by + /// this function and the statements created here are inserted at the top of the closure body. + fn construct_async_arguments(&mut self, asyncness: &mut Spanned, decl: &FnDecl) { + if let IsAsync::Async { ref mut arguments, .. } = asyncness.node { + for (index, input) in decl.inputs.iter().enumerate() { + let id = ast::DUMMY_NODE_ID; + let span = input.pat.span; + + // Construct a name for our temporary argument. + let name = format!("__arg{}", index); + let ident = Ident::from_str(&name); + + // Construct an argument representing `__argN: ` to replace the argument of the + // async function. + let arg = Arg { + ty: input.ty.clone(), + id, + pat: P(Pat { + id, + node: PatKind::Ident( + BindingMode::ByValue(Mutability::Immutable), ident, None, + ), + span, + }), + source: ArgSource::AsyncFn(input.pat.clone()), + }; + + // Construct a `let = __argN;` statement to insert at the top of the + // async closure. + let local = P(Local { + pat: input.pat.clone(), + // We explicitly do not specify the type for this statement. When the user's + // argument type is `impl Trait` then this would require the + // `impl_trait_in_bindings` feature to also be present for that same type to + // be valid in this binding. At the time of writing (13 Mar 19), + // `impl_trait_in_bindings` is not stable. + ty: None, + init: Some(P(Expr { + id, + node: ExprKind::Path(None, ast::Path { + span, + segments: vec![PathSegment { ident, id, args: None }], + }), + span, + attrs: ThinVec::new(), + })), + id, + span, + attrs: ThinVec::new(), + source: LocalSource::AsyncFn, + }); + let stmt = Stmt { id, node: StmtKind::Local(local), span, }; + + arguments.push(AsyncArgument { ident, arg, stmt }); + } + } + } } pub fn emit_unclosed_delims(unclosed_delims: &mut Vec, handler: &errors::Handler) { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index d94e4762e671..7ce3951f13ec 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -372,7 +372,7 @@ pub fn vis_to_string(v: &ast::Visibility) -> String { } pub fn fun_to_string(decl: &ast::FnDecl, - header: ast::FnHeader, + header: &ast::FnHeader, name: ast::Ident, generics: &ast::Generics) -> String { @@ -1133,7 +1133,7 @@ impl<'a> State<'a> { match item.node { ast::ForeignItemKind::Fn(ref decl, ref generics) => { self.head("")?; - self.print_fn(decl, ast::FnHeader::default(), + self.print_fn(decl, &ast::FnHeader::default(), Some(item.ident), generics, &item.vis)?; self.end()?; // end head-ibox @@ -1263,7 +1263,7 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer cbox } - ast::ItemKind::Fn(ref decl, header, ref param_names, ref body) => { + ast::ItemKind::Fn(ref decl, ref header, ref param_names, ref body) => { self.head("")?; self.print_fn( decl, @@ -1615,7 +1615,7 @@ impl<'a> State<'a> { vis: &ast::Visibility) -> io::Result<()> { self.print_fn(&m.decl, - m.header, + &m.header, Some(ident), &generics, vis) @@ -2213,7 +2213,7 @@ impl<'a> State<'a> { self.bclose_(expr.span, INDENT_UNIT)?; } ast::ExprKind::Closure( - capture_clause, asyncness, movability, ref decl, ref body, _) => { + capture_clause, ref asyncness, movability, ref decl, ref body, _) => { self.print_movability(movability)?; self.print_asyncness(asyncness)?; self.print_capture_clause(capture_clause)?; @@ -2798,7 +2798,7 @@ impl<'a> State<'a> { pub fn print_fn(&mut self, decl: &ast::FnDecl, - header: ast::FnHeader, + header: &ast::FnHeader, name: Option, generics: &ast::Generics, vis: &ast::Visibility) -> io::Result<()> { @@ -2853,8 +2853,7 @@ impl<'a> State<'a> { } } - pub fn print_asyncness(&mut self, asyncness: ast::IsAsync) - -> io::Result<()> { + pub fn print_asyncness(&mut self, asyncness: &ast::IsAsync) -> io::Result<()> { if asyncness.is_async() { self.word_nbsp("async")?; } @@ -3126,7 +3125,7 @@ impl<'a> State<'a> { span: syntax_pos::DUMMY_SP, }; self.print_fn(decl, - ast::FnHeader { unsafety, abi, ..ast::FnHeader::default() }, + &ast::FnHeader { unsafety, abi, ..ast::FnHeader::default() }, name, &generics, &source_map::dummy_spanned(ast::VisibilityKind::Inherited))?; @@ -3189,7 +3188,7 @@ impl<'a> State<'a> { } pub fn print_fn_header_info(&mut self, - header: ast::FnHeader, + header: &ast::FnHeader, vis: &ast::Visibility) -> io::Result<()> { self.s.word(visibility_qualified(vis, ""))?; @@ -3198,7 +3197,7 @@ impl<'a> State<'a> { ast::Constness::Const => self.word_nbsp("const")? } - self.print_asyncness(header.asyncness.node)?; + self.print_asyncness(&header.asyncness.node)?; self.print_unsafety(header.unsafety)?; if header.abi != Abi::Rust { @@ -3247,7 +3246,7 @@ mod tests { assert_eq!( fun_to_string( &decl, - ast::FnHeader { + &ast::FnHeader { unsafety: ast::Unsafety::Normal, constness: source_map::dummy_spanned(ast::Constness::NotConst), asyncness: source_map::dummy_spanned(ast::IsAsync::NotAsync), diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index fe74cbd64961..fc99d10b0b6c 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -544,6 +544,9 @@ pub fn walk_fn_ret_ty<'a, V: Visitor<'a>>(visitor: &mut V, ret_ty: &'a FunctionR pub fn walk_fn_decl<'a, V: Visitor<'a>>(visitor: &mut V, function_declaration: &'a FnDecl) { for argument in &function_declaration.inputs { visitor.visit_pat(&argument.pat); + if let ArgSource::AsyncFn(pat) = &argument.source { + visitor.visit_pat(pat); + } visitor.visit_ty(&argument.ty) } visitor.visit_fn_ret_ty(&function_declaration.output) diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 7c47c6ff79ac..2fc1fc9140dc 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -128,6 +128,7 @@ fn stmt_let_undescore(cx: &mut ExtCtxt<'_>, sp: Span, expr: P) -> ast id: ast::DUMMY_NODE_ID, span: sp, attrs: ThinVec::new(), + source: ast::LocalSource::Normal, }); ast::Stmt { id: ast::DUMMY_NODE_ID, diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index 1ffecea44edf..c806020039d2 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -24,11 +24,11 @@ struct SyntaxContextData { outer_mark: Mark, transparency: Transparency, prev_ctxt: SyntaxContext, - // This context, but with all transparent and semi-transparent marks filtered away. + /// This context, but with all transparent and semi-transparent marks filtered away. opaque: SyntaxContext, - // This context, but with all transparent marks filtered away. + /// This context, but with all transparent marks filtered away. opaque_and_semitransparent: SyntaxContext, - // Name of the crate to which `$crate` with this context would resolve. + /// Name of the crate to which `$crate` with this context would resolve. dollar_crate_name: Symbol, } diff --git a/src/test/codegen-units/item-collection/cross-crate-closures.rs b/src/test/codegen-units/item-collection/cross-crate-closures.rs index bd04422c39f7..6af344fab151 100644 --- a/src/test/codegen-units/item-collection/cross-crate-closures.rs +++ b/src/test/codegen-units/item-collection/cross-crate-closures.rs @@ -3,7 +3,6 @@ // ignoring this test until MIR codegen has taken over completely // ignore-test -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/cross-crate-generic-functions.rs b/src/test/codegen-units/item-collection/cross-crate-generic-functions.rs index cf7bde4a091d..e1991046d436 100644 --- a/src/test/codegen-units/item-collection/cross-crate-generic-functions.rs +++ b/src/test/codegen-units/item-collection/cross-crate-generic-functions.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/cross-crate-trait-method.rs b/src/test/codegen-units/item-collection/cross-crate-trait-method.rs index 8a19a7bd9f8f..442438b64b66 100644 --- a/src/test/codegen-units/item-collection/cross-crate-trait-method.rs +++ b/src/test/codegen-units/item-collection/cross-crate-trait-method.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/function-as-argument.rs b/src/test/codegen-units/item-collection/function-as-argument.rs index bdf6826f21aa..3f61f124d240 100644 --- a/src/test/codegen-units/item-collection/function-as-argument.rs +++ b/src/test/codegen-units/item-collection/function-as-argument.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/generic-functions.rs b/src/test/codegen-units/item-collection/generic-functions.rs index f879724c9a16..839097042048 100644 --- a/src/test/codegen-units/item-collection/generic-functions.rs +++ b/src/test/codegen-units/item-collection/generic-functions.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/generic-impl.rs b/src/test/codegen-units/item-collection/generic-impl.rs index 01b4e5301833..571bb4fa867c 100644 --- a/src/test/codegen-units/item-collection/generic-impl.rs +++ b/src/test/codegen-units/item-collection/generic-impl.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/impl-in-non-instantiated-generic.rs b/src/test/codegen-units/item-collection/impl-in-non-instantiated-generic.rs index 702ecba321e3..e45644cd3756 100644 --- a/src/test/codegen-units/item-collection/impl-in-non-instantiated-generic.rs +++ b/src/test/codegen-units/item-collection/impl-in-non-instantiated-generic.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/items-within-generic-items.rs b/src/test/codegen-units/item-collection/items-within-generic-items.rs index 748b6094a2a4..10bc52f6a8d2 100644 --- a/src/test/codegen-units/item-collection/items-within-generic-items.rs +++ b/src/test/codegen-units/item-collection/items-within-generic-items.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/non-generic-functions.rs b/src/test/codegen-units/item-collection/non-generic-functions.rs index e147b54fdaf0..26d2fb1b4219 100644 --- a/src/test/codegen-units/item-collection/non-generic-functions.rs +++ b/src/test/codegen-units/item-collection/non-generic-functions.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/overloaded-operators.rs b/src/test/codegen-units/item-collection/overloaded-operators.rs index db91486012dd..2358d38942a7 100644 --- a/src/test/codegen-units/item-collection/overloaded-operators.rs +++ b/src/test/codegen-units/item-collection/overloaded-operators.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/static-init.rs b/src/test/codegen-units/item-collection/static-init.rs index 397bccc4bf83..f6005eed43c7 100644 --- a/src/test/codegen-units/item-collection/static-init.rs +++ b/src/test/codegen-units/item-collection/static-init.rs @@ -1,5 +1,4 @@ // compile-flags:-Zprint-mono-items=eager -// ignore-tidy-linelength #![feature(start)] diff --git a/src/test/codegen-units/item-collection/statics-and-consts.rs b/src/test/codegen-units/item-collection/statics-and-consts.rs index db2d83aeefab..7e28ba58b63f 100644 --- a/src/test/codegen-units/item-collection/statics-and-consts.rs +++ b/src/test/codegen-units/item-collection/statics-and-consts.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/trait-implementations.rs b/src/test/codegen-units/item-collection/trait-implementations.rs index 004198a624ef..f090c0c8d130 100644 --- a/src/test/codegen-units/item-collection/trait-implementations.rs +++ b/src/test/codegen-units/item-collection/trait-implementations.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/trait-method-as-argument.rs b/src/test/codegen-units/item-collection/trait-method-as-argument.rs index cab4a7091342..27ace8e31add 100644 --- a/src/test/codegen-units/item-collection/trait-method-as-argument.rs +++ b/src/test/codegen-units/item-collection/trait-method-as-argument.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/trait-method-default-impl.rs b/src/test/codegen-units/item-collection/trait-method-default-impl.rs index ba99d430acc6..11f6cc62d49e 100644 --- a/src/test/codegen-units/item-collection/trait-method-default-impl.rs +++ b/src/test/codegen-units/item-collection/trait-method-default-impl.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/unreferenced-const-fn.rs b/src/test/codegen-units/item-collection/unreferenced-const-fn.rs index 5fae72f711d7..ec6be0ecf43e 100644 --- a/src/test/codegen-units/item-collection/unreferenced-const-fn.rs +++ b/src/test/codegen-units/item-collection/unreferenced-const-fn.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=lazy #![deny(dead_code)] diff --git a/src/test/codegen-units/item-collection/unreferenced-inline-function.rs b/src/test/codegen-units/item-collection/unreferenced-inline-function.rs index 4c8d1215c042..4d095e4d6c7e 100644 --- a/src/test/codegen-units/item-collection/unreferenced-inline-function.rs +++ b/src/test/codegen-units/item-collection/unreferenced-inline-function.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=lazy // N.B., we do not expect *any* monomorphization to be generated here. diff --git a/src/test/codegen-units/item-collection/unsizing.rs b/src/test/codegen-units/item-collection/unsizing.rs index 6b2acab7f7b7..fd794df37608 100644 --- a/src/test/codegen-units/item-collection/unsizing.rs +++ b/src/test/codegen-units/item-collection/unsizing.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager // compile-flags:-Zinline-in-all-cgus diff --git a/src/test/codegen-units/item-collection/unused-traits-and-generics.rs b/src/test/codegen-units/item-collection/unused-traits-and-generics.rs index 598efdbdad1b..4a5e294ea0f4 100644 --- a/src/test/codegen-units/item-collection/unused-traits-and-generics.rs +++ b/src/test/codegen-units/item-collection/unused-traits-and-generics.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![crate_type="lib"] diff --git a/src/test/codegen-units/partitioning/statics.rs b/src/test/codegen-units/partitioning/statics.rs index 40483318795b..bbded480b0c1 100644 --- a/src/test/codegen-units/partitioning/statics.rs +++ b/src/test/codegen-units/partitioning/statics.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // We specify -Z incremental here because we want to test the partitioning for // incremental compilation // compile-flags:-Zprint-mono-items=lazy -Zincremental=tmp/partitioning-tests/statics diff --git a/src/test/codegen/adjustments.rs b/src/test/codegen/adjustments.rs index b8398f6ac842..ae2ff9994fdf 100644 --- a/src/test/codegen/adjustments.rs +++ b/src/test/codegen/adjustments.rs @@ -1,5 +1,4 @@ // compile-flags: -C no-prepopulate-passes -// ignore-tidy-linelength #![crate_type = "lib"] diff --git a/src/test/codegen/enum-debug-niche.rs b/src/test/codegen/enum-debug-niche.rs index 93eebde7b8f4..2272488375fd 100644 --- a/src/test/codegen/enum-debug-niche.rs +++ b/src/test/codegen/enum-debug-niche.rs @@ -2,7 +2,6 @@ // before 7.0, then backported to the Rust LLVM fork. It tests that // optimized enum debug info accurately reflects the enum layout. -// ignore-tidy-linelength // ignore-windows // min-system-llvm-version 8.0 diff --git a/src/test/codegen/enum-debug-tagged.rs b/src/test/codegen/enum-debug-tagged.rs index 84976ce97af4..3539aae42eae 100644 --- a/src/test/codegen/enum-debug-tagged.rs +++ b/src/test/codegen/enum-debug-tagged.rs @@ -2,7 +2,6 @@ // before 7.0, then backported to the Rust LLVM fork. It tests that // debug info for tagged (ordinary) enums is properly emitted. -// ignore-tidy-linelength // ignore-windows // min-system-llvm-version 8.0 diff --git a/src/test/codegen/generic-debug.rs b/src/test/codegen/generic-debug.rs index 0bee2a1a8689..eea16805c596 100644 --- a/src/test/codegen/generic-debug.rs +++ b/src/test/codegen/generic-debug.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // ignore-windows // compile-flags: -g -C no-prepopulate-passes diff --git a/src/test/codegen/mainsubprogram.rs b/src/test/codegen/mainsubprogram.rs index d886cb88004c..7f1b0e17f871 100644 --- a/src/test/codegen/mainsubprogram.rs +++ b/src/test/codegen/mainsubprogram.rs @@ -1,7 +1,6 @@ // This test depends on a patch that was committed to upstream LLVM // before 4.0, formerly backported to the Rust LLVM fork. -// ignore-tidy-linelength // ignore-windows // ignore-macos diff --git a/src/test/codegen/mainsubprogramstart.rs b/src/test/codegen/mainsubprogramstart.rs index d91f91ee7ab6..b03290af0e3b 100644 --- a/src/test/codegen/mainsubprogramstart.rs +++ b/src/test/codegen/mainsubprogramstart.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // ignore-windows // ignore-macos diff --git a/src/test/codegen/noreturn-uninhabited.rs b/src/test/codegen/noreturn-uninhabited.rs index 1b65da9f2877..49f93cf62c75 100644 --- a/src/test/codegen/noreturn-uninhabited.rs +++ b/src/test/codegen/noreturn-uninhabited.rs @@ -1,5 +1,4 @@ // compile-flags: -g -C no-prepopulate-passes -// ignore-tidy-linelength #![crate_type = "lib"] diff --git a/src/test/codegen/noreturnflag.rs b/src/test/codegen/noreturnflag.rs index fc288eb0cf1e..95c100571ce6 100644 --- a/src/test/codegen/noreturnflag.rs +++ b/src/test/codegen/noreturnflag.rs @@ -1,5 +1,4 @@ // compile-flags: -g -C no-prepopulate-passes -// ignore-tidy-linelength #![crate_type = "lib"] diff --git a/src/test/codegen/panic-abort-windows.rs b/src/test/codegen/panic-abort-windows.rs index e2d942e86999..bbe0d81de3d4 100644 --- a/src/test/codegen/panic-abort-windows.rs +++ b/src/test/codegen/panic-abort-windows.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - // This test is for *-windows-msvc only. // ignore-android // ignore-bitrig diff --git a/src/test/codegen/refs.rs b/src/test/codegen/refs.rs index 9583730e9dd5..cbb994234767 100644 --- a/src/test/codegen/refs.rs +++ b/src/test/codegen/refs.rs @@ -1,5 +1,4 @@ // compile-flags: -C no-prepopulate-passes -// ignore-tidy-linelength #![crate_type = "lib"] diff --git a/src/test/codegen/remap_path_prefix/xcrate-generic.rs b/src/test/codegen/remap_path_prefix/xcrate-generic.rs index 70d29577b2f2..30d6112fd02f 100644 --- a/src/test/codegen/remap_path_prefix/xcrate-generic.rs +++ b/src/test/codegen/remap_path_prefix/xcrate-generic.rs @@ -1,5 +1,4 @@ // ignore-windows -// ignore-tidy-linelength // compile-flags: -g -C metadata=foo -C no-prepopulate-passes // aux-build:xcrate-generic.rs diff --git a/src/test/codegen/vtabletype.rs b/src/test/codegen/vtabletype.rs index 70b97a67bbcf..82d65b101b06 100644 --- a/src/test/codegen/vtabletype.rs +++ b/src/test/codegen/vtabletype.rs @@ -1,7 +1,6 @@ // This test depends on a patch that was committed to upstream LLVM // after 5.0, then backported to the Rust LLVM fork. -// ignore-tidy-linelength // ignore-windows // ignore-macos diff --git a/src/test/debuginfo/enum-thinlto.rs b/src/test/debuginfo/enum-thinlto.rs index 7f15ed90e67b..13577b0587ff 100644 --- a/src/test/debuginfo/enum-thinlto.rs +++ b/src/test/debuginfo/enum-thinlto.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - // Require LLVM with DW_TAG_variant_part and a gdb that can read it. // min-system-llvm-version: 8.0 // min-gdb-version: 8.2 diff --git a/src/test/debuginfo/generic-enum-with-different-disr-sizes.rs b/src/test/debuginfo/generic-enum-with-different-disr-sizes.rs index e26294cb730a..72d38a6f0454 100644 --- a/src/test/debuginfo/generic-enum-with-different-disr-sizes.rs +++ b/src/test/debuginfo/generic-enum-with-different-disr-sizes.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // ignore-lldb: FIXME(#27089) // min-lldb-version: 310 diff --git a/src/test/debuginfo/recursive-struct.rs b/src/test/debuginfo/recursive-struct.rs index 8fb83b7956be..4f75ef4fa9b9 100644 --- a/src/test/debuginfo/recursive-struct.rs +++ b/src/test/debuginfo/recursive-struct.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // ignore-lldb // Require LLVM with DW_TAG_variant_part and a gdb that can read it. diff --git a/src/test/debuginfo/unique-enum.rs b/src/test/debuginfo/unique-enum.rs index 32bd93f1ed2c..c440ce059f72 100644 --- a/src/test/debuginfo/unique-enum.rs +++ b/src/test/debuginfo/unique-enum.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - // Require LLVM with DW_TAG_variant_part and a gdb and lldb that can // read it. // min-system-llvm-version: 8.0 diff --git a/src/test/incremental/remapped_paths_cc/auxiliary/extern_crate.rs b/src/test/incremental/remapped_paths_cc/auxiliary/extern_crate.rs index 52e7f4bd7c78..627b99445ea8 100644 --- a/src/test/incremental/remapped_paths_cc/auxiliary/extern_crate.rs +++ b/src/test/incremental/remapped_paths_cc/auxiliary/extern_crate.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - //[rpass1] compile-flags: -g //[rpass2] compile-flags: -g //[rpass3] compile-flags: -g --remap-path-prefix={{src-base}}=/the/src diff --git a/src/test/mir-opt/basic_assignment.rs b/src/test/mir-opt/basic_assignment.rs index c771013f7281..ca0e9fa811a2 100644 --- a/src/test/mir-opt/basic_assignment.rs +++ b/src/test/mir-opt/basic_assignment.rs @@ -5,8 +5,6 @@ // so subtle breakage in them can leave a quite hard-to-find trail of // destruction. -// ignore-tidy-linelength - fn main() { let nodrop_x = false; let nodrop_y; diff --git a/src/test/mir-opt/inline-closure-borrows-arg.rs b/src/test/mir-opt/inline-closure-borrows-arg.rs index 2c30c7f36514..84567e1b4b8f 100644 --- a/src/test/mir-opt/inline-closure-borrows-arg.rs +++ b/src/test/mir-opt/inline-closure-borrows-arg.rs @@ -20,7 +20,7 @@ fn foo(_t: T, q: &i32) -> i32 { // ... // bb0: { // ... -// _3 = [closure@HirId { owner: DefIndex(0:4), local_id: 29 }]; +// _3 = [closure@HirId { owner: DefIndex(0:4), local_id: 31 }]; // ... // _4 = &_3; // ... diff --git a/src/test/mir-opt/inline-closure.rs b/src/test/mir-opt/inline-closure.rs index 8116a445467f..2be48927fd3b 100644 --- a/src/test/mir-opt/inline-closure.rs +++ b/src/test/mir-opt/inline-closure.rs @@ -16,7 +16,7 @@ fn foo(_t: T, q: i32) -> i32 { // ... // bb0: { // ... -// _3 = [closure@HirId { owner: DefIndex(0:4), local_id: 13 }]; +// _3 = [closure@HirId { owner: DefIndex(0:4), local_id: 15 }]; // ... // _4 = &_3; // ... diff --git a/src/test/mir-opt/nll/named-lifetimes-basic.rs b/src/test/mir-opt/nll/named-lifetimes-basic.rs index 4833ba19554b..2a6c2db03bec 100644 --- a/src/test/mir-opt/nll/named-lifetimes-basic.rs +++ b/src/test/mir-opt/nll/named-lifetimes-basic.rs @@ -5,7 +5,6 @@ // compile-flags:-Zborrowck=mir -Zverbose // ^^^^^^^^^ force compiler to dump more region information -// ignore-tidy-linelength #![allow(warnings)] diff --git a/src/test/mir-opt/storage_ranges.rs b/src/test/mir-opt/storage_ranges.rs index 9a22f57116ed..c099b1dccb66 100644 --- a/src/test/mir-opt/storage_ranges.rs +++ b/src/test/mir-opt/storage_ranges.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - fn main() { let a = 0; { diff --git a/src/test/run-pass/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs b/src/test/run-pass/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs index fb0bc3c436d9..6d5a9876c373 100644 --- a/src/test/run-pass/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs +++ b/src/test/run-pass/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs @@ -12,7 +12,7 @@ fn expect_free_supply_free<'x>(x: &'x u32) { x.push(22_u32); // ...since we now know the type of `y` and can resolve the method call. - y.wrapping_add(1); + let _ = y.wrapping_add(1); }); } diff --git a/src/test/run-pass/issue-54716.rs b/src/test/run-pass/issue-54716.rs new file mode 100644 index 000000000000..ea4f5e076b00 --- /dev/null +++ b/src/test/run-pass/issue-54716.rs @@ -0,0 +1,184 @@ +// aux-build:arc_wake.rs +// edition:2018 +// run-pass + +#![allow(unused_variables)] +#![feature(async_await, await_macro, futures_api)] + +extern crate arc_wake; + +use arc_wake::ArcWake; +use std::cell::RefCell; +use std::future::Future; +use std::marker::PhantomData; +use std::sync::Arc; +use std::rc::Rc; +use std::task::Context; + +struct EmptyWaker; + +impl ArcWake for EmptyWaker { + fn wake(self: Arc) {} +} + +#[derive(Debug, Eq, PartialEq)] +enum DropOrder { + Function, + Val(&'static str), +} + +type DropOrderListPtr = Rc>>; + +struct D(&'static str, DropOrderListPtr); + +impl Drop for D { + fn drop(&mut self) { + self.1.borrow_mut().push(DropOrder::Val(self.0)); + } +} + +/// Check that unused bindings are dropped after the function is polled. +async fn foo(x: D, _y: D) { + x.1.borrow_mut().push(DropOrder::Function); +} + +/// Check that underscore patterns are dropped after the function is polled. +async fn bar(x: D, _: D) { + x.1.borrow_mut().push(DropOrder::Function); +} + +/// Check that underscore patterns within more complex patterns are dropped after the function +/// is polled. +async fn baz((x, _): (D, D)) { + x.1.borrow_mut().push(DropOrder::Function); +} + +/// Check that underscore and unused bindings within and outwith more complex patterns are dropped +/// after the function is polled. +async fn foobar(x: D, (a, _, _c): (D, D, D), _: D, _y: D) { + x.1.borrow_mut().push(DropOrder::Function); +} + +struct Foo; + +impl Foo { + /// Check that unused bindings are dropped after the method is polled. + async fn foo(x: D, _y: D) { + x.1.borrow_mut().push(DropOrder::Function); + } + + /// Check that underscore patterns are dropped after the method is polled. + async fn bar(x: D, _: D) { + x.1.borrow_mut().push(DropOrder::Function); + } + + /// Check that underscore patterns within more complex patterns are dropped after the method + /// is polled. + async fn baz((x, _): (D, D)) { + x.1.borrow_mut().push(DropOrder::Function); + } + + /// Check that underscore and unused bindings within and outwith more complex patterns are + /// dropped after the method is polled. + async fn foobar(x: D, (a, _, _c): (D, D, D), _: D, _y: D) { + x.1.borrow_mut().push(DropOrder::Function); + } +} + +struct Bar<'a>(PhantomData<&'a ()>); + +impl<'a> Bar<'a> { + /// Check that unused bindings are dropped after the method with self is polled. + async fn foo(&'a self, x: D, _y: D) { + x.1.borrow_mut().push(DropOrder::Function); + } + + /// Check that underscore patterns are dropped after the method with self is polled. + async fn bar(&'a self, x: D, _: D) { + x.1.borrow_mut().push(DropOrder::Function); + } + + /// Check that underscore patterns within more complex patterns are dropped after the method + /// with self is polled. + async fn baz(&'a self, (x, _): (D, D)) { + x.1.borrow_mut().push(DropOrder::Function); + } + + /// Check that underscore and unused bindings within and outwith more complex patterns are + /// dropped after the method with self is polled. + async fn foobar(&'a self, x: D, (a, _, _c): (D, D, D), _: D, _y: D) { + x.1.borrow_mut().push(DropOrder::Function); + } +} + +fn assert_drop_order_after_poll>( + f: impl FnOnce(DropOrderListPtr) -> Fut, + expected_order: &[DropOrder], +) { + let empty = Arc::new(EmptyWaker); + let waker = ArcWake::into_waker(empty); + let mut cx = Context::from_waker(&waker); + + let actual_order = Rc::new(RefCell::new(Vec::new())); + let mut fut = Box::pin(f(actual_order.clone())); + let _ = fut.as_mut().poll(&mut cx); + + assert_eq!(*actual_order.borrow(), expected_order); +} + +fn main() { + use DropOrder::*; + + // At time of writing (23/04/19), the `bar` and `foobar` tests do not output the same order as + // the equivalent non-async functions. This is because the drop order of captured variables + // doesn't match the drop order of arguments in a function. + + // Free functions (see doc comment on function for what it tests). + assert_drop_order_after_poll(|l| foo(D("x", l.clone()), D("_y", l.clone())), + &[Function, Val("_y"), Val("x")]); + assert_drop_order_after_poll(|l| bar(D("x", l.clone()), D("_", l.clone())), + &[Function, Val("x"), Val("_")]); + assert_drop_order_after_poll(|l| baz((D("x", l.clone()), D("_", l.clone()))), + &[Function, Val("x"), Val("_")]); + assert_drop_order_after_poll(|l| { + foobar( + D("x", l.clone()), + (D("a", l.clone()), D("_", l.clone()), D("_c", l.clone())), + D("_", l.clone()), + D("_y", l.clone()), + ) + }, &[Function, Val("_y"), Val("_c"), Val("a"), Val("x"), Val("_"), Val("_")]); + + // Methods w/out self (see doc comment on function for what it tests). + assert_drop_order_after_poll(|l| Foo::foo(D("x", l.clone()), D("_y", l.clone())), + &[Function, Val("_y"), Val("x")]); + assert_drop_order_after_poll(|l| Foo::bar(D("x", l.clone()), D("_", l.clone())), + &[Function, Val("x"), Val("_")]); + assert_drop_order_after_poll(|l| Foo::baz((D("x", l.clone()), D("_", l.clone()))), + &[Function, Val("x"), Val("_")]); + assert_drop_order_after_poll(|l| { + Foo::foobar( + D("x", l.clone()), + (D("a", l.clone()), D("_", l.clone()), D("_c", l.clone())), + D("_", l.clone()), + D("_y", l.clone()), + ) + }, &[Function, Val("_y"), Val("_c"), Val("a"), Val("x"), Val("_"), Val("_")]); + + // Methods (see doc comment on function for what it tests). + let b = Bar(Default::default()); + assert_drop_order_after_poll(|l| b.foo(D("x", l.clone()), D("_y", l.clone())), + &[Function, Val("_y"), Val("x")]); + assert_drop_order_after_poll(|l| b.bar(D("x", l.clone()), D("_", l.clone())), + &[Function, Val("x"), Val("_")]); + assert_drop_order_after_poll(|l| b.baz((D("x", l.clone()), D("_", l.clone()))), + &[Function, Val("x"), Val("_")]); + assert_drop_order_after_poll(|l| { + b.foobar( + D("x", l.clone()), + (D("a", l.clone()), D("_", l.clone()), D("_c", l.clone())), + D("_", l.clone()), + D("_y", l.clone()), + ) + }, &[Function, Val("_y"), Val("_c"), Val("a"), Val("x"), Val("_"), Val("_")]); +} diff --git a/src/test/run-pass/issues/issue-16278.rs b/src/test/run-pass/issues/issue-16278.rs index ad9af8473def..2f47b694ae91 100644 --- a/src/test/run-pass/issues/issue-16278.rs +++ b/src/test/run-pass/issues/issue-16278.rs @@ -3,8 +3,8 @@ // this file has some special \r\n endings (use xxd to see them) -fn main() {assert_eq!(b"", b"\ +fn main() {assert_eq!(b"", b"\ "); -assert_eq!(b"\n", b" +assert_eq!(b"\n", b" "); } diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.rs b/src/test/rustdoc-ui/intra-link-span-ice-55723.rs index 5891a553e325..c7a13bbf606c 100644 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.rs +++ b/src/test/rustdoc-ui/intra-link-span-ice-55723.rs @@ -1,5 +1,3 @@ -// ignore-tidy-end-whitespace - #![deny(intra_doc_link_resolution_failure)] // An error in calculating spans while reporting intra-doc link resolution errors caused rustdoc to diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr index 7ee9ca479239..79702a1a546b 100644 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr +++ b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr @@ -1,11 +1,11 @@ error: `[i]` cannot be resolved, ignoring it... - --> $DIR/intra-link-span-ice-55723.rs:11:10 + --> $DIR/intra-link-span-ice-55723.rs:9:10 | LL | /// (arr[i]) | ^ cannot be resolved, ignoring | note: lint level defined here - --> $DIR/intra-link-span-ice-55723.rs:3:9 + --> $DIR/intra-link-span-ice-55723.rs:1:9 | LL | #![deny(intra_doc_link_resolution_failure)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/rustdoc/empty-mod-private.rs b/src/test/rustdoc/empty-mod-private.rs index 12576a1b535f..c2a98049a48c 100644 --- a/src/test/rustdoc/empty-mod-private.rs +++ b/src/test/rustdoc/empty-mod-private.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags: --document-private-items // @has 'empty_mod_private/index.html' '//a[@href="foo/index.html"]' 'foo' diff --git a/src/test/rustdoc/extern-html-root-url.rs b/src/test/rustdoc/extern-html-root-url.rs index 674d0305f2ea..60b7b28ae4ac 100644 --- a/src/test/rustdoc/extern-html-root-url.rs +++ b/src/test/rustdoc/extern-html-root-url.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - // compile-flags:-Z unstable-options --extern-html-root-url core=https://example.com/core/0.1.0 // @has extern_html_root_url/index.html diff --git a/src/test/rustdoc/method-list.rs b/src/test/rustdoc/method-list.rs index f84be3eb3f71..9f24e817fd3e 100644 --- a/src/test/rustdoc/method-list.rs +++ b/src/test/rustdoc/method-list.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - #![crate_name = "foo"] // @has foo/struct.Foo.html diff --git a/src/test/rustdoc/pub-method.rs b/src/test/rustdoc/pub-method.rs index 01e5141fe258..8e88b2b59015 100644 --- a/src/test/rustdoc/pub-method.rs +++ b/src/test/rustdoc/pub-method.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // compile-flags: --document-private-items #![crate_name = "foo"] diff --git a/src/test/ui/borrowck/two-phase-activation-sharing-interference.nll_target.stderr b/src/test/ui/borrowck/two-phase-activation-sharing-interference.nll_target.stderr index 8370aad6f304..40786c032b18 100644 --- a/src/test/ui/borrowck/two-phase-activation-sharing-interference.nll_target.stderr +++ b/src/test/ui/borrowck/two-phase-activation-sharing-interference.nll_target.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-activation-sharing-interference.rs:32:15 + --> $DIR/two-phase-activation-sharing-interference.rs:30:15 | LL | let y = &mut x; | ------ mutable borrow occurs here @@ -10,7 +10,7 @@ LL | *y += 1; | ------- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-activation-sharing-interference.rs:40:13 + --> $DIR/two-phase-activation-sharing-interference.rs:38:13 | LL | let y = &mut x; | ------ mutable borrow occurs here @@ -21,7 +21,7 @@ LL | *y += 1; | ------- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-activation-sharing-interference.rs:51:13 + --> $DIR/two-phase-activation-sharing-interference.rs:49:13 | LL | let y = &mut x; | ------ mutable borrow occurs here @@ -32,7 +32,7 @@ LL | *y += 1; | ------- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-activation-sharing-interference.rs:62:14 + --> $DIR/two-phase-activation-sharing-interference.rs:60:14 | LL | let y = &mut x; | ------ mutable borrow occurs here diff --git a/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs b/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs index 55a8ae7a49ef..4d77ac915b1e 100644 --- a/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs +++ b/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - // revisions: nll_target // The following revisions are disabled due to missing support from two-phase beyond autorefs diff --git a/src/test/ui/consts/const-array-oob.rs b/src/test/ui/consts/const-array-oob.rs index 39ef45175f9e..1174a76adabc 100644 --- a/src/test/ui/consts/const-array-oob.rs +++ b/src/test/ui/consts/const-array-oob.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - #![feature(const_indexing)] const FOO: [usize; 3] = [1, 2, 3]; diff --git a/src/test/ui/consts/const-array-oob.stderr b/src/test/ui/consts/const-array-oob.stderr index 2d9a4fd0dea2..f25cac5cddd4 100644 --- a/src/test/ui/consts/const-array-oob.stderr +++ b/src/test/ui/consts/const-array-oob.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const-array-oob.rs:8:19 + --> $DIR/const-array-oob.rs:6:19 | LL | const BLUB: [u32; FOO[4]] = [5, 6]; | ^^^^^^ index out of bounds: the len is 3 but the index is 4 diff --git a/src/test/ui/deprecation/deprecation-in-future.rs b/src/test/ui/deprecation/deprecation-in-future.rs index 138d902621cb..c4f9fdce7490 100644 --- a/src/test/ui/deprecation/deprecation-in-future.rs +++ b/src/test/ui/deprecation/deprecation-in-future.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - // run-pass #![deny(deprecated_in_future)] diff --git a/src/test/ui/deprecation/deprecation-in-future.stderr b/src/test/ui/deprecation/deprecation-in-future.stderr index 81d2461c1bd8..2284cfa8d685 100644 --- a/src/test/ui/deprecation/deprecation-in-future.stderr +++ b/src/test/ui/deprecation/deprecation-in-future.stderr @@ -1,5 +1,5 @@ warning: use of deprecated item 'deprecated_future': text - --> $DIR/deprecation-in-future.rs:11:5 + --> $DIR/deprecation-in-future.rs:9:5 | LL | deprecated_future(); // ok; deprecated_in_future only applies to rustc_deprecated | ^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/derives/deriving-meta-unknown-trait.rs b/src/test/ui/derives/deriving-meta-unknown-trait.rs index 2b29f10150b9..f4a6f3fd62a0 100644 --- a/src/test/ui/derives/deriving-meta-unknown-trait.rs +++ b/src/test/ui/derives/deriving-meta-unknown-trait.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - #[derive(Eqr)] //~^ ERROR cannot find derive macro `Eqr` in this scope struct Foo; diff --git a/src/test/ui/derives/deriving-meta-unknown-trait.stderr b/src/test/ui/derives/deriving-meta-unknown-trait.stderr index 2b121ac679ae..cf0173dfad5c 100644 --- a/src/test/ui/derives/deriving-meta-unknown-trait.stderr +++ b/src/test/ui/derives/deriving-meta-unknown-trait.stderr @@ -1,5 +1,5 @@ error: cannot find derive macro `Eqr` in this scope - --> $DIR/deriving-meta-unknown-trait.rs:3:10 + --> $DIR/deriving-meta-unknown-trait.rs:1:10 | LL | #[derive(Eqr)] | ^^^ help: try: `Eq` diff --git a/src/test/ui/discrim/discrim-overflow-2.rs b/src/test/ui/discrim/discrim-overflow-2.rs index 9ff39cd04845..f8f565f4d9c1 100644 --- a/src/test/ui/discrim/discrim-overflow-2.rs +++ b/src/test/ui/discrim/discrim-overflow-2.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - // Issue 23030: Detect overflowing discriminant // // Check that we detect the overflow even if enum is not used. diff --git a/src/test/ui/discrim/discrim-overflow-2.stderr b/src/test/ui/discrim/discrim-overflow-2.stderr index 744324d1f0ff..198ebe9eb51f 100644 --- a/src/test/ui/discrim/discrim-overflow-2.stderr +++ b/src/test/ui/discrim/discrim-overflow-2.stderr @@ -1,5 +1,5 @@ error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:17:9 + --> $DIR/discrim-overflow-2.rs:15:9 | LL | OhNo, | ^^^^ overflowed on value after 127 @@ -7,7 +7,7 @@ LL | OhNo, = note: explicitly set `OhNo = -128` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:26:9 + --> $DIR/discrim-overflow-2.rs:24:9 | LL | OhNo, | ^^^^ overflowed on value after 255 @@ -15,7 +15,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:35:9 + --> $DIR/discrim-overflow-2.rs:33:9 | LL | OhNo, | ^^^^ overflowed on value after 32767 @@ -23,7 +23,7 @@ LL | OhNo, = note: explicitly set `OhNo = -32768` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:44:9 + --> $DIR/discrim-overflow-2.rs:42:9 | LL | OhNo, | ^^^^ overflowed on value after 65535 @@ -31,7 +31,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:53:9 + --> $DIR/discrim-overflow-2.rs:51:9 | LL | OhNo, | ^^^^ overflowed on value after 2147483647 @@ -39,7 +39,7 @@ LL | OhNo, = note: explicitly set `OhNo = -2147483648` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:62:9 + --> $DIR/discrim-overflow-2.rs:60:9 | LL | OhNo, | ^^^^ overflowed on value after 4294967295 @@ -47,7 +47,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:71:9 + --> $DIR/discrim-overflow-2.rs:69:9 | LL | OhNo, | ^^^^ overflowed on value after 9223372036854775807 @@ -55,7 +55,7 @@ LL | OhNo, = note: explicitly set `OhNo = -9223372036854775808` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:80:9 + --> $DIR/discrim-overflow-2.rs:78:9 | LL | OhNo, | ^^^^ overflowed on value after 18446744073709551615 diff --git a/src/test/ui/discrim/discrim-overflow.rs b/src/test/ui/discrim/discrim-overflow.rs index c612661178cf..d8a9dacfa518 100644 --- a/src/test/ui/discrim/discrim-overflow.rs +++ b/src/test/ui/discrim/discrim-overflow.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - // Issue 23030: Detect overflowing discriminant // See also run-pass/discrim-explicit-23030.rs where the suggested diff --git a/src/test/ui/discrim/discrim-overflow.stderr b/src/test/ui/discrim/discrim-overflow.stderr index c831fdfe1a34..a2ae4863f9f7 100644 --- a/src/test/ui/discrim/discrim-overflow.stderr +++ b/src/test/ui/discrim/discrim-overflow.stderr @@ -1,5 +1,5 @@ error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:15:9 + --> $DIR/discrim-overflow.rs:13:9 | LL | OhNo, | ^^^^ overflowed on value after 127 @@ -7,7 +7,7 @@ LL | OhNo, = note: explicitly set `OhNo = -128` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:26:9 + --> $DIR/discrim-overflow.rs:24:9 | LL | OhNo, | ^^^^ overflowed on value after 255 @@ -15,7 +15,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:37:9 + --> $DIR/discrim-overflow.rs:35:9 | LL | OhNo, | ^^^^ overflowed on value after 32767 @@ -23,7 +23,7 @@ LL | OhNo, = note: explicitly set `OhNo = -32768` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:48:9 + --> $DIR/discrim-overflow.rs:46:9 | LL | OhNo, | ^^^^ overflowed on value after 65535 @@ -31,7 +31,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:60:9 + --> $DIR/discrim-overflow.rs:58:9 | LL | OhNo, | ^^^^ overflowed on value after 2147483647 @@ -39,7 +39,7 @@ LL | OhNo, = note: explicitly set `OhNo = -2147483648` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:72:9 + --> $DIR/discrim-overflow.rs:70:9 | LL | OhNo, | ^^^^ overflowed on value after 4294967295 @@ -47,7 +47,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:84:9 + --> $DIR/discrim-overflow.rs:82:9 | LL | OhNo, | ^^^^ overflowed on value after 9223372036854775807 @@ -55,7 +55,7 @@ LL | OhNo, = note: explicitly set `OhNo = -9223372036854775808` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:96:9 + --> $DIR/discrim-overflow.rs:94:9 | LL | OhNo, | ^^^^ overflowed on value after 18446744073709551615 diff --git a/src/test/ui/editions/edition-raw-pointer-method-2015.rs b/src/test/ui/editions/edition-raw-pointer-method-2015.rs index a538bca75f67..3631415fc5f9 100644 --- a/src/test/ui/editions/edition-raw-pointer-method-2015.rs +++ b/src/test/ui/editions/edition-raw-pointer-method-2015.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // edition:2015 // tests that editions work with the tyvar warning-turned-error diff --git a/src/test/ui/editions/edition-raw-pointer-method-2015.stderr b/src/test/ui/editions/edition-raw-pointer-method-2015.stderr index deea6a71b24f..508d5df2a716 100644 --- a/src/test/ui/editions/edition-raw-pointer-method-2015.stderr +++ b/src/test/ui/editions/edition-raw-pointer-method-2015.stderr @@ -1,11 +1,11 @@ error: type annotations needed - --> $DIR/edition-raw-pointer-method-2015.rs:10:15 + --> $DIR/edition-raw-pointer-method-2015.rs:9:15 | LL | let _ = y.is_null(); | ^^^^^^^ | note: lint level defined here - --> $DIR/edition-raw-pointer-method-2015.rs:6:8 + --> $DIR/edition-raw-pointer-method-2015.rs:5:8 | LL | #[deny(warnings)] | ^^^^^^^^ diff --git a/src/test/ui/editions/edition-raw-pointer-method-2018.rs b/src/test/ui/editions/edition-raw-pointer-method-2018.rs index eabab5e4739a..af0b2d6bd4aa 100644 --- a/src/test/ui/editions/edition-raw-pointer-method-2018.rs +++ b/src/test/ui/editions/edition-raw-pointer-method-2018.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength // edition:2018 // tests that editions work with the tyvar warning-turned-error diff --git a/src/test/ui/editions/edition-raw-pointer-method-2018.stderr b/src/test/ui/editions/edition-raw-pointer-method-2018.stderr index 03e7f3a9449d..23452495b4bc 100644 --- a/src/test/ui/editions/edition-raw-pointer-method-2018.stderr +++ b/src/test/ui/editions/edition-raw-pointer-method-2018.stderr @@ -1,5 +1,5 @@ error[E0699]: the type of this value must be known to call a method on a raw pointer on it - --> $DIR/edition-raw-pointer-method-2018.rs:10:15 + --> $DIR/edition-raw-pointer-method-2018.rs:9:15 | LL | let _ = y.is_null(); | ^^^^^^^ diff --git a/src/test/ui/error-codes/E0375.rs b/src/test/ui/error-codes/E0375.rs index 362854a53aa6..0c03a8761df0 100644 --- a/src/test/ui/error-codes/E0375.rs +++ b/src/test/ui/error-codes/E0375.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - #![feature(coerce_unsized)] use std::ops::CoerceUnsized; diff --git a/src/test/ui/error-codes/E0375.stderr b/src/test/ui/error-codes/E0375.stderr index 18416e9b7d8b..a68b3af5aaf7 100644 --- a/src/test/ui/error-codes/E0375.stderr +++ b/src/test/ui/error-codes/E0375.stderr @@ -1,5 +1,5 @@ error[E0375]: implementing the trait `CoerceUnsized` requires multiple coercions - --> $DIR/E0375.rs:12:12 + --> $DIR/E0375.rs:10:12 | LL | impl CoerceUnsized> for Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^ requires multiple coercions diff --git a/src/test/ui/feature-gates/feature-gate-ffi_returns_twice.rs b/src/test/ui/feature-gates/feature-gate-ffi_returns_twice.rs index 2ea60029492a..d118b7f4ff2b 100644 --- a/src/test/ui/feature-gates/feature-gate-ffi_returns_twice.rs +++ b/src/test/ui/feature-gates/feature-gate-ffi_returns_twice.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength #![crate_type = "lib"] extern { diff --git a/src/test/ui/feature-gates/feature-gate-ffi_returns_twice.stderr b/src/test/ui/feature-gates/feature-gate-ffi_returns_twice.stderr index c28d45df7cd4..72e414eab924 100644 --- a/src/test/ui/feature-gates/feature-gate-ffi_returns_twice.stderr +++ b/src/test/ui/feature-gates/feature-gate-ffi_returns_twice.stderr @@ -1,5 +1,5 @@ error[E0658]: the `#[ffi_returns_twice]` attribute is an experimental feature - --> $DIR/feature-gate-ffi_returns_twice.rs:5:5 + --> $DIR/feature-gate-ffi_returns_twice.rs:4:5 | LL | #[ffi_returns_twice] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/ffi_returns_twice.rs b/src/test/ui/ffi_returns_twice.rs index 93c372e1d83d..845e18df11b5 100644 --- a/src/test/ui/ffi_returns_twice.rs +++ b/src/test/ui/ffi_returns_twice.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength #![feature(ffi_returns_twice)] #![crate_type = "lib"] diff --git a/src/test/ui/ffi_returns_twice.stderr b/src/test/ui/ffi_returns_twice.stderr index e51d3d8c146b..862892e27be9 100644 --- a/src/test/ui/ffi_returns_twice.stderr +++ b/src/test/ui/ffi_returns_twice.stderr @@ -1,5 +1,5 @@ error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions - --> $DIR/ffi_returns_twice.rs:5:1 + --> $DIR/ffi_returns_twice.rs:4:1 | LL | #[ffi_returns_twice] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/impl-trait/auto-trait-leak.rs b/src/test/ui/impl-trait/auto-trait-leak.rs index ea0be0b346cb..1c601bc3c34e 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.rs +++ b/src/test/ui/impl-trait/auto-trait-leak.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - use std::cell::Cell; use std::rc::Rc; diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index de0043eee8fd..61450d3203cd 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -1,29 +1,29 @@ error[E0391]: cycle detected when processing `cycle1::{{opaque}}#0` - --> $DIR/auto-trait-leak.rs:14:16 + --> $DIR/auto-trait-leak.rs:12:16 | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^ | note: ...which requires processing `cycle1`... - --> $DIR/auto-trait-leak.rs:14:1 + --> $DIR/auto-trait-leak.rs:12:1 | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`... note: ...which requires processing `cycle2::{{opaque}}#0`... - --> $DIR/auto-trait-leak.rs:23:16 + --> $DIR/auto-trait-leak.rs:21:16 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^ note: ...which requires processing `cycle2`... - --> $DIR/auto-trait-leak.rs:23:1 + --> $DIR/auto-trait-leak.rs:21:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`... = note: ...which again requires processing `cycle1::{{opaque}}#0`, completing the cycle note: cycle used when checking item types in top-level module - --> $DIR/auto-trait-leak.rs:3:1 + --> $DIR/auto-trait-leak.rs:1:1 | LL | / use std::cell::Cell; LL | | use std::rc::Rc; @@ -35,30 +35,30 @@ LL | | } | |_^ error[E0391]: cycle detected when processing `cycle1::{{opaque}}#0` - --> $DIR/auto-trait-leak.rs:14:16 + --> $DIR/auto-trait-leak.rs:12:16 | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^ | note: ...which requires processing `cycle1`... - --> $DIR/auto-trait-leak.rs:14:1 + --> $DIR/auto-trait-leak.rs:12:1 | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`... note: ...which requires processing `cycle2::{{opaque}}#0`... - --> $DIR/auto-trait-leak.rs:23:16 + --> $DIR/auto-trait-leak.rs:21:16 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^ note: ...which requires processing `cycle2`... - --> $DIR/auto-trait-leak.rs:23:1 + --> $DIR/auto-trait-leak.rs:21:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires processing `cycle1::{{opaque}}#0`, completing the cycle note: cycle used when checking item types in top-level module - --> $DIR/auto-trait-leak.rs:3:1 + --> $DIR/auto-trait-leak.rs:1:1 | LL | / use std::cell::Cell; LL | | use std::rc::Rc; @@ -70,7 +70,7 @@ LL | | } | |_^ error[E0277]: `std::rc::Rc` cannot be sent between threads safely - --> $DIR/auto-trait-leak.rs:17:5 + --> $DIR/auto-trait-leak.rs:15:5 | LL | send(cycle2().clone()); | ^^^^ `std::rc::Rc` cannot be sent between threads safely @@ -78,7 +78,7 @@ LL | send(cycle2().clone()); = help: within `impl std::clone::Clone`, the trait `std::marker::Send` is not implemented for `std::rc::Rc` = note: required because it appears within the type `impl std::clone::Clone` note: required by `send` - --> $DIR/auto-trait-leak.rs:6:1 + --> $DIR/auto-trait-leak.rs:4:1 | LL | fn send(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/impl-trait/auto-trait-leak2.rs b/src/test/ui/impl-trait/auto-trait-leak2.rs index e529b4757ed1..fb4b54051237 100644 --- a/src/test/ui/impl-trait/auto-trait-leak2.rs +++ b/src/test/ui/impl-trait/auto-trait-leak2.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - use std::cell::Cell; use std::rc::Rc; diff --git a/src/test/ui/impl-trait/auto-trait-leak2.stderr b/src/test/ui/impl-trait/auto-trait-leak2.stderr index 4e427d3d6b38..19899ff83f7c 100644 --- a/src/test/ui/impl-trait/auto-trait-leak2.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak2.stderr @@ -1,29 +1,29 @@ error[E0277]: `std::rc::Rc>` cannot be sent between threads safely - --> $DIR/auto-trait-leak2.rs:15:5 + --> $DIR/auto-trait-leak2.rs:13:5 | LL | send(before()); | ^^^^ `std::rc::Rc>` cannot be sent between threads safely | = help: within `impl std::ops::Fn<(i32,)>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` - = note: required because it appears within the type `[closure@$DIR/auto-trait-leak2.rs:9:5: 9:22 p:std::rc::Rc>]` + = note: required because it appears within the type `[closure@$DIR/auto-trait-leak2.rs:7:5: 7:22 p:std::rc::Rc>]` = note: required because it appears within the type `impl std::ops::Fn<(i32,)>` note: required by `send` - --> $DIR/auto-trait-leak2.rs:12:1 + --> $DIR/auto-trait-leak2.rs:10:1 | LL | fn send(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `std::rc::Rc>` cannot be sent between threads safely - --> $DIR/auto-trait-leak2.rs:18:5 + --> $DIR/auto-trait-leak2.rs:16:5 | LL | send(after()); | ^^^^ `std::rc::Rc>` cannot be sent between threads safely | = help: within `impl std::ops::Fn<(i32,)>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` - = note: required because it appears within the type `[closure@$DIR/auto-trait-leak2.rs:26:5: 26:22 p:std::rc::Rc>]` + = note: required because it appears within the type `[closure@$DIR/auto-trait-leak2.rs:24:5: 24:22 p:std::rc::Rc>]` = note: required because it appears within the type `impl std::ops::Fn<(i32,)>` note: required by `send` - --> $DIR/auto-trait-leak2.rs:12:1 + --> $DIR/auto-trait-leak2.rs:10:1 | LL | fn send(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/impl-trait/method-suggestion-no-duplication.rs b/src/test/ui/impl-trait/method-suggestion-no-duplication.rs index 32f351716734..c5c966a959ae 100644 --- a/src/test/ui/impl-trait/method-suggestion-no-duplication.rs +++ b/src/test/ui/impl-trait/method-suggestion-no-duplication.rs @@ -1,6 +1,4 @@ // issue #21405 -// ignore-tidy-linelength - struct Foo; fn foo(f: F) where F: FnMut(Foo) {} diff --git a/src/test/ui/impl-trait/method-suggestion-no-duplication.stderr b/src/test/ui/impl-trait/method-suggestion-no-duplication.stderr index 8da1ce41a0f9..afb3376638a9 100644 --- a/src/test/ui/impl-trait/method-suggestion-no-duplication.stderr +++ b/src/test/ui/impl-trait/method-suggestion-no-duplication.stderr @@ -1,5 +1,5 @@ error[E0599]: no method named `is_empty` found for type `Foo` in the current scope - --> $DIR/method-suggestion-no-duplication.rs:9:15 + --> $DIR/method-suggestion-no-duplication.rs:7:15 | LL | struct Foo; | ----------- method `is_empty` not found for this diff --git a/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs b/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs index 3b1cd9fbdc80..254d810d79db 100644 --- a/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs +++ b/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - mod auxiliary { mod foo; } diff --git a/src/test/ui/issues/issue-21950.rs b/src/test/ui/issues/issue-21950.rs index 0f78b37fedba..b902893bf822 100644 --- a/src/test/ui/issues/issue-21950.rs +++ b/src/test/ui/issues/issue-21950.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - use std::ops::Add; fn main() { diff --git a/src/test/ui/issues/issue-21950.stderr b/src/test/ui/issues/issue-21950.stderr index d40893b94237..7655e0811e06 100644 --- a/src/test/ui/issues/issue-21950.stderr +++ b/src/test/ui/issues/issue-21950.stderr @@ -1,5 +1,5 @@ error[E0393]: the type parameter `Rhs` must be explicitly specified - --> $DIR/issue-21950.rs:7:14 + --> $DIR/issue-21950.rs:5:14 | LL | &Add; | ^^^ missing reference to `Rhs` @@ -7,7 +7,7 @@ LL | &Add; = note: because of the default `Self` reference, type parameters must be specified on object types error[E0191]: the value of the associated type `Output` (from the trait `std::ops::Add`) must be specified - --> $DIR/issue-21950.rs:7:14 + --> $DIR/issue-21950.rs:5:14 | LL | &Add; | ^^^ associated type `Output` must be specified diff --git a/src/test/ui/issues/issue-22370.rs b/src/test/ui/issues/issue-22370.rs index 44eef2da83ce..90912cfda0d4 100644 --- a/src/test/ui/issues/issue-22370.rs +++ b/src/test/ui/issues/issue-22370.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - trait A {} fn f(a: &A) {} diff --git a/src/test/ui/issues/issue-22370.stderr b/src/test/ui/issues/issue-22370.stderr index 5d76d84d11e6..f21551a55bc9 100644 --- a/src/test/ui/issues/issue-22370.stderr +++ b/src/test/ui/issues/issue-22370.stderr @@ -1,5 +1,5 @@ error[E0393]: the type parameter `T` must be explicitly specified - --> $DIR/issue-22370.rs:5:10 + --> $DIR/issue-22370.rs:3:10 | LL | fn f(a: &A) {} | ^ missing reference to `T` diff --git a/src/test/ui/issues/issue-22560.rs b/src/test/ui/issues/issue-22560.rs index d91211e556b1..4b8e3aa9eb3e 100644 --- a/src/test/ui/issues/issue-22560.rs +++ b/src/test/ui/issues/issue-22560.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - use std::ops::{Add, Sub}; type Test = Add + diff --git a/src/test/ui/issues/issue-22560.stderr b/src/test/ui/issues/issue-22560.stderr index a0ad1fd1279d..5a056dff590f 100644 --- a/src/test/ui/issues/issue-22560.stderr +++ b/src/test/ui/issues/issue-22560.stderr @@ -1,5 +1,5 @@ error[E0393]: the type parameter `Rhs` must be explicitly specified - --> $DIR/issue-22560.rs:5:13 + --> $DIR/issue-22560.rs:3:13 | LL | type Test = Add + | ^^^ missing reference to `Rhs` @@ -7,7 +7,7 @@ LL | type Test = Add + = note: because of the default `Self` reference, type parameters must be specified on object types error[E0393]: the type parameter `Rhs` must be explicitly specified - --> $DIR/issue-22560.rs:8:13 + --> $DIR/issue-22560.rs:6:13 | LL | Sub; | ^^^ missing reference to `Rhs` @@ -15,13 +15,13 @@ LL | Sub; = note: because of the default `Self` reference, type parameters must be specified on object types error[E0225]: only auto traits can be used as additional traits in a trait object - --> $DIR/issue-22560.rs:8:13 + --> $DIR/issue-22560.rs:6:13 | LL | Sub; | ^^^ non-auto additional trait error[E0191]: the value of the associated type `Output` (from the trait `std::ops::Add`) must be specified - --> $DIR/issue-22560.rs:5:13 + --> $DIR/issue-22560.rs:3:13 | LL | type Test = Add + | _____________^ diff --git a/src/test/ui/issues/issue-23080-2.rs b/src/test/ui/issues/issue-23080-2.rs index 750b7e19d89d..319aa2a5cce9 100644 --- a/src/test/ui/issues/issue-23080-2.rs +++ b/src/test/ui/issues/issue-23080-2.rs @@ -1,6 +1,4 @@ -// ignore-tidy-linelength - -//~^^ ERROR +//~ ERROR #![feature(optin_builtin_traits)] diff --git a/src/test/ui/issues/issue-23080-2.stderr b/src/test/ui/issues/issue-23080-2.stderr index 4179ca37a54c..1103de0d9104 100644 --- a/src/test/ui/issues/issue-23080-2.stderr +++ b/src/test/ui/issues/issue-23080-2.stderr @@ -1,5 +1,5 @@ error[E0380]: auto traits cannot have methods or associated items - --> $DIR/issue-23080-2.rs:7:1 + --> $DIR/issue-23080-2.rs:5:1 | LL | / unsafe auto trait Trait { LL | | diff --git a/src/test/ui/issues/issue-23080.rs b/src/test/ui/issues/issue-23080.rs index e25a2d916f5f..fdfee6981447 100644 --- a/src/test/ui/issues/issue-23080.rs +++ b/src/test/ui/issues/issue-23080.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - #![feature(optin_builtin_traits)] unsafe auto trait Trait { diff --git a/src/test/ui/issues/issue-23080.stderr b/src/test/ui/issues/issue-23080.stderr index ed843e793bee..91c272173242 100644 --- a/src/test/ui/issues/issue-23080.stderr +++ b/src/test/ui/issues/issue-23080.stderr @@ -1,5 +1,5 @@ error[E0380]: auto traits cannot have methods or associated items - --> $DIR/issue-23080.rs:5:1 + --> $DIR/issue-23080.rs:3:1 | LL | / unsafe auto trait Trait { LL | | diff --git a/src/test/ui/issues/issue-23281.rs b/src/test/ui/issues/issue-23281.rs index 98a0495451d0..2b457a57d3ed 100644 --- a/src/test/ui/issues/issue-23281.rs +++ b/src/test/ui/issues/issue-23281.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - pub struct Struct; impl Struct { diff --git a/src/test/ui/issues/issue-23281.stderr b/src/test/ui/issues/issue-23281.stderr index 1e57774afe55..e540d4e81924 100644 --- a/src/test/ui/issues/issue-23281.stderr +++ b/src/test/ui/issues/issue-23281.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `(dyn std::ops::Fn() + 'static)` cannot be known at compilation time - --> $DIR/issue-23281.rs:6:5 + --> $DIR/issue-23281.rs:4:5 | LL | pub fn function(funs: Vec ()>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/issues/issue-59488.rs b/src/test/ui/issues/issue-59488.rs index e0a37f6adcc3..6fa9961f26cc 100644 --- a/src/test/ui/issues/issue-59488.rs +++ b/src/test/ui/issues/issue-59488.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - fn foo() -> i32 { 42 } diff --git a/src/test/ui/issues/issue-59488.stderr b/src/test/ui/issues/issue-59488.stderr index e8f0f7bbebf8..e0cb1f7b96df 100644 --- a/src/test/ui/issues/issue-59488.stderr +++ b/src/test/ui/issues/issue-59488.stderr @@ -1,5 +1,5 @@ error[E0369]: binary operation `>` cannot be applied to type `fn() -> i32 {foo}` - --> $DIR/issue-59488.rs:16:9 + --> $DIR/issue-59488.rs:14:9 | LL | foo > 12; | --- ^ -- {integer} @@ -8,7 +8,7 @@ LL | foo > 12; | help: you might have forgotten to call this function: `foo()` error[E0308]: mismatched types - --> $DIR/issue-59488.rs:16:11 + --> $DIR/issue-59488.rs:14:11 | LL | foo > 12; | ^^ expected fn item, found integer @@ -17,7 +17,7 @@ LL | foo > 12; found type `i32` error[E0369]: binary operation `>` cannot be applied to type `fn(i64) -> i64 {bar}` - --> $DIR/issue-59488.rs:20:9 + --> $DIR/issue-59488.rs:18:9 | LL | bar > 13; | --- ^ -- {integer} @@ -26,7 +26,7 @@ LL | bar > 13; | help: you might have forgotten to call this function: `bar( /* arguments */ )` error[E0308]: mismatched types - --> $DIR/issue-59488.rs:20:11 + --> $DIR/issue-59488.rs:18:11 | LL | bar > 13; | ^^ expected fn item, found integer @@ -35,7 +35,7 @@ LL | bar > 13; found type `i64` error[E0369]: binary operation `>` cannot be applied to type `fn() -> i32 {foo}` - --> $DIR/issue-59488.rs:24:9 + --> $DIR/issue-59488.rs:22:9 | LL | foo > foo; | --- ^ --- fn() -> i32 {foo} @@ -51,7 +51,7 @@ LL | foo > foo(); | ^^^^^ error[E0369]: binary operation `>` cannot be applied to type `fn() -> i32 {foo}` - --> $DIR/issue-59488.rs:27:9 + --> $DIR/issue-59488.rs:25:9 | LL | foo > bar; | --- ^ --- fn(i64) -> i64 {bar} @@ -61,7 +61,7 @@ LL | foo > bar; = note: an implementation of `std::cmp::PartialOrd` might be missing for `fn() -> i32 {foo}` error[E0308]: mismatched types - --> $DIR/issue-59488.rs:27:11 + --> $DIR/issue-59488.rs:25:11 | LL | foo > bar; | ^^^ expected fn item, found a different fn item @@ -70,7 +70,7 @@ LL | foo > bar; found type `fn(i64) -> i64 {bar}` error[E0369]: binary operation `==` cannot be applied to type `fn(usize) -> Foo {Foo::Bar}` - --> $DIR/issue-59488.rs:32:5 + --> $DIR/issue-59488.rs:30:5 | LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -82,7 +82,7 @@ LL | assert_eq!(Foo::Bar, i); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `std::fmt::Debug` - --> $DIR/issue-59488.rs:32:5 + --> $DIR/issue-59488.rs:30:5 | LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` @@ -93,7 +93,7 @@ LL | assert_eq!(Foo::Bar, i); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `std::fmt::Debug` - --> $DIR/issue-59488.rs:32:5 + --> $DIR/issue-59488.rs:30:5 | LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` diff --git a/src/test/ui/lint/lint-incoherent-auto-trait-objects.rs b/src/test/ui/lint/lint-incoherent-auto-trait-objects.rs index 0d18965ee733..d53b51447602 100644 --- a/src/test/ui/lint/lint-incoherent-auto-trait-objects.rs +++ b/src/test/ui/lint/lint-incoherent-auto-trait-objects.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - trait Foo {} impl Foo for dyn Send {} diff --git a/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr b/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr index 928c92ef9165..448cc953d40a 100644 --- a/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr +++ b/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr @@ -1,5 +1,5 @@ error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + 'static)`: (E0119) - --> $DIR/lint-incoherent-auto-trait-objects.rs:7:1 + --> $DIR/lint-incoherent-auto-trait-objects.rs:5:1 | LL | impl Foo for dyn Send {} | --------------------- first implementation here @@ -12,7 +12,7 @@ LL | impl Foo for dyn Send + Send {} = note: for more information, see issue #56484 error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) - --> $DIR/lint-incoherent-auto-trait-objects.rs:13:1 + --> $DIR/lint-incoherent-auto-trait-objects.rs:11:1 | LL | impl Foo for dyn Send + Sync {} | ---------------------------- first implementation here @@ -24,7 +24,7 @@ LL | impl Foo for dyn Sync + Send {} = note: for more information, see issue #56484 error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) - --> $DIR/lint-incoherent-auto-trait-objects.rs:17:1 + --> $DIR/lint-incoherent-auto-trait-objects.rs:15:1 | LL | impl Foo for dyn Sync + Send {} | ---------------------------- first implementation here diff --git a/src/test/ui/moves/moves-based-on-type-block-bad.rs b/src/test/ui/moves/moves-based-on-type-block-bad.rs index 99928caa926a..516325ce1d79 100644 --- a/src/test/ui/moves/moves-based-on-type-block-bad.rs +++ b/src/test/ui/moves/moves-based-on-type-block-bad.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - #![feature(box_patterns)] #![feature(box_syntax)] diff --git a/src/test/ui/moves/moves-based-on-type-block-bad.stderr b/src/test/ui/moves/moves-based-on-type-block-bad.stderr index b83a15c9d4da..e28b22035f5d 100644 --- a/src/test/ui/moves/moves-based-on-type-block-bad.stderr +++ b/src/test/ui/moves/moves-based-on-type-block-bad.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/moves-based-on-type-block-bad.rs:24:19 + --> $DIR/moves-based-on-type-block-bad.rs:22:19 | LL | match hellothere.x { | ^^^^^^^^^^^^ @@ -11,7 +11,7 @@ LL | box E::Bar(x) => println!("{}", x.to_string()), | - data moved here | note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait - --> $DIR/moves-based-on-type-block-bad.rs:27:28 + --> $DIR/moves-based-on-type-block-bad.rs:25:28 | LL | box E::Bar(x) => println!("{}", x.to_string()), | ^ diff --git a/src/test/ui/on-unimplemented/auxiliary/no_debug.rs b/src/test/ui/on-unimplemented/auxiliary/no_debug.rs index f240d0e1f1fa..fd3dc0abdc8f 100644 --- a/src/test/ui/on-unimplemented/auxiliary/no_debug.rs +++ b/src/test/ui/on-unimplemented/auxiliary/no_debug.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - #![crate_type = "lib"] pub struct Bar; diff --git a/src/test/ui/on-unimplemented/slice-index.rs b/src/test/ui/on-unimplemented/slice-index.rs index b5e18e2397e0..758220d3c4ec 100644 --- a/src/test/ui/on-unimplemented/slice-index.rs +++ b/src/test/ui/on-unimplemented/slice-index.rs @@ -1,7 +1,4 @@ // Test new Index error message for slices -// ignore-tidy-linelength - - use std::ops::Index; diff --git a/src/test/ui/on-unimplemented/slice-index.stderr b/src/test/ui/on-unimplemented/slice-index.stderr index c1d884929a0c..25a65460071d 100644 --- a/src/test/ui/on-unimplemented/slice-index.stderr +++ b/src/test/ui/on-unimplemented/slice-index.stderr @@ -1,5 +1,5 @@ error[E0277]: the type `[i32]` cannot be indexed by `i32` - --> $DIR/slice-index.rs:11:5 + --> $DIR/slice-index.rs:8:5 | LL | x[1i32]; | ^^^^^^^ slice indices are of type `usize` or ranges of `usize` @@ -8,7 +8,7 @@ LL | x[1i32]; = note: required because of the requirements on the impl of `std::ops::Index` for `[i32]` error[E0277]: the type `[i32]` cannot be indexed by `std::ops::RangeTo` - --> $DIR/slice-index.rs:12:5 + --> $DIR/slice-index.rs:9:5 | LL | x[..1i32]; | ^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` diff --git a/src/test/ui/parser/byte-string-literals.rs b/src/test/ui/parser/byte-string-literals.rs index d028f28655b8..8d8ee4da9871 100644 --- a/src/test/ui/parser/byte-string-literals.rs +++ b/src/test/ui/parser/byte-string-literals.rs @@ -1,8 +1,5 @@ // compile-flags: -Z continue-parse-after-error - -// ignore-tidy-tab - static FOO: &'static [u8] = b"\f"; //~ ERROR unknown byte escape pub fn main() { diff --git a/src/test/ui/parser/byte-string-literals.stderr b/src/test/ui/parser/byte-string-literals.stderr index 6701cfd8e66c..b85548444401 100644 --- a/src/test/ui/parser/byte-string-literals.stderr +++ b/src/test/ui/parser/byte-string-literals.stderr @@ -1,29 +1,29 @@ error: unknown byte escape: f - --> $DIR/byte-string-literals.rs:6:32 + --> $DIR/byte-string-literals.rs:3:32 | LL | static FOO: &'static [u8] = b"\f"; | ^ unknown byte escape error: unknown byte escape: f - --> $DIR/byte-string-literals.rs:9:8 + --> $DIR/byte-string-literals.rs:6:8 | LL | b"\f"; | ^ unknown byte escape error: invalid character in numeric character escape: Z - --> $DIR/byte-string-literals.rs:10:10 + --> $DIR/byte-string-literals.rs:7:10 | LL | b"\x0Z"; | ^ error: byte constant must be ASCII. Use a \xHH escape for a non-ASCII byte - --> $DIR/byte-string-literals.rs:11:7 + --> $DIR/byte-string-literals.rs:8:7 | LL | b"é"; | ^ error: unterminated double quote byte string - --> $DIR/byte-string-literals.rs:12:7 + --> $DIR/byte-string-literals.rs:9:7 | LL | b"a | _______^ diff --git a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs index 9e81ee461695..5297d0d9842e 100644 --- a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs +++ b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - /* * We don't infer `T: 'static` outlives relationships by default. * Instead an additional feature gate `infer_static_outlives_requirements` diff --git a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr index 26cbeeaf5acd..b049d8a4ab3c 100644 --- a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `U` may not live long enough - --> $DIR/dont-infer-static.rs:10:5 + --> $DIR/dont-infer-static.rs:8:5 | LL | struct Foo { | - help: consider adding an explicit lifetime bound `U: 'static`... @@ -7,7 +7,7 @@ LL | bar: Bar | ^^^^^^^^^^^ | note: ...so that the type `U` will meet its required lifetime bounds - --> $DIR/dont-infer-static.rs:10:5 + --> $DIR/dont-infer-static.rs:8:5 | LL | bar: Bar | ^^^^^^^^^^^ diff --git a/src/test/ui/rfc-2093-infer-outlives/enum.rs b/src/test/ui/rfc-2093-infer-outlives/enum.rs index 622794ea9ac3..71d2d3222655 100644 --- a/src/test/ui/rfc-2093-infer-outlives/enum.rs +++ b/src/test/ui/rfc-2093-infer-outlives/enum.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - #![feature(rustc_attrs)] // Needs an explicit where clause stating outlives condition. (RFC 2093) diff --git a/src/test/ui/rfc-2093-infer-outlives/enum.stderr b/src/test/ui/rfc-2093-infer-outlives/enum.stderr index e81d10a66dff..dd56c1f79c71 100644 --- a/src/test/ui/rfc-2093-infer-outlives/enum.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/enum.stderr @@ -1,5 +1,5 @@ error: rustc_outlives - --> $DIR/enum.rs:9:1 + --> $DIR/enum.rs:7:1 | LL | / enum Foo<'a, T> { LL | | One(Bar<'a, T>) @@ -9,7 +9,7 @@ LL | | } = note: T : 'a error: rustc_outlives - --> $DIR/enum.rs:15:1 + --> $DIR/enum.rs:13:1 | LL | / struct Bar<'b, U> { LL | | field2: &'b U @@ -19,7 +19,7 @@ LL | | } = note: U : 'b error: rustc_outlives - --> $DIR/enum.rs:21:1 + --> $DIR/enum.rs:19:1 | LL | / enum Ying<'c, K> { LL | | One(&'c Yang) diff --git a/src/test/ui/span/issue-24356.rs b/src/test/ui/span/issue-24356.rs index 7696bd54226d..7ec05aab29a7 100644 --- a/src/test/ui/span/issue-24356.rs +++ b/src/test/ui/span/issue-24356.rs @@ -1,7 +1,5 @@ // Regression test for #24356 -// ignore-tidy-linelength - fn main() { { use std::ops::Deref; diff --git a/src/test/ui/span/issue-24356.stderr b/src/test/ui/span/issue-24356.stderr index 102cc4201e2e..4827e9ddd50f 100644 --- a/src/test/ui/span/issue-24356.stderr +++ b/src/test/ui/span/issue-24356.stderr @@ -1,5 +1,5 @@ error[E0046]: not all trait items implemented, missing: `Target` - --> $DIR/issue-24356.rs:20:9 + --> $DIR/issue-24356.rs:18:9 | LL | impl Deref for Thing { | ^^^^^^^^^^^^^^^^^^^^ missing `Target` in implementation diff --git a/src/test/ui/span/issue-7575.rs b/src/test/ui/span/issue-7575.rs index c33398cd39ca..ea0a66540b93 100644 --- a/src/test/ui/span/issue-7575.rs +++ b/src/test/ui/span/issue-7575.rs @@ -1,6 +1,4 @@ // Test the mechanism for warning about possible missing `self` declarations. -// ignore-tidy-linelength - trait CtxtFn { fn f8(self, _: usize) -> usize; fn f9(_: usize) -> usize; diff --git a/src/test/ui/span/issue-7575.stderr b/src/test/ui/span/issue-7575.stderr index b2c9e505f07b..614638752f16 100644 --- a/src/test/ui/span/issue-7575.stderr +++ b/src/test/ui/span/issue-7575.stderr @@ -1,24 +1,24 @@ error[E0599]: no method named `f9` found for type `usize` in the current scope - --> $DIR/issue-7575.rs:64:18 + --> $DIR/issue-7575.rs:62:18 | LL | u.f8(42) + u.f9(342) + m.fff(42) | ^^ this is an associated function, not a method | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter note: candidate #1 is defined in the trait `CtxtFn` - --> $DIR/issue-7575.rs:6:5 + --> $DIR/issue-7575.rs:4:5 | LL | fn f9(_: usize) -> usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to disambiguate the method call, write `CtxtFn::f9(u, 342)` instead note: candidate #2 is defined in the trait `OtherTrait` - --> $DIR/issue-7575.rs:10:5 + --> $DIR/issue-7575.rs:8:5 | LL | fn f9(_: usize) -> usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to disambiguate the method call, write `OtherTrait::f9(u, 342)` instead note: candidate #3 is defined in the trait `UnusedTrait` - --> $DIR/issue-7575.rs:19:5 + --> $DIR/issue-7575.rs:17:5 | LL | fn f9(_: usize) -> usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | fn f9(_: usize) -> usize; candidate #3: `UnusedTrait` error[E0599]: no method named `fff` found for type `Myisize` in the current scope - --> $DIR/issue-7575.rs:64:30 + --> $DIR/issue-7575.rs:62:30 | LL | struct Myisize(isize); | ---------------------- method `fff` not found for this @@ -43,20 +43,20 @@ LL | u.f8(42) + u.f9(342) + m.fff(42) | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter note: the candidate is defined in an impl for the type `Myisize` - --> $DIR/issue-7575.rs:41:5 + --> $DIR/issue-7575.rs:39:5 | LL | fn fff(i: isize) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0599]: no method named `is_str` found for type `T` in the current scope - --> $DIR/issue-7575.rs:72:7 + --> $DIR/issue-7575.rs:70:7 | LL | t.is_str() | ^^^^^^ this is an associated function, not a method | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter note: the candidate is defined in the trait `ManyImplTrait` - --> $DIR/issue-7575.rs:47:5 + --> $DIR/issue-7575.rs:45:5 | LL | fn is_str() -> bool { | ^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/stability-attribute/stability-attribute-issue.rs b/src/test/ui/stability-attribute/stability-attribute-issue.rs index ca4d7cc6a6cc..cda1aff133f9 100644 --- a/src/test/ui/stability-attribute/stability-attribute-issue.rs +++ b/src/test/ui/stability-attribute/stability-attribute-issue.rs @@ -1,6 +1,4 @@ // aux-build:stability_attribute_issue.rs -// ignore-tidy-linelength - #![deny(deprecated)] extern crate stability_attribute_issue; diff --git a/src/test/ui/stability-attribute/stability-attribute-issue.stderr b/src/test/ui/stability-attribute/stability-attribute-issue.stderr index 36e192e583e6..7e6fbe1600d1 100644 --- a/src/test/ui/stability-attribute/stability-attribute-issue.stderr +++ b/src/test/ui/stability-attribute/stability-attribute-issue.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature 'unstable_test_feature' - --> $DIR/stability-attribute-issue.rs:10:5 + --> $DIR/stability-attribute-issue.rs:8:5 | LL | unstable(); | ^^^^^^^^ @@ -8,7 +8,7 @@ LL | unstable(); = help: add #![feature(unstable_test_feature)] to the crate attributes to enable error[E0658]: use of unstable library feature 'unstable_test_feature': message - --> $DIR/stability-attribute-issue.rs:12:5 + --> $DIR/stability-attribute-issue.rs:10:5 | LL | unstable_msg(); | ^^^^^^^^^^^^ diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.rs b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.rs index f31dac27caec..e4487fb110cf 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.rs +++ b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.rs @@ -1,5 +1,3 @@ -// ignore-tidy-linelength - #![feature(optin_builtin_traits)] struct Managed; diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr index 5330c04074b2..4d435bf4e8b2 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr @@ -1,18 +1,18 @@ error[E0277]: `MyNotSync` cannot be shared between threads safely - --> $DIR/typeck-default-trait-impl-negation-sync.rs:35:5 + --> $DIR/typeck-default-trait-impl-negation-sync.rs:33:5 | LL | is_sync::(); | ^^^^^^^^^^^^^^^^^^^^ `MyNotSync` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `MyNotSync` note: required by `is_sync` - --> $DIR/typeck-default-trait-impl-negation-sync.rs:31:1 + --> $DIR/typeck-default-trait-impl-negation-sync.rs:29:1 | LL | fn is_sync() {} | ^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `std::cell::UnsafeCell` cannot be shared between threads safely - --> $DIR/typeck-default-trait-impl-negation-sync.rs:38:5 + --> $DIR/typeck-default-trait-impl-negation-sync.rs:36:5 | LL | is_sync::(); | ^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` cannot be shared between threads safely @@ -20,13 +20,13 @@ LL | is_sync::(); = help: within `MyTypeWUnsafe`, the trait `std::marker::Sync` is not implemented for `std::cell::UnsafeCell` = note: required because it appears within the type `MyTypeWUnsafe` note: required by `is_sync` - --> $DIR/typeck-default-trait-impl-negation-sync.rs:31:1 + --> $DIR/typeck-default-trait-impl-negation-sync.rs:29:1 | LL | fn is_sync() {} | ^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `Managed` cannot be shared between threads safely - --> $DIR/typeck-default-trait-impl-negation-sync.rs:41:5 + --> $DIR/typeck-default-trait-impl-negation-sync.rs:39:5 | LL | is_sync::(); | ^^^^^^^^^^^^^^^^^^^^^^^^ `Managed` cannot be shared between threads safely @@ -34,7 +34,7 @@ LL | is_sync::(); = help: within `MyTypeManaged`, the trait `std::marker::Sync` is not implemented for `Managed` = note: required because it appears within the type `MyTypeManaged` note: required by `is_sync` - --> $DIR/typeck-default-trait-impl-negation-sync.rs:31:1 + --> $DIR/typeck-default-trait-impl-negation-sync.rs:29:1 | LL | fn is_sync() {} | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index fb2bfb13a747..9ab88d6e9aea 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -9,8 +9,8 @@ //! * No `TODO` or `XXX` directives. //! * No unexplained ` ```ignore ` or ` ```rust,ignore ` doc tests. //! -//! A number of these checks can be opted-out of with various directives like -//! `// ignore-tidy-linelength`. +//! A number of these checks can be opted-out of with various directives of the form: +//! `// ignore-tidy-CHECK-NAME`. use std::fs::File; use std::io::prelude::*; @@ -90,6 +90,36 @@ fn long_line_is_ok(line: &str) -> bool { false } +enum Directive { + /// By default, tidy always warns against style issues. + Deny, + + /// `Ignore(false)` means that an `ignore-tidy-*` directive + /// has been provided, but is unnecessary. `Ignore(true)` + /// means that it is necessary (i.e. a warning would be + /// produced if `ignore-tidy-*` was not present). + Ignore(bool), +} + +fn contains_ignore_directive(contents: &String, check: &str) -> Directive { + if contents.contains(&format!("// ignore-tidy-{}", check)) || + contents.contains(&format!("# ignore-tidy-{}", check)) { + Directive::Ignore(false) + } else { + Directive::Deny + } +} + +macro_rules! suppressible_tidy_err { + ($err:ident, $skip:ident, $msg:expr) => { + if let Directive::Deny = $skip { + $err($msg); + } else { + $skip = Directive::Ignore(true); + } + }; +} + pub fn check(path: &Path, bad: &mut bool) { let mut contents = String::new(); super::walk(path, &mut super::filter_dirs, &mut |file| { @@ -107,29 +137,32 @@ pub fn check(path: &Path, bad: &mut bool) { tidy_error!(bad, "{}: empty file", file.display()); } - let skip_cr = contents.contains("ignore-tidy-cr"); - let skip_tab = contents.contains("ignore-tidy-tab"); - let skip_length = contents.contains("ignore-tidy-linelength"); - let skip_end_whitespace = contents.contains("ignore-tidy-end-whitespace"); - let skip_copyright = contents.contains("ignore-tidy-copyright"); + let mut skip_cr = contains_ignore_directive(&contents, "cr"); + let mut skip_tab = contains_ignore_directive(&contents, "tab"); + let mut skip_length = contains_ignore_directive(&contents, "linelength"); + let mut skip_end_whitespace = contains_ignore_directive(&contents, "end-whitespace"); + let mut skip_copyright = contains_ignore_directive(&contents, "copyright"); let mut leading_new_lines = false; let mut trailing_new_lines = 0; for (i, line) in contents.split('\n').enumerate() { let mut err = |msg: &str| { tidy_error!(bad, "{}:{}: {}", file.display(), i + 1, msg); }; - if !skip_length && line.chars().count() > COLS - && !long_line_is_ok(line) { - err(&format!("line longer than {} chars", COLS)); + if line.chars().count() > COLS && !long_line_is_ok(line) { + suppressible_tidy_err!( + err, + skip_length, + &format!("line longer than {} chars", COLS) + ); } - if !skip_tab && line.contains('\t') { - err("tab character"); + if line.contains('\t') { + suppressible_tidy_err!(err, skip_tab, "tab character"); } - if !skip_end_whitespace && (line.ends_with(' ') || line.ends_with('\t')) { - err("trailing whitespace"); + if line.ends_with(' ') || line.ends_with('\t') { + suppressible_tidy_err!(err, skip_end_whitespace, "trailing whitespace"); } - if !skip_cr && line.contains('\r') { - err("CR character"); + if line.contains('\r') { + suppressible_tidy_err!(err, skip_cr, "CR character"); } if filename != "style.rs" { if line.contains("TODO") { @@ -139,12 +172,16 @@ pub fn check(path: &Path, bad: &mut bool) { err("XXX is deprecated; use FIXME") } } - if !skip_copyright && (line.starts_with("// Copyright") || - line.starts_with("# Copyright") || - line.starts_with("Copyright")) - && (line.contains("Rust Developers") || - line.contains("Rust Project Developers")) { - err("copyright notices attributed to the Rust Project Developers are deprecated"); + if (line.starts_with("// Copyright") || + line.starts_with("# Copyright") || + line.starts_with("Copyright")) + && (line.contains("Rust Developers") || + line.contains("Rust Project Developers")) { + suppressible_tidy_err!( + err, + skip_copyright, + "copyright notices attributed to the Rust Project Developers are deprecated" + ); } if line.ends_with("```ignore") || line.ends_with("```rust,ignore") { err(UNEXPLAINED_IGNORE_DOCTEST_INFO); @@ -169,5 +206,21 @@ pub fn check(path: &Path, bad: &mut bool) { 1 => {} n => tidy_error!(bad, "{}: too many trailing newlines ({})", file.display(), n), }; + + if let Directive::Ignore(false) = skip_cr { + tidy_error!(bad, "{}: ignoring CR characters unnecessarily", file.display()); + } + if let Directive::Ignore(false) = skip_tab { + tidy_error!(bad, "{}: ignoring tab characters unnecessarily", file.display()); + } + if let Directive::Ignore(false) = skip_length { + tidy_error!(bad, "{}: ignoring line length unnecessarily", file.display()); + } + if let Directive::Ignore(false) = skip_end_whitespace { + tidy_error!(bad, "{}: ignoring trailing whitespace unnecessarily", file.display()); + } + if let Directive::Ignore(false) = skip_copyright { + tidy_error!(bad, "{}: ignoring copyright unnecessarily", file.display()); + } }) }