From 6b02362b32271e90894ede6bfd94909bd1c0b229 Mon Sep 17 00:00:00 2001 From: Kyle Strand Date: Sat, 24 Aug 2019 14:58:01 -0700 Subject: [PATCH 01/12] Add 'must_use' to all functions 'fn(float) -> float' --- src/libstd/f32.rs | 28 ++++++++++++++++++++++++++++ src/libstd/f64.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index e55afc2344f79..d0c64243ee3f5 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -40,6 +40,7 @@ impl f32 { /// assert_eq!(g.floor(), 3.0); /// assert_eq!(h.floor(), -4.0); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn floor(self) -> f32 { @@ -73,6 +74,7 @@ impl f32 { /// assert_eq!(f.ceil(), 4.0); /// assert_eq!(g.ceil(), 4.0); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn ceil(self) -> f32 { @@ -95,6 +97,7 @@ impl f32 { /// assert_eq!(f.round(), 3.0); /// assert_eq!(g.round(), -3.0); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn round(self) -> f32 { @@ -114,6 +117,7 @@ impl f32 { /// assert_eq!(g.trunc(), 3.0); /// assert_eq!(h.trunc(), -3.0); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn trunc(self) -> f32 { @@ -135,6 +139,7 @@ impl f32 { /// assert!(abs_difference_x <= f32::EPSILON); /// assert!(abs_difference_y <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn fract(self) -> f32 { self - self.trunc() } @@ -158,6 +163,7 @@ impl f32 { /// /// assert!(f32::NAN.abs().is_nan()); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn abs(self) -> f32 { @@ -182,6 +188,7 @@ impl f32 { /// /// assert!(f32::NAN.signum().is_nan()); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn signum(self) -> f32 { @@ -367,6 +374,7 @@ impl f32 { /// assert!(abs_difference <= f32::EPSILON); /// assert!(negative.sqrt().is_nan()); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sqrt(self) -> f32 { @@ -393,6 +401,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn exp(self) -> f32 { @@ -417,6 +426,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn exp2(self) -> f32 { @@ -439,6 +449,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn ln(self) -> f32 { @@ -485,6 +496,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn log2(self) -> f32 { @@ -508,6 +520,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn log10(self) -> f32 { @@ -565,6 +578,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn cbrt(self) -> f32 { @@ -606,6 +620,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sin(self) -> f32 { @@ -629,6 +644,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn cos(self) -> f32 { @@ -651,6 +667,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn tan(self) -> f32 { @@ -673,6 +690,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn asin(self) -> f32 { @@ -695,6 +713,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn acos(self) -> f32 { @@ -716,6 +735,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn atan(self) -> f32 { @@ -794,6 +814,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn exp_m1(self) -> f32 { @@ -815,6 +836,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn ln_1p(self) -> f32 { @@ -838,6 +860,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sinh(self) -> f32 { @@ -861,6 +884,7 @@ impl f32 { /// // Same result /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn cosh(self) -> f32 { @@ -884,6 +908,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn tanh(self) -> f32 { @@ -904,6 +929,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn asinh(self) -> f32 { @@ -928,6 +954,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn acosh(self) -> f32 { @@ -951,6 +978,7 @@ impl f32 { /// /// assert!(abs_difference <= 1e-5); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn atanh(self) -> f32 { diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index b357102630091..0878cfd68b486 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -40,6 +40,7 @@ impl f64 { /// assert_eq!(g.floor(), 3.0); /// assert_eq!(h.floor(), -4.0); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn floor(self) -> f64 { @@ -57,6 +58,7 @@ impl f64 { /// assert_eq!(f.ceil(), 4.0); /// assert_eq!(g.ceil(), 4.0); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn ceil(self) -> f64 { @@ -75,6 +77,7 @@ impl f64 { /// assert_eq!(f.round(), 3.0); /// assert_eq!(g.round(), -3.0); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn round(self) -> f64 { @@ -94,6 +97,7 @@ impl f64 { /// assert_eq!(g.trunc(), 3.0); /// assert_eq!(h.trunc(), -3.0); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn trunc(self) -> f64 { @@ -113,6 +117,7 @@ impl f64 { /// assert!(abs_difference_x < 1e-10); /// assert!(abs_difference_y < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn fract(self) -> f64 { self - self.trunc() } @@ -136,6 +141,7 @@ impl f64 { /// /// assert!(f64::NAN.abs().is_nan()); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn abs(self) -> f64 { @@ -160,6 +166,7 @@ impl f64 { /// /// assert!(f64::NAN.signum().is_nan()); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn signum(self) -> f64 { @@ -332,6 +339,7 @@ impl f64 { /// assert!(abs_difference < 1e-10); /// assert!(negative.sqrt().is_nan()); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sqrt(self) -> f64 { @@ -356,6 +364,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn exp(self) -> f64 { @@ -374,6 +383,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn exp2(self) -> f64 { @@ -394,6 +404,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn ln(self) -> f64 { @@ -432,6 +443,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn log2(self) -> f64 { @@ -455,6 +467,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn log10(self) -> f64 { @@ -504,6 +517,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn cbrt(self) -> f64 { @@ -543,6 +557,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sin(self) -> f64 { @@ -562,6 +577,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn cos(self) -> f64 { @@ -580,6 +596,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-14); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn tan(self) -> f64 { @@ -602,6 +619,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn asin(self) -> f64 { @@ -624,6 +642,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn acos(self) -> f64 { @@ -643,6 +662,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn atan(self) -> f64 { @@ -719,6 +739,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn exp_m1(self) -> f64 { @@ -740,6 +761,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn ln_1p(self) -> f64 { @@ -763,6 +785,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sinh(self) -> f64 { @@ -786,6 +809,7 @@ impl f64 { /// // Same result /// assert!(abs_difference < 1.0e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn cosh(self) -> f64 { @@ -809,6 +833,7 @@ impl f64 { /// /// assert!(abs_difference < 1.0e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn tanh(self) -> f64 { @@ -827,6 +852,7 @@ impl f64 { /// /// assert!(abs_difference < 1.0e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn asinh(self) -> f64 { @@ -849,6 +875,7 @@ impl f64 { /// /// assert!(abs_difference < 1.0e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn acosh(self) -> f64 { @@ -872,6 +899,7 @@ impl f64 { /// /// assert!(abs_difference < 1.0e-10); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn atanh(self) -> f64 { From ba2a1fa898c4af38469f4861392defcfb1da00bb Mon Sep 17 00:00:00 2001 From: Kyle Strand Date: Wed, 28 Aug 2019 09:37:52 -0600 Subject: [PATCH 02/12] Add reason for each 'must_use' --- src/libstd/f32.rs | 58 +++++++++++++++++++++++------------------------ src/libstd/f64.rs | 58 +++++++++++++++++++++++------------------------ 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index d0c64243ee3f5..3c08b25446638 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -40,7 +40,7 @@ impl f32 { /// assert_eq!(g.floor(), 3.0); /// assert_eq!(h.floor(), -4.0); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn floor(self) -> f32 { @@ -74,7 +74,7 @@ impl f32 { /// assert_eq!(f.ceil(), 4.0); /// assert_eq!(g.ceil(), 4.0); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn ceil(self) -> f32 { @@ -97,7 +97,7 @@ impl f32 { /// assert_eq!(f.round(), 3.0); /// assert_eq!(g.round(), -3.0); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn round(self) -> f32 { @@ -117,7 +117,7 @@ impl f32 { /// assert_eq!(g.trunc(), 3.0); /// assert_eq!(h.trunc(), -3.0); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn trunc(self) -> f32 { @@ -139,7 +139,7 @@ impl f32 { /// assert!(abs_difference_x <= f32::EPSILON); /// assert!(abs_difference_y <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn fract(self) -> f32 { self - self.trunc() } @@ -163,7 +163,7 @@ impl f32 { /// /// assert!(f32::NAN.abs().is_nan()); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn abs(self) -> f32 { @@ -188,7 +188,7 @@ impl f32 { /// /// assert!(f32::NAN.signum().is_nan()); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn signum(self) -> f32 { @@ -221,7 +221,7 @@ impl f32 { /// assert!(f32::NAN.copysign(1.0).is_nan()); /// ``` #[inline] - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "copysign", since = "1.35.0")] pub fn copysign(self, sign: f32) -> f32 { unsafe { intrinsics::copysignf32(self, sign) } @@ -374,7 +374,7 @@ impl f32 { /// assert!(abs_difference <= f32::EPSILON); /// assert!(negative.sqrt().is_nan()); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sqrt(self) -> f32 { @@ -401,7 +401,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn exp(self) -> f32 { @@ -426,7 +426,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn exp2(self) -> f32 { @@ -449,7 +449,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn ln(self) -> f32 { @@ -496,7 +496,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn log2(self) -> f32 { @@ -520,7 +520,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn log10(self) -> f32 { @@ -578,7 +578,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn cbrt(self) -> f32 { @@ -620,7 +620,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sin(self) -> f32 { @@ -644,7 +644,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn cos(self) -> f32 { @@ -667,7 +667,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn tan(self) -> f32 { @@ -690,7 +690,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn asin(self) -> f32 { @@ -713,7 +713,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn acos(self) -> f32 { @@ -735,7 +735,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn atan(self) -> f32 { @@ -814,7 +814,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn exp_m1(self) -> f32 { @@ -836,7 +836,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn ln_1p(self) -> f32 { @@ -860,7 +860,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sinh(self) -> f32 { @@ -884,7 +884,7 @@ impl f32 { /// // Same result /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn cosh(self) -> f32 { @@ -908,7 +908,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn tanh(self) -> f32 { @@ -929,7 +929,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn asinh(self) -> f32 { @@ -954,7 +954,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn acosh(self) -> f32 { @@ -978,7 +978,7 @@ impl f32 { /// /// assert!(abs_difference <= 1e-5); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn atanh(self) -> f32 { diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 0878cfd68b486..74c81b47bbba1 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -40,7 +40,7 @@ impl f64 { /// assert_eq!(g.floor(), 3.0); /// assert_eq!(h.floor(), -4.0); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn floor(self) -> f64 { @@ -58,7 +58,7 @@ impl f64 { /// assert_eq!(f.ceil(), 4.0); /// assert_eq!(g.ceil(), 4.0); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn ceil(self) -> f64 { @@ -77,7 +77,7 @@ impl f64 { /// assert_eq!(f.round(), 3.0); /// assert_eq!(g.round(), -3.0); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn round(self) -> f64 { @@ -97,7 +97,7 @@ impl f64 { /// assert_eq!(g.trunc(), 3.0); /// assert_eq!(h.trunc(), -3.0); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn trunc(self) -> f64 { @@ -117,7 +117,7 @@ impl f64 { /// assert!(abs_difference_x < 1e-10); /// assert!(abs_difference_y < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn fract(self) -> f64 { self - self.trunc() } @@ -141,7 +141,7 @@ impl f64 { /// /// assert!(f64::NAN.abs().is_nan()); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn abs(self) -> f64 { @@ -166,7 +166,7 @@ impl f64 { /// /// assert!(f64::NAN.signum().is_nan()); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn signum(self) -> f64 { @@ -199,7 +199,7 @@ impl f64 { /// assert!(f64::NAN.copysign(1.0).is_nan()); /// ``` #[inline] - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "copysign", since = "1.35.0")] pub fn copysign(self, sign: f64) -> f64 { unsafe { intrinsics::copysignf64(self, sign) } @@ -339,7 +339,7 @@ impl f64 { /// assert!(abs_difference < 1e-10); /// assert!(negative.sqrt().is_nan()); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sqrt(self) -> f64 { @@ -364,7 +364,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn exp(self) -> f64 { @@ -383,7 +383,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn exp2(self) -> f64 { @@ -404,7 +404,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn ln(self) -> f64 { @@ -443,7 +443,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn log2(self) -> f64 { @@ -467,7 +467,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn log10(self) -> f64 { @@ -517,7 +517,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn cbrt(self) -> f64 { @@ -557,7 +557,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sin(self) -> f64 { @@ -577,7 +577,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn cos(self) -> f64 { @@ -596,7 +596,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-14); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn tan(self) -> f64 { @@ -619,7 +619,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn asin(self) -> f64 { @@ -642,7 +642,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn acos(self) -> f64 { @@ -662,7 +662,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn atan(self) -> f64 { @@ -739,7 +739,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn exp_m1(self) -> f64 { @@ -761,7 +761,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn ln_1p(self) -> f64 { @@ -785,7 +785,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn sinh(self) -> f64 { @@ -809,7 +809,7 @@ impl f64 { /// // Same result /// assert!(abs_difference < 1.0e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn cosh(self) -> f64 { @@ -833,7 +833,7 @@ impl f64 { /// /// assert!(abs_difference < 1.0e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn tanh(self) -> f64 { @@ -852,7 +852,7 @@ impl f64 { /// /// assert!(abs_difference < 1.0e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn asinh(self) -> f64 { @@ -875,7 +875,7 @@ impl f64 { /// /// assert!(abs_difference < 1.0e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn acosh(self) -> f64 { @@ -899,7 +899,7 @@ impl f64 { /// /// assert!(abs_difference < 1.0e-10); /// ``` - #[must_use] + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn atanh(self) -> f64 { From c5b0003d9948ac302631f83e2addfa51db6ac601 Mon Sep 17 00:00:00 2001 From: Kyle Strand Date: Wed, 28 Aug 2019 09:41:45 -0600 Subject: [PATCH 03/12] Annotate functions taking extra args --- src/libstd/f32.rs | 12 +++++++++++- src/libstd/f64.rs | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 3c08b25446638..142558a9f0aa9 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -220,8 +220,8 @@ impl f32 { /// /// assert!(f32::NAN.copysign(1.0).is_nan()); /// ``` - #[inline] #[must_use = "method returns a new number and does not mutate the original value"] + #[inline] #[stable(feature = "copysign", since = "1.35.0")] pub fn copysign(self, sign: f32) -> f32 { unsafe { intrinsics::copysignf32(self, sign) } @@ -247,6 +247,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn mul_add(self, a: f32, b: f32) -> f32 { @@ -270,6 +271,7 @@ impl f32 { /// assert_eq!(a.div_euclid(-b), -1.0); // 7.0 >= -4.0 * -1.0 /// assert_eq!((-a).div_euclid(-b), 2.0); // -7.0 >= -4.0 * 2.0 /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[inline] #[stable(feature = "euclidean_division", since = "1.38.0")] pub fn div_euclid(self, rhs: f32) -> f32 { @@ -303,6 +305,7 @@ impl f32 { /// // limitation due to round-off error /// assert!((-std::f32::EPSILON).rem_euclid(3.0) != 0.0); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[inline] #[stable(feature = "euclidean_division", since = "1.38.0")] pub fn rem_euclid(self, rhs: f32) -> f32 { @@ -329,6 +332,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn powi(self, n: i32) -> f32 { @@ -347,6 +351,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn powf(self, n: f32) -> f32 { @@ -478,6 +483,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn log(self, base: f32) -> f32 { self.ln() / base.ln() } @@ -550,6 +556,7 @@ impl f32 { /// assert!(abs_difference_x <= f32::EPSILON); /// assert!(abs_difference_y <= f32::EPSILON); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] #[rustc_deprecated(since = "1.10.0", @@ -601,6 +608,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn hypot(self, other: f32) -> f32 { @@ -770,6 +778,7 @@ impl f32 { /// assert!(abs_difference_1 <= f32::EPSILON); /// assert!(abs_difference_2 <= f32::EPSILON); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn atan2(self, other: f32) -> f32 { @@ -1006,6 +1015,7 @@ impl f32 { /// assert!((2.0f32).clamp(-2.0, 1.0) == 1.0); /// assert!((std::f32::NAN).clamp(-2.0, 1.0).is_nan()); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[unstable(feature = "clamp", issue = "44095")] #[inline] pub fn clamp(self, min: f32, max: f32) -> f32 { diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 74c81b47bbba1..d46cef149f14c 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -198,9 +198,9 @@ impl f64 { /// /// assert!(f64::NAN.copysign(1.0).is_nan()); /// ``` - #[inline] #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "copysign", since = "1.35.0")] + #[inline] pub fn copysign(self, sign: f64) -> f64 { unsafe { intrinsics::copysignf64(self, sign) } } @@ -223,6 +223,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn mul_add(self, a: f64, b: f64) -> f64 { @@ -246,6 +247,7 @@ impl f64 { /// assert_eq!(a.div_euclid(-b), -1.0); // 7.0 >= -4.0 * -1.0 /// assert_eq!((-a).div_euclid(-b), 2.0); // -7.0 >= -4.0 * 2.0 /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[inline] #[stable(feature = "euclidean_division", since = "1.38.0")] pub fn div_euclid(self, rhs: f64) -> f64 { @@ -279,6 +281,7 @@ impl f64 { /// // limitation due to round-off error /// assert!((-std::f64::EPSILON).rem_euclid(3.0) != 0.0); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[inline] #[stable(feature = "euclidean_division", since = "1.38.0")] pub fn rem_euclid(self, rhs: f64) -> f64 { @@ -302,6 +305,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn powi(self, n: i32) -> f64 { @@ -318,6 +322,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn powf(self, n: f64) -> f64 { @@ -427,6 +432,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn log(self, base: f64) -> f64 { self.ln() / base.ln() } @@ -491,6 +497,7 @@ impl f64 { /// assert!(abs_difference_x < 1e-10); /// assert!(abs_difference_y < 1e-10); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] #[rustc_deprecated(since = "1.10.0", @@ -538,6 +545,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn hypot(self, other: f64) -> f64 { @@ -697,6 +705,7 @@ impl f64 { /// assert!(abs_difference_1 < 1e-10); /// assert!(abs_difference_2 < 1e-10); /// ``` + #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn atan2(self, other: f64) -> f64 { From 54cb728ab8b89ef31578455031519101a93dadc7 Mon Sep 17 00:00:00 2001 From: Kyle Strand Date: Wed, 28 Aug 2019 12:04:32 -0600 Subject: [PATCH 04/12] Let 'clamp' be invoked without using return value; used in tests --- src/libstd/f32.rs | 3 ++- src/libstd/f64.rs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 142558a9f0aa9..aefe4690b106c 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -1015,7 +1015,8 @@ impl f32 { /// assert!((2.0f32).clamp(-2.0, 1.0) == 1.0); /// assert!((std::f32::NAN).clamp(-2.0, 1.0).is_nan()); /// ``` - #[must_use = "method returns a new number and does not mutate the original value"] + // The tests below invoke `clamp` without a return value in order to cause a `panic`. + // #[must_use = "method returns a new number and does not mutate the original value"] #[unstable(feature = "clamp", issue = "44095")] #[inline] pub fn clamp(self, min: f32, max: f32) -> f32 { diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index d46cef149f14c..0eca1434a637f 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -936,6 +936,8 @@ impl f64 { /// assert!((2.0f64).clamp(-2.0, 1.0) == 1.0); /// assert!((std::f64::NAN).clamp(-2.0, 1.0).is_nan()); /// ``` + // The tests below invoke `clamp` without a return value in order to cause a `panic`. + // #[must_use = "method returns a new number and does not mutate the original value"] #[unstable(feature = "clamp", issue = "44095")] #[inline] pub fn clamp(self, min: f64, max: f64) -> f64 { From 1aa5d0cace3a72ae23f32ece5bb18085b36b5258 Mon Sep 17 00:00:00 2001 From: Kyle Strand Date: Thu, 5 Sep 2019 10:22:11 -0600 Subject: [PATCH 05/12] Restore 'must_use' for 'clamp'; fix warning for tests --- src/libstd/f32.rs | 9 ++++----- src/libstd/f64.rs | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index aefe4690b106c..72a8f31cec18b 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -1015,8 +1015,7 @@ impl f32 { /// assert!((2.0f32).clamp(-2.0, 1.0) == 1.0); /// assert!((std::f32::NAN).clamp(-2.0, 1.0).is_nan()); /// ``` - // The tests below invoke `clamp` without a return value in order to cause a `panic`. - // #[must_use = "method returns a new number and does not mutate the original value"] + #[must_use = "method returns a new number and does not mutate the original value"] #[unstable(feature = "clamp", issue = "44095")] #[inline] pub fn clamp(self, min: f32, max: f32) -> f32 { @@ -1631,18 +1630,18 @@ mod tests { #[test] #[should_panic] fn test_clamp_min_greater_than_max() { - 1.0f32.clamp(3.0, 1.0); + let _ = 1.0f32.clamp(3.0, 1.0); } #[test] #[should_panic] fn test_clamp_min_is_nan() { - 1.0f32.clamp(NAN, 1.0); + let _ = 1.0f32.clamp(NAN, 1.0); } #[test] #[should_panic] fn test_clamp_max_is_nan() { - 1.0f32.clamp(3.0, NAN); + let _ = 1.0f32.clamp(3.0, NAN); } } diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 0eca1434a637f..762a87e257279 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -936,8 +936,7 @@ impl f64 { /// assert!((2.0f64).clamp(-2.0, 1.0) == 1.0); /// assert!((std::f64::NAN).clamp(-2.0, 1.0).is_nan()); /// ``` - // The tests below invoke `clamp` without a return value in order to cause a `panic`. - // #[must_use = "method returns a new number and does not mutate the original value"] + #[must_use = "method returns a new number and does not mutate the original value"] #[unstable(feature = "clamp", issue = "44095")] #[inline] pub fn clamp(self, min: f64, max: f64) -> f64 { @@ -1571,18 +1570,18 @@ mod tests { #[test] #[should_panic] fn test_clamp_min_greater_than_max() { - 1.0f64.clamp(3.0, 1.0); + let _ = 1.0f64.clamp(3.0, 1.0); } #[test] #[should_panic] fn test_clamp_min_is_nan() { - 1.0f64.clamp(NAN, 1.0); + let _ = 1.0f64.clamp(NAN, 1.0); } #[test] #[should_panic] fn test_clamp_max_is_nan() { - 1.0f64.clamp(3.0, NAN); + let _ = 1.0f64.clamp(3.0, NAN); } } From 65af429c681e874bee6fb3a864ae3496517a72f4 Mon Sep 17 00:00:00 2001 From: Ethan Brierley Date: Tue, 24 Sep 2019 20:19:32 +0100 Subject: [PATCH 06/12] Stabilize `Option::flatten` --- src/liballoc/tests/lib.rs | 1 - src/libcore/option.rs | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/liballoc/tests/lib.rs b/src/liballoc/tests/lib.rs index 676874c8b27df..79e5ba340b784 100644 --- a/src/liballoc/tests/lib.rs +++ b/src/liballoc/tests/lib.rs @@ -3,7 +3,6 @@ #![feature(drain_filter)] #![feature(exact_size_is_empty)] #![feature(new_uninit)] -#![feature(option_flattening)] #![feature(pattern)] #![feature(trusted_len)] #![feature(try_reserve)] diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 47e3a0d21676f..a0f09fabb3456 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1568,7 +1568,6 @@ impl Option> { /// # Examples /// Basic usage: /// ``` - /// #![feature(option_flattening)] /// let x: Option> = Some(Some(6)); /// assert_eq!(Some(6), x.flatten()); /// @@ -1580,13 +1579,12 @@ impl Option> { /// ``` /// Flattening once only removes one level of nesting: /// ``` - /// #![feature(option_flattening)] /// let x: Option>> = Some(Some(Some(6))); /// assert_eq!(Some(Some(6)), x.flatten()); /// assert_eq!(Some(6), x.flatten().flatten()); /// ``` #[inline] - #[unstable(feature = "option_flattening", issue = "60258")] + #[stable(feature = "option_flattening", since = "1.40.0")] pub fn flatten(self) -> Option { self.and_then(convert::identity) } From 16329402bff5115135804580386ffa8a9e89f1f9 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 9 Oct 2019 13:19:15 +0200 Subject: [PATCH 07/12] syntax/attr: reduce reliance on parser --- src/libsyntax/attr/mod.rs | 29 ++--------------------------- src/libsyntax/config.rs | 4 +++- src/libsyntax/lib.rs | 3 +-- src/libsyntax/parse/mod.rs | 21 +++++++++++++++++++++ src/libsyntax/parse/parser/path.rs | 2 +- src/libsyntax_expand/proc_macro.rs | 9 ++++++++- 6 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 27de084ae98ca..3e240a855e280 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -15,7 +15,7 @@ use crate::ast::{Lit, LitKind, Expr, Item, Local, Stmt, StmtKind, GenericParam}; use crate::mut_visit::visit_clobber; use crate::source_map::{BytePos, Spanned}; use crate::parse::lexer::comments::doc_comment_style; -use crate::parse::parser::Parser; +use crate::parse; use crate::parse::PResult; use crate::parse::token::{self, Token}; use crate::ptr::P; @@ -280,35 +280,10 @@ impl Attribute { self.item.meta(self.span) } - crate fn parse<'a, T, F>(&self, sess: &'a ParseSess, mut f: F) -> PResult<'a, T> - where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, - { - let mut parser = Parser::new( - sess, - self.tokens.clone(), - None, - false, - false, - Some("attribute"), - ); - let result = f(&mut parser)?; - if parser.token != token::Eof { - parser.unexpected()?; - } - Ok(result) - } - - pub fn parse_derive_paths<'a>(&self, sess: &'a ParseSess) -> PResult<'a, Vec> { - if self.tokens.is_empty() { - return Ok(Vec::new()); - } - self.parse(sess, |p| p.parse_derive_paths()) - } - pub fn parse_meta<'a>(&self, sess: &'a ParseSess) -> PResult<'a, MetaItem> { Ok(MetaItem { path: self.path.clone(), - kind: self.parse(sess, |parser| parser.parse_meta_item_kind())?, + kind: parse::parse_in_attr(sess, self, |p| p.parse_meta_item_kind())?, span: self.span, }) } diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 54dc95291d67f..6003fd1d2861a 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -10,6 +10,7 @@ use crate::attr; use crate::ast; use crate::edition::Edition; use crate::mut_visit::*; +use crate::parse; use crate::ptr::P; use crate::sess::ParseSess; use crate::symbol::sym; @@ -112,7 +113,8 @@ impl<'a> StripUnconfigured<'a> { return vec![]; } - let (cfg_predicate, expanded_attrs) = match attr.parse(self.sess, |p| p.parse_cfg_attr()) { + let res = parse::parse_in_attr(self.sess, &attr, |p| p.parse_cfg_attr()); + let (cfg_predicate, expanded_attrs) = match res { Ok(result) => result, Err(mut e) => { e.emit(); diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 3a2af96f7db64..c1114674f14f8 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -96,8 +96,7 @@ pub mod json; pub mod ast; pub mod attr; pub mod source_map; -#[macro_use] -pub mod config; +#[macro_use] pub mod config; pub mod entry; pub mod feature_gate; pub mod mut_visit; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index e6ddf8778ccf0..f5e416b722bbf 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -288,6 +288,27 @@ pub fn stream_to_parser_with_base_dir<'a>( Parser::new(sess, stream, Some(base_dir), true, false, None) } +/// Runs the given subparser `f` on the tokens of the given `attr`'s item. +pub fn parse_in_attr<'a, T>( + sess: &'a ParseSess, + attr: &ast::Attribute, + mut f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, +) -> PResult<'a, T> { + let mut parser = Parser::new( + sess, + attr.tokens.clone(), + None, + false, + false, + Some("attribute"), + ); + let result = f(&mut parser)?; + if parser.token != token::Eof { + parser.unexpected()?; + } + Ok(result) +} + // NOTE(Centril): The following probably shouldn't be here but it acknowledges the // fact that architecturally, we are using parsing (read on below to understand why). diff --git a/src/libsyntax/parse/parser/path.rs b/src/libsyntax/parse/parser/path.rs index 77709a2295339..38a28224daba4 100644 --- a/src/libsyntax/parse/parser/path.rs +++ b/src/libsyntax/parse/parser/path.rs @@ -130,7 +130,7 @@ impl<'a> Parser<'a> { } /// Parse a list of paths inside `#[derive(path_0, ..., path_n)]`. - crate fn parse_derive_paths(&mut self) -> PResult<'a, Vec> { + pub fn parse_derive_paths(&mut self) -> PResult<'a, Vec> { self.expect(&token::OpenDelim(token::Paren))?; let mut list = Vec::new(); while !self.eat(&token::CloseDelim(token::Paren)) { diff --git a/src/libsyntax_expand/proc_macro.rs b/src/libsyntax_expand/proc_macro.rs index 07b618c99a556..8146566549812 100644 --- a/src/libsyntax_expand/proc_macro.rs +++ b/src/libsyntax_expand/proc_macro.rs @@ -200,7 +200,14 @@ crate fn collect_derives(cx: &mut ExtCtxt<'_>, attrs: &mut Vec) return false; } - match attr.parse_derive_paths(cx.parse_sess) { + let parse_derive_paths = |attr: &ast::Attribute| { + if attr.tokens.is_empty() { + return Ok(Vec::new()); + } + parse::parse_in_attr(cx.parse_sess, attr, |p| p.parse_derive_paths()) + }; + + match parse_derive_paths(attr) { Ok(traits) => { result.extend(traits); true From fb12c708521d66b1f727ad4c1ec752a78799980d Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 9 Oct 2019 16:47:38 +0200 Subject: [PATCH 08/12] rustc, rustc_passes: don't depend on syntax_expand. This is done by moving some data definitions to syntax::expand. --- Cargo.lock | 3 --- src/librustc/Cargo.toml | 1 - src/librustc/hir/def.rs | 2 +- src/librustc/hir/lowering.rs | 2 +- src/librustc/hir/lowering/item.rs | 2 +- src/librustc/hir/map/def_collector.rs | 2 +- src/librustc/hir/map/definitions.rs | 4 ++-- src/librustc/hir/map/mod.rs | 2 +- src/librustc/ich/hcx.rs | 3 +-- src/librustc/ich/impls_syntax.rs | 2 +- src/librustc/lint/mod.rs | 2 +- src/librustc/session/mod.rs | 2 +- src/librustc/ty/mod.rs | 4 ++-- src/librustc_codegen_llvm/allocator.rs | 2 +- src/librustc_codegen_llvm/lib.rs | 3 +-- src/librustc_codegen_ssa/Cargo.toml | 1 - .../back/symbol_export.rs | 2 +- src/librustc_codegen_ssa/back/write.rs | 2 +- src/librustc_codegen_ssa/traits/backend.rs | 2 +- src/librustc_interface/passes.rs | 2 +- src/librustc_metadata/creader.rs | 2 +- src/librustc_metadata/decoder.rs | 8 +++---- src/librustc_metadata/encoder.rs | 2 +- src/librustc_passes/Cargo.toml | 1 - src/librustc_passes/ast_validation.rs | 2 +- src/librustc_resolve/build_reduced_graph.rs | 7 +++---- src/librustc_resolve/diagnostics.rs | 2 +- src/librustc_resolve/late/diagnostics.rs | 2 +- src/librustc_resolve/lib.rs | 11 +++++----- src/librustc_resolve/macros.rs | 13 ++++++------ src/librustc_resolve/resolve_imports.rs | 2 +- src/librustdoc/clean/inline.rs | 2 +- src/librustdoc/clean/mod.rs | 4 ++-- src/librustdoc/doctree.rs | 2 +- src/librustdoc/html/item_type.rs | 2 +- src/librustdoc/html/render.rs | 2 +- src/librustdoc/visit_ast.rs | 2 +- .../expand}/allocator.rs | 4 ++-- src/libsyntax/expand/mod.rs | 21 +++++++++++++++++++ src/libsyntax/lib.rs | 1 + src/libsyntax_expand/base.rs | 16 +++----------- src/libsyntax_expand/lib.rs | 3 +-- src/libsyntax_expand/proc_macro.rs | 5 ----- src/libsyntax_ext/deriving/clone.rs | 3 ++- src/libsyntax_ext/deriving/cmp/eq.rs | 3 ++- src/libsyntax_ext/deriving/cmp/partial_eq.rs | 5 +++-- src/libsyntax_ext/deriving/generic/mod.rs | 5 +++-- src/libsyntax_ext/global_allocator.rs | 4 ++-- src/libsyntax_ext/proc_macro_harness.rs | 2 +- src/libsyntax_ext/standard_library_imports.rs | 2 +- 50 files changed, 94 insertions(+), 91 deletions(-) rename src/{libsyntax_expand => libsyntax/expand}/allocator.rs (96%) create mode 100644 src/libsyntax/expand/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 64f3a7ac619c2..4b264ef3f9faf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3135,7 +3135,6 @@ dependencies = [ "serialize", "smallvec", "syntax", - "syntax_expand", "syntax_pos", ] @@ -3451,7 +3450,6 @@ dependencies = [ "rustc_target", "serialize", "syntax", - "syntax_expand", "syntax_pos", "tempfile", ] @@ -3707,7 +3705,6 @@ dependencies = [ "rustc_index", "rustc_target", "syntax", - "syntax_expand", "syntax_pos", ] diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index 38631224fd359..9d26ff6001767 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -29,7 +29,6 @@ rustc_index = { path = "../librustc_index" } errors = { path = "../librustc_errors", package = "rustc_errors" } rustc_serialize = { path = "../libserialize", package = "serialize" } syntax = { path = "../libsyntax" } -syntax_expand = { path = "../libsyntax_expand" } syntax_pos = { path = "../libsyntax_pos" } backtrace = "0.3.3" parking_lot = "0.9" diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs index a071a539e01df..d4d7af92fe359 100644 --- a/src/librustc/hir/def.rs +++ b/src/librustc/hir/def.rs @@ -6,8 +6,8 @@ use crate::ty; use crate::util::nodemap::DefIdMap; use syntax::ast; -use syntax_expand::base::MacroKind; use syntax::ast::NodeId; +use syntax_pos::hygiene::MacroKind; use syntax_pos::Span; use rustc_macros::HashStable; diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 002e6874466bb..12ab44515c38d 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -64,7 +64,7 @@ use syntax::ast; use syntax::ptr::P as AstP; use syntax::ast::*; use syntax::errors; -use syntax_expand::base::SpecialDerives; +use syntax::expand::SpecialDerives; use syntax::print::pprust; use syntax::parse::token::{self, Nonterminal, Token}; use syntax::tokenstream::{TokenStream, TokenTree}; diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 73d2ac5c134d3..9da87090c79bb 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -18,7 +18,7 @@ use smallvec::SmallVec; use syntax::attr; use syntax::ast::*; use syntax::visit::{self, Visitor}; -use syntax_expand::base::SpecialDerives; +use syntax::expand::SpecialDerives; use syntax::source_map::{respan, DesugaringKind, Spanned}; use syntax::symbol::{kw, sym}; use syntax_pos::Span; diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs index 7c8fdcc8b12e9..e9970e30bf9e5 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -2,10 +2,10 @@ use crate::hir::map::definitions::*; use crate::hir::def_id::DefIndex; use syntax::ast::*; -use syntax_expand::hygiene::ExpnId; use syntax::visit; use syntax::symbol::{kw, sym}; use syntax::parse::token::{self, Token}; +use syntax_pos::hygiene::ExpnId; use syntax_pos::Span; /// Creates `DefId`s for nodes in the AST. diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index 58e638e93ba34..4e163314f6b07 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -17,8 +17,8 @@ use std::borrow::Borrow; use std::fmt::Write; use std::hash::Hash; use syntax::ast; -use syntax_expand::hygiene::ExpnId; -use syntax::symbol::{Symbol, sym}; +use syntax_pos::symbol::{Symbol, sym}; +use syntax_pos::hygiene::ExpnId; use syntax_pos::{Span, DUMMY_SP}; /// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa. diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index f839087ec0271..cd36944253dbb 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -20,7 +20,7 @@ use rustc_data_structures::svh::Svh; use rustc_index::vec::IndexVec; use syntax::ast::{self, Name, NodeId}; use syntax::source_map::Spanned; -use syntax_expand::base::MacroKind; +use syntax_pos::hygiene::MacroKind; use syntax_pos::{Span, DUMMY_SP}; pub mod blocks; diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 14d0673ecc03f..957dab39414f0 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -13,11 +13,10 @@ use std::cell::RefCell; use syntax::ast; use syntax::source_map::SourceMap; -use syntax_expand::hygiene::SyntaxContext; use syntax::symbol::Symbol; use syntax::tokenstream::DelimSpan; use syntax_pos::{Span, DUMMY_SP}; -use syntax_pos::hygiene; +use syntax_pos::hygiene::{self, SyntaxContext}; use rustc_data_structures::stable_hasher::{ HashStable, StableHasher, ToStableHashKey, diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 2510d7efb59e7..51aa79078f2fc 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -60,7 +60,7 @@ impl_stable_hash_for!(enum ::syntax::ast::AsmDialect { Intel }); -impl_stable_hash_for!(enum ::syntax_expand::base::MacroKind { +impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind { Bang, Attr, Derive, diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 3c35bdae66e9d..4da146b1e5d57 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -39,8 +39,8 @@ use syntax::ast; use syntax::source_map::{MultiSpan, ExpnKind, DesugaringKind}; use syntax::early_buffered_lints::BufferedEarlyLintId; use syntax::edition::Edition; -use syntax_expand::base::MacroKind; use syntax::symbol::{Symbol, sym}; +use syntax_pos::hygiene::MacroKind; use syntax_pos::Span; pub use crate::lint::context::{LateContext, EarlyContext, LintContext, LintStore, diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index bd2460cfab116..8bf4765111d36 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -24,7 +24,7 @@ use errors::emitter::HumanReadableErrorType; use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter}; use syntax::ast::{self, NodeId}; use syntax::edition::Edition; -use syntax_expand::allocator::AllocatorKind; +use syntax::expand::allocator::AllocatorKind; use syntax::feature_gate::{self, AttributeType}; use syntax::json::JsonEmitter; use syntax::source_map; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 260b525507e80..1353fe89017c4 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -46,8 +46,8 @@ use std::{mem, ptr}; use std::ops::Range; use syntax::ast::{self, Name, Ident, NodeId}; use syntax::attr; -use syntax_expand::hygiene::ExpnId; -use syntax::symbol::{kw, sym, Symbol}; +use syntax_pos::symbol::{kw, sym, Symbol}; +use syntax_pos::hygiene::ExpnId; use syntax_pos::Span; use smallvec; diff --git a/src/librustc_codegen_llvm/allocator.rs b/src/librustc_codegen_llvm/allocator.rs index 8c60c030eacdb..11b6e0befa1b1 100644 --- a/src/librustc_codegen_llvm/allocator.rs +++ b/src/librustc_codegen_llvm/allocator.rs @@ -3,7 +3,7 @@ use std::ffi::CString; use crate::attributes; use libc::c_uint; use rustc::ty::TyCtxt; -use syntax_expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; +use syntax::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; use crate::ModuleLlvm; use crate::llvm::{self, False, True}; diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index e09b600afd4e5..2ad6c28cd0838 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -39,7 +39,6 @@ extern crate rustc_driver as _; #[macro_use] extern crate log; extern crate syntax; -extern crate syntax_expand; extern crate syntax_pos; extern crate rustc_errors as errors; @@ -49,7 +48,7 @@ use rustc_codegen_ssa::back::lto::{SerializedModule, LtoModuleCodegen, ThinModul use rustc_codegen_ssa::CompiledModule; use errors::{FatalError, Handler}; use rustc::dep_graph::WorkProduct; -use syntax_expand::allocator::AllocatorKind; +use syntax::expand::allocator::AllocatorKind; pub use llvm_util::target_features; use std::any::Any; use std::sync::Arc; diff --git a/src/librustc_codegen_ssa/Cargo.toml b/src/librustc_codegen_ssa/Cargo.toml index 6992f93d99949..c7d09a423d5e3 100644 --- a/src/librustc_codegen_ssa/Cargo.toml +++ b/src/librustc_codegen_ssa/Cargo.toml @@ -21,7 +21,6 @@ tempfile = "3.1" rustc_serialize = { path = "../libserialize", package = "serialize" } syntax = { path = "../libsyntax" } -syntax_expand = { path = "../libsyntax_expand" } syntax_pos = { path = "../libsyntax_pos" } rustc = { path = "../librustc" } rustc_apfloat = { path = "../librustc_apfloat" } diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index d866a10f06935..9443f22572378 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -14,7 +14,7 @@ use rustc::ty::query::Providers; use rustc::ty::subst::SubstsRef; use rustc::util::nodemap::{FxHashMap, DefIdMap}; use rustc_index::vec::IndexVec; -use syntax_expand::allocator::ALLOCATOR_METHODS; +use syntax::expand::allocator::ALLOCATOR_METHODS; pub type ExportedSymbols = FxHashMap< CrateNum, diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index 762b50f1659cc..b302b9ae7f0e4 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -27,7 +27,7 @@ use rustc_errors::{Handler, Level, FatalError, DiagnosticId, SourceMapperDyn}; use rustc_errors::emitter::{Emitter}; use rustc_target::spec::MergeFunctions; use syntax::attr; -use syntax_expand::hygiene::ExpnId; +use syntax_pos::hygiene::ExpnId; use syntax_pos::symbol::{Symbol, sym}; use jobserver::{Client, Acquired}; diff --git a/src/librustc_codegen_ssa/traits/backend.rs b/src/librustc_codegen_ssa/traits/backend.rs index 1fff740d7403f..8ab8243afdab7 100644 --- a/src/librustc_codegen_ssa/traits/backend.rs +++ b/src/librustc_codegen_ssa/traits/backend.rs @@ -9,7 +9,7 @@ use rustc::ty::TyCtxt; use rustc_codegen_utils::codegen_backend::CodegenBackend; use std::sync::Arc; use std::sync::mpsc; -use syntax_expand::allocator::AllocatorKind; +use syntax::expand::allocator::AllocatorKind; use syntax_pos::symbol::Symbol; pub trait BackendTypes { diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 58936172c5bce..b8593bd91990e 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -502,7 +502,7 @@ pub fn lower_to_hir( // Discard hygiene data, which isn't required after lowering to HIR. if !sess.opts.debugging_opts.keep_hygiene_data { - syntax_expand::hygiene::clear_syntax_context_map(); + syntax_pos::hygiene::clear_syntax_context_map(); } Ok(hir_forest) diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index f0a68058de8ca..234a5395047c6 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -25,7 +25,7 @@ use std::{cmp, fs}; use syntax::ast; use syntax::attr; -use syntax_expand::allocator::{global_allocator_spans, AllocatorKind}; +use syntax::expand::allocator::{global_allocator_spans, AllocatorKind}; use syntax::symbol::{Symbol, sym}; use syntax::span_fatal; use syntax_pos::{Span, DUMMY_SP}; diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 09ff7891a9deb..0e6ecbbf0176a 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -33,12 +33,12 @@ use rustc_serialize::{Decodable, Decoder, Encodable, SpecializedDecoder, opaque} use syntax::attr; use syntax::ast::{self, Ident}; use syntax::source_map::{self, respan, Spanned}; -use syntax::symbol::{Symbol, sym}; -use syntax_expand::base::{MacroKind, SyntaxExtensionKind, SyntaxExtension}; -use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP}; +use syntax_expand::base::{SyntaxExtensionKind, SyntaxExtension}; +use syntax_expand::proc_macro::{AttrProcMacro, ProcMacroDerive, BangProcMacro}; +use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP, hygiene::MacroKind}; +use syntax_pos::symbol::{Symbol, sym}; use log::debug; use proc_macro::bridge::client::ProcMacro; -use syntax_expand::proc_macro::{AttrProcMacro, ProcMacroDerive, BangProcMacro}; crate struct DecodeContext<'a, 'tcx> { opaque: opaque::Decoder<'a>, diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 0dc9f91ae00e1..fa961fe04dcc4 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -32,7 +32,7 @@ use std::path::Path; use std::u32; use syntax::ast; use syntax::attr; -use syntax_expand::proc_macro::is_proc_macro_attr; +use syntax::expand::is_proc_macro_attr; use syntax::source_map::Spanned; use syntax::symbol::{kw, sym, Ident, Symbol}; use syntax_pos::{self, FileName, SourceFile, Span}; diff --git a/src/librustc_passes/Cargo.toml b/src/librustc_passes/Cargo.toml index 118deb560d62f..9d29a23031443 100644 --- a/src/librustc_passes/Cargo.toml +++ b/src/librustc_passes/Cargo.toml @@ -13,7 +13,6 @@ log = "0.4" rustc = { path = "../librustc" } rustc_data_structures = { path = "../librustc_data_structures" } syntax = { path = "../libsyntax" } -syntax_expand = { path = "../libsyntax_expand" } syntax_pos = { path = "../libsyntax_pos" } errors = { path = "../librustc_errors", package = "rustc_errors" } rustc_target = { path = "../librustc_target" } diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 74de31263d394..994e9405fb643 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -14,7 +14,7 @@ use rustc::session::Session; use rustc_data_structures::fx::FxHashMap; use syntax::ast::*; use syntax::attr; -use syntax_expand::proc_macro::is_proc_macro_attr; +use syntax::expand::is_proc_macro_attr; use syntax::feature_gate::is_builtin_attr; use syntax::source_map::Spanned; use syntax::symbol::{kw, sym}; diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index c0fb8e33a819e..d0725c7b8028d 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -32,9 +32,6 @@ use syntax::attr; use syntax::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId}; use syntax::ast::{MetaItemKind, StmtKind, TraitItem, TraitItemKind}; -use syntax_expand::base::{MacroKind, SyntaxExtension}; -use syntax_expand::expand::AstFragment; -use syntax_expand::hygiene::ExpnId; use syntax::feature_gate::is_builtin_attr; use syntax::parse::token::{self, Token}; use syntax::print::pprust; @@ -42,7 +39,9 @@ use syntax::{span_err, struct_span_err}; use syntax::source_map::{respan, Spanned}; use syntax::symbol::{kw, sym}; use syntax::visit::{self, Visitor}; - +use syntax_expand::base::SyntaxExtension; +use syntax_expand::expand::AstFragment; +use syntax_pos::hygiene::{MacroKind, ExpnId}; use syntax_pos::{Span, DUMMY_SP}; use log::debug; diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 7634093fbefba..c0dfb7381acc2 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -10,12 +10,12 @@ use rustc::session::Session; use rustc::ty::{self, DefIdTree}; use rustc::util::nodemap::FxHashSet; use syntax::ast::{self, Ident, Path}; -use syntax_expand::base::MacroKind; use syntax::feature_gate::BUILTIN_ATTRIBUTES; use syntax::source_map::SourceMap; use syntax::struct_span_err; use syntax::symbol::{Symbol, kw}; use syntax::util::lev_distance::find_best_match_for_name; +use syntax_pos::hygiene::MacroKind; use syntax_pos::{BytePos, Span, MultiSpan}; use crate::resolve_imports::{ImportDirective, ImportDirectiveSubclass, ImportResolver}; diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index 2721df4c68763..9c31f89987ed0 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -13,9 +13,9 @@ use rustc::hir::PrimTy; use rustc::session::config::nightly_options; use rustc::util::nodemap::FxHashSet; use syntax::ast::{self, Expr, ExprKind, Ident, NodeId, Path, Ty, TyKind}; -use syntax_expand::base::MacroKind; use syntax::symbol::kw; use syntax::util::lev_distance::find_best_match_for_name; +use syntax_pos::hygiene::MacroKind; use syntax_pos::Span; type Res = def::Res; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 9239280634724..cea205a823665 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -35,17 +35,18 @@ use rustc::span_bug; use rustc_metadata::creader::CrateLoader; use rustc_metadata::cstore::CStore; -use syntax_expand::hygiene::{ExpnId, Transparency, SyntaxContext}; -use syntax_expand::base::{SyntaxExtension, MacroKind, SpecialDerives}; use syntax::{struct_span_err, unwrap_or}; -use syntax::attr; +use syntax::expand::SpecialDerives; use syntax::ast::{self, Name, NodeId, Ident, FloatTy, IntTy, UintTy}; -use syntax::ast::{ItemKind, Path, CRATE_NODE_ID, Crate}; +use syntax::ast::{CRATE_NODE_ID, Crate}; +use syntax::ast::{ItemKind, Path}; +use syntax::attr; use syntax::print::pprust; use syntax::symbol::{kw, sym}; use syntax::source_map::Spanned; use syntax::visit::{self, Visitor}; - +use syntax_expand::base::SyntaxExtension; +use syntax_pos::hygiene::{MacroKind, ExpnId, Transparency, SyntaxContext}; use syntax_pos::{Span, DUMMY_SP}; use errors::{Applicability, DiagnosticBuilder}; diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 94fe0cc57403e..8b1b6db3ddc23 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -14,20 +14,21 @@ use rustc::{ty, lint, span_bug}; use syntax::ast::{self, NodeId, Ident}; use syntax::attr::StabilityLevel; use syntax::edition::Edition; -use syntax_expand::base::{self, InvocationRes, Indeterminate, SpecialDerives}; -use syntax_expand::base::{MacroKind, SyntaxExtension}; -use syntax_expand::expand::{AstFragment, AstFragmentKind, Invocation, InvocationKind}; -use syntax_expand::hygiene::{self, ExpnId, ExpnData, ExpnKind}; -use syntax_expand::compile_declarative_macro; +use syntax::expand::SpecialDerives; use syntax::feature_gate::{emit_feature_err, is_builtin_attr_name}; use syntax::feature_gate::GateIssue; use syntax::print::pprust; use syntax::symbol::{Symbol, kw, sym}; +use syntax_expand::base::{self, InvocationRes, Indeterminate}; +use syntax_expand::base::SyntaxExtension; +use syntax_expand::expand::{AstFragment, AstFragmentKind, Invocation, InvocationKind}; +use syntax_expand::compile_declarative_macro; +use syntax_pos::hygiene::{self, ExpnId, ExpnData, ExpnKind}; use syntax_pos::{Span, DUMMY_SP}; use std::{mem, ptr}; use rustc_data_structures::sync::Lrc; -use syntax_pos::hygiene::AstPass; +use syntax_pos::hygiene::{MacroKind, AstPass}; type Res = def::Res; diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 31340ddd68372..c95009858e4c0 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -28,10 +28,10 @@ use rustc::util::nodemap::FxHashSet; use rustc::{bug, span_bug}; use syntax::ast::{Ident, Name, NodeId, CRATE_NODE_ID}; -use syntax_expand::hygiene::ExpnId; use syntax::symbol::kw; use syntax::util::lev_distance::find_best_match_for_name; use syntax::{struct_span_err, unwrap_or}; +use syntax_pos::hygiene::ExpnId; use syntax_pos::{MultiSpan, Span}; use log::*; diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index a6a8fec429e20..b3b3750320a95 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -3,8 +3,8 @@ use std::iter::once; use syntax::ast; -use syntax_expand::base::MacroKind; use syntax::symbol::sym; +use syntax_pos::hygiene::MacroKind; use syntax_pos::Span; use rustc::hir; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a642491b28181..bdc0206223036 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -28,10 +28,10 @@ use rustc::ty::layout::VariantIdx; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use syntax::ast::{self, Attribute, AttrStyle, AttrItem, Ident}; use syntax::attr; -use syntax_expand::base::MacroKind; use syntax::parse::lexer::comments; use syntax::source_map::DUMMY_SP; -use syntax::symbol::{Symbol, kw, sym}; +use syntax_pos::symbol::{Symbol, kw, sym}; +use syntax_pos::hygiene::MacroKind; use syntax_pos::{self, Pos, FileName}; use std::collections::hash_map::Entry; diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index bbc00147ee14e..002ca6fe983ba 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -4,7 +4,7 @@ pub use self::StructType::*; use syntax::ast; use syntax::ast::Name; -use syntax_expand::base::MacroKind; +use syntax_pos::hygiene::MacroKind; use syntax_pos::{self, Span}; use rustc::hir; diff --git a/src/librustdoc/html/item_type.rs b/src/librustdoc/html/item_type.rs index e015739b03c40..f5e45924893ea 100644 --- a/src/librustdoc/html/item_type.rs +++ b/src/librustdoc/html/item_type.rs @@ -1,7 +1,7 @@ //! Item types. use std::fmt; -use syntax_expand::base::MacroKind; +use syntax_pos::hygiene::MacroKind; use crate::clean; /// Item type. Corresponds to `clean::ItemEnum` variants. diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 414c3137376a9..c4ee84d33f39b 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -49,7 +49,7 @@ use syntax::feature_gate::UnstableFeatures; use syntax::print::pprust; use syntax::source_map::FileName; use syntax::symbol::{Symbol, sym}; -use syntax_expand::base::MacroKind; +use syntax_pos::hygiene::MacroKind; use rustc::hir::def_id::DefId; use rustc::middle::privacy::AccessLevels; use rustc::middle::stability; diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 70c30687dabca..5a83569f02a5c 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -8,9 +8,9 @@ use rustc::middle::privacy::AccessLevel; use rustc::util::nodemap::{FxHashSet, FxHashMap}; use rustc::ty::TyCtxt; use syntax::ast; -use syntax_expand::base::MacroKind; use syntax::source_map::Spanned; use syntax::symbol::sym; +use syntax_pos::hygiene::MacroKind; use syntax_pos::{self, Span}; use std::mem; diff --git a/src/libsyntax_expand/allocator.rs b/src/libsyntax/expand/allocator.rs similarity index 96% rename from src/libsyntax_expand/allocator.rs rename to src/libsyntax/expand/allocator.rs index 3526be17721a8..20487b9af03a6 100644 --- a/src/libsyntax_expand/allocator.rs +++ b/src/libsyntax/expand/allocator.rs @@ -1,5 +1,5 @@ -use syntax::{ast, attr, visit}; -use syntax::symbol::{sym, Symbol}; +use crate::{ast, attr, visit}; +use syntax_pos::symbol::{sym, Symbol}; use syntax_pos::Span; #[derive(Clone, Copy)] diff --git a/src/libsyntax/expand/mod.rs b/src/libsyntax/expand/mod.rs new file mode 100644 index 0000000000000..038f60287befd --- /dev/null +++ b/src/libsyntax/expand/mod.rs @@ -0,0 +1,21 @@ +//! Definitions shared by macros / syntax extensions and e.g. librustc. + +use crate::ast::Attribute; +use syntax_pos::symbol::sym; + +pub mod allocator; + +bitflags::bitflags! { + /// Built-in derives that need some extra tracking beyond the usual macro functionality. + #[derive(Default)] + pub struct SpecialDerives: u8 { + const PARTIAL_EQ = 1 << 0; + const EQ = 1 << 1; + const COPY = 1 << 2; + } +} + +pub fn is_proc_macro_attr(attr: &Attribute) -> bool { + [sym::proc_macro, sym::proc_macro_attribute, sym::proc_macro_derive] + .iter().any(|kind| attr.check_name(*kind)) +} diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index c1114674f14f8..7be6e6c7e1876 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -95,6 +95,7 @@ pub mod json; pub mod ast; pub mod attr; +pub mod expand; pub mod source_map; #[macro_use] pub mod config; pub mod entry; diff --git a/src/libsyntax_expand/base.rs b/src/libsyntax_expand/base.rs index 58edf23a5b1e2..a66263a9a028a 100644 --- a/src/libsyntax_expand/base.rs +++ b/src/libsyntax_expand/base.rs @@ -1,5 +1,4 @@ use crate::expand::{self, AstFragment, Invocation}; -use crate::hygiene::ExpnId; use syntax::ast::{self, NodeId, Attribute, Name, PatKind}; use syntax::attr::{self, HasAttrs, Stability, Deprecation}; @@ -14,11 +13,12 @@ use syntax::symbol::{kw, sym, Ident, Symbol}; use syntax::{ThinVec, MACRO_ARGUMENTS}; use syntax::tokenstream::{self, TokenStream}; use syntax::visit::Visitor; +crate use syntax::expand::SpecialDerives; use errors::{DiagnosticBuilder, DiagnosticId}; use smallvec::{smallvec, SmallVec}; use syntax_pos::{FileName, Span, MultiSpan, DUMMY_SP}; -use syntax_pos::hygiene::{AstPass, ExpnData, ExpnKind}; +use syntax_pos::hygiene::{AstPass, ExpnId, ExpnData, ExpnKind}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::{self, Lrc}; @@ -27,7 +27,7 @@ use std::path::PathBuf; use std::rc::Rc; use std::default::Default; -pub use syntax_pos::hygiene::MacroKind; +crate use syntax_pos::hygiene::MacroKind; #[derive(Debug,Clone)] pub enum Annotatable { @@ -837,16 +837,6 @@ pub enum InvocationRes { /// Error type that denotes indeterminacy. pub struct Indeterminate; -bitflags::bitflags! { - /// Built-in derives that need some extra tracking beyond the usual macro functionality. - #[derive(Default)] - pub struct SpecialDerives: u8 { - const PARTIAL_EQ = 1 << 0; - const EQ = 1 << 1; - const COPY = 1 << 2; - } -} - pub trait Resolver { fn next_node_id(&mut self) -> NodeId; diff --git a/src/libsyntax_expand/lib.rs b/src/libsyntax_expand/lib.rs index db292b619be39..10eb3ecb20bd0 100644 --- a/src/libsyntax_expand/lib.rs +++ b/src/libsyntax_expand/lib.rs @@ -28,9 +28,8 @@ macro_rules! panictry { mod placeholders; mod proc_macro_server; -pub use syntax_pos::hygiene; +crate use syntax_pos::hygiene; pub use mbe::macro_rules::compile_declarative_macro; -pub mod allocator; pub mod base; pub mod build; pub mod expand; diff --git a/src/libsyntax_expand/proc_macro.rs b/src/libsyntax_expand/proc_macro.rs index 8146566549812..bda9478ce96a9 100644 --- a/src/libsyntax_expand/proc_macro.rs +++ b/src/libsyntax_expand/proc_macro.rs @@ -178,11 +178,6 @@ impl<'a> Visitor<'a> for MarkAttrs<'a> { fn visit_mac(&mut self, _mac: &Mac) {} } -pub fn is_proc_macro_attr(attr: &Attribute) -> bool { - [sym::proc_macro, sym::proc_macro_attribute, sym::proc_macro_derive] - .iter().any(|kind| attr.check_name(*kind)) -} - crate fn collect_derives(cx: &mut ExtCtxt<'_>, attrs: &mut Vec) -> Vec { let mut result = Vec::new(); attrs.retain(|attr| { diff --git a/src/libsyntax_ext/deriving/clone.rs b/src/libsyntax_ext/deriving/clone.rs index 67ef69babdc0a..061afa379c6e3 100644 --- a/src/libsyntax_ext/deriving/clone.rs +++ b/src/libsyntax_ext/deriving/clone.rs @@ -3,7 +3,8 @@ use crate::deriving::generic::*; use crate::deriving::generic::ty::*; use syntax::ast::{self, Expr, GenericArg, Generics, ItemKind, MetaItem, VariantData}; -use syntax_expand::base::{Annotatable, ExtCtxt, SpecialDerives}; +use syntax::expand::SpecialDerives; +use syntax_expand::base::{Annotatable, ExtCtxt}; use syntax::ptr::P; use syntax::symbol::{kw, sym, Symbol}; use syntax_pos::Span; diff --git a/src/libsyntax_ext/deriving/cmp/eq.rs b/src/libsyntax_ext/deriving/cmp/eq.rs index 162aaedafea32..eddf8eea1db32 100644 --- a/src/libsyntax_ext/deriving/cmp/eq.rs +++ b/src/libsyntax_ext/deriving/cmp/eq.rs @@ -3,9 +3,10 @@ use crate::deriving::generic::*; use crate::deriving::generic::ty::*; use syntax::ast::{self, Ident, Expr, MetaItem, GenericArg}; -use syntax_expand::base::{Annotatable, ExtCtxt, SpecialDerives}; +use syntax::expand::SpecialDerives; use syntax::ptr::P; use syntax::symbol::{sym, Symbol}; +use syntax_expand::base::{Annotatable, ExtCtxt}; use syntax_pos::Span; pub fn expand_deriving_eq(cx: &mut ExtCtxt<'_>, diff --git a/src/libsyntax_ext/deriving/cmp/partial_eq.rs b/src/libsyntax_ext/deriving/cmp/partial_eq.rs index c3e2b78bbe506..2e2be91de8a46 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_eq.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_eq.rs @@ -3,10 +3,11 @@ use crate::deriving::generic::*; use crate::deriving::generic::ty::*; use syntax::ast::{BinOpKind, Expr, MetaItem}; -use syntax_expand::base::{Annotatable, ExtCtxt, SpecialDerives}; +use syntax::expand::SpecialDerives; use syntax::ptr::P; use syntax::symbol::sym; -use syntax_pos::{self, Span}; +use syntax_expand::base::{Annotatable, ExtCtxt}; +use syntax_pos::Span; pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt<'_>, span: Span, diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 216338c1a8861..c04b65245e1f7 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -186,13 +186,14 @@ use rustc_target::spec::abi::Abi; use syntax::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind}; use syntax::ast::{VariantData, GenericParamKind, GenericArg}; use syntax::attr; +use syntax::expand::SpecialDerives; use syntax::source_map::respan; use syntax::util::map_in_place::MapInPlace; use syntax::ptr::P; use syntax::sess::ParseSess; use syntax::symbol::{Symbol, kw, sym}; -use syntax_expand::base::{Annotatable, ExtCtxt, SpecialDerives}; -use syntax_pos::{Span}; +use syntax_expand::base::{Annotatable, ExtCtxt}; +use syntax_pos::Span; use ty::{LifetimeBounds, Path, Ptr, PtrTy, Self_, Ty}; diff --git a/src/libsyntax_ext/global_allocator.rs b/src/libsyntax_ext/global_allocator.rs index 75dda9535b333..90d2ea38bc336 100644 --- a/src/libsyntax_ext/global_allocator.rs +++ b/src/libsyntax_ext/global_allocator.rs @@ -2,10 +2,10 @@ use crate::util::check_builtin_macro_attribute; use syntax::ast::{ItemKind, Mutability, Stmt, Ty, TyKind, Unsafety}; use syntax::ast::{self, Param, Attribute, Expr, FnHeader, Generics, Ident}; -use syntax_expand::allocator::{AllocatorKind, AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS}; -use syntax_expand::base::{Annotatable, ExtCtxt}; +use syntax::expand::allocator::{AllocatorKind, AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS}; use syntax::ptr::P; use syntax::symbol::{kw, sym, Symbol}; +use syntax_expand::base::{Annotatable, ExtCtxt}; use syntax_pos::Span; pub fn expand( diff --git a/src/libsyntax_ext/proc_macro_harness.rs b/src/libsyntax_ext/proc_macro_harness.rs index c874f1ffb1175..fc4a7a0a0fe47 100644 --- a/src/libsyntax_ext/proc_macro_harness.rs +++ b/src/libsyntax_ext/proc_macro_harness.rs @@ -3,6 +3,7 @@ use std::mem; use smallvec::smallvec; use syntax::ast::{self, Ident}; use syntax::attr; +use syntax::expand::is_proc_macro_attr; use syntax::print::pprust; use syntax::ptr::P; use syntax::sess::ParseSess; @@ -10,7 +11,6 @@ use syntax::symbol::{kw, sym}; use syntax::visit::{self, Visitor}; use syntax_expand::base::{ExtCtxt, Resolver}; use syntax_expand::expand::{AstFragment, ExpansionConfig}; -use syntax_expand::proc_macro::is_proc_macro_attr; use syntax_pos::{Span, DUMMY_SP}; use syntax_pos::hygiene::AstPass; diff --git a/src/libsyntax_ext/standard_library_imports.rs b/src/libsyntax_ext/standard_library_imports.rs index fd27a21890698..6514ff5e25268 100644 --- a/src/libsyntax_ext/standard_library_imports.rs +++ b/src/libsyntax_ext/standard_library_imports.rs @@ -4,9 +4,9 @@ use syntax::ptr::P; use syntax::sess::ParseSess; use syntax::symbol::{Ident, Symbol, kw, sym}; use syntax_expand::expand::ExpansionConfig; -use syntax_expand::hygiene::AstPass; use syntax_expand::base::{ExtCtxt, Resolver}; use syntax_pos::DUMMY_SP; +use syntax_pos::hygiene::AstPass; pub fn inject( mut krate: ast::Crate, From 993b920032b17def5c773ed78b09890abb95854e Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Sat, 26 Oct 2019 19:12:58 +0300 Subject: [PATCH 09/12] librustc_lexer: Enhance documentation Apply review suggestions Apply review suggestions --- src/librustc_lexer/src/cursor.rs | 19 +++- src/librustc_lexer/src/lib.rs | 156 +++++++++++++++++++++++++++-- src/librustc_lexer/src/unescape.rs | 74 +++++++++++--- 3 files changed, 225 insertions(+), 24 deletions(-) diff --git a/src/librustc_lexer/src/cursor.rs b/src/librustc_lexer/src/cursor.rs index 5831159c344d7..73d305c6d4fe2 100644 --- a/src/librustc_lexer/src/cursor.rs +++ b/src/librustc_lexer/src/cursor.rs @@ -1,5 +1,9 @@ use std::str::Chars; +/// Peekable iterator over a char sequence. +/// +/// Next characters can be peeked via `nth_char` method, +/// and position can be shifted forward via `bump` method. pub(crate) struct Cursor<'a> { initial_len: usize, chars: Chars<'a>, @@ -18,7 +22,9 @@ impl<'a> Cursor<'a> { prev: EOF_CHAR, } } + /// For debug assertions only + /// Returns the last eaten symbol (or '\0' in release builds). pub(crate) fn prev(&self) -> char { #[cfg(debug_assertions)] { @@ -30,19 +36,30 @@ impl<'a> Cursor<'a> { '\0' } } + + /// Returns nth character relative to the current cursor position. + /// If requested position doesn't exist, `EOF_CHAR` is returned. + /// However, getting `EOF_CHAR` doesn't always mean actual end of file, + /// it should be checked with `is_eof` method. pub(crate) fn nth_char(&self, n: usize) -> char { self.chars().nth(n).unwrap_or(EOF_CHAR) } + + /// Checks if there is nothing more to consume. pub(crate) fn is_eof(&self) -> bool { self.chars.as_str().is_empty() } + + /// Returns amount of already consumed symbols. pub(crate) fn len_consumed(&self) -> usize { self.initial_len - self.chars.as_str().len() } - /// Returns an iterator over the remaining characters. + + /// Returns a `Chars` iterator over the remaining characters. fn chars(&self) -> Chars<'a> { self.chars.clone() } + /// Moves to the next character. pub(crate) fn bump(&mut self) -> Option { let c = self.chars.next()?; diff --git a/src/librustc_lexer/src/lib.rs b/src/librustc_lexer/src/lib.rs index 30a5175d8cdb0..d55ef46d7506e 100644 --- a/src/librustc_lexer/src/lib.rs +++ b/src/librustc_lexer/src/lib.rs @@ -1,3 +1,16 @@ +//! Low-level Rust lexer. +//! +//! Tokens produced by this lexer are not yet ready for parsing the Rust syntax, +//! for that see `libsyntax::parse::lexer`, which converts this basic token stream +//! into wide tokens used by actual parser. +//! +//! The purpose of this crate is to convert raw sources into a labeled sequence +//! of well-known token types, so building an actual Rust token stream will +//! be easier. +//! +//! Main entity of this crate is [`TokenKind`] enum which represents common +//! lexeme types. + // We want to be able to build this crate with a stable compiler, so no // `#![feature]` attributes should be added. @@ -6,78 +19,144 @@ pub mod unescape; use crate::cursor::{Cursor, EOF_CHAR}; +/// Parsed token. +/// It doesn't contain information about data that has been parsed, +/// only the type of the token and its size. pub struct Token { pub kind: TokenKind, pub len: usize, } +impl Token { + fn new(kind: TokenKind, len: usize) -> Token { + Token { kind, len } + } +} + +/// Enum represening common lexeme types. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum TokenKind { + // Multi-char tokens: + + /// "// comment" LineComment, + /// "/* block comment */" + /// Block comments can be recursive, so the sequence like "/* /* */" + /// will not be considered terminated and will result in a parsing error. BlockComment { terminated: bool }, + /// Any whitespace characters sequence. Whitespace, + /// "ident" or "continue" + /// At this step keywords are also considered identifiers. Ident, + /// "r#ident" RawIdent, + /// "12_u8", "1.0e-40", "b"123"". See `LiteralKind` for more details. Literal { kind: LiteralKind, suffix_start: usize }, + /// "'a" Lifetime { starts_with_number: bool }, + + // One-char tokens: + + /// ";" Semi, + /// "," Comma, + /// "." Dot, + /// "(" OpenParen, + /// ")" CloseParen, + /// "{" OpenBrace, + /// "}" CloseBrace, + /// "[" OpenBracket, + /// "]" CloseBracket, + /// "@" At, + /// "#" Pound, + /// "~" Tilde, + /// "?" Question, + /// ":" Colon, + /// "$" Dollar, + /// "=" Eq, + /// "!" Not, + /// "<" Lt, + /// ">" Gt, + /// "-" Minus, + /// "&" And, + /// "|" Or, + /// "+" Plus, + /// "*" Star, + /// "/" Slash, + /// "^" Caret, + /// "%" Percent, + + /// Unknown token, not expected by the lexer, e.g. "№" Unknown, } use self::TokenKind::*; #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum LiteralKind { + /// "12_u8", "0o100", "0b120i99" Int { base: Base, empty_int: bool }, + /// "12.34f32", "0b100.100" Float { base: Base, empty_exponent: bool }, + /// "'a'", "'\\'", "'''", "';" Char { terminated: bool }, + /// "b'a'", "b'\\'", "b'''", "b';" Byte { terminated: bool }, + /// ""abc"", ""abc" Str { terminated: bool }, + /// "b"abc"", "b"abc" ByteStr { terminated: bool }, + /// "r"abc"", "r#"abc"#", "r####"ab"###"c"####", "r#"a" RawStr { n_hashes: usize, started: bool, terminated: bool }, + /// "br"abc"", "br#"abc"#", "br####"ab"###"c"####", "br#"a" RawByteStr { n_hashes: usize, started: bool, terminated: bool }, } use self::LiteralKind::*; +/// Base of numeric literal encoding according to its prefix. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum Base { + /// Literal starts with "0b". Binary, + /// Literal starts with "0o". Octal, + /// Literal starts with "0x". Hexadecimal, + /// Literal doesn't contain a prefix. Decimal, } -impl Token { - fn new(kind: TokenKind, len: usize) -> Token { - Token { kind, len } - } -} - +/// `rustc` allows files to have a shebang, e.g. "#!/usr/bin/rustrun", +/// but shebang isn't a part of rust syntax, so this function +/// skips the line if it starts with a shebang ("#!"). +/// Line won't be skipped if it represents a valid Rust syntax +/// (e.g. "#![deny(missing_docs)]"). pub fn strip_shebang(input: &str) -> Option { debug_assert!(!input.is_empty()); if !input.starts_with("#!") || input.starts_with("#![") { @@ -86,11 +165,13 @@ pub fn strip_shebang(input: &str) -> Option { Some(input.find('\n').unwrap_or(input.len())) } +/// Parses the first token from the provided input string. pub fn first_token(input: &str) -> Token { debug_assert!(!input.is_empty()); Cursor::new(input).advance_token() } +/// Creates an iterator that produces tokens from the input string. pub fn tokenize(mut input: &str) -> impl Iterator + '_ { std::iter::from_fn(move || { if input.is_empty() { @@ -102,10 +183,9 @@ pub fn tokenize(mut input: &str) -> impl Iterator + '_ { }) } -// See [UAX #31](http://unicode.org/reports/tr31) for definitions of these -// classes. - /// True if `c` is considered a whitespace according to Rust language definition. +/// See [Rust language reference](https://doc.rust-lang.org/reference/whitespace.html) +/// for definitions of these classes. pub fn is_whitespace(c: char) -> bool { // This is Pattern_White_Space. // @@ -137,6 +217,8 @@ pub fn is_whitespace(c: char) -> bool { } /// True if `c` is valid as a first character of an identifier. +/// See [Rust language reference](https://doc.rust-lang.org/reference/identifiers.html) for +/// a formal definition of valid identifier name. pub fn is_id_start(c: char) -> bool { // This is XID_Start OR '_' (which formally is not a XID_Start). // We also add fast-path for ascii idents @@ -147,6 +229,8 @@ pub fn is_id_start(c: char) -> bool { } /// True if `c` is valid as a non-first character of an identifier. +/// See [Rust language reference](https://doc.rust-lang.org/reference/identifiers.html) for +/// a formal definition of valid identifier name. pub fn is_id_continue(c: char) -> bool { // This is exactly XID_Continue. // We also add fast-path for ascii idents @@ -159,15 +243,21 @@ pub fn is_id_continue(c: char) -> bool { impl Cursor<'_> { + /// Parses a token from the input string. fn advance_token(&mut self) -> Token { let first_char = self.bump().unwrap(); let token_kind = match first_char { + // Slash, comment or block comment. '/' => match self.nth_char(0) { '/' => self.line_comment(), '*' => self.block_comment(), _ => Slash, }, + + // Whitespace sequence. c if is_whitespace(c) => self.whitespace(), + + // Raw string literal or identifier. 'r' => match (self.nth_char(0), self.nth_char(1)) { ('#', c1) if is_id_start(c1) => self.raw_ident(), ('#', _) | ('"', _) => { @@ -181,6 +271,8 @@ impl Cursor<'_> { } _ => self.ident(), }, + + // Byte literal, byte string literal, raw byte string literal or identifier. 'b' => match (self.nth_char(0), self.nth_char(1)) { ('\'', _) => { self.bump(); @@ -214,13 +306,20 @@ impl Cursor<'_> { } _ => self.ident(), }, + + // Identifier (this should be checked after other variant that can + // start as identifier). c if is_id_start(c) => self.ident(), + + // Numeric literal. c @ '0'..='9' => { let literal_kind = self.number(c); let suffix_start = self.len_consumed(); self.eat_literal_suffix(); TokenKind::Literal { kind: literal_kind, suffix_start } } + + // One-symbol tokens. ';' => Semi, ',' => Comma, '.' => Dot, @@ -247,7 +346,11 @@ impl Cursor<'_> { '*' => Star, '^' => Caret, '%' => Percent, + + // Lifetime or character literal. '\'' => self.lifetime_or_char(), + + // String literal. '"' => { let terminated = self.double_quoted_string(); let suffix_start = self.len_consumed(); @@ -291,6 +394,9 @@ impl Cursor<'_> { self.bump(); depth -= 1; if depth == 0 { + // This block comment is closed, so for a construction like "/* */ */" + // there will be a successfully parsed block comment "/* */" + // and " */" will be processed separately. break; } } @@ -335,6 +441,7 @@ impl Cursor<'_> { debug_assert!('0' <= self.prev() && self.prev() <= '9'); let mut base = Base::Decimal; if first_digit == '0' { + // Attempt to parse encoding base. let has_digits = match self.nth_char(0) { 'b' => { base = Base::Binary; @@ -351,17 +458,21 @@ impl Cursor<'_> { self.bump(); self.eat_hexadecimal_digits() } + // Not a base prefix. '0'..='9' | '_' | '.' | 'e' | 'E' => { self.eat_decimal_digits(); true } - // just a 0 + // Just a 0. _ => return Int { base, empty_int: false }, }; + // Base prefix was provided, but there were no digits + // after it, e.g. "0x". if !has_digits { return Int { base, empty_int: true }; } } else { + // No base prefix, parse number in the usual way. self.eat_decimal_digits(); }; @@ -400,6 +511,9 @@ impl Cursor<'_> { fn lifetime_or_char(&mut self) -> TokenKind { debug_assert!(self.prev() == '\''); let mut starts_with_number = false; + + // Check if the first symbol after '\'' is a valid identifier + // character or a number (not a digit followed by '\''). if (is_id_start(self.nth_char(0)) || self.nth_char(0).is_digit(10) && { starts_with_number = true; @@ -408,6 +522,8 @@ impl Cursor<'_> { && self.nth_char(1) != '\'' { self.bump(); + + // Skip the identifier. while is_id_continue(self.nth_char(0)) { self.bump(); } @@ -420,6 +536,8 @@ impl Cursor<'_> { Lifetime { starts_with_number } }; } + + // This is not a lifetime (checked above), parse a char literal. let terminated = self.single_quoted_string(); let suffix_start = self.len_consumed(); if terminated { @@ -431,24 +549,32 @@ impl Cursor<'_> { fn single_quoted_string(&mut self) -> bool { debug_assert!(self.prev() == '\''); - // parse `'''` as a single char literal + // Parse `'''` as a single char literal. if self.nth_char(0) == '\'' && self.nth_char(1) == '\'' { self.bump(); } + // Parse until either quotes are terminated or error is detected. let mut first = true; loop { match self.nth_char(0) { + // Probably beginning of the comment, which we don't want to include + // to the error report. '/' if !first => break, + // Newline without following '\'' means unclosed quote, stop parsing. '\n' if self.nth_char(1) != '\'' => break, + // End of file, stop parsing. EOF_CHAR if self.is_eof() => break, + // Quotes are terminated, finish parsing. '\'' => { self.bump(); return true; } + // Escaped slash is considered one character, so bump twice. '\\' => { self.bump(); self.bump(); } + // Skip the character. _ => { self.bump(); } @@ -458,6 +584,8 @@ impl Cursor<'_> { false } + /// Eats double-quoted string and returns true + /// if string is terminated. fn double_quoted_string(&mut self) -> bool { debug_assert!(self.prev() == '"'); loop { @@ -476,8 +604,11 @@ impl Cursor<'_> { } } + /// Eats the double-quoted string and returns a tuple of + /// (amount of the '#' symbols, raw string started, raw string terminated) fn raw_double_quoted_string(&mut self) -> (usize, bool, bool) { debug_assert!(self.prev() == 'r'); + // Count opening '#' symbols. let n_hashes = { let mut acc: usize = 0; loop { @@ -489,6 +620,8 @@ impl Cursor<'_> { } }; + // Skip the string itself and check that amount of closing '#' + // symbols is equal to the amount of opening ones. loop { match self.bump() { Some('"') => { @@ -549,6 +682,7 @@ impl Cursor<'_> { if self.eat_decimal_digits() { Ok(()) } else { Err(()) } } + // Eats the suffix if it's an identifier. fn eat_literal_suffix(&mut self) { if !is_id_start(self.nth_char(0)) { return; diff --git a/src/librustc_lexer/src/unescape.rs b/src/librustc_lexer/src/unescape.rs index c709b7526082f..dee7bc2260bf0 100644 --- a/src/librustc_lexer/src/unescape.rs +++ b/src/librustc_lexer/src/unescape.rs @@ -7,32 +7,54 @@ use std::ops::Range; #[cfg(test)] mod tests; +/// Errors that can occur during string unescaping. #[derive(Debug, PartialEq, Eq)] pub enum EscapeError { + /// Expected 1 char, but 0 were found. ZeroChars, + /// Expected 1 char, but more than 1 were found. MoreThanOneChar, + /// Escaped '\' character without continuation. LoneSlash, + /// Invalid escape characted (e.g. '\z'). InvalidEscape, + /// Raw '\r' encountered. BareCarriageReturn, + /// Raw '\r' encountered in raw string. BareCarriageReturnInRawString, + /// Unescaped character that was expected to be escaped (e.g. raw '\t'). EscapeOnlyChar, + /// Numeric character escape is too short (e.g. '\x1'). TooShortHexEscape, + /// Invalid character in numeric escape (e.g. '\xz') InvalidCharInHexEscape, + /// Character code in numeric escape is non-ascii (e.g. '\xFF'). OutOfRangeHexEscape, + /// '\u' not followed by '{'. NoBraceInUnicodeEscape, + /// Non-hexadecimal value in '\u{..}'. InvalidCharInUnicodeEscape, + /// '\u{}' EmptyUnicodeEscape, + /// No closing brace in '\u{..}', e.g. '\u{12'. UnclosedUnicodeEscape, + /// '\u{_12}' LeadingUnderscoreUnicodeEscape, + /// More than 6 charactes in '\u{..}', e.g. '\u{10FFFF_FF}' OverlongUnicodeEscape, + /// Invalid in-bound unicode character code, e.g. '\u{DFFF}'. LoneSurrogateUnicodeEscape, + /// Out of bounds unicode character code, e.g. '\u{FFFFFF}'. OutOfRangeUnicodeEscape, + /// Unicode escape code in byte literal. UnicodeEscapeInByte, + /// Non-ascii character in byte literal. NonAsciiCharInByte, + /// Non-ascii character in byte string literal. NonAsciiCharInByteString, } @@ -44,15 +66,8 @@ pub fn unescape_char(literal_text: &str) -> Result { .map_err(|err| (literal_text.len() - chars.as_str().len(), err)) } -/// Takes a contents of a string literal (without quotes) and produces a -/// sequence of escaped characters or errors. -pub fn unescape_str(literal_text: &str, callback: &mut F) -where - F: FnMut(Range, Result), -{ - unescape_str_or_byte_str(literal_text, Mode::Str, callback) -} - +/// Takes a contents of a byte literal (without quotes), and returns an +/// unescaped byte or an error. pub fn unescape_byte(literal_text: &str) -> Result { let mut chars = literal_text.chars(); unescape_char_or_byte(&mut chars, Mode::Byte) @@ -62,6 +77,17 @@ pub fn unescape_byte(literal_text: &str) -> Result { /// Takes a contents of a string literal (without quotes) and produces a /// sequence of escaped characters or errors. +/// Values are returned through invoking of the provided callback. +pub fn unescape_str(literal_text: &str, callback: &mut F) +where + F: FnMut(Range, Result), +{ + unescape_str_or_byte_str(literal_text, Mode::Str, callback) +} + +/// Takes a contents of a byte string literal (without quotes) and produces a +/// sequence of bytes or errors. +/// Values are returned through invoking of the provided callback. pub fn unescape_byte_str(literal_text: &str, callback: &mut F) where F: FnMut(Range, Result), @@ -71,8 +97,9 @@ where }) } -/// Takes a contents of a string literal (without quotes) and produces a +/// Takes a contents of a raw string literal (without quotes) and produces a /// sequence of characters or errors. +/// Values are returned through invoking of the provided callback. /// NOTE: Raw strings do not perform any explicit character escaping, here we /// only translate CRLF to LF and produce errors on bare CR. pub fn unescape_raw_str(literal_text: &str, callback: &mut F) @@ -82,8 +109,9 @@ where unescape_raw_str_or_byte_str(literal_text, Mode::Str, callback) } -/// Takes a contents of a string literal (without quotes) and produces a -/// sequence of characters or errors. +/// Takes a contents of a raw byte string literal (without quotes) and produces a +/// sequence of bytes or errors. +/// Values are returned through invoking of the provided callback. /// NOTE: Raw strings do not perform any explicit character escaping, here we /// only translate CRLF to LF and produce errors on bare CR. pub fn unescape_raw_byte_str(literal_text: &str, callback: &mut F) @@ -95,6 +123,7 @@ where }) } +/// What kind of literal do we parse. #[derive(Debug, Clone, Copy)] pub enum Mode { Char, @@ -126,6 +155,8 @@ impl Mode { fn scan_escape(first_char: char, chars: &mut Chars<'_>, mode: Mode) -> Result { if first_char != '\\' { + // Previous character was not a slash, and we don't expect it to be + // an escape-only character. return match first_char { '\t' | '\n' => Err(EscapeError::EscapeOnlyChar), '\r' => Err(EscapeError::BareCarriageReturn), @@ -133,6 +164,7 @@ fn scan_escape(first_char: char, chars: &mut Chars<'_>, mode: Mode) -> Result Err(EscapeError::EscapeOnlyChar), _ => { if mode.is_bytes() && !first_char.is_ascii() { + // Byte literal can't be a non-ascii character. return Err(EscapeError::NonAsciiCharInByte); } Ok(first_char) @@ -140,6 +172,8 @@ fn scan_escape(first_char: char, chars: &mut Chars<'_>, mode: Mode) -> Result, mode: Mode) -> Result '\0', 'x' => { + // Parse hexadecimal character code. + let hi = chars.next().ok_or(EscapeError::TooShortHexEscape)?; let hi = hi.to_digit(16).ok_or(EscapeError::InvalidCharInHexEscape)?; @@ -160,6 +196,7 @@ fn scan_escape(first_char: char, chars: &mut Chars<'_>, mode: Mode) -> Result, mode: Mode) -> Result { + // We've parsed '\u', now we have to parse '{..}'. + if chars.next() != Some('{') { return Err(EscapeError::NoBraceInUnicodeEscape); } + // First characrer must be a hexadecimal digit. let mut n_digits = 1; let mut value: u32 = match chars.next().ok_or(EscapeError::UnclosedUnicodeEscape)? { '_' => return Err(EscapeError::LeadingUnderscoreUnicodeEscape), @@ -180,6 +220,8 @@ fn scan_escape(first_char: char, chars: &mut Chars<'_>, mode: Mode) -> Result c.to_digit(16).ok_or(EscapeError::InvalidCharInUnicodeEscape)?, }; + // First character is valid, now parse the rest of the number + // and closing brace. loop { match chars.next() { None => return Err(EscapeError::UnclosedUnicodeEscape), @@ -188,6 +230,9 @@ fn scan_escape(first_char: char, chars: &mut Chars<'_>, mode: Mode) -> Result 6 { return Err(EscapeError::OverlongUnicodeEscape); } + + // Incorrect syntax has higher priority for error reporting + // than unallowed value for a literal. if mode.is_bytes() { return Err(EscapeError::UnicodeEscapeInByte); } @@ -204,6 +249,7 @@ fn scan_escape(first_char: char, chars: &mut Chars<'_>, mode: Mode) -> Result 6 { + // Stop updating value since we're sure that it's is incorrect already. continue; } let digit = digit as u32; @@ -243,6 +289,10 @@ where let second_char = chars.clone().next(); match second_char { Some('\n') => { + // Rust language specification requires us to skip whitespaces + // if unescaped '\' character is followed by '\n'. + // For details see [Rust language reference] + // (https://doc.rust-lang.org/reference/tokens.html#string-literals). skip_ascii_whitespace(&mut chars); continue; } From 3f980785fb55e31aca9215faa474d751e5a28d69 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 27 Oct 2019 17:31:01 +0000 Subject: [PATCH 10/12] doc: explain why it is unsafe to construct Vec from Vec Co-authored-by: Steve Klabnik --- src/liballoc/vec.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 641f9eafa8d23..5e733fa43d705 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -411,7 +411,11 @@ impl Vec { /// /// Violating these may cause problems like corrupting the allocator's /// internal data structures. For example it is **not** safe - /// to build a `Vec` from a pointer to a C `char` array and a `size_t`. + /// to build a `Vec` from a pointer to a C `char` array with length `size_t`. + /// It's also not safe to build one from a `Vec` and its length, because + /// the allocator cares about the alignment, and these two types have different + /// alignments. The buffer was allocated with alignment 2 (for `u16`), but after + /// turning it into a `Vec` it'll be deallocated with alignment 1. /// /// The ownership of `ptr` is effectively transferred to the /// `Vec` which may then deallocate, reallocate or change the From b26ddb8af37362e33c45c78c9c91a3c5cdabfe7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 14 Oct 2019 17:20:50 -0700 Subject: [PATCH 11/12] Point at local similarly named element and tweak references to variants Point at the span for the definition of ADTs internal to the current crate. Look at the leading char of the ident to determine whether we're expecting a likely fn or any of a fn, a tuple struct or a tuple variant. Turn fn `add_typo_suggestion` into a `Resolver` method. --- src/librustc_resolve/build_reduced_graph.rs | 20 ++--- src/librustc_resolve/diagnostics.rs | 44 +++++++---- src/librustc_resolve/error_codes.rs | 7 +- src/librustc_resolve/late.rs | 25 ++++-- src/librustc_resolve/late/diagnostics.rs | 21 ++--- src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/check/pat.rs | 8 +- src/librustc_typeck/error_codes.rs | 5 +- .../associated-types-eq-1.stderr | 2 + src/test/ui/class-missing-self.rs | 2 +- .../struct-with-invalid-const-param.stderr | 5 +- .../issue-43871-enum-instead-of-variant.rs | 10 +-- ...issue-43871-enum-instead-of-variant.stderr | 10 +-- src/test/ui/empty/empty-struct-braces-expr.rs | 9 ++- .../ui/empty/empty-struct-braces-expr.stderr | 20 ++--- .../ui/empty/empty-struct-braces-pat-1.rs | 4 +- .../ui/empty/empty-struct-braces-pat-1.stderr | 4 +- .../ui/empty/empty-struct-braces-pat-2.rs | 8 +- .../ui/empty/empty-struct-braces-pat-2.stderr | 8 +- .../ui/empty/empty-struct-braces-pat-3.rs | 8 +- .../ui/empty/empty-struct-braces-pat-3.stderr | 8 +- src/test/ui/empty/empty-struct-tuple-pat.rs | 4 +- .../ui/empty/empty-struct-tuple-pat.stderr | 4 +- src/test/ui/empty/empty-struct-unit-pat.rs | 21 +++-- .../ui/empty/empty-struct-unit-pat.stderr | 32 ++++---- src/test/ui/enums-pats-not-idents.rs | 2 +- src/test/ui/enums-pats-not-idents.stderr | 2 +- src/test/ui/error-codes/E0164.stderr | 2 +- src/test/ui/error-codes/E0423.stderr | 22 ++++-- src/test/ui/error-codes/E0424.stderr | 2 +- src/test/ui/error-codes/E0532.rs | 2 +- src/test/ui/error-codes/E0532.stderr | 4 +- src/test/ui/fn-in-pat.rs | 2 +- src/test/ui/fn-in-pat.stderr | 2 +- src/test/ui/glob-resolve1.stderr | 9 +++ ...elude-extern-crate-restricted-shadowing.rs | 2 + ...e-extern-crate-restricted-shadowing.stderr | 14 ++-- src/test/ui/issues/issue-10200.rs | 2 +- src/test/ui/issues/issue-10200.stderr | 5 +- src/test/ui/issues/issue-12863.rs | 3 +- src/test/ui/issues/issue-12863.stderr | 4 +- src/test/ui/issues/issue-17933.rs | 2 +- src/test/ui/issues/issue-17933.stderr | 4 +- src/test/ui/issues/issue-19086.rs | 2 +- src/test/ui/issues/issue-19086.stderr | 2 +- src/test/ui/issues/issue-27033.rs | 2 + src/test/ui/issues/issue-27033.stderr | 9 ++- src/test/ui/issues/issue-28992-empty.rs | 4 +- src/test/ui/issues/issue-28992-empty.stderr | 6 +- src/test/ui/issues/issue-31845.stderr | 7 +- src/test/ui/issues/issue-32004.rs | 4 +- src/test/ui/issues/issue-32004.stderr | 8 +- src/test/ui/issues/issue-32086.rs | 4 +- src/test/ui/issues/issue-32086.stderr | 10 ++- src/test/ui/issues/issue-35675.rs | 4 +- src/test/ui/issues/issue-35675.stderr | 4 +- src/test/ui/issues/issue-38412.rs | 2 +- src/test/ui/issues/issue-38412.stderr | 2 +- src/test/ui/issues/issue-42944.rs | 6 +- src/test/ui/issues/issue-42944.stderr | 6 +- src/test/ui/issues/issue-46332.stderr | 3 + src/test/ui/issues/issue-55587.rs | 2 +- src/test/ui/issues/issue-55587.stderr | 2 +- src/test/ui/issues/issue-56835.rs | 2 +- src/test/ui/issues/issue-56835.stderr | 2 +- src/test/ui/issues/issue-58022.rs | 3 +- src/test/ui/issues/issue-58022.stderr | 4 +- src/test/ui/issues/issue-5927.rs | 2 +- src/test/ui/issues/issue-5927.stderr | 2 +- src/test/ui/issues/issue-63983.rs | 4 +- src/test/ui/issues/issue-63983.stderr | 4 +- .../ui/issues/issue-64792-bad-unicode-ctor.rs | 2 +- .../issue-64792-bad-unicode-ctor.stderr | 11 +-- src/test/ui/issues/issue-pr29383.rs | 6 +- src/test/ui/issues/issue-pr29383.stderr | 10 +-- .../ui/keyword/keyword-self-as-identifier.rs | 2 +- .../keyword/keyword-self-as-identifier.stderr | 2 +- src/test/ui/macros/macro_undefined.stderr | 9 ++- src/test/ui/match/match-fn-call.rs | 4 +- src/test/ui/match/match-fn-call.stderr | 4 +- .../match/match-pattern-field-mismatch-2.rs | 2 +- .../match-pattern-field-mismatch-2.stderr | 4 +- .../ui/match/match-pattern-field-mismatch.rs | 2 +- src/test/ui/methods/method-path-in-pattern.rs | 12 +-- .../ui/methods/method-path-in-pattern.stderr | 12 +-- .../method-resolvable-path-in-pattern.rs | 2 +- .../method-resolvable-path-in-pattern.stderr | 4 +- src/test/ui/namespace/namespace-mix.stderr | 5 ++ .../ui/parser/recover-from-bad-variant.rs | 2 +- .../ui/parser/recover-from-bad-variant.stderr | 2 +- src/test/ui/pattern/pattern-error-continue.rs | 2 +- .../ui/pattern/pattern-error-continue.stderr | 5 +- src/test/ui/privacy/privacy-ns1.rs | 4 +- src/test/ui/privacy/privacy-ns1.stderr | 16 +++- src/test/ui/privacy/privacy-ns2.rs | 4 +- src/test/ui/privacy/privacy-ns2.stderr | 12 ++- src/test/ui/proc-macro/parent-source-spans.rs | 2 - .../ui/proc-macro/parent-source-spans.stderr | 42 +++++----- src/test/ui/proc-macro/resolve-error.stderr | 18 ++++- .../ui/qualified/qualified-path-params.rs | 2 +- .../ui/qualified/qualified-path-params.stderr | 2 +- .../ui/resolve/enums-are-namespaced-xc.rs | 2 +- .../ui/resolve/enums-are-namespaced-xc.stderr | 2 +- src/test/ui/resolve/issue-18252.rs | 2 +- src/test/ui/resolve/issue-18252.stderr | 2 +- src/test/ui/resolve/issue-5035.stderr | 3 + src/test/ui/resolve/issue-6702.rs | 3 +- src/test/ui/resolve/issue-6702.stderr | 2 +- src/test/ui/resolve/levenshtein.stderr | 15 ++++ src/test/ui/resolve/privacy-enum-ctor.stderr | 76 ++++++++++++++++--- .../ui/resolve/privacy-struct-ctor.stderr | 3 + .../ui/resolve/resolve-assoc-suggestions.rs | 6 +- .../resolve/resolve-assoc-suggestions.stderr | 6 +- ...uggest-path-instead-of-mod-dot-item.stderr | 15 ++++ src/test/ui/resolve/tuple-struct-alias.rs | 2 +- src/test/ui/resolve/tuple-struct-alias.stderr | 10 ++- src/test/ui/rfc-2008-non-exhaustive/struct.rs | 2 +- .../ui/rfc-2008-non-exhaustive/struct.stderr | 2 +- .../keyword-crate-as-identifier.rs | 2 +- .../keyword-crate-as-identifier.stderr | 4 +- src/test/ui/self/self_type_keyword-2.rs | 6 +- src/test/ui/self/self_type_keyword-2.stderr | 6 +- src/test/ui/self/self_type_keyword.rs | 2 +- src/test/ui/self/self_type_keyword.stderr | 2 +- .../fn-or-tuple-struct-without-args.stderr | 2 + .../ui/traits/trait-impl-for-module.stderr | 8 +- ...t-variant-form-through-Self-issue-58006.rs | 2 +- ...riant-form-through-Self-issue-58006.stderr | 2 +- ...rrect-variant-form-through-alias-caught.rs | 8 +- ...t-variant-form-through-alias-caught.stderr | 8 +- .../ui/ufcs/ufcs-partially-resolved.stderr | 21 +++++ src/test/ui/ui-testing-optout.stderr | 11 ++- 132 files changed, 600 insertions(+), 331 deletions(-) diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index c0fb8e33a819e..5a885135dfd03 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -850,12 +850,14 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { Res::Def(kind @ DefKind::Mod, def_id) | Res::Def(kind @ DefKind::Enum, def_id) | Res::Def(kind @ DefKind::Trait, def_id) => { - let module = self.r.new_module(parent, - ModuleKind::Def(kind, def_id, ident.name), - def_id, - expansion, - span); - self.r.define(parent, ident, TypeNS, (module, vis, DUMMY_SP, expansion)); + let module = self.r.new_module( + parent, + ModuleKind::Def(kind, def_id, ident.name), + def_id, + expansion, + span, + ); + self.r.define(parent, ident, TypeNS, (module, vis, span, expansion)); } Res::Def(DefKind::Struct, _) | Res::Def(DefKind::Union, _) @@ -868,17 +870,17 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { | Res::Def(DefKind::AssocOpaqueTy, _) | Res::PrimTy(..) | Res::ToolMod => - self.r.define(parent, ident, TypeNS, (res, vis, DUMMY_SP, expansion)), + self.r.define(parent, ident, TypeNS, (res, vis, span, expansion)), Res::Def(DefKind::Fn, _) | Res::Def(DefKind::Method, _) | Res::Def(DefKind::Static, _) | Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::Ctor(..), _) => - self.r.define(parent, ident, ValueNS, (res, vis, DUMMY_SP, expansion)), + self.r.define(parent, ident, ValueNS, (res, vis, span, expansion)), Res::Def(DefKind::Macro(..), _) | Res::NonMacroAttr(..) => - self.r.define(parent, ident, MacroNS, (res, vis, DUMMY_SP, expansion)), + self.r.define(parent, ident, MacroNS, (res, vis, span, expansion)), Res::Def(DefKind::TyParam, _) | Res::Def(DefKind::ConstParam, _) | Res::Local(..) | Res::SelfTy(..) | Res::SelfCtor(..) | Res::Err => bug!("unexpected resolution: {:?}", res) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 7634093fbefba..511221e143b17 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -58,21 +58,6 @@ fn reduce_impl_span_to_impl_keyword(cm: &SourceMap, impl_span: Span) -> Span { impl_span } -crate fn add_typo_suggestion( - err: &mut DiagnosticBuilder<'_>, suggestion: Option, span: Span -) -> bool { - if let Some(suggestion) = suggestion { - let msg = format!( - "{} {} with a similar name exists", suggestion.res.article(), suggestion.res.descr() - ); - err.span_suggestion( - span, &msg, suggestion.candidate.to_string(), Applicability::MaybeIncorrect - ); - return true; - } - false -} - impl<'a> Resolver<'a> { crate fn add_module_candidates( &mut self, @@ -641,7 +626,7 @@ impl<'a> Resolver<'a> { let suggestion = self.early_lookup_typo_candidate( ScopeSet::Macro(macro_kind), parent_scope, ident, is_expected ); - add_typo_suggestion(err, suggestion, ident.span); + self.add_typo_suggestion(err, suggestion, ident.span); if macro_kind == MacroKind::Derive && (ident.as_str() == "Send" || ident.as_str() == "Sync") { @@ -652,6 +637,33 @@ impl<'a> Resolver<'a> { err.help("have you added the `#[macro_use]` on the module/import?"); } } + + crate fn add_typo_suggestion( + &self, + err: &mut DiagnosticBuilder<'_>, + suggestion: Option, + span: Span, + ) -> bool { + if let Some(suggestion) = suggestion { + let msg = format!( + "{} {} with a similar name exists", suggestion.res.article(), suggestion.res.descr() + ); + err.span_suggestion( + span, &msg, suggestion.candidate.to_string(), Applicability::MaybeIncorrect + ); + let def_span = suggestion.res.opt_def_id() + .and_then(|def_id| self.definitions.opt_span(def_id)); + if let Some(span) = def_span { + err.span_label(span, &format!( + "similarly named {} `{}` defined here", + suggestion.res.descr(), + suggestion.candidate.as_str(), + )); + } + return true; + } + false + } } impl<'a, 'b> ImportResolver<'a, 'b> { diff --git a/src/librustc_resolve/error_codes.rs b/src/librustc_resolve/error_codes.rs index be2e9f505aa6f..9515c87ce4bb5 100644 --- a/src/librustc_resolve/error_codes.rs +++ b/src/librustc_resolve/error_codes.rs @@ -974,7 +974,7 @@ function: struct Foo { a: bool }; let f = Foo(); -// error: expected function, found `Foo` +// error: expected function, tuple struct or tuple variant, found `Foo` // `Foo` is a struct name, but this expression uses it like a function name ``` @@ -992,7 +992,8 @@ yield this error: ```compile_fail,E0423 println(""); -// error: expected function, found macro `println` +// error: expected function, tuple struct or tuple variant, +// found macro `println` // did you mean `println!(...)`? (notice the trailing `!`) ``` @@ -1592,7 +1593,7 @@ enum State { fn print_on_failure(state: &State) { match *state { - // error: expected unit struct/variant or constant, found tuple + // error: expected unit struct, unit variant or constant, found tuple // variant `State::Failed` State::Failed => println!("Failed"), _ => () diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index 136ab1f0444fa..faf7696288bd1 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -199,21 +199,36 @@ impl<'a> PathSource<'a> { } fn descr_expected(self) -> &'static str { - match self { + match &self { PathSource::Type => "type", PathSource::Trait(_) => "trait", - PathSource::Pat => "unit struct/variant or constant", + PathSource::Pat => "unit struct, unit variant or constant", PathSource::Struct => "struct, variant or union type", - PathSource::TupleStruct => "tuple struct/variant", + PathSource::TupleStruct => "tuple struct or tuple variant", PathSource::TraitItem(ns) => match ns { TypeNS => "associated type", ValueNS => "method or associated constant", MacroNS => bug!("associated macro"), }, - PathSource::Expr(parent) => match parent.map(|p| &p.kind) { + PathSource::Expr(parent) => match &parent.as_ref().map(|p| &p.kind) { // "function" here means "anything callable" rather than `DefKind::Fn`, // this is not precise but usually more helpful than just "value". - Some(&ExprKind::Call(..)) => "function", + Some(ExprKind::Call(call_expr, _)) => { + match &call_expr.kind { + ExprKind::Path(_, path) => { + let mut msg = "function"; + if let Some(segment) = path.segments.iter().last() { + if let Some(c) = segment.ident.to_string().chars().next() { + if c.is_uppercase() { + msg = "function, tuple struct or tuple variant"; + } + } + } + msg + } + _ => "function" + } + } _ => "value", }, } diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index 2721df4c68763..71a6f0d464d9f 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -1,7 +1,7 @@ use crate::{CrateLint, Module, ModuleKind, ModuleOrUniformRoot}; use crate::{PathResult, PathSource, Segment}; use crate::path_names_to_string; -use crate::diagnostics::{add_typo_suggestion, ImportSuggestion, TypoSuggestion}; +use crate::diagnostics::{ImportSuggestion, TypoSuggestion}; use crate::late::{LateResolutionVisitor, RibKind}; use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; @@ -237,18 +237,19 @@ impl<'a> LateResolutionVisitor<'a, '_> { } // Try Levenshtein algorithm. - let levenshtein_worked = add_typo_suggestion( - &mut err, self.lookup_typo_candidate(path, ns, is_expected, span), ident_span - ); + let typo_sugg = self.lookup_typo_candidate(path, ns, is_expected, span); + let levenshtein_worked = self.r.add_typo_suggestion(&mut err, typo_sugg, ident_span); // Try context-dependent help if relaxed lookup didn't work. if let Some(res) = res { - if self.smart_resolve_context_dependent_help(&mut err, - span, - source, - res, - &path_str, - &fallback_label) { + if self.smart_resolve_context_dependent_help( + &mut err, + span, + source, + res, + &path_str, + &fallback_label, + ) { return (err, candidates); } } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 96a097695fa1f..f7132cd868aac 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2269,7 +2269,7 @@ pub fn check_enum<'tcx>(tcx: TyCtxt<'tcx>, sp: Span, vs: &'tcx [hir::Variant], i fn report_unexpected_variant_res(tcx: TyCtxt<'_>, res: Res, span: Span, qpath: &QPath) { span_err!(tcx.sess, span, E0533, - "expected unit struct/variant or constant, found {} `{}`", + "expected unit struct, unit variant or constant, found {} `{}`", res.descr(), hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false))); } diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index 97c30f208f5ec..950ae7c1d62e2 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -613,9 +613,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } }; let report_unexpected_res = |res: Res| { - let msg = format!("expected tuple struct/variant, found {} `{}`", - res.descr(), - hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false))); + let msg = format!( + "expected tuple struct or tuple variant, found {} `{}`", + res.descr(), + hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false)), + ); let mut err = struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg); match (res, &pat.kind) { (Res::Def(DefKind::Fn, _), _) | (Res::Def(DefKind::Method, _), _) => { diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs index 75b508a1bbf0f..ae67f54ac1229 100644 --- a/src/librustc_typeck/error_codes.rs +++ b/src/librustc_typeck/error_codes.rs @@ -4346,11 +4346,12 @@ enum X { Entry, } -X::Entry(); // error: expected function, found `X::Entry` +X::Entry(); // error: expected function, tuple struct or tuple variant, + // found `X::Entry` // Or even simpler: let x = 0i32; -x(); // error: expected function, found `i32` +x(); // error: expected function, tuple struct or tuple variant, found `i32` ``` Only functions and methods can be called using `()`. Example: diff --git a/src/test/ui/associated-types/associated-types-eq-1.stderr b/src/test/ui/associated-types/associated-types-eq-1.stderr index aa987316801a7..66c5f34644c01 100644 --- a/src/test/ui/associated-types/associated-types-eq-1.stderr +++ b/src/test/ui/associated-types/associated-types-eq-1.stderr @@ -1,6 +1,8 @@ error[E0412]: cannot find type `A` in this scope --> $DIR/associated-types-eq-1.rs:10:12 | +LL | fn foo2(x: I) { + | - similarly named type parameter `I` defined here LL | let _: A = x.boo(); | ^ help: a type parameter with a similar name exists: `I` diff --git a/src/test/ui/class-missing-self.rs b/src/test/ui/class-missing-self.rs index 515754e54fe07..8ad347d20e6e4 100644 --- a/src/test/ui/class-missing-self.rs +++ b/src/test/ui/class-missing-self.rs @@ -7,7 +7,7 @@ impl Cat { fn meow(&self) { println!("Meow"); meows += 1; //~ ERROR cannot find value `meows` in this scope - sleep(); //~ ERROR cannot find function `sleep` in this scope + sleep(); //~ ERROR cannot find function `sleep` in this } } diff --git a/src/test/ui/const-generics/struct-with-invalid-const-param.stderr b/src/test/ui/const-generics/struct-with-invalid-const-param.stderr index b3aa35e079aec..a96b071c05f42 100644 --- a/src/test/ui/const-generics/struct-with-invalid-const-param.stderr +++ b/src/test/ui/const-generics/struct-with-invalid-const-param.stderr @@ -2,7 +2,10 @@ error[E0573]: expected type, found const parameter `C` --> $DIR/struct-with-invalid-const-param.rs:4:23 | LL | struct S(C); - | ^ help: a struct with a similar name exists: `S` + | ----------------------^-- + | | | + | | help: a struct with a similar name exists: `S` + | similarly named struct `S` defined here warning: the feature `const_generics` is incomplete and may cause the compiler to crash --> $DIR/struct-with-invalid-const-param.rs:1:12 diff --git a/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs b/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs index 7d3aba364897f..9602d27469427 100644 --- a/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs +++ b/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs @@ -16,21 +16,21 @@ enum ManyVariants { } fn result_test() { - let x = Option(1); //~ ERROR expected function, found enum + let x = Option(1); //~ ERROR expected function, tuple struct or tuple variant, found enum - if let Option(_) = x { //~ ERROR expected tuple struct/variant, found enum + if let Option(_) = x { //~ ERROR expected tuple struct or tuple variant, found enum println!("It is OK."); } let y = Example::Ex(String::from("test")); - if let Example(_) = y { //~ ERROR expected tuple struct/variant, found enum + if let Example(_) = y { //~ ERROR expected tuple struct or tuple variant, found enum println!("It is OK."); } - let y = Void(); //~ ERROR expected function, found enum + let y = Void(); //~ ERROR expected function, tuple struct or tuple variant, found enum - let z = ManyVariants(); //~ ERROR expected function, found enum + let z = ManyVariants(); //~ ERROR expected function, tuple struct or tuple variant, found enum } fn main() {} diff --git a/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr b/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr index 0a2fbe4918f15..2140fd3a5a037 100644 --- a/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr +++ b/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, found enum `Option` +error[E0423]: expected function, tuple struct or tuple variant, found enum `Option` --> $DIR/issue-43871-enum-instead-of-variant.rs:19:13 | LL | let x = Option(1); @@ -11,7 +11,7 @@ LL | let x = std::option::Option::None(1); LL | let x = std::option::Option::Some(1); | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0532]: expected tuple struct/variant, found enum `Option` +error[E0532]: expected tuple struct or tuple variant, found enum `Option` --> $DIR/issue-43871-enum-instead-of-variant.rs:21:12 | LL | if let Option(_) = x { @@ -24,7 +24,7 @@ LL | if let std::option::Option::None(_) = x { LL | if let std::option::Option::Some(_) = x { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0532]: expected tuple struct/variant, found enum `Example` +error[E0532]: expected tuple struct or tuple variant, found enum `Example` --> $DIR/issue-43871-enum-instead-of-variant.rs:27:12 | LL | if let Example(_) = y { @@ -37,13 +37,13 @@ LL | if let Example::Ex(_) = y { LL | if let Example::NotEx(_) = y { | ^^^^^^^^^^^^^^ -error[E0423]: expected function, found enum `Void` +error[E0423]: expected function, tuple struct or tuple variant, found enum `Void` --> $DIR/issue-43871-enum-instead-of-variant.rs:31:13 | LL | let y = Void(); | ^^^^ -error[E0423]: expected function, found enum `ManyVariants` +error[E0423]: expected function, tuple struct or tuple variant, found enum `ManyVariants` --> $DIR/issue-43871-enum-instead-of-variant.rs:33:13 | LL | let z = ManyVariants(); diff --git a/src/test/ui/empty/empty-struct-braces-expr.rs b/src/test/ui/empty/empty-struct-braces-expr.rs index e33fcb70db775..1a38d3d7601b8 100644 --- a/src/test/ui/empty/empty-struct-braces-expr.rs +++ b/src/test/ui/empty/empty-struct-braces-expr.rs @@ -13,12 +13,15 @@ enum E { fn main() { let e1 = Empty1; //~ ERROR expected value, found struct `Empty1` - let e1 = Empty1(); //~ ERROR expected function, found struct `Empty1` + let e1 = Empty1(); + //~^ ERROR expected function, tuple struct or tuple variant, found struct `Empty1` let e3 = E::Empty3; //~ ERROR expected value, found struct variant `E::Empty3` - let e3 = E::Empty3(); //~ ERROR expected function, found struct variant `E::Empty3` + let e3 = E::Empty3(); + //~^ ERROR expected function, tuple struct or tuple variant, found struct variant `E::Empty3` let xe1 = XEmpty1; //~ ERROR expected value, found struct `XEmpty1` - let xe1 = XEmpty1(); //~ ERROR expected function, found struct `XEmpty1` + let xe1 = XEmpty1(); + //~^ ERROR expected function, tuple struct or tuple variant, found struct `XEmpty1` let xe3 = XE::Empty3; //~ ERROR no variant or associated item named `Empty3` found for type let xe3 = XE::Empty3(); //~ ERROR no variant or associated item named `Empty3` found for type diff --git a/src/test/ui/empty/empty-struct-braces-expr.stderr b/src/test/ui/empty/empty-struct-braces-expr.stderr index 9712157552716..f427c1ba0adfb 100644 --- a/src/test/ui/empty/empty-struct-braces-expr.stderr +++ b/src/test/ui/empty/empty-struct-braces-expr.stderr @@ -10,7 +10,7 @@ LL | let e1 = Empty1; | did you mean `Empty1 { /* fields */ }`? | help: a unit struct with a similar name exists: `XEmpty2` -error[E0423]: expected function, found struct `Empty1` +error[E0423]: expected function, tuple struct or tuple variant, found struct `Empty1` --> $DIR/empty-struct-braces-expr.rs:16:14 | LL | struct Empty1 {} @@ -23,7 +23,7 @@ LL | let e1 = Empty1(); | help: a unit struct with a similar name exists: `XEmpty2` error[E0423]: expected value, found struct variant `E::Empty3` - --> $DIR/empty-struct-braces-expr.rs:17:14 + --> $DIR/empty-struct-braces-expr.rs:18:14 | LL | Empty3 {} | --------- `E::Empty3` defined here @@ -31,8 +31,8 @@ LL | Empty3 {} LL | let e3 = E::Empty3; | ^^^^^^^^^ did you mean `E::Empty3 { /* fields */ }`? -error[E0423]: expected function, found struct variant `E::Empty3` - --> $DIR/empty-struct-braces-expr.rs:18:14 +error[E0423]: expected function, tuple struct or tuple variant, found struct variant `E::Empty3` + --> $DIR/empty-struct-braces-expr.rs:19:14 | LL | Empty3 {} | --------- `E::Empty3` defined here @@ -41,7 +41,7 @@ LL | let e3 = E::Empty3(); | ^^^^^^^^^ did you mean `E::Empty3 { /* fields */ }`? error[E0423]: expected value, found struct `XEmpty1` - --> $DIR/empty-struct-braces-expr.rs:20:15 + --> $DIR/empty-struct-braces-expr.rs:22:15 | LL | let xe1 = XEmpty1; | ^^^^^^^ @@ -49,8 +49,8 @@ LL | let xe1 = XEmpty1; | did you mean `XEmpty1 { /* fields */ }`? | help: a unit struct with a similar name exists: `XEmpty2` -error[E0423]: expected function, found struct `XEmpty1` - --> $DIR/empty-struct-braces-expr.rs:21:15 +error[E0423]: expected function, tuple struct or tuple variant, found struct `XEmpty1` + --> $DIR/empty-struct-braces-expr.rs:23:15 | LL | let xe1 = XEmpty1(); | ^^^^^^^ @@ -59,7 +59,7 @@ LL | let xe1 = XEmpty1(); | help: a unit struct with a similar name exists: `XEmpty2` error[E0599]: no variant or associated item named `Empty3` found for type `empty_struct::XE` in the current scope - --> $DIR/empty-struct-braces-expr.rs:22:19 + --> $DIR/empty-struct-braces-expr.rs:25:19 | LL | let xe3 = XE::Empty3; | ^^^^^^ @@ -68,7 +68,7 @@ LL | let xe3 = XE::Empty3; | help: there is a variant with a similar name: `XEmpty3` error[E0599]: no variant or associated item named `Empty3` found for type `empty_struct::XE` in the current scope - --> $DIR/empty-struct-braces-expr.rs:23:19 + --> $DIR/empty-struct-braces-expr.rs:26:19 | LL | let xe3 = XE::Empty3(); | ^^^^^^ @@ -77,7 +77,7 @@ LL | let xe3 = XE::Empty3(); | help: there is a variant with a similar name: `XEmpty3` error: no variant `Empty1` in enum `empty_struct::XE` - --> $DIR/empty-struct-braces-expr.rs:25:9 + --> $DIR/empty-struct-braces-expr.rs:28:9 | LL | XE::Empty1 {}; | ^^^^^^ help: there is a variant with a similar name: `XEmpty3` diff --git a/src/test/ui/empty/empty-struct-braces-pat-1.rs b/src/test/ui/empty/empty-struct-braces-pat-1.rs index 81062320fe47c..9bed93f9c1536 100644 --- a/src/test/ui/empty/empty-struct-braces-pat-1.rs +++ b/src/test/ui/empty/empty-struct-braces-pat-1.rs @@ -22,13 +22,13 @@ fn main() { } match e3 { E::Empty3 => () - //~^ ERROR expected unit struct/variant or constant, found struct variant `E::Empty3` + //~^ ERROR expected unit struct, unit variant or constant, found struct variant `E::Empty3` } match xe1 { XEmpty1 => () // Not an error, `XEmpty1` is interpreted as a new binding } match xe3 { XE::XEmpty3 => () - //~^ ERROR expected unit struct/variant or constant, found struct variant `XE::XEmpty3` + //~^ ERROR expected unit struct, unit variant or constant, found struct variant `XE::XEmpty3` } } diff --git a/src/test/ui/empty/empty-struct-braces-pat-1.stderr b/src/test/ui/empty/empty-struct-braces-pat-1.stderr index 271e811a2fd65..9b5f31157d1bb 100644 --- a/src/test/ui/empty/empty-struct-braces-pat-1.stderr +++ b/src/test/ui/empty/empty-struct-braces-pat-1.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected unit struct/variant or constant, found struct variant `E::Empty3` +error[E0532]: expected unit struct, unit variant or constant, found struct variant `E::Empty3` --> $DIR/empty-struct-braces-pat-1.rs:24:9 | LL | Empty3 {} @@ -7,7 +7,7 @@ LL | Empty3 {} LL | E::Empty3 => () | ^^^^^^^^^ did you mean `E::Empty3 { /* fields */ }`? -error[E0532]: expected unit struct/variant or constant, found struct variant `XE::XEmpty3` +error[E0532]: expected unit struct, unit variant or constant, found struct variant `XE::XEmpty3` --> $DIR/empty-struct-braces-pat-1.rs:31:9 | LL | XE::XEmpty3 => () diff --git a/src/test/ui/empty/empty-struct-braces-pat-2.rs b/src/test/ui/empty/empty-struct-braces-pat-2.rs index 187d953d805e1..cfe4641f35604 100644 --- a/src/test/ui/empty/empty-struct-braces-pat-2.rs +++ b/src/test/ui/empty/empty-struct-braces-pat-2.rs @@ -12,15 +12,15 @@ fn main() { let xe1 = XEmpty1 {}; match e1 { - Empty1() => () //~ ERROR expected tuple struct/variant, found struct `Empty1` + Empty1() => () //~ ERROR expected tuple struct or tuple variant, found struct `Empty1` } match xe1 { - XEmpty1() => () //~ ERROR expected tuple struct/variant, found struct `XEmpty1` + XEmpty1() => () //~ ERROR expected tuple struct or tuple variant, found struct `XEmpty1` } match e1 { - Empty1(..) => () //~ ERROR expected tuple struct/variant, found struct `Empty1` + Empty1(..) => () //~ ERROR expected tuple struct or tuple variant, found struct `Empty1` } match xe1 { - XEmpty1(..) => () //~ ERROR expected tuple struct/variant, found struct `XEmpty1` + XEmpty1(..) => () //~ ERROR expected tuple struct or tuple variant, found struct `XEmpty1` } } diff --git a/src/test/ui/empty/empty-struct-braces-pat-2.stderr b/src/test/ui/empty/empty-struct-braces-pat-2.stderr index 3352473788894..0b3c9ae51519e 100644 --- a/src/test/ui/empty/empty-struct-braces-pat-2.stderr +++ b/src/test/ui/empty/empty-struct-braces-pat-2.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected tuple struct/variant, found struct `Empty1` +error[E0532]: expected tuple struct or tuple variant, found struct `Empty1` --> $DIR/empty-struct-braces-pat-2.rs:15:9 | LL | struct Empty1 {} @@ -10,7 +10,7 @@ LL | Empty1() => () | did you mean `Empty1 { /* fields */ }`? | help: a tuple struct with a similar name exists: `XEmpty6` -error[E0532]: expected tuple struct/variant, found struct `XEmpty1` +error[E0532]: expected tuple struct or tuple variant, found struct `XEmpty1` --> $DIR/empty-struct-braces-pat-2.rs:18:9 | LL | XEmpty1() => () @@ -19,7 +19,7 @@ LL | XEmpty1() => () | did you mean `XEmpty1 { /* fields */ }`? | help: a tuple struct with a similar name exists: `XEmpty6` -error[E0532]: expected tuple struct/variant, found struct `Empty1` +error[E0532]: expected tuple struct or tuple variant, found struct `Empty1` --> $DIR/empty-struct-braces-pat-2.rs:21:9 | LL | struct Empty1 {} @@ -31,7 +31,7 @@ LL | Empty1(..) => () | did you mean `Empty1 { /* fields */ }`? | help: a tuple struct with a similar name exists: `XEmpty6` -error[E0532]: expected tuple struct/variant, found struct `XEmpty1` +error[E0532]: expected tuple struct or tuple variant, found struct `XEmpty1` --> $DIR/empty-struct-braces-pat-2.rs:24:9 | LL | XEmpty1(..) => () diff --git a/src/test/ui/empty/empty-struct-braces-pat-3.rs b/src/test/ui/empty/empty-struct-braces-pat-3.rs index fad28d78fe557..54d547eefcc95 100644 --- a/src/test/ui/empty/empty-struct-braces-pat-3.rs +++ b/src/test/ui/empty/empty-struct-braces-pat-3.rs @@ -15,18 +15,18 @@ fn main() { match e3 { E::Empty3() => () - //~^ ERROR expected tuple struct/variant, found struct variant `E::Empty3` + //~^ ERROR expected tuple struct or tuple variant, found struct variant `E::Empty3` } match xe3 { XE::XEmpty3() => () - //~^ ERROR expected tuple struct/variant, found struct variant `XE::XEmpty3` + //~^ ERROR expected tuple struct or tuple variant, found struct variant `XE::XEmpty3` } match e3 { E::Empty3(..) => () - //~^ ERROR expected tuple struct/variant, found struct variant `E::Empty3` + //~^ ERROR expected tuple struct or tuple variant, found struct variant `E::Empty3` } match xe3 { XE::XEmpty3(..) => () - //~^ ERROR expected tuple struct/variant, found struct variant `XE::XEmpty3 + //~^ ERROR expected tuple struct or tuple variant, found struct variant `XE::XEmpty3 } } diff --git a/src/test/ui/empty/empty-struct-braces-pat-3.stderr b/src/test/ui/empty/empty-struct-braces-pat-3.stderr index aefdd772b1bfd..785396c448bb0 100644 --- a/src/test/ui/empty/empty-struct-braces-pat-3.stderr +++ b/src/test/ui/empty/empty-struct-braces-pat-3.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected tuple struct/variant, found struct variant `E::Empty3` +error[E0532]: expected tuple struct or tuple variant, found struct variant `E::Empty3` --> $DIR/empty-struct-braces-pat-3.rs:17:9 | LL | Empty3 {} @@ -7,7 +7,7 @@ LL | Empty3 {} LL | E::Empty3() => () | ^^^^^^^^^ did you mean `E::Empty3 { /* fields */ }`? -error[E0532]: expected tuple struct/variant, found struct variant `XE::XEmpty3` +error[E0532]: expected tuple struct or tuple variant, found struct variant `XE::XEmpty3` --> $DIR/empty-struct-braces-pat-3.rs:21:9 | LL | XE::XEmpty3() => () @@ -16,7 +16,7 @@ LL | XE::XEmpty3() => () | | help: a tuple variant with a similar name exists: `XEmpty5` | did you mean `XE::XEmpty3 { /* fields */ }`? -error[E0532]: expected tuple struct/variant, found struct variant `E::Empty3` +error[E0532]: expected tuple struct or tuple variant, found struct variant `E::Empty3` --> $DIR/empty-struct-braces-pat-3.rs:25:9 | LL | Empty3 {} @@ -25,7 +25,7 @@ LL | Empty3 {} LL | E::Empty3(..) => () | ^^^^^^^^^ did you mean `E::Empty3 { /* fields */ }`? -error[E0532]: expected tuple struct/variant, found struct variant `XE::XEmpty3` +error[E0532]: expected tuple struct or tuple variant, found struct variant `XE::XEmpty3` --> $DIR/empty-struct-braces-pat-3.rs:29:9 | LL | XE::XEmpty3(..) => () diff --git a/src/test/ui/empty/empty-struct-tuple-pat.rs b/src/test/ui/empty/empty-struct-tuple-pat.rs index 00a48594e93af..47da8a306a4b2 100644 --- a/src/test/ui/empty/empty-struct-tuple-pat.rs +++ b/src/test/ui/empty/empty-struct-tuple-pat.rs @@ -27,11 +27,11 @@ fn main() { match e4 { E::Empty4 => () - //~^ ERROR expected unit struct/variant or constant, found tuple variant `E::Empty4` + //~^ ERROR expected unit struct, unit variant or constant, found tuple variant `E::Empty4` } match xe5 { XE::XEmpty5 => (), - //~^ ERROR expected unit struct/variant or constant, found tuple variant `XE::XEmpty5` + //~^ ERROR expected unit struct, unit variant or constant, found tuple variant `XE::XEmpty5` _ => {}, } } diff --git a/src/test/ui/empty/empty-struct-tuple-pat.stderr b/src/test/ui/empty/empty-struct-tuple-pat.stderr index 4b828c0d942e3..cfbb468e5e633 100644 --- a/src/test/ui/empty/empty-struct-tuple-pat.stderr +++ b/src/test/ui/empty/empty-struct-tuple-pat.stderr @@ -16,7 +16,7 @@ LL | use empty_struct::*; LL | XEmpty6 => () | ^^^^^^^ cannot be named the same as a tuple struct -error[E0532]: expected unit struct/variant or constant, found tuple variant `E::Empty4` +error[E0532]: expected unit struct, unit variant or constant, found tuple variant `E::Empty4` --> $DIR/empty-struct-tuple-pat.rs:29:9 | LL | Empty4() @@ -25,7 +25,7 @@ LL | Empty4() LL | E::Empty4 => () | ^^^^^^^^^ did you mean `E::Empty4( /* fields */ )`? -error[E0532]: expected unit struct/variant or constant, found tuple variant `XE::XEmpty5` +error[E0532]: expected unit struct, unit variant or constant, found tuple variant `XE::XEmpty5` --> $DIR/empty-struct-tuple-pat.rs:33:9 | LL | XE::XEmpty5 => (), diff --git a/src/test/ui/empty/empty-struct-unit-pat.rs b/src/test/ui/empty/empty-struct-unit-pat.rs index 8a0e2f505e443..44a1e9e3d93bc 100644 --- a/src/test/ui/empty/empty-struct-unit-pat.rs +++ b/src/test/ui/empty/empty-struct-unit-pat.rs @@ -18,32 +18,37 @@ fn main() { let xe4 = XE::XEmpty4; match e2 { - Empty2() => () //~ ERROR expected tuple struct/variant, found unit struct `Empty2` + Empty2() => () //~ ERROR expected tuple struct or tuple variant, found unit struct `Empty2` } match xe2 { - XEmpty2() => () //~ ERROR expected tuple struct/variant, found unit struct `XEmpty2` + XEmpty2() => () + //~^ ERROR expected tuple struct or tuple variant, found unit struct `XEmpty2` } match e2 { - Empty2(..) => () //~ ERROR expected tuple struct/variant, found unit struct `Empty2` + Empty2(..) => () + //~^ ERROR expected tuple struct or tuple variant, found unit struct `Empty2` } match xe2 { - XEmpty2(..) => () //~ ERROR expected tuple struct/variant, found unit struct `XEmpty2` + XEmpty2(..) => () + //~^ ERROR expected tuple struct or tuple variant, found unit struct `XEmpty2` } match e4 { - E::Empty4() => () //~ ERROR expected tuple struct/variant, found unit variant `E::Empty4` + E::Empty4() => () + //~^ ERROR expected tuple struct or tuple variant, found unit variant `E::Empty4` } match xe4 { XE::XEmpty4() => (), - //~^ ERROR expected tuple struct/variant, found unit variant `XE::XEmpty4` + //~^ ERROR expected tuple struct or tuple variant, found unit variant `XE::XEmpty4` _ => {}, } match e4 { - E::Empty4(..) => () //~ ERROR expected tuple struct/variant, found unit variant `E::Empty4` + E::Empty4(..) => () + //~^ ERROR expected tuple struct or tuple variant, found unit variant `E::Empty4` } match xe4 { XE::XEmpty4(..) => (), - //~^ ERROR expected tuple struct/variant, found unit variant `XE::XEmpty4` + //~^ ERROR expected tuple struct or tuple variant, found unit variant `XE::XEmpty4` _ => {}, } } diff --git a/src/test/ui/empty/empty-struct-unit-pat.stderr b/src/test/ui/empty/empty-struct-unit-pat.stderr index 268fc7a6e0c19..fd41a6ed38284 100644 --- a/src/test/ui/empty/empty-struct-unit-pat.stderr +++ b/src/test/ui/empty/empty-struct-unit-pat.stderr @@ -1,49 +1,49 @@ -error[E0532]: expected tuple struct/variant, found unit struct `Empty2` +error[E0532]: expected tuple struct or tuple variant, found unit struct `Empty2` --> $DIR/empty-struct-unit-pat.rs:21:9 | LL | Empty2() => () | ^^^^^^ help: a tuple struct with a similar name exists: `XEmpty6` -error[E0532]: expected tuple struct/variant, found unit struct `XEmpty2` +error[E0532]: expected tuple struct or tuple variant, found unit struct `XEmpty2` --> $DIR/empty-struct-unit-pat.rs:24:9 | LL | XEmpty2() => () | ^^^^^^^ help: a tuple struct with a similar name exists: `XEmpty6` -error[E0532]: expected tuple struct/variant, found unit struct `Empty2` - --> $DIR/empty-struct-unit-pat.rs:27:9 +error[E0532]: expected tuple struct or tuple variant, found unit struct `Empty2` + --> $DIR/empty-struct-unit-pat.rs:28:9 | LL | Empty2(..) => () | ^^^^^^ help: a tuple struct with a similar name exists: `XEmpty6` -error[E0532]: expected tuple struct/variant, found unit struct `XEmpty2` - --> $DIR/empty-struct-unit-pat.rs:30:9 +error[E0532]: expected tuple struct or tuple variant, found unit struct `XEmpty2` + --> $DIR/empty-struct-unit-pat.rs:32:9 | LL | XEmpty2(..) => () | ^^^^^^^ help: a tuple struct with a similar name exists: `XEmpty6` -error[E0532]: expected tuple struct/variant, found unit variant `E::Empty4` - --> $DIR/empty-struct-unit-pat.rs:34:9 +error[E0532]: expected tuple struct or tuple variant, found unit variant `E::Empty4` + --> $DIR/empty-struct-unit-pat.rs:37:9 | LL | E::Empty4() => () - | ^^^^^^^^^ not a tuple struct/variant + | ^^^^^^^^^ not a tuple struct or tuple variant -error[E0532]: expected tuple struct/variant, found unit variant `XE::XEmpty4` - --> $DIR/empty-struct-unit-pat.rs:37:9 +error[E0532]: expected tuple struct or tuple variant, found unit variant `XE::XEmpty4` + --> $DIR/empty-struct-unit-pat.rs:41:9 | LL | XE::XEmpty4() => (), | ^^^^------- | | | help: a tuple variant with a similar name exists: `XEmpty5` -error[E0532]: expected tuple struct/variant, found unit variant `E::Empty4` - --> $DIR/empty-struct-unit-pat.rs:42:9 +error[E0532]: expected tuple struct or tuple variant, found unit variant `E::Empty4` + --> $DIR/empty-struct-unit-pat.rs:46:9 | LL | E::Empty4(..) => () - | ^^^^^^^^^ not a tuple struct/variant + | ^^^^^^^^^ not a tuple struct or tuple variant -error[E0532]: expected tuple struct/variant, found unit variant `XE::XEmpty4` - --> $DIR/empty-struct-unit-pat.rs:45:9 +error[E0532]: expected tuple struct or tuple variant, found unit variant `XE::XEmpty4` + --> $DIR/empty-struct-unit-pat.rs:50:9 | LL | XE::XEmpty4(..) => (), | ^^^^------- diff --git a/src/test/ui/enums-pats-not-idents.rs b/src/test/ui/enums-pats-not-idents.rs index 1593f1e1b16ef..5b918eef6d65b 100644 --- a/src/test/ui/enums-pats-not-idents.rs +++ b/src/test/ui/enums-pats-not-idents.rs @@ -1,3 +1,3 @@ fn main() { - let a(1) = 13; //~ ERROR cannot find tuple struct/variant `a` in this scope + let a(1) = 13; //~ ERROR cannot find tuple struct or tuple variant `a` in this scope } diff --git a/src/test/ui/enums-pats-not-idents.stderr b/src/test/ui/enums-pats-not-idents.stderr index 6b1e6046260a9..072b88716ad7c 100644 --- a/src/test/ui/enums-pats-not-idents.stderr +++ b/src/test/ui/enums-pats-not-idents.stderr @@ -1,4 +1,4 @@ -error[E0531]: cannot find tuple struct/variant `a` in this scope +error[E0531]: cannot find tuple struct or tuple variant `a` in this scope --> $DIR/enums-pats-not-idents.rs:2:9 | LL | let a(1) = 13; diff --git a/src/test/ui/error-codes/E0164.stderr b/src/test/ui/error-codes/E0164.stderr index 0a153d85b4215..4bbddb1978cc5 100644 --- a/src/test/ui/error-codes/E0164.stderr +++ b/src/test/ui/error-codes/E0164.stderr @@ -1,4 +1,4 @@ -error[E0164]: expected tuple struct/variant, found associated constant `::B` +error[E0164]: expected tuple struct or tuple variant, found associated constant `::B` --> $DIR/E0164.rs:9:9 | LL | Foo::B(i) => i, diff --git a/src/test/ui/error-codes/E0423.stderr b/src/test/ui/error-codes/E0423.stderr index 4e016dbd1c029..09792845d162c 100644 --- a/src/test/ui/error-codes/E0423.stderr +++ b/src/test/ui/error-codes/E0423.stderr @@ -26,17 +26,23 @@ help: surround the struct literal with parentheses LL | for _ in (std::ops::Range { start: 0, end: 10 }) {} | ^ ^ -error[E0423]: expected function, found struct `Foo` +error[E0423]: expected function, tuple struct or tuple variant, found struct `Foo` --> $DIR/E0423.rs:4:13 | -LL | struct Foo { a: bool }; - | ---------------------- `Foo` defined here +LL | struct Foo { a: bool }; + | ---------------------- `Foo` defined here LL | -LL | let f = Foo(); - | ^^^ - | | - | did you mean `Foo { /* fields */ }`? - | help: a function with a similar name exists (notice the capitalization): `foo` +LL | let f = Foo(); + | ^^^ + | | + | did you mean `Foo { /* fields */ }`? + | help: a function with a similar name exists (notice the capitalization): `foo` +... +LL | / fn foo() { +LL | | for _ in std::ops::Range { start: 0, end: 10 } {} +LL | | +LL | | } + | |_- similarly named function `foo` defined here error[E0423]: expected value, found struct `T` --> $DIR/E0423.rs:14:8 diff --git a/src/test/ui/error-codes/E0424.stderr b/src/test/ui/error-codes/E0424.stderr index 567d1b3cc75f4..690a101496d73 100644 --- a/src/test/ui/error-codes/E0424.stderr +++ b/src/test/ui/error-codes/E0424.stderr @@ -7,7 +7,7 @@ LL | | self.bar(); LL | | } | |_____- this function doesn't have a `self` parameter -error[E0424]: expected unit struct/variant or constant, found module `self` +error[E0424]: expected unit struct, unit variant or constant, found module `self` --> $DIR/E0424.rs:12:9 | LL | / fn main () { diff --git a/src/test/ui/error-codes/E0532.rs b/src/test/ui/error-codes/E0532.rs index 931ca4628fe1d..486da0e029ef3 100644 --- a/src/test/ui/error-codes/E0532.rs +++ b/src/test/ui/error-codes/E0532.rs @@ -3,7 +3,7 @@ fn main() { match SomeStruct(value) { StructConst1(_) => { }, - //~^ ERROR expected tuple struct/variant, found constant `StructConst1` + //~^ ERROR expected tuple struct or tuple variant, found constant `StructConst1` _ => { }, } diff --git a/src/test/ui/error-codes/E0532.stderr b/src/test/ui/error-codes/E0532.stderr index 887ede0a4124b..eeccadccc636a 100644 --- a/src/test/ui/error-codes/E0532.stderr +++ b/src/test/ui/error-codes/E0532.stderr @@ -1,8 +1,8 @@ -error[E0532]: expected tuple struct/variant, found constant `StructConst1` +error[E0532]: expected tuple struct or tuple variant, found constant `StructConst1` --> $DIR/E0532.rs:5:9 | LL | StructConst1(_) => { }, - | ^^^^^^^^^^^^ not a tuple struct/variant + | ^^^^^^^^^^^^ not a tuple struct or tuple variant error: aborting due to previous error diff --git a/src/test/ui/fn-in-pat.rs b/src/test/ui/fn-in-pat.rs index ed76b2c5db025..b83252012b8f8 100644 --- a/src/test/ui/fn-in-pat.rs +++ b/src/test/ui/fn-in-pat.rs @@ -8,7 +8,7 @@ fn hof(_: F) where F: FnMut(()) {} fn ice() { hof(|c| match c { - A::new() => (), //~ ERROR expected tuple struct/variant, found method + A::new() => (), //~ ERROR expected tuple struct or tuple variant, found method _ => () }) } diff --git a/src/test/ui/fn-in-pat.stderr b/src/test/ui/fn-in-pat.stderr index 0bb24365ef42b..70f84993acfe7 100644 --- a/src/test/ui/fn-in-pat.stderr +++ b/src/test/ui/fn-in-pat.stderr @@ -1,4 +1,4 @@ -error[E0164]: expected tuple struct/variant, found method `::new` +error[E0164]: expected tuple struct or tuple variant, found method `::new` --> $DIR/fn-in-pat.rs:11:9 | LL | A::new() => (), diff --git a/src/test/ui/glob-resolve1.stderr b/src/test/ui/glob-resolve1.stderr index ddd1e0954893f..3db24431586da 100644 --- a/src/test/ui/glob-resolve1.stderr +++ b/src/test/ui/glob-resolve1.stderr @@ -46,6 +46,9 @@ LL | import(); error[E0412]: cannot find type `A` in this scope --> $DIR/glob-resolve1.rs:28:11 | +LL | pub enum B { B1 } + | ----------------- similarly named enum `B` defined here +... LL | foo::(); | ^ | @@ -61,6 +64,9 @@ LL | use bar::A; error[E0412]: cannot find type `C` in this scope --> $DIR/glob-resolve1.rs:29:11 | +LL | pub enum B { B1 } + | ----------------- similarly named enum `B` defined here +... LL | foo::(); | ^ | @@ -76,6 +82,9 @@ LL | use bar::C; error[E0412]: cannot find type `D` in this scope --> $DIR/glob-resolve1.rs:30:11 | +LL | pub enum B { B1 } + | ----------------- similarly named enum `B` defined here +... LL | foo::(); | ^ | diff --git a/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs b/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs index 6ff3ab73639c0..ce8c2d5168fbb 100644 --- a/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs +++ b/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs @@ -1,3 +1,5 @@ +// ignore-x86 +// ^ due to stderr output differences // aux-build:two_macros.rs macro_rules! define_vec { diff --git a/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr b/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr index e8dfd43b6767c..8e01fc8df3def 100644 --- a/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr +++ b/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr @@ -1,5 +1,5 @@ error: macro-expanded `extern crate` items cannot shadow names passed with `--extern` - --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:19:9 + --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:21:9 | LL | extern crate std as core; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,20 +8,24 @@ LL | define_other_core!(); | --------------------- in this macro invocation error[E0659]: `Vec` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) - --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:13:9 + --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:15:9 | LL | Vec::panic!(); | ^^^ ambiguous name | - = note: `Vec` could refer to a struct from prelude -note: `Vec` could also refer to the crate imported here - --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:5:9 +note: `Vec` could refer to the crate imported here + --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:7:9 | LL | extern crate std as Vec; | ^^^^^^^^^^^^^^^^^^^^^^^^ ... LL | define_vec!(); | -------------- in this macro invocation +note: `Vec` could also refer to the struct defined here + --> $SRC_DIR/libstd/prelude/v1.rs:LL:COL + | +LL | pub use crate::vec::Vec; + | ^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-10200.rs b/src/test/ui/issues/issue-10200.rs index 12867a878f310..fe36a7e00bff3 100644 --- a/src/test/ui/issues/issue-10200.rs +++ b/src/test/ui/issues/issue-10200.rs @@ -3,7 +3,7 @@ fn foo(_: usize) -> Foo { Foo(false) } fn main() { match Foo(true) { - foo(x) //~ ERROR expected tuple struct/variant, found function `foo` + foo(x) //~ ERROR expected tuple struct or tuple variant, found function `foo` => () } } diff --git a/src/test/ui/issues/issue-10200.stderr b/src/test/ui/issues/issue-10200.stderr index b1057d45869a8..e60489f5b82f4 100644 --- a/src/test/ui/issues/issue-10200.stderr +++ b/src/test/ui/issues/issue-10200.stderr @@ -1,6 +1,9 @@ -error[E0532]: expected tuple struct/variant, found function `foo` +error[E0532]: expected tuple struct or tuple variant, found function `foo` --> $DIR/issue-10200.rs:6:9 | +LL | struct Foo(bool); + | ----------------- similarly named tuple struct `Foo` defined here +... LL | foo(x) | ^^^ help: a tuple struct with a similar name exists (notice the capitalization): `Foo` diff --git a/src/test/ui/issues/issue-12863.rs b/src/test/ui/issues/issue-12863.rs index d7941a70d51fd..1ac1c3d818e58 100644 --- a/src/test/ui/issues/issue-12863.rs +++ b/src/test/ui/issues/issue-12863.rs @@ -2,6 +2,7 @@ mod foo { pub fn bar() {} } fn main() { match () { - foo::bar => {} //~ ERROR expected unit struct/variant or constant, found function `foo::bar` + foo::bar => {} + //~^ ERROR expected unit struct, unit variant or constant, found function `foo::bar` } } diff --git a/src/test/ui/issues/issue-12863.stderr b/src/test/ui/issues/issue-12863.stderr index bec70a5fb95a2..9c29a37cb930b 100644 --- a/src/test/ui/issues/issue-12863.stderr +++ b/src/test/ui/issues/issue-12863.stderr @@ -1,8 +1,8 @@ -error[E0532]: expected unit struct/variant or constant, found function `foo::bar` +error[E0532]: expected unit struct, unit variant or constant, found function `foo::bar` --> $DIR/issue-12863.rs:5:9 | LL | foo::bar => {} - | ^^^^^^^^ not a unit struct/variant or constant + | ^^^^^^^^ not a unit struct, unit variant or constant error: aborting due to previous error diff --git a/src/test/ui/issues/issue-17933.rs b/src/test/ui/issues/issue-17933.rs index c649b64dcd44a..6da4e6e15284b 100644 --- a/src/test/ui/issues/issue-17933.rs +++ b/src/test/ui/issues/issue-17933.rs @@ -3,7 +3,7 @@ pub static X: usize = 1; fn main() { match 1 { self::X => { }, - //~^ ERROR expected unit struct/variant or constant, found static `self::X` + //~^ ERROR expected unit struct, unit variant or constant, found static `self::X` _ => { }, } } diff --git a/src/test/ui/issues/issue-17933.stderr b/src/test/ui/issues/issue-17933.stderr index e48a65087f4a3..33534d3f8f6a9 100644 --- a/src/test/ui/issues/issue-17933.stderr +++ b/src/test/ui/issues/issue-17933.stderr @@ -1,8 +1,8 @@ -error[E0532]: expected unit struct/variant or constant, found static `self::X` +error[E0532]: expected unit struct, unit variant or constant, found static `self::X` --> $DIR/issue-17933.rs:5:9 | LL | self::X => { }, - | ^^^^^^^ not a unit struct/variant or constant + | ^^^^^^^ not a unit struct, unit variant or constant error: aborting due to previous error diff --git a/src/test/ui/issues/issue-19086.rs b/src/test/ui/issues/issue-19086.rs index 9802814a87a51..cc83874cb16c2 100644 --- a/src/test/ui/issues/issue-19086.rs +++ b/src/test/ui/issues/issue-19086.rs @@ -8,6 +8,6 @@ fn main() { let f = FooB { x: 3, y: 4 }; match f { FooB(a, b) => println!("{} {}", a, b), - //~^ ERROR expected tuple struct/variant, found struct variant `FooB` + //~^ ERROR expected tuple struct or tuple variant, found struct variant `FooB` } } diff --git a/src/test/ui/issues/issue-19086.stderr b/src/test/ui/issues/issue-19086.stderr index e2229cbc20922..27992da0ebd2f 100644 --- a/src/test/ui/issues/issue-19086.stderr +++ b/src/test/ui/issues/issue-19086.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected tuple struct/variant, found struct variant `FooB` +error[E0532]: expected tuple struct or tuple variant, found struct variant `FooB` --> $DIR/issue-19086.rs:10:9 | LL | FooB { x: i32, y: i32 } diff --git a/src/test/ui/issues/issue-27033.rs b/src/test/ui/issues/issue-27033.rs index a23819a20f9aa..bcb06d743a05d 100644 --- a/src/test/ui/issues/issue-27033.rs +++ b/src/test/ui/issues/issue-27033.rs @@ -1,3 +1,5 @@ +// ignore-x86 +// ^ due to stderr output differences fn main() { match Some(1) { None @ _ => {} //~ ERROR match bindings cannot shadow unit variants diff --git a/src/test/ui/issues/issue-27033.stderr b/src/test/ui/issues/issue-27033.stderr index ab95433228037..a4baa7bdf7f85 100644 --- a/src/test/ui/issues/issue-27033.stderr +++ b/src/test/ui/issues/issue-27033.stderr @@ -1,11 +1,16 @@ error[E0530]: match bindings cannot shadow unit variants - --> $DIR/issue-27033.rs:3:9 + --> $DIR/issue-27033.rs:5:9 | LL | None @ _ => {} | ^^^^ cannot be named the same as a unit variant + | + ::: $SRC_DIR/libstd/prelude/v1.rs:LL:COL + | +LL | pub use crate::option::Option::{self, Some, None}; + | ---- the unit variant `None` is defined here error[E0530]: match bindings cannot shadow constants - --> $DIR/issue-27033.rs:7:9 + --> $DIR/issue-27033.rs:9:9 | LL | const C: u8 = 1; | ---------------- the constant `C` is defined here diff --git a/src/test/ui/issues/issue-28992-empty.rs b/src/test/ui/issues/issue-28992-empty.rs index 22961fc61d134..f61daa94c5d72 100644 --- a/src/test/ui/issues/issue-28992-empty.rs +++ b/src/test/ui/issues/issue-28992-empty.rs @@ -10,7 +10,7 @@ impl S { } fn main() { - if let C1(..) = 0 {} //~ ERROR expected tuple struct/variant, found constant `C1` + if let C1(..) = 0 {} //~ ERROR expected tuple struct or tuple variant, found constant `C1` if let S::C2(..) = 0 {} - //~^ ERROR expected tuple struct/variant, found associated constant `::C2` + //~^ ERROR expected tuple struct or tuple variant, found associated constant `::C2` } diff --git a/src/test/ui/issues/issue-28992-empty.stderr b/src/test/ui/issues/issue-28992-empty.stderr index 9f9f574aa5dd4..a4311880bcbe9 100644 --- a/src/test/ui/issues/issue-28992-empty.stderr +++ b/src/test/ui/issues/issue-28992-empty.stderr @@ -1,10 +1,10 @@ -error[E0532]: expected tuple struct/variant, found constant `C1` +error[E0532]: expected tuple struct or tuple variant, found constant `C1` --> $DIR/issue-28992-empty.rs:13:12 | LL | if let C1(..) = 0 {} - | ^^ not a tuple struct/variant + | ^^ not a tuple struct or tuple variant -error[E0164]: expected tuple struct/variant, found associated constant `::C2` +error[E0164]: expected tuple struct or tuple variant, found associated constant `::C2` --> $DIR/issue-28992-empty.rs:14:12 | LL | if let S::C2(..) = 0 {} diff --git a/src/test/ui/issues/issue-31845.stderr b/src/test/ui/issues/issue-31845.stderr index 10cb398cb24f1..75d8859961a04 100644 --- a/src/test/ui/issues/issue-31845.stderr +++ b/src/test/ui/issues/issue-31845.stderr @@ -1,8 +1,11 @@ error[E0425]: cannot find function `g` in this scope --> $DIR/issue-31845.rs:7:12 | -LL | g(); - | ^ help: a function with a similar name exists: `h` +LL | / fn h() { +LL | | g(); + | | ^ help: a function with a similar name exists: `h` +LL | | } + | |_________- similarly named function `h` defined here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-32004.rs b/src/test/ui/issues/issue-32004.rs index aeddb00e2b04c..b3493508c5a9f 100644 --- a/src/test/ui/issues/issue-32004.rs +++ b/src/test/ui/issues/issue-32004.rs @@ -8,12 +8,12 @@ struct S; fn main() { match Foo::Baz { Foo::Bar => {} - //~^ ERROR expected unit struct/variant or constant, found tuple variant `Foo::Bar` + //~^ ERROR expected unit struct, unit variant or constant, found tuple variant `Foo::Bar` _ => {} } match S { S(()) => {} - //~^ ERROR expected tuple struct/variant, found unit struct `S` + //~^ ERROR expected tuple struct or tuple variant, found unit struct `S` } } diff --git a/src/test/ui/issues/issue-32004.stderr b/src/test/ui/issues/issue-32004.stderr index e9a5e217392a6..ab723e26680dc 100644 --- a/src/test/ui/issues/issue-32004.stderr +++ b/src/test/ui/issues/issue-32004.stderr @@ -1,8 +1,10 @@ -error[E0532]: expected unit struct/variant or constant, found tuple variant `Foo::Bar` +error[E0532]: expected unit struct, unit variant or constant, found tuple variant `Foo::Bar` --> $DIR/issue-32004.rs:10:9 | LL | Bar(i32), | -------- `Foo::Bar` defined here +LL | Baz + | --- similarly named unit variant `Baz` defined here ... LL | Foo::Bar => {} | ^^^^^--- @@ -10,11 +12,11 @@ LL | Foo::Bar => {} | | help: a unit variant with a similar name exists: `Baz` | did you mean `Foo::Bar( /* fields */ )`? -error[E0532]: expected tuple struct/variant, found unit struct `S` +error[E0532]: expected tuple struct or tuple variant, found unit struct `S` --> $DIR/issue-32004.rs:16:9 | LL | S(()) => {} - | ^ not a tuple struct/variant + | ^ not a tuple struct or tuple variant error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-32086.rs b/src/test/ui/issues/issue-32086.rs index 3188377584dc0..d595d1dd7e6d1 100644 --- a/src/test/ui/issues/issue-32086.rs +++ b/src/test/ui/issues/issue-32086.rs @@ -2,6 +2,6 @@ struct S(u8); const C: S = S(10); fn main() { - let C(a) = S(11); //~ ERROR expected tuple struct/variant, found constant `C` - let C(..) = S(11); //~ ERROR expected tuple struct/variant, found constant `C` + let C(a) = S(11); //~ ERROR expected tuple struct or tuple variant, found constant `C` + let C(..) = S(11); //~ ERROR expected tuple struct or tuple variant, found constant `C` } diff --git a/src/test/ui/issues/issue-32086.stderr b/src/test/ui/issues/issue-32086.stderr index b5a120c4b9cee..e566dea89088d 100644 --- a/src/test/ui/issues/issue-32086.stderr +++ b/src/test/ui/issues/issue-32086.stderr @@ -1,12 +1,18 @@ -error[E0532]: expected tuple struct/variant, found constant `C` +error[E0532]: expected tuple struct or tuple variant, found constant `C` --> $DIR/issue-32086.rs:5:9 | +LL | struct S(u8); + | ------------- similarly named tuple struct `S` defined here +... LL | let C(a) = S(11); | ^ help: a tuple struct with a similar name exists: `S` -error[E0532]: expected tuple struct/variant, found constant `C` +error[E0532]: expected tuple struct or tuple variant, found constant `C` --> $DIR/issue-32086.rs:6:9 | +LL | struct S(u8); + | ------------- similarly named tuple struct `S` defined here +... LL | let C(..) = S(11); | ^ help: a tuple struct with a similar name exists: `S` diff --git a/src/test/ui/issues/issue-35675.rs b/src/test/ui/issues/issue-35675.rs index fae5cdc0733f1..7876811a9ac39 100644 --- a/src/test/ui/issues/issue-35675.rs +++ b/src/test/ui/issues/issue-35675.rs @@ -7,13 +7,13 @@ enum Fruit { fn should_return_fruit() -> Apple { //~^ ERROR cannot find type `Apple` in this scope Apple(5) - //~^ ERROR cannot find function `Apple` in this scope + //~^ ERROR cannot find function, tuple struct or tuple variant `Apple` in this scope } fn should_return_fruit_too() -> Fruit::Apple { //~^ ERROR expected type, found variant `Fruit::Apple` Apple(5) - //~^ ERROR cannot find function `Apple` in this scope + //~^ ERROR cannot find function, tuple struct or tuple variant `Apple` in this scope } fn foo() -> Ok { diff --git a/src/test/ui/issues/issue-35675.stderr b/src/test/ui/issues/issue-35675.stderr index 8072141aefd20..a9a27da55b1a1 100644 --- a/src/test/ui/issues/issue-35675.stderr +++ b/src/test/ui/issues/issue-35675.stderr @@ -9,7 +9,7 @@ help: there is an enum variant `Fruit::Apple`; try using the variant's enum LL | fn should_return_fruit() -> Fruit { | ^^^^^ -error[E0425]: cannot find function `Apple` in this scope +error[E0425]: cannot find function, tuple struct or tuple variant `Apple` in this scope --> $DIR/issue-35675.rs:9:5 | LL | Apple(5) @@ -29,7 +29,7 @@ LL | fn should_return_fruit_too() -> Fruit::Apple { | not a type | help: try using the variant's enum: `Fruit` -error[E0425]: cannot find function `Apple` in this scope +error[E0425]: cannot find function, tuple struct or tuple variant `Apple` in this scope --> $DIR/issue-35675.rs:15:5 | LL | Apple(5) diff --git a/src/test/ui/issues/issue-38412.rs b/src/test/ui/issues/issue-38412.rs index a7c818d9bcb70..058e1be756577 100644 --- a/src/test/ui/issues/issue-38412.rs +++ b/src/test/ui/issues/issue-38412.rs @@ -1,6 +1,6 @@ fn main() { let Box(a) = loop { }; - //~^ ERROR expected tuple struct/variant, found struct `Box` + //~^ ERROR expected tuple struct or tuple variant, found struct `Box` // (The below is a trick to allow compiler to infer a type for // variable `a` without attempting to ascribe a type to the diff --git a/src/test/ui/issues/issue-38412.stderr b/src/test/ui/issues/issue-38412.stderr index c44a0bfc8b027..318c92ad35fc5 100644 --- a/src/test/ui/issues/issue-38412.stderr +++ b/src/test/ui/issues/issue-38412.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected tuple struct/variant, found struct `Box` +error[E0532]: expected tuple struct or tuple variant, found struct `Box` --> $DIR/issue-38412.rs:2:9 | LL | let Box(a) = loop { }; diff --git a/src/test/ui/issues/issue-42944.rs b/src/test/ui/issues/issue-42944.rs index 9d746673f4dae..cc365dc4c938e 100644 --- a/src/test/ui/issues/issue-42944.rs +++ b/src/test/ui/issues/issue-42944.rs @@ -6,13 +6,15 @@ mod bar { use foo::B; fn foo() { - B(()); //~ ERROR expected function, found struct `B` [E0423] + B(()); + //~^ ERROR expected function, tuple struct or tuple variant, found struct `B` [E0423] } } mod baz { fn foo() { - B(()); //~ ERROR cannot find function `B` in this scope [E0425] + B(()); + //~^ ERROR cannot find function, tuple struct or tuple variant `B` in this scope [E0425] } } diff --git a/src/test/ui/issues/issue-42944.stderr b/src/test/ui/issues/issue-42944.stderr index 4ab272b9e9b3b..c71194f41c114 100644 --- a/src/test/ui/issues/issue-42944.stderr +++ b/src/test/ui/issues/issue-42944.stderr @@ -1,11 +1,11 @@ -error[E0423]: expected function, found struct `B` +error[E0423]: expected function, tuple struct or tuple variant, found struct `B` --> $DIR/issue-42944.rs:9:9 | LL | B(()); | ^ constructor is not visible here due to private fields -error[E0425]: cannot find function `B` in this scope - --> $DIR/issue-42944.rs:15:9 +error[E0425]: cannot find function, tuple struct or tuple variant `B` in this scope + --> $DIR/issue-42944.rs:16:9 | LL | B(()); | ^ not found in this scope diff --git a/src/test/ui/issues/issue-46332.stderr b/src/test/ui/issues/issue-46332.stderr index c7e9d71700e6d..5d8a859a7379c 100644 --- a/src/test/ui/issues/issue-46332.stderr +++ b/src/test/ui/issues/issue-46332.stderr @@ -1,6 +1,9 @@ error[E0422]: cannot find struct, variant or union type `TyUInt` in this scope --> $DIR/issue-46332.rs:9:5 | +LL | struct TyUint {} + | ---------------- similarly named struct `TyUint` defined here +... LL | TyUInt {}; | ^^^^^^ help: a struct with a similar name exists (notice the capitalization): `TyUint` diff --git a/src/test/ui/issues/issue-55587.rs b/src/test/ui/issues/issue-55587.rs index 8b78749f6529a..d9100cf555b3c 100644 --- a/src/test/ui/issues/issue-55587.rs +++ b/src/test/ui/issues/issue-55587.rs @@ -1,5 +1,5 @@ use std::path::Path; fn main() { - let Path::new(); //~ ERROR expected tuple struct/variant + let Path::new(); //~ ERROR expected tuple struct or tuple variant } diff --git a/src/test/ui/issues/issue-55587.stderr b/src/test/ui/issues/issue-55587.stderr index 3928a3cd53201..307227e1c4d10 100644 --- a/src/test/ui/issues/issue-55587.stderr +++ b/src/test/ui/issues/issue-55587.stderr @@ -1,4 +1,4 @@ -error[E0164]: expected tuple struct/variant, found method `::new` +error[E0164]: expected tuple struct or tuple variant, found method `::new` --> $DIR/issue-55587.rs:4:9 | LL | let Path::new(); diff --git a/src/test/ui/issues/issue-56835.rs b/src/test/ui/issues/issue-56835.rs index 4f976da680e64..7132d15ee5fbf 100644 --- a/src/test/ui/issues/issue-56835.rs +++ b/src/test/ui/issues/issue-56835.rs @@ -3,7 +3,7 @@ pub struct Foo {} impl Foo { fn bar(Self(foo): Self) {} //~^ ERROR the `Self` constructor can only be used with tuple or unit structs - //~^^ ERROR expected tuple struct/variant, found self constructor `Self` [E0164] + //~^^ ERROR expected tuple struct or tuple variant, found self constructor `Self` [E0164] } fn main() {} diff --git a/src/test/ui/issues/issue-56835.stderr b/src/test/ui/issues/issue-56835.stderr index f9fdf23af9715..c200ba8d52a32 100644 --- a/src/test/ui/issues/issue-56835.stderr +++ b/src/test/ui/issues/issue-56835.stderr @@ -4,7 +4,7 @@ error: the `Self` constructor can only be used with tuple or unit structs LL | fn bar(Self(foo): Self) {} | ^^^^^^^^^ help: use curly brackets: `Self { /* fields */ }` -error[E0164]: expected tuple struct/variant, found self constructor `Self` +error[E0164]: expected tuple struct or tuple variant, found self constructor `Self` --> $DIR/issue-56835.rs:4:12 | LL | fn bar(Self(foo): Self) {} diff --git a/src/test/ui/issues/issue-58022.rs b/src/test/ui/issues/issue-58022.rs index c6dd45e6cf3e9..30527903ed0f2 100644 --- a/src/test/ui/issues/issue-58022.rs +++ b/src/test/ui/issues/issue-58022.rs @@ -11,7 +11,8 @@ impl Bar<[u8]> { const SIZE: usize = 32; fn new(slice: &[u8; Self::SIZE]) -> Self { - Foo(Box::new(*slice)) //~ ERROR: expected function, found trait `Foo` + Foo(Box::new(*slice)) + //~^ ERROR: expected function, tuple struct or tuple variant, found trait `Foo` } } diff --git a/src/test/ui/issues/issue-58022.stderr b/src/test/ui/issues/issue-58022.stderr index 71bad7b81fa87..a3e4cb6320240 100644 --- a/src/test/ui/issues/issue-58022.stderr +++ b/src/test/ui/issues/issue-58022.stderr @@ -1,8 +1,8 @@ -error[E0423]: expected function, found trait `Foo` +error[E0423]: expected function, tuple struct or tuple variant, found trait `Foo` --> $DIR/issue-58022.rs:14:9 | LL | Foo(Box::new(*slice)) - | ^^^ not a function + | ^^^ not a function, tuple struct or tuple variant error[E0283]: type annotations needed: cannot resolve `_: Foo` --> $DIR/issue-58022.rs:4:25 diff --git a/src/test/ui/issues/issue-5927.rs b/src/test/ui/issues/issue-5927.rs index 847936cc95402..14f95827be8ea 100644 --- a/src/test/ui/issues/issue-5927.rs +++ b/src/test/ui/issues/issue-5927.rs @@ -1,6 +1,6 @@ fn main() { let z = match 3 { - x(1) => x(1) //~ ERROR cannot find tuple struct/variant `x` in this scope + x(1) => x(1) //~ ERROR cannot find tuple struct or tuple variant `x` in this scope //~^ ERROR cannot find function `x` in this scope }; assert!(z == 3); diff --git a/src/test/ui/issues/issue-5927.stderr b/src/test/ui/issues/issue-5927.stderr index 3d4550ec8b238..d6cd6853dbdb5 100644 --- a/src/test/ui/issues/issue-5927.stderr +++ b/src/test/ui/issues/issue-5927.stderr @@ -1,4 +1,4 @@ -error[E0531]: cannot find tuple struct/variant `x` in this scope +error[E0531]: cannot find tuple struct or tuple variant `x` in this scope --> $DIR/issue-5927.rs:3:9 | LL | x(1) => x(1) diff --git a/src/test/ui/issues/issue-63983.rs b/src/test/ui/issues/issue-63983.rs index c1c79091fc802..ab952666fd1da 100644 --- a/src/test/ui/issues/issue-63983.rs +++ b/src/test/ui/issues/issue-63983.rs @@ -6,9 +6,9 @@ enum MyEnum { fn foo(en: MyEnum) { match en { MyEnum::Tuple => "", - //~^ ERROR expected unit struct/variant or constant, found tuple variant `MyEnum::Tuple` +//~^ ERROR expected unit struct, unit variant or constant, found tuple variant `MyEnum::Tuple` MyEnum::Struct => "", - //~^ ERROR expected unit struct/variant or constant, found struct variant `MyEnum::Struct` +//~^ ERROR expected unit struct, unit variant or constant, found struct variant `MyEnum::Struct` }; } diff --git a/src/test/ui/issues/issue-63983.stderr b/src/test/ui/issues/issue-63983.stderr index 8949c475b6f72..e54466faedde6 100644 --- a/src/test/ui/issues/issue-63983.stderr +++ b/src/test/ui/issues/issue-63983.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected unit struct/variant or constant, found tuple variant `MyEnum::Tuple` +error[E0532]: expected unit struct, unit variant or constant, found tuple variant `MyEnum::Tuple` --> $DIR/issue-63983.rs:8:9 | LL | Tuple(i32), @@ -7,7 +7,7 @@ LL | Tuple(i32), LL | MyEnum::Tuple => "", | ^^^^^^^^^^^^^ did you mean `MyEnum::Tuple( /* fields */ )`? -error[E0532]: expected unit struct/variant or constant, found struct variant `MyEnum::Struct` +error[E0532]: expected unit struct, unit variant or constant, found struct variant `MyEnum::Struct` --> $DIR/issue-63983.rs:10:9 | LL | Struct{ s: i32 }, diff --git a/src/test/ui/issues/issue-64792-bad-unicode-ctor.rs b/src/test/ui/issues/issue-64792-bad-unicode-ctor.rs index 7bce57923a5b7..f1427ef46e928 100644 --- a/src/test/ui/issues/issue-64792-bad-unicode-ctor.rs +++ b/src/test/ui/issues/issue-64792-bad-unicode-ctor.rs @@ -1,5 +1,5 @@ struct X {} -const Y: X = X("ö"); //~ ERROR expected function, found struct `X` +const Y: X = X("ö"); //~ ERROR expected function, tuple struct or tuple variant, found struct `X` fn main() {} diff --git a/src/test/ui/issues/issue-64792-bad-unicode-ctor.stderr b/src/test/ui/issues/issue-64792-bad-unicode-ctor.stderr index ae9025bb041ab..44e5d38abbc54 100644 --- a/src/test/ui/issues/issue-64792-bad-unicode-ctor.stderr +++ b/src/test/ui/issues/issue-64792-bad-unicode-ctor.stderr @@ -1,14 +1,15 @@ -error[E0423]: expected function, found struct `X` +error[E0423]: expected function, tuple struct or tuple variant, found struct `X` --> $DIR/issue-64792-bad-unicode-ctor.rs:3:14 | LL | struct X {} | ----------- `X` defined here LL | LL | const Y: X = X("ö"); - | ^ - | | - | did you mean `X { /* fields */ }`? - | help: a constant with a similar name exists: `Y` + | -------------^------ + | | | + | | did you mean `X { /* fields */ }`? + | | help: a constant with a similar name exists: `Y` + | similarly named constant `Y` defined here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-pr29383.rs b/src/test/ui/issues/issue-pr29383.rs index 334fdacb81ec4..2bcc0aa2782dd 100644 --- a/src/test/ui/issues/issue-pr29383.rs +++ b/src/test/ui/issues/issue-pr29383.rs @@ -6,7 +6,9 @@ enum E { fn main() { match None { None => {} - Some(E::A(..)) => {} //~ ERROR expected tuple struct/variant, found unit variant `E::A` - Some(E::B(..)) => {} //~ ERROR expected tuple struct/variant, found unit variant `E::B` + Some(E::A(..)) => {} + //~^ ERROR expected tuple struct or tuple variant, found unit variant `E::A` + Some(E::B(..)) => {} + //~^ ERROR expected tuple struct or tuple variant, found unit variant `E::B` } } diff --git a/src/test/ui/issues/issue-pr29383.stderr b/src/test/ui/issues/issue-pr29383.stderr index 9695e1e3c07f5..e92fd6c2fdc5a 100644 --- a/src/test/ui/issues/issue-pr29383.stderr +++ b/src/test/ui/issues/issue-pr29383.stderr @@ -1,14 +1,14 @@ -error[E0532]: expected tuple struct/variant, found unit variant `E::A` +error[E0532]: expected tuple struct or tuple variant, found unit variant `E::A` --> $DIR/issue-pr29383.rs:9:14 | LL | Some(E::A(..)) => {} - | ^^^^ not a tuple struct/variant + | ^^^^ not a tuple struct or tuple variant -error[E0532]: expected tuple struct/variant, found unit variant `E::B` - --> $DIR/issue-pr29383.rs:10:14 +error[E0532]: expected tuple struct or tuple variant, found unit variant `E::B` + --> $DIR/issue-pr29383.rs:11:14 | LL | Some(E::B(..)) => {} - | ^^^^ not a tuple struct/variant + | ^^^^ not a tuple struct or tuple variant error: aborting due to 2 previous errors diff --git a/src/test/ui/keyword/keyword-self-as-identifier.rs b/src/test/ui/keyword/keyword-self-as-identifier.rs index b30002cddafea..72e4f01e21edd 100644 --- a/src/test/ui/keyword/keyword-self-as-identifier.rs +++ b/src/test/ui/keyword/keyword-self-as-identifier.rs @@ -1,3 +1,3 @@ fn main() { - let Self = 22; //~ ERROR cannot find unit struct/variant or constant `Self` in this scope + let Self = 22; //~ ERROR cannot find unit struct, unit variant or constant `Self` in this scope } diff --git a/src/test/ui/keyword/keyword-self-as-identifier.stderr b/src/test/ui/keyword/keyword-self-as-identifier.stderr index be57c6ad26fd8..060e7c3eafc26 100644 --- a/src/test/ui/keyword/keyword-self-as-identifier.stderr +++ b/src/test/ui/keyword/keyword-self-as-identifier.stderr @@ -1,4 +1,4 @@ -error[E0531]: cannot find unit struct/variant or constant `Self` in this scope +error[E0531]: cannot find unit struct, unit variant or constant `Self` in this scope --> $DIR/keyword-self-as-identifier.rs:2:9 | LL | let Self = 22; diff --git a/src/test/ui/macros/macro_undefined.stderr b/src/test/ui/macros/macro_undefined.stderr index 01c8ebea62a2c..b2caba893e072 100644 --- a/src/test/ui/macros/macro_undefined.stderr +++ b/src/test/ui/macros/macro_undefined.stderr @@ -1,8 +1,13 @@ error: cannot find macro `k` in this scope --> $DIR/macro_undefined.rs:11:5 | -LL | k!(); - | ^ help: a macro with a similar name exists: `kl` +LL | / macro_rules! kl { +LL | | () => () +LL | | } + | |_____- similarly named macro `kl` defined here +... +LL | k!(); + | ^ help: a macro with a similar name exists: `kl` error: aborting due to previous error diff --git a/src/test/ui/match/match-fn-call.rs b/src/test/ui/match/match-fn-call.rs index d9c50e75c4944..99092602c9647 100644 --- a/src/test/ui/match/match-fn-call.rs +++ b/src/test/ui/match/match-fn-call.rs @@ -4,9 +4,9 @@ fn main() { let path = Path::new("foo"); match path { Path::new("foo") => println!("foo"), - //~^ ERROR expected tuple struct/variant + //~^ ERROR expected tuple struct or tuple variant Path::new("bar") => println!("bar"), - //~^ ERROR expected tuple struct/variant + //~^ ERROR expected tuple struct or tuple variant _ => (), } } diff --git a/src/test/ui/match/match-fn-call.stderr b/src/test/ui/match/match-fn-call.stderr index bd918428351b9..611904e6e91a0 100644 --- a/src/test/ui/match/match-fn-call.stderr +++ b/src/test/ui/match/match-fn-call.stderr @@ -1,4 +1,4 @@ -error[E0164]: expected tuple struct/variant, found method `::new` +error[E0164]: expected tuple struct or tuple variant, found method `::new` --> $DIR/match-fn-call.rs:6:9 | LL | Path::new("foo") => println!("foo"), @@ -6,7 +6,7 @@ LL | Path::new("foo") => println!("foo"), | = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html -error[E0164]: expected tuple struct/variant, found method `::new` +error[E0164]: expected tuple struct or tuple variant, found method `::new` --> $DIR/match-fn-call.rs:8:9 | LL | Path::new("bar") => println!("bar"), diff --git a/src/test/ui/match/match-pattern-field-mismatch-2.rs b/src/test/ui/match/match-pattern-field-mismatch-2.rs index 3351c756a3145..fa03cdac29fc2 100644 --- a/src/test/ui/match/match-pattern-field-mismatch-2.rs +++ b/src/test/ui/match/match-pattern-field-mismatch-2.rs @@ -10,7 +10,7 @@ fn main() { Color::Rgb(_, _, _) => { } Color::Cmyk(_, _, _, _) => { } Color::NoColor(_) => { } - //~^ ERROR expected tuple struct/variant, found unit variant `Color::NoColor` + //~^ ERROR expected tuple struct or tuple variant, found unit variant `Color::NoColor` } } } diff --git a/src/test/ui/match/match-pattern-field-mismatch-2.stderr b/src/test/ui/match/match-pattern-field-mismatch-2.stderr index a42d62e80297b..cfffcd13851b8 100644 --- a/src/test/ui/match/match-pattern-field-mismatch-2.stderr +++ b/src/test/ui/match/match-pattern-field-mismatch-2.stderr @@ -1,8 +1,8 @@ -error[E0532]: expected tuple struct/variant, found unit variant `Color::NoColor` +error[E0532]: expected tuple struct or tuple variant, found unit variant `Color::NoColor` --> $DIR/match-pattern-field-mismatch-2.rs:12:11 | LL | Color::NoColor(_) => { } - | ^^^^^^^^^^^^^^ not a tuple struct/variant + | ^^^^^^^^^^^^^^ not a tuple struct or tuple variant error: aborting due to previous error diff --git a/src/test/ui/match/match-pattern-field-mismatch.rs b/src/test/ui/match/match-pattern-field-mismatch.rs index 1266aec6220f7..a4fa97fef38e9 100644 --- a/src/test/ui/match/match-pattern-field-mismatch.rs +++ b/src/test/ui/match/match-pattern-field-mismatch.rs @@ -8,7 +8,7 @@ fn main() { fn foo(c: Color) { match c { Color::Rgb(_, _) => { } - //~^ ERROR this pattern has 2 fields, but the corresponding tuple variant has 3 fields + //~^ ERROR this pattern has 2 fields, but the corresponding tuple variant has 3 Color::Cmyk(_, _, _, _) => { } Color::NoColor => { } } diff --git a/src/test/ui/methods/method-path-in-pattern.rs b/src/test/ui/methods/method-path-in-pattern.rs index 21a91f3f32b24..49f5e09edf45a 100644 --- a/src/test/ui/methods/method-path-in-pattern.rs +++ b/src/test/ui/methods/method-path-in-pattern.rs @@ -13,20 +13,20 @@ impl MyTrait for Foo {} fn main() { match 0u32 { Foo::bar => {} - //~^ ERROR expected unit struct/variant or constant, found method `::bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `::bar` } match 0u32 { ::bar => {} - //~^ ERROR expected unit struct/variant or constant, found method `::bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `::bar` } match 0u32 { ::trait_bar => {} - //~^ ERROR expected unit struct/variant or constant, found method `::trait_bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `::trait_bar` } if let Foo::bar = 0u32 {} - //~^ ERROR expected unit struct/variant or constant, found method `::bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `::bar` if let ::bar = 0u32 {} - //~^ ERROR expected unit struct/variant or constant, found method `::bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `::bar` if let Foo::trait_bar = 0u32 {} - //~^ ERROR expected unit struct/variant or constant, found method `::trait_bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `::trait_bar` } diff --git a/src/test/ui/methods/method-path-in-pattern.stderr b/src/test/ui/methods/method-path-in-pattern.stderr index 257fff4c37dc0..b290c34d52774 100644 --- a/src/test/ui/methods/method-path-in-pattern.stderr +++ b/src/test/ui/methods/method-path-in-pattern.stderr @@ -1,34 +1,34 @@ -error[E0533]: expected unit struct/variant or constant, found method `::bar` +error[E0533]: expected unit struct, unit variant or constant, found method `::bar` --> $DIR/method-path-in-pattern.rs:15:9 | LL | Foo::bar => {} | ^^^^^^^^ -error[E0533]: expected unit struct/variant or constant, found method `::bar` +error[E0533]: expected unit struct, unit variant or constant, found method `::bar` --> $DIR/method-path-in-pattern.rs:19:9 | LL | ::bar => {} | ^^^^^^^^^^ -error[E0533]: expected unit struct/variant or constant, found method `::trait_bar` +error[E0533]: expected unit struct, unit variant or constant, found method `::trait_bar` --> $DIR/method-path-in-pattern.rs:23:9 | LL | ::trait_bar => {} | ^^^^^^^^^^^^^^^^ -error[E0533]: expected unit struct/variant or constant, found method `::bar` +error[E0533]: expected unit struct, unit variant or constant, found method `::bar` --> $DIR/method-path-in-pattern.rs:26:12 | LL | if let Foo::bar = 0u32 {} | ^^^^^^^^ -error[E0533]: expected unit struct/variant or constant, found method `::bar` +error[E0533]: expected unit struct, unit variant or constant, found method `::bar` --> $DIR/method-path-in-pattern.rs:28:12 | LL | if let ::bar = 0u32 {} | ^^^^^^^^^^ -error[E0533]: expected unit struct/variant or constant, found method `::trait_bar` +error[E0533]: expected unit struct, unit variant or constant, found method `::trait_bar` --> $DIR/method-path-in-pattern.rs:30:12 | LL | if let Foo::trait_bar = 0u32 {} diff --git a/src/test/ui/methods/method-resolvable-path-in-pattern.rs b/src/test/ui/methods/method-resolvable-path-in-pattern.rs index 1d373cfa6a767..c05160792d360 100644 --- a/src/test/ui/methods/method-resolvable-path-in-pattern.rs +++ b/src/test/ui/methods/method-resolvable-path-in-pattern.rs @@ -9,6 +9,6 @@ impl MyTrait for Foo {} fn main() { match 0u32 { ::trait_bar => {} - //~^ ERROR expected unit struct/variant or constant, found method `MyTrait::trait_bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `MyTrait::trait_bar` } } diff --git a/src/test/ui/methods/method-resolvable-path-in-pattern.stderr b/src/test/ui/methods/method-resolvable-path-in-pattern.stderr index f631c92172021..4b25b694e13ac 100644 --- a/src/test/ui/methods/method-resolvable-path-in-pattern.stderr +++ b/src/test/ui/methods/method-resolvable-path-in-pattern.stderr @@ -1,8 +1,8 @@ -error[E0532]: expected unit struct/variant or constant, found method `MyTrait::trait_bar` +error[E0532]: expected unit struct, unit variant or constant, found method `MyTrait::trait_bar` --> $DIR/method-resolvable-path-in-pattern.rs:11:9 | LL | ::trait_bar => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a unit struct/variant or constant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a unit struct, unit variant or constant error: aborting due to previous error diff --git a/src/test/ui/namespace/namespace-mix.stderr b/src/test/ui/namespace/namespace-mix.stderr index c3f2c79fdd21e..0484661a2e154 100644 --- a/src/test/ui/namespace/namespace-mix.stderr +++ b/src/test/ui/namespace/namespace-mix.stderr @@ -1,6 +1,9 @@ error[E0423]: expected value, found type alias `m1::S` --> $DIR/namespace-mix.rs:34:11 | +LL | pub struct TS(); + | ---------------- similarly named tuple struct `TS` defined here +... LL | check(m1::S); | ^^^^^ | @@ -39,6 +42,8 @@ error[E0423]: expected value, found struct variant `m7::V` | LL | V {}, | ---- `m7::V` defined here +LL | TV(), + | ---- similarly named tuple variant `TV` defined here ... LL | check(m7::V); | ^^^^^ did you mean `m7::V { /* fields */ }`? diff --git a/src/test/ui/parser/recover-from-bad-variant.rs b/src/test/ui/parser/recover-from-bad-variant.rs index 35088fb306882..27b03c0c2db27 100644 --- a/src/test/ui/parser/recover-from-bad-variant.rs +++ b/src/test/ui/parser/recover-from-bad-variant.rs @@ -8,7 +8,7 @@ fn main() { //~^ ERROR expected type, found `3` match x { Enum::Foo(a, b) => {} - //~^ ERROR expected tuple struct/variant, found struct variant `Enum::Foo` + //~^ ERROR expected tuple struct or tuple variant, found struct variant `Enum::Foo` Enum::Bar(a, b) => {} } } diff --git a/src/test/ui/parser/recover-from-bad-variant.stderr b/src/test/ui/parser/recover-from-bad-variant.stderr index 32bb88d31c4c7..375e2d5454489 100644 --- a/src/test/ui/parser/recover-from-bad-variant.stderr +++ b/src/test/ui/parser/recover-from-bad-variant.stderr @@ -9,7 +9,7 @@ LL | let x = Enum::Foo(a: 3, b: 4); = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` = note: for more information, see https://github.com/rust-lang/rust/issues/23416 -error[E0532]: expected tuple struct/variant, found struct variant `Enum::Foo` +error[E0532]: expected tuple struct or tuple variant, found struct variant `Enum::Foo` --> $DIR/recover-from-bad-variant.rs:10:9 | LL | Foo { a: usize, b: usize }, diff --git a/src/test/ui/pattern/pattern-error-continue.rs b/src/test/ui/pattern/pattern-error-continue.rs index 7e79868f874d9..79cc4b552a717 100644 --- a/src/test/ui/pattern/pattern-error-continue.rs +++ b/src/test/ui/pattern/pattern-error-continue.rs @@ -15,7 +15,7 @@ fn f(_c: char) {} fn main() { match A::B(1, 2) { A::B(_, _, _) => (), //~ ERROR this pattern has 3 fields, but - A::D(_) => (), //~ ERROR expected tuple struct/variant, found unit variant `A::D` + A::D(_) => (), //~ ERROR expected tuple struct or tuple variant, found unit variant `A::D` _ => () } match 'c' { diff --git a/src/test/ui/pattern/pattern-error-continue.stderr b/src/test/ui/pattern/pattern-error-continue.stderr index 4fbc630644baa..5a7dab30d83be 100644 --- a/src/test/ui/pattern/pattern-error-continue.stderr +++ b/src/test/ui/pattern/pattern-error-continue.stderr @@ -4,9 +4,12 @@ error[E0433]: failed to resolve: use of undeclared type or module `E` LL | E::V => {} | ^ use of undeclared type or module `E` -error[E0532]: expected tuple struct/variant, found unit variant `A::D` +error[E0532]: expected tuple struct or tuple variant, found unit variant `A::D` --> $DIR/pattern-error-continue.rs:18:9 | +LL | B(isize, isize), + | --------------- similarly named tuple variant `B` defined here +... LL | A::D(_) => (), | ^^^- | | diff --git a/src/test/ui/privacy/privacy-ns1.rs b/src/test/ui/privacy/privacy-ns1.rs index 91cf8e8161994..3326b12ffa535 100644 --- a/src/test/ui/privacy/privacy-ns1.rs +++ b/src/test/ui/privacy/privacy-ns1.rs @@ -17,7 +17,7 @@ pub mod foo1 { fn test_glob1() { use foo1::*; - Bar(); //~ ERROR expected function, found trait `Bar` + Bar(); //~ ERROR expected function, tuple struct or tuple variant, found trait `Bar` } // private type, public value @@ -47,7 +47,7 @@ pub mod foo3 { fn test_glob3() { use foo3::*; - Bar(); //~ ERROR cannot find function `Bar` in this scope + Bar(); //~ ERROR cannot find function, tuple struct or tuple variant `Bar` in this scope let _x: Box; //~ ERROR cannot find type `Bar` in this scope } diff --git a/src/test/ui/privacy/privacy-ns1.stderr b/src/test/ui/privacy/privacy-ns1.stderr index 16da57a78e092..3c766a33baae8 100644 --- a/src/test/ui/privacy/privacy-ns1.stderr +++ b/src/test/ui/privacy/privacy-ns1.stderr @@ -1,6 +1,9 @@ -error[E0423]: expected function, found trait `Bar` +error[E0423]: expected function, tuple struct or tuple variant, found trait `Bar` --> $DIR/privacy-ns1.rs:20:5 | +LL | pub struct Baz; + | --------------- similarly named unit struct `Baz` defined here +... LL | Bar(); | ^^^ | @@ -20,6 +23,9 @@ LL | use foo3::Bar; error[E0573]: expected type, found function `Bar` --> $DIR/privacy-ns1.rs:35:17 | +LL | pub struct Baz; + | --------------- similarly named struct `Baz` defined here +... LL | let _x: Box; | ^^^ | @@ -36,9 +42,12 @@ LL | use foo2::Bar; LL | use foo3::Bar; | -error[E0425]: cannot find function `Bar` in this scope +error[E0425]: cannot find function, tuple struct or tuple variant `Bar` in this scope --> $DIR/privacy-ns1.rs:50:5 | +LL | pub struct Baz; + | --------------- similarly named unit struct `Baz` defined here +... LL | Bar(); | ^^^ | @@ -58,6 +67,9 @@ LL | use foo3::Bar; error[E0412]: cannot find type `Bar` in this scope --> $DIR/privacy-ns1.rs:51:17 | +LL | pub struct Baz; + | --------------- similarly named struct `Baz` defined here +... LL | let _x: Box; | ^^^ | diff --git a/src/test/ui/privacy/privacy-ns2.rs b/src/test/ui/privacy/privacy-ns2.rs index c4e400f5adbd9..788a36fd92ca2 100644 --- a/src/test/ui/privacy/privacy-ns2.rs +++ b/src/test/ui/privacy/privacy-ns2.rs @@ -17,13 +17,13 @@ pub mod foo1 { fn test_single1() { use foo1::Bar; - Bar(); //~ ERROR expected function, found trait `Bar` + Bar(); //~ ERROR expected function, tuple struct or tuple variant, found trait `Bar` } fn test_list1() { use foo1::{Bar,Baz}; - Bar(); //~ ERROR expected function, found trait `Bar` + Bar(); //~ ERROR expected function, tuple struct or tuple variant, found trait `Bar` } // private type, public value diff --git a/src/test/ui/privacy/privacy-ns2.stderr b/src/test/ui/privacy/privacy-ns2.stderr index f0d5da6868596..48e06821cd61c 100644 --- a/src/test/ui/privacy/privacy-ns2.stderr +++ b/src/test/ui/privacy/privacy-ns2.stderr @@ -1,8 +1,8 @@ -error[E0423]: expected function, found trait `Bar` +error[E0423]: expected function, tuple struct or tuple variant, found trait `Bar` --> $DIR/privacy-ns2.rs:20:5 | LL | Bar(); - | ^^^ not a function + | ^^^ not a function, tuple struct or tuple variant | help: possible better candidates are found in other modules, you can import them into scope | @@ -13,9 +13,12 @@ LL | use foo2::Bar; LL | use foo3::Bar; | -error[E0423]: expected function, found trait `Bar` +error[E0423]: expected function, tuple struct or tuple variant, found trait `Bar` --> $DIR/privacy-ns2.rs:26:5 | +LL | pub struct Baz; + | --------------- similarly named unit struct `Baz` defined here +... LL | Bar(); | ^^^ | @@ -50,6 +53,9 @@ LL | use foo3::Bar; error[E0573]: expected type, found function `Bar` --> $DIR/privacy-ns2.rs:47:17 | +LL | pub struct Baz; + | --------------- similarly named struct `Baz` defined here +... LL | let _x: Box; | ^^^ | diff --git a/src/test/ui/proc-macro/parent-source-spans.rs b/src/test/ui/proc-macro/parent-source-spans.rs index 799f1de586ed4..7b2ffefb05b19 100644 --- a/src/test/ui/proc-macro/parent-source-spans.rs +++ b/src/test/ui/proc-macro/parent-source-spans.rs @@ -1,6 +1,4 @@ // aux-build:parent-source-spans.rs - - #![feature(decl_macro, proc_macro_hygiene)] extern crate parent_source_spans; diff --git a/src/test/ui/proc-macro/parent-source-spans.stderr b/src/test/ui/proc-macro/parent-source-spans.stderr index 423122539c803..3e54a71f0e810 100644 --- a/src/test/ui/proc-macro/parent-source-spans.stderr +++ b/src/test/ui/proc-macro/parent-source-spans.stderr @@ -1,5 +1,5 @@ error: first final: "hello" - --> $DIR/parent-source-spans.rs:17:12 + --> $DIR/parent-source-spans.rs:15:12 | LL | three!($a, $b); | ^^ @@ -8,7 +8,7 @@ LL | one!("hello", "world"); | ----------------------- in this macro invocation error: second final: "world" - --> $DIR/parent-source-spans.rs:17:16 + --> $DIR/parent-source-spans.rs:15:16 | LL | three!($a, $b); | ^^ @@ -17,7 +17,7 @@ LL | one!("hello", "world"); | ----------------------- in this macro invocation error: first parent: "hello" - --> $DIR/parent-source-spans.rs:11:5 + --> $DIR/parent-source-spans.rs:9:5 | LL | two!($a, $b); | ^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | one!("hello", "world"); | ----------------------- in this macro invocation error: second parent: "world" - --> $DIR/parent-source-spans.rs:11:5 + --> $DIR/parent-source-spans.rs:9:5 | LL | two!($a, $b); | ^^^^^^^^^^^^^ @@ -35,31 +35,31 @@ LL | one!("hello", "world"); | ----------------------- in this macro invocation error: first grandparent: "hello" - --> $DIR/parent-source-spans.rs:37:5 + --> $DIR/parent-source-spans.rs:35:5 | LL | one!("hello", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: second grandparent: "world" - --> $DIR/parent-source-spans.rs:37:5 + --> $DIR/parent-source-spans.rs:35:5 | LL | one!("hello", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: first source: "hello" - --> $DIR/parent-source-spans.rs:37:5 + --> $DIR/parent-source-spans.rs:35:5 | LL | one!("hello", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: second source: "world" - --> $DIR/parent-source-spans.rs:37:5 + --> $DIR/parent-source-spans.rs:35:5 | LL | one!("hello", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: first final: "yay" - --> $DIR/parent-source-spans.rs:17:12 + --> $DIR/parent-source-spans.rs:15:12 | LL | three!($a, $b); | ^^ @@ -68,7 +68,7 @@ LL | two!("yay", "rust"); | -------------------- in this macro invocation error: second final: "rust" - --> $DIR/parent-source-spans.rs:17:16 + --> $DIR/parent-source-spans.rs:15:16 | LL | three!($a, $b); | ^^ @@ -77,55 +77,55 @@ LL | two!("yay", "rust"); | -------------------- in this macro invocation error: first parent: "yay" - --> $DIR/parent-source-spans.rs:43:5 + --> $DIR/parent-source-spans.rs:41:5 | LL | two!("yay", "rust"); | ^^^^^^^^^^^^^^^^^^^^ error: second parent: "rust" - --> $DIR/parent-source-spans.rs:43:5 + --> $DIR/parent-source-spans.rs:41:5 | LL | two!("yay", "rust"); | ^^^^^^^^^^^^^^^^^^^^ error: first source: "yay" - --> $DIR/parent-source-spans.rs:43:5 + --> $DIR/parent-source-spans.rs:41:5 | LL | two!("yay", "rust"); | ^^^^^^^^^^^^^^^^^^^^ error: second source: "rust" - --> $DIR/parent-source-spans.rs:43:5 + --> $DIR/parent-source-spans.rs:41:5 | LL | two!("yay", "rust"); | ^^^^^^^^^^^^^^^^^^^^ error: first final: "hip" - --> $DIR/parent-source-spans.rs:49:12 + --> $DIR/parent-source-spans.rs:47:12 | LL | three!("hip", "hop"); | ^^^^^ error: second final: "hop" - --> $DIR/parent-source-spans.rs:49:19 + --> $DIR/parent-source-spans.rs:47:19 | LL | three!("hip", "hop"); | ^^^^^ error: first source: "hip" - --> $DIR/parent-source-spans.rs:49:12 + --> $DIR/parent-source-spans.rs:47:12 | LL | three!("hip", "hop"); | ^^^^^ error: second source: "hop" - --> $DIR/parent-source-spans.rs:49:19 + --> $DIR/parent-source-spans.rs:47:19 | LL | three!("hip", "hop"); | ^^^^^ error[E0425]: cannot find value `ok` in this scope - --> $DIR/parent-source-spans.rs:30:5 + --> $DIR/parent-source-spans.rs:28:5 | LL | parent_source_spans!($($tokens)*); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple variant with a similar name exists: `Ok` @@ -134,7 +134,7 @@ LL | one!("hello", "world"); | ----------------------- in this macro invocation error[E0425]: cannot find value `ok` in this scope - --> $DIR/parent-source-spans.rs:30:5 + --> $DIR/parent-source-spans.rs:28:5 | LL | parent_source_spans!($($tokens)*); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple variant with a similar name exists: `Ok` @@ -143,7 +143,7 @@ LL | two!("yay", "rust"); | -------------------- in this macro invocation error[E0425]: cannot find value `ok` in this scope - --> $DIR/parent-source-spans.rs:30:5 + --> $DIR/parent-source-spans.rs:28:5 | LL | parent_source_spans!($($tokens)*); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple variant with a similar name exists: `Ok` diff --git a/src/test/ui/proc-macro/resolve-error.stderr b/src/test/ui/proc-macro/resolve-error.stderr index 3dca5cee63caa..02c82c01ed3e0 100644 --- a/src/test/ui/proc-macro/resolve-error.stderr +++ b/src/test/ui/proc-macro/resolve-error.stderr @@ -13,14 +13,24 @@ LL | Dlona!(); error: cannot find macro `attr_proc_macra` in this scope --> $DIR/resolve-error.rs:50:5 | -LL | attr_proc_macra!(); - | ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `attr_proc_mac` +LL | / macro_rules! attr_proc_mac { +LL | | () => {} +LL | | } + | |_- similarly named macro `attr_proc_mac` defined here +... +LL | attr_proc_macra!(); + | ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `attr_proc_mac` error: cannot find macro `FooWithLongNama` in this scope --> $DIR/resolve-error.rs:47:5 | -LL | FooWithLongNama!(); - | ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `FooWithLongNam` +LL | / macro_rules! FooWithLongNam { +LL | | () => {} +LL | | } + | |_- similarly named macro `FooWithLongNam` defined here +... +LL | FooWithLongNama!(); + | ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `FooWithLongNam` error: cannot find derive macro `attr_proc_macra` in this scope --> $DIR/resolve-error.rs:42:10 diff --git a/src/test/ui/qualified/qualified-path-params.rs b/src/test/ui/qualified/qualified-path-params.rs index ea2ae0e86bf64..b1b60b4b73fb9 100644 --- a/src/test/ui/qualified/qualified-path-params.rs +++ b/src/test/ui/qualified/qualified-path-params.rs @@ -18,7 +18,7 @@ impl S { fn main() { match 10 { ::A::f:: => {} - //~^ ERROR expected unit struct/variant or constant, found method `<::A>::f` + //~^ ERROR expected unit struct, unit variant or constant, found method `<::A>::f` 0 ..= ::A::f:: => {} //~ ERROR only char and numeric types are allowed in range } } diff --git a/src/test/ui/qualified/qualified-path-params.stderr b/src/test/ui/qualified/qualified-path-params.stderr index 3e8fcdc7ca3e2..92792f2e86a83 100644 --- a/src/test/ui/qualified/qualified-path-params.stderr +++ b/src/test/ui/qualified/qualified-path-params.stderr @@ -1,4 +1,4 @@ -error[E0533]: expected unit struct/variant or constant, found method `<::A>::f` +error[E0533]: expected unit struct, unit variant or constant, found method `<::A>::f` --> $DIR/qualified-path-params.rs:20:9 | LL | ::A::f:: => {} diff --git a/src/test/ui/resolve/enums-are-namespaced-xc.rs b/src/test/ui/resolve/enums-are-namespaced-xc.rs index 4c660c27e3b1a..dfc16d6ce443c 100644 --- a/src/test/ui/resolve/enums-are-namespaced-xc.rs +++ b/src/test/ui/resolve/enums-are-namespaced-xc.rs @@ -5,7 +5,7 @@ fn main() { let _ = namespaced_enums::A; //~^ ERROR cannot find value `A` let _ = namespaced_enums::B(10); - //~^ ERROR cannot find function `B` + //~^ ERROR cannot find function, tuple struct or tuple variant `B` let _ = namespaced_enums::C { a: 10 }; //~^ ERROR cannot find struct, variant or union type `C` } diff --git a/src/test/ui/resolve/enums-are-namespaced-xc.stderr b/src/test/ui/resolve/enums-are-namespaced-xc.stderr index 092051ed874ed..61816709ecc5d 100644 --- a/src/test/ui/resolve/enums-are-namespaced-xc.stderr +++ b/src/test/ui/resolve/enums-are-namespaced-xc.stderr @@ -9,7 +9,7 @@ help: possible candidate is found in another module, you can import it into scop LL | use namespaced_enums::Foo::A; | -error[E0425]: cannot find function `B` in crate `namespaced_enums` +error[E0425]: cannot find function, tuple struct or tuple variant `B` in crate `namespaced_enums` --> $DIR/enums-are-namespaced-xc.rs:7:31 | LL | let _ = namespaced_enums::B(10); diff --git a/src/test/ui/resolve/issue-18252.rs b/src/test/ui/resolve/issue-18252.rs index 894762115ab10..af0a3cbcb2d81 100644 --- a/src/test/ui/resolve/issue-18252.rs +++ b/src/test/ui/resolve/issue-18252.rs @@ -4,5 +4,5 @@ enum Foo { fn main() { let f = Foo::Variant(42); - //~^ ERROR expected function, found struct variant `Foo::Variant` + //~^ ERROR expected function, tuple struct or tuple variant, found struct variant `Foo::Variant` } diff --git a/src/test/ui/resolve/issue-18252.stderr b/src/test/ui/resolve/issue-18252.stderr index c76e5ef8b3617..39b444498102c 100644 --- a/src/test/ui/resolve/issue-18252.stderr +++ b/src/test/ui/resolve/issue-18252.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, found struct variant `Foo::Variant` +error[E0423]: expected function, tuple struct or tuple variant, found struct variant `Foo::Variant` --> $DIR/issue-18252.rs:6:13 | LL | Variant { x: usize } diff --git a/src/test/ui/resolve/issue-5035.stderr b/src/test/ui/resolve/issue-5035.stderr index 96befdbe07339..1674c166ddacb 100644 --- a/src/test/ui/resolve/issue-5035.stderr +++ b/src/test/ui/resolve/issue-5035.stderr @@ -7,6 +7,9 @@ LL | use ImportError; error[E0404]: expected trait, found type alias `K` --> $DIR/issue-5035.rs:3:6 | +LL | trait I {} + | ---------- similarly named trait `I` defined here +LL | type K = dyn I; LL | impl K for isize {} | ^ | | diff --git a/src/test/ui/resolve/issue-6702.rs b/src/test/ui/resolve/issue-6702.rs index 6469c7ec29fa1..954dc36f38e30 100644 --- a/src/test/ui/resolve/issue-6702.rs +++ b/src/test/ui/resolve/issue-6702.rs @@ -4,5 +4,6 @@ struct Monster { fn main() { - let _m = Monster(); //~ ERROR expected function, found struct `Monster` + let _m = Monster(); + //~^ ERROR expected function, tuple struct or tuple variant, found struct `Monster` } diff --git a/src/test/ui/resolve/issue-6702.stderr b/src/test/ui/resolve/issue-6702.stderr index 3fdc7acb274e5..252d50c70f8c4 100644 --- a/src/test/ui/resolve/issue-6702.stderr +++ b/src/test/ui/resolve/issue-6702.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, found struct `Monster` +error[E0423]: expected function, tuple struct or tuple variant, found struct `Monster` --> $DIR/issue-6702.rs:7:14 | LL | / struct Monster { diff --git a/src/test/ui/resolve/levenshtein.stderr b/src/test/ui/resolve/levenshtein.stderr index e693a0ef91fc2..8d8f3f35211e2 100644 --- a/src/test/ui/resolve/levenshtein.stderr +++ b/src/test/ui/resolve/levenshtein.stderr @@ -7,6 +7,9 @@ LL | fn foo(c: esize) {} // Misspelled primitive type name. error[E0412]: cannot find type `Baz` in this scope --> $DIR/levenshtein.rs:10:10 | +LL | enum Bar { } + | ------------ similarly named enum `Bar` defined here +LL | LL | type A = Baz; // Misspelled type name. | ^^^ help: an enum with a similar name exists: `Bar` @@ -25,24 +28,36 @@ LL | type A = Baz; // No suggestion here, Bar is not visible error[E0425]: cannot find value `MAXITEM` in this scope --> $DIR/levenshtein.rs:24:20 | +LL | const MAX_ITEM: usize = 10; + | --------------------------- similarly named constant `MAX_ITEM` defined here +... LL | let v = [0u32; MAXITEM]; // Misspelled constant name. | ^^^^^^^ help: a constant with a similar name exists: `MAX_ITEM` error[E0425]: cannot find function `foobar` in this scope --> $DIR/levenshtein.rs:26:5 | +LL | fn foo_bar() {} + | --------------- similarly named function `foo_bar` defined here +... LL | foobar(); // Misspelled function name. | ^^^^^^ help: a function with a similar name exists: `foo_bar` error[E0412]: cannot find type `first` in module `m` --> $DIR/levenshtein.rs:28:15 | +LL | pub struct First; + | ----------------- similarly named struct `First` defined here +... LL | let b: m::first = m::second; // Misspelled item in module. | ^^^^^ help: a struct with a similar name exists (notice the capitalization): `First` error[E0425]: cannot find value `second` in module `m` --> $DIR/levenshtein.rs:28:26 | +LL | pub struct Second; + | ------------------ similarly named unit struct `Second` defined here +... LL | let b: m::first = m::second; // Misspelled item in module. | ^^^^^^ help: a unit struct with a similar name exists (notice the capitalization): `Second` diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr index b7cc79cfed9e6..8a450ab85e926 100644 --- a/src/test/ui/resolve/privacy-enum-ctor.stderr +++ b/src/test/ui/resolve/privacy-enum-ctor.stderr @@ -16,8 +16,15 @@ LL | m::Z::Unit; error[E0423]: expected value, found enum `Z` --> $DIR/privacy-enum-ctor.rs:25:9 | -LL | Z; - | ^ +LL | / fn f() { +LL | | n::Z; +LL | | +LL | | Z; + | | ^ +... | +LL | | // This is ok, it is equivalent to not having braces +LL | | } + | |_____- similarly named function `f` defined here | help: a function with a similar name exists | @@ -46,8 +53,17 @@ LL | let _: Z = Z::Struct; error[E0423]: expected value, found enum `m::E` --> $DIR/privacy-enum-ctor.rs:41:16 | -LL | let _: E = m::E; - | ^^^^ +LL | / fn f() { +LL | | n::Z; +LL | | +LL | | Z; +... | +LL | | // This is ok, it is equivalent to not having braces +LL | | } + | |_____- similarly named function `f` defined here +... +LL | let _: E = m::E; + | ^^^^ | help: a function with a similar name exists | @@ -114,8 +130,17 @@ LL | let _: E = E::Struct; error[E0412]: cannot find type `Z` in this scope --> $DIR/privacy-enum-ctor.rs:57:12 | -LL | let _: Z = m::n::Z; - | ^ +LL | / pub enum E { +LL | | Fn(u8), +LL | | Struct { +LL | | s: u8, +LL | | }, +LL | | Unit, +LL | | } + | |_____- similarly named enum `E` defined here +... +LL | let _: Z = m::n::Z; + | ^ | help: an enum with a similar name exists | @@ -144,8 +169,17 @@ LL | let _: Z = m::Z::Unit; error[E0412]: cannot find type `Z` in this scope --> $DIR/privacy-enum-ctor.rs:61:12 | -LL | let _: Z = m::n::Z::Fn; - | ^ +LL | / pub enum E { +LL | | Fn(u8), +LL | | Struct { +LL | | s: u8, +LL | | }, +LL | | Unit, +LL | | } + | |_____- similarly named enum `E` defined here +... +LL | let _: Z = m::n::Z::Fn; + | ^ | help: an enum with a similar name exists | @@ -159,8 +193,17 @@ LL | use m::n::Z; error[E0412]: cannot find type `Z` in this scope --> $DIR/privacy-enum-ctor.rs:64:12 | -LL | let _: Z = m::n::Z::Struct; - | ^ +LL | / pub enum E { +LL | | Fn(u8), +LL | | Struct { +LL | | s: u8, +LL | | }, +LL | | Unit, +LL | | } + | |_____- similarly named enum `E` defined here +... +LL | let _: Z = m::n::Z::Struct; + | ^ | help: an enum with a similar name exists | @@ -185,8 +228,17 @@ LL | let _: Z = m::n::Z::Struct; error[E0412]: cannot find type `Z` in this scope --> $DIR/privacy-enum-ctor.rs:68:12 | -LL | let _: Z = m::n::Z::Unit {}; - | ^ +LL | / pub enum E { +LL | | Fn(u8), +LL | | Struct { +LL | | s: u8, +LL | | }, +LL | | Unit, +LL | | } + | |_____- similarly named enum `E` defined here +... +LL | let _: Z = m::n::Z::Unit {}; + | ^ | help: an enum with a similar name exists | diff --git a/src/test/ui/resolve/privacy-struct-ctor.stderr b/src/test/ui/resolve/privacy-struct-ctor.stderr index 51928c32e31f7..f1a1de4d9c0fd 100644 --- a/src/test/ui/resolve/privacy-struct-ctor.stderr +++ b/src/test/ui/resolve/privacy-struct-ctor.stderr @@ -1,6 +1,9 @@ error[E0423]: expected value, found struct `Z` --> $DIR/privacy-struct-ctor.rs:20:9 | +LL | pub struct S(u8); + | ----------------- similarly named tuple struct `S` defined here +... LL | Z; | ^ | | diff --git a/src/test/ui/resolve/resolve-assoc-suggestions.rs b/src/test/ui/resolve/resolve-assoc-suggestions.rs index 8cdbe64af0d83..ee9bce60ce631 100644 --- a/src/test/ui/resolve/resolve-assoc-suggestions.rs +++ b/src/test/ui/resolve/resolve-assoc-suggestions.rs @@ -16,21 +16,21 @@ impl Tr for S { let _: field; //~^ ERROR cannot find type `field` let field(..); - //~^ ERROR cannot find tuple struct/variant `field` + //~^ ERROR cannot find tuple struct or tuple variant `field` field; //~^ ERROR cannot find value `field` let _: Type; //~^ ERROR cannot find type `Type` let Type(..); - //~^ ERROR cannot find tuple struct/variant `Type` + //~^ ERROR cannot find tuple struct or tuple variant `Type` Type; //~^ ERROR cannot find value `Type` let _: method; //~^ ERROR cannot find type `method` let method(..); - //~^ ERROR cannot find tuple struct/variant `method` + //~^ ERROR cannot find tuple struct or tuple variant `method` method; //~^ ERROR cannot find value `method` } diff --git a/src/test/ui/resolve/resolve-assoc-suggestions.stderr b/src/test/ui/resolve/resolve-assoc-suggestions.stderr index f3b8909ab2236..a05ac0f854395 100644 --- a/src/test/ui/resolve/resolve-assoc-suggestions.stderr +++ b/src/test/ui/resolve/resolve-assoc-suggestions.stderr @@ -4,7 +4,7 @@ error[E0412]: cannot find type `field` in this scope LL | let _: field; | ^^^^^ not found in this scope -error[E0531]: cannot find tuple struct/variant `field` in this scope +error[E0531]: cannot find tuple struct or tuple variant `field` in this scope --> $DIR/resolve-assoc-suggestions.rs:18:13 | LL | let field(..); @@ -22,7 +22,7 @@ error[E0412]: cannot find type `Type` in this scope LL | let _: Type; | ^^^^ help: try: `Self::Type` -error[E0531]: cannot find tuple struct/variant `Type` in this scope +error[E0531]: cannot find tuple struct or tuple variant `Type` in this scope --> $DIR/resolve-assoc-suggestions.rs:25:13 | LL | let Type(..); @@ -40,7 +40,7 @@ error[E0412]: cannot find type `method` in this scope LL | let _: method; | ^^^^^^ not found in this scope -error[E0531]: cannot find tuple struct/variant `method` in this scope +error[E0531]: cannot find tuple struct or tuple variant `method` in this scope --> $DIR/resolve-assoc-suggestions.rs:32:13 | LL | let method(..); diff --git a/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr index 9a3d5feee0426..33080340cb67a 100644 --- a/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr +++ b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr @@ -25,6 +25,9 @@ LL | a.b.J error[E0423]: expected value, found module `a::b` --> $DIR/suggest-path-instead-of-mod-dot-item.rs:32:5 | +LL | pub const I: i32 = 1; + | --------------------- similarly named constant `I` defined here +... LL | a::b.J | ^^^^ | @@ -48,6 +51,9 @@ LL | a.b.f(); error[E0423]: expected value, found module `a::b` --> $DIR/suggest-path-instead-of-mod-dot-item.rs:40:12 | +LL | pub const I: i32 = 1; + | --------------------- similarly named constant `I` defined here +... LL | v.push(a::b); | ^^^- | | @@ -56,6 +62,9 @@ LL | v.push(a::b); error[E0423]: expected value, found module `a::b` --> $DIR/suggest-path-instead-of-mod-dot-item.rs:45:5 | +LL | pub const I: i32 = 1; + | --------------------- similarly named constant `I` defined here +... LL | a::b.f() | ^^^^ | @@ -71,6 +80,9 @@ LL | a::b::f() error[E0423]: expected value, found module `a::b` --> $DIR/suggest-path-instead-of-mod-dot-item.rs:50:5 | +LL | pub const I: i32 = 1; + | --------------------- similarly named constant `I` defined here +... LL | a::b | ^^^- | | @@ -79,6 +91,9 @@ LL | a::b error[E0423]: expected function, found module `a::b` --> $DIR/suggest-path-instead-of-mod-dot-item.rs:55:5 | +LL | pub const I: i32 = 1; + | --------------------- similarly named constant `I` defined here +... LL | a::b() | ^^^- | | diff --git a/src/test/ui/resolve/tuple-struct-alias.rs b/src/test/ui/resolve/tuple-struct-alias.rs index 65977e1110c5c..298e7e479983d 100644 --- a/src/test/ui/resolve/tuple-struct-alias.rs +++ b/src/test/ui/resolve/tuple-struct-alias.rs @@ -4,6 +4,6 @@ type A = S; fn main() { let s = A(0, 1); //~ ERROR expected function match s { - A(..) => {} //~ ERROR expected tuple struct/variant + A(..) => {} //~ ERROR expected tuple struct or tuple variant } } diff --git a/src/test/ui/resolve/tuple-struct-alias.stderr b/src/test/ui/resolve/tuple-struct-alias.stderr index 02af357a2c32c..5a7873301c8c7 100644 --- a/src/test/ui/resolve/tuple-struct-alias.stderr +++ b/src/test/ui/resolve/tuple-struct-alias.stderr @@ -1,14 +1,20 @@ -error[E0423]: expected function, found type alias `A` +error[E0423]: expected function, tuple struct or tuple variant, found type alias `A` --> $DIR/tuple-struct-alias.rs:5:13 | +LL | struct S(u8, u16); + | ------------------ similarly named tuple struct `S` defined here +... LL | let s = A(0, 1); | ^ help: a tuple struct with a similar name exists: `S` | = note: can't use a type alias as a constructor -error[E0532]: expected tuple struct/variant, found type alias `A` +error[E0532]: expected tuple struct or tuple variant, found type alias `A` --> $DIR/tuple-struct-alias.rs:7:9 | +LL | struct S(u8, u16); + | ------------------ similarly named tuple struct `S` defined here +... LL | A(..) => {} | ^ help: a tuple struct with a similar name exists: `S` | diff --git a/src/test/ui/rfc-2008-non-exhaustive/struct.rs b/src/test/ui/rfc-2008-non-exhaustive/struct.rs index cf383a260e044..8cff35c4bc5ec 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/struct.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/struct.rs @@ -18,7 +18,7 @@ fn main() { //~^ ERROR `..` required with struct marked as non-exhaustive let ts = TupleStruct(640, 480); - //~^ ERROR expected function, found struct `TupleStruct` [E0423] + //~^ ERROR expected function, tuple struct or tuple variant, found struct `TupleStruct` [E0423] let ts_explicit = structs::TupleStruct(640, 480); //~^ ERROR tuple struct constructor `TupleStruct` is private [E0603] diff --git a/src/test/ui/rfc-2008-non-exhaustive/struct.stderr b/src/test/ui/rfc-2008-non-exhaustive/struct.stderr index 04cfe51cab025..944965a15e3d0 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/struct.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/struct.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, found struct `TupleStruct` +error[E0423]: expected function, tuple struct or tuple variant, found struct `TupleStruct` --> $DIR/struct.rs:20:14 | LL | let ts = TupleStruct(640, 480); diff --git a/src/test/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.rs b/src/test/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.rs index ab87ecbde30e9..d52ac7ec3c39d 100644 --- a/src/test/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.rs +++ b/src/test/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.rs @@ -2,5 +2,5 @@ fn main() { let crate = 0; - //~^ ERROR expected unit struct/variant or constant, found module `crate` + //~^ ERROR expected unit struct, unit variant or constant, found module `crate` } diff --git a/src/test/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr b/src/test/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr index e07b5d80fb806..acbb4cf1a6942 100644 --- a/src/test/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr +++ b/src/test/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr @@ -1,8 +1,8 @@ -error[E0532]: expected unit struct/variant or constant, found module `crate` +error[E0532]: expected unit struct, unit variant or constant, found module `crate` --> $DIR/keyword-crate-as-identifier.rs:4:9 | LL | let crate = 0; - | ^^^^^ not a unit struct/variant or constant + | ^^^^^ not a unit struct, unit variant or constant error: aborting due to previous error diff --git a/src/test/ui/self/self_type_keyword-2.rs b/src/test/ui/self/self_type_keyword-2.rs index dde5762fd7804..cfb87f5186d32 100644 --- a/src/test/ui/self/self_type_keyword-2.rs +++ b/src/test/ui/self/self_type_keyword-2.rs @@ -2,12 +2,12 @@ use self::Self as Foo; //~ ERROR unresolved import `self::Self` pub fn main() { let Self = 5; - //~^ ERROR cannot find unit struct/variant or constant `Self` in this scope + //~^ ERROR cannot find unit struct, unit variant or constant `Self` in this scope match 15 { Self => (), - //~^ ERROR cannot find unit struct/variant or constant `Self` in this scope + //~^ ERROR cannot find unit struct, unit variant or constant `Self` in this scope Foo { x: Self } => (), - //~^ ERROR cannot find unit struct/variant or constant `Self` in this scope + //~^ ERROR cannot find unit struct, unit variant or constant `Self` in this scope } } diff --git a/src/test/ui/self/self_type_keyword-2.stderr b/src/test/ui/self/self_type_keyword-2.stderr index 560c6d2199ca0..4e931f91f70c4 100644 --- a/src/test/ui/self/self_type_keyword-2.stderr +++ b/src/test/ui/self/self_type_keyword-2.stderr @@ -4,19 +4,19 @@ error[E0432]: unresolved import `self::Self` LL | use self::Self as Foo; | ^^^^^^^^^^^^^^^^^ no `Self` in the root -error[E0531]: cannot find unit struct/variant or constant `Self` in this scope +error[E0531]: cannot find unit struct, unit variant or constant `Self` in this scope --> $DIR/self_type_keyword-2.rs:4:9 | LL | let Self = 5; | ^^^^ not found in this scope -error[E0531]: cannot find unit struct/variant or constant `Self` in this scope +error[E0531]: cannot find unit struct, unit variant or constant `Self` in this scope --> $DIR/self_type_keyword-2.rs:8:9 | LL | Self => (), | ^^^^ not found in this scope -error[E0531]: cannot find unit struct/variant or constant `Self` in this scope +error[E0531]: cannot find unit struct, unit variant or constant `Self` in this scope --> $DIR/self_type_keyword-2.rs:10:18 | LL | Foo { x: Self } => (), diff --git a/src/test/ui/self/self_type_keyword.rs b/src/test/ui/self/self_type_keyword.rs index dfb7d6583d9dd..b42bf8eea1a16 100644 --- a/src/test/ui/self/self_type_keyword.rs +++ b/src/test/ui/self/self_type_keyword.rs @@ -15,7 +15,7 @@ pub fn main() { //~^ ERROR expected identifier, found keyword `Self` mut Self => (), //~^ ERROR `mut` must be followed by a named binding - //~| ERROR cannot find unit struct/variant or constant `Self` + //~| ERROR cannot find unit struct, unit variant or constant `Self` ref mut Self => (), //~^ ERROR expected identifier, found keyword `Self` Self!() => (), diff --git a/src/test/ui/self/self_type_keyword.stderr b/src/test/ui/self/self_type_keyword.stderr index e3b871bd86764..fa603276c8eb5 100644 --- a/src/test/ui/self/self_type_keyword.stderr +++ b/src/test/ui/self/self_type_keyword.stderr @@ -60,7 +60,7 @@ error: cannot find macro `Self` in this scope LL | Self!() => (), | ^^^^ -error[E0531]: cannot find unit struct/variant or constant `Self` in this scope +error[E0531]: cannot find unit struct, unit variant or constant `Self` in this scope --> $DIR/self_type_keyword.rs:16:13 | LL | mut Self => (), diff --git a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr index 1af0f7a191e80..56810a4915869 100644 --- a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr +++ b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr @@ -1,6 +1,8 @@ error[E0423]: expected value, found struct variant `E::B` --> $DIR/fn-or-tuple-struct-without-args.rs:36:16 | +LL | A(usize), + | -------- similarly named tuple variant `A` defined here LL | B { a: usize }, | -------------- `E::B` defined here ... diff --git a/src/test/ui/traits/trait-impl-for-module.stderr b/src/test/ui/traits/trait-impl-for-module.stderr index c62bcfca94de9..4b3c930dccd45 100644 --- a/src/test/ui/traits/trait-impl-for-module.stderr +++ b/src/test/ui/traits/trait-impl-for-module.stderr @@ -1,8 +1,12 @@ error[E0573]: expected type, found module `a` --> $DIR/trait-impl-for-module.rs:7:12 | -LL | impl A for a { - | ^ help: a trait with a similar name exists: `A` +LL | / trait A { +LL | | } + | |_- similarly named trait `A` defined here +LL | +LL | impl A for a { + | ^ help: a trait with a similar name exists: `A` error: aborting due to previous error diff --git a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.rs b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.rs index c1e56fc4caa9f..ab40bf580ea8f 100644 --- a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.rs +++ b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.rs @@ -6,7 +6,7 @@ impl Enum { fn foo(&self) -> () { match self { Self::A => (), - //~^ ERROR expected unit struct/variant or constant, found tuple variant + //~^ ERROR expected unit struct, unit variant or constant, found tuple variant } } } diff --git a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.stderr b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.stderr index 357b33de51b84..cfe273b9dd255 100644 --- a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.stderr +++ b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.stderr @@ -1,4 +1,4 @@ -error[E0533]: expected unit struct/variant or constant, found tuple variant `::A` +error[E0533]: expected unit struct, unit variant or constant, found tuple variant `::A` --> $DIR/incorrect-variant-form-through-Self-issue-58006.rs:8:13 | LL | Self::A => (), diff --git a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs index ce45d59198af8..efdbebf266219 100644 --- a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs +++ b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs @@ -8,14 +8,14 @@ type Alias = Enum; fn main() { Alias::Braced; - //~^ ERROR expected unit struct/variant or constant, found struct variant `::Braced` [E0533] + //~^ ERROR expected unit struct, unit variant or constant, found struct variant `::Braced` [E0533] let Alias::Braced = panic!(); - //~^ ERROR expected unit struct/variant or constant, found struct variant `::Braced` [E0533] + //~^ ERROR expected unit struct, unit variant or constant, found struct variant `::Braced` [E0533] let Alias::Braced(..) = panic!(); - //~^ ERROR expected tuple struct/variant, found struct variant `::Braced` [E0164] + //~^ ERROR expected tuple struct or tuple variant, found struct variant `::Braced` [E0164] Alias::Unit(); //~^ ERROR expected function, found enum variant `::Unit` let Alias::Unit() = panic!(); - //~^ ERROR expected tuple struct/variant, found unit variant `::Unit` [E0164] + //~^ ERROR expected tuple struct or tuple variant, found unit variant `::Unit` [E0164] } diff --git a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr index 801ca5f013b3e..17efc08c6327f 100644 --- a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr +++ b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr @@ -1,16 +1,16 @@ -error[E0533]: expected unit struct/variant or constant, found struct variant `::Braced` +error[E0533]: expected unit struct, unit variant or constant, found struct variant `::Braced` --> $DIR/incorrect-variant-form-through-alias-caught.rs:10:5 | LL | Alias::Braced; | ^^^^^^^^^^^^^ -error[E0533]: expected unit struct/variant or constant, found struct variant `::Braced` +error[E0533]: expected unit struct, unit variant or constant, found struct variant `::Braced` --> $DIR/incorrect-variant-form-through-alias-caught.rs:12:9 | LL | let Alias::Braced = panic!(); | ^^^^^^^^^^^^^ -error[E0164]: expected tuple struct/variant, found struct variant `::Braced` +error[E0164]: expected tuple struct or tuple variant, found struct variant `::Braced` --> $DIR/incorrect-variant-form-through-alias-caught.rs:14:9 | LL | let Alias::Braced(..) = panic!(); @@ -32,7 +32,7 @@ help: `::Unit` is a unit variant, you need to write it without the parent LL | ::Unit; | ^^^^^^^^^^^^^ -error[E0164]: expected tuple struct/variant, found unit variant `::Unit` +error[E0164]: expected tuple struct or tuple variant, found unit variant `::Unit` --> $DIR/incorrect-variant-form-through-alias-caught.rs:19:9 | LL | let Alias::Unit() = panic!(); diff --git a/src/test/ui/ufcs/ufcs-partially-resolved.stderr b/src/test/ui/ufcs/ufcs-partially-resolved.stderr index dee990ec3d1cb..dbd41da6daf0b 100644 --- a/src/test/ui/ufcs/ufcs-partially-resolved.stderr +++ b/src/test/ui/ufcs/ufcs-partially-resolved.stderr @@ -13,6 +13,9 @@ LL | ::NN; error[E0576]: cannot find associated type `N` in trait `Tr` --> $DIR/ufcs-partially-resolved.rs:19:24 | +LL | type Y = u16; + | ------------- similarly named associated type `Y` defined here +... LL | let _: ::N; | ^ help: an associated type with a similar name exists: `Y` @@ -31,6 +34,9 @@ LL | let _: ::N; error[E0576]: cannot find method or associated constant `N` in trait `Tr` --> $DIR/ufcs-partially-resolved.rs:22:17 | +LL | fn Y() {} + | --------- similarly named method `Y` defined here +... LL | ::N; | ^ help: a method with a similar name exists: `Y` @@ -61,6 +67,9 @@ LL | ::Y; error[E0576]: cannot find associated type `N` in trait `Tr` --> $DIR/ufcs-partially-resolved.rs:30:24 | +LL | type Y = u16; + | ------------- similarly named associated type `Y` defined here +... LL | let _: ::N::NN; | ^ help: an associated type with a similar name exists: `Y` @@ -79,6 +88,9 @@ LL | let _: ::N::NN; error[E0576]: cannot find associated type `N` in trait `Tr` --> $DIR/ufcs-partially-resolved.rs:33:17 | +LL | type Y = u16; + | ------------- similarly named associated type `Y` defined here +... LL | ::N::NN; | ^ help: an associated type with a similar name exists: `Y` @@ -157,6 +169,9 @@ LL | ::NN; error[E0575]: expected associated type, found method `Dr::Z` --> $DIR/ufcs-partially-resolved.rs:52:12 | +LL | type X = u16; + | ------------- similarly named associated type `X` defined here +... LL | let _: ::Z; | ^^^^^^^^^^^^- | | @@ -165,6 +180,9 @@ LL | let _: ::Z; error[E0575]: expected method or associated constant, found associated type `Dr::X` --> $DIR/ufcs-partially-resolved.rs:53:5 | +LL | fn Z() {} + | --------- similarly named method `Z` defined here +... LL | ::X; | ^^^^^^^^^^^^- | | @@ -175,6 +193,9 @@ LL | ::X; error[E0575]: expected associated type, found method `Dr::Z` --> $DIR/ufcs-partially-resolved.rs:54:12 | +LL | type X = u16; + | ------------- similarly named associated type `X` defined here +... LL | let _: ::Z::N; | ^^^^^^^^^^^^-^^^ | | diff --git a/src/test/ui/ui-testing-optout.stderr b/src/test/ui/ui-testing-optout.stderr index 313e198e39e36..ff5bf6238e20b 100644 --- a/src/test/ui/ui-testing-optout.stderr +++ b/src/test/ui/ui-testing-optout.stderr @@ -2,17 +2,26 @@ error[E0412]: cannot find type `B` in this scope --> $DIR/ui-testing-optout.rs:4:10 | 4 | type A = B; - | ^ help: a type alias with a similar name exists: `A` + | ---------^- + | | | + | | help: a type alias with a similar name exists: `A` + | similarly named type alias `A` defined here error[E0412]: cannot find type `D` in this scope --> $DIR/ui-testing-optout.rs:10:10 | +4 | type A = B; + | ----------- similarly named type alias `A` defined here +... 10 | type C = D; | ^ help: a type alias with a similar name exists: `A` error[E0412]: cannot find type `F` in this scope --> $DIR/ui-testing-optout.rs:95:10 | +4 | type A = B; + | ----------- similarly named type alias `A` defined here +... 95 | type E = F; | ^ help: a type alias with a similar name exists: `A` From b62644891905e3a2cdf512ceb2e818f5a910323b Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 27 Oct 2019 19:22:06 +0000 Subject: [PATCH 12/12] doc: introduce `once` in `iter::chain` document --- src/libcore/iter/traits/iterator.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs index a272035150a15..028cef9f4d804 100644 --- a/src/libcore/iter/traits/iterator.rs +++ b/src/libcore/iter/traits/iterator.rs @@ -384,6 +384,9 @@ pub trait Iterator { /// /// In other words, it links two iterators together, in a chain. 🔗 /// + /// [`once`] is commonly used to adapt a single value into a chain of + /// other kinds of iteration. + /// /// # Examples /// /// Basic usage: @@ -408,9 +411,6 @@ pub trait Iterator { /// [`Iterator`] itself. For example, slices (`&[T]`) implement /// [`IntoIterator`], and so can be passed to `chain()` directly: /// - /// [`IntoIterator`]: trait.IntoIterator.html - /// [`Iterator`]: trait.Iterator.html - /// /// ``` /// let s1 = &[1, 2, 3]; /// let s2 = &[4, 5, 6]; @@ -425,6 +425,21 @@ pub trait Iterator { /// assert_eq!(iter.next(), Some(&6)); /// assert_eq!(iter.next(), None); /// ``` + /// + /// If you work with Windows API, you may wish to convert [`OsStr`] to `Vec`: + /// + /// ``` + /// #[cfg(windows)] + /// fn os_str_to_utf16(s: &OsStr) -> Vec { + /// use std::os::windows::ffi::OsStrExt; + /// s.encode_wide().chain(std::iter::once(0)).collect() + /// } + /// ``` + /// + /// [`once`]: fn.once.html + /// [`Iterator`]: trait.Iterator.html + /// [`IntoIterator`]: trait.IntoIterator.html + /// [`OsStr`]: ../../std/ffi/struct.OsStr.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn chain(self, other: U) -> Chain where