diff --git a/library/core/src/ops/range.rs b/library/core/src/ops/range.rs index a0b74ff383ea4..79f3f307a5e1a 100644 --- a/library/core/src/ops/range.rs +++ b/library/core/src/ops/range.rs @@ -79,17 +79,17 @@ impl fmt::Debug for RangeFull { #[derive(Eq, Hash)] #[derive_const(Clone, Default, PartialEq)] // not Copy -- see #27186 #[stable(feature = "rust1", since = "1.0.0")] -pub struct Range { +pub struct Range { /// The lower bound of the range (inclusive). #[stable(feature = "rust1", since = "1.0.0")] - pub start: Idx, + pub start: Start, /// The upper bound of the range (exclusive). #[stable(feature = "rust1", since = "1.0.0")] - pub end: Idx, + pub end: End, } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Debug for Range { +impl fmt::Debug for Range { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { self.start.fmt(fmt)?; write!(fmt, "..")?; @@ -98,7 +98,7 @@ impl fmt::Debug for Range { } } -impl> Range { +impl, End: PartialOrd> Range { /// Returns `true` if `item` is contained in the range. /// /// # Examples @@ -122,10 +122,11 @@ impl> Range { #[rustc_const_unstable(feature = "const_range", issue = "none")] pub const fn contains(&self, item: &U) -> bool where - Idx: [const] PartialOrd, - U: ?Sized + [const] PartialOrd, + Start: [const] PartialOrd, + End: [const] PartialOrd, + U: ?Sized + [const] PartialOrd + [const] PartialOrd, { - >::contains(self, item) + >::contains(self, item) } /// Returns `true` if the range contains no items. @@ -150,7 +151,8 @@ impl> Range { #[rustc_const_unstable(feature = "const_range", issue = "none")] pub const fn is_empty(&self) -> bool where - Idx: [const] PartialOrd, + Start: [const] PartialOrd, + End: [const] PartialOrd, { !(self.start < self.end) } @@ -354,14 +356,14 @@ impl> RangeTo { #[derive(Clone, Hash)] #[derive_const(Eq, PartialEq)] // not Copy -- see #27186 #[stable(feature = "inclusive_range", since = "1.26.0")] -pub struct RangeInclusive { +pub struct RangeInclusive { // Note that the fields here are not public to allow changing the // representation in the future; in particular, while we could plausibly // expose start/end, modifying them without changing (future/current) // private fields may lead to incorrect behavior, so we don't want to // support that mode. - pub(crate) start: Idx, - pub(crate) end: Idx, + pub(crate) start: Start, + pub(crate) end: End, // This field is: // - `false` upon construction @@ -372,7 +374,7 @@ pub struct RangeInclusive { pub(crate) exhausted: bool, } -impl RangeInclusive { +impl RangeInclusive { /// Creates a new inclusive range. Equivalent to writing `start..=end`. /// /// # Examples @@ -387,7 +389,7 @@ impl RangeInclusive { #[inline] #[rustc_promotable] #[rustc_const_stable(feature = "const_range_new", since = "1.32.0")] - pub const fn new(start: Idx, end: Idx) -> Self { + pub const fn new(start: Start, end: End) -> Self { Self { start, end, exhausted: false } } @@ -412,7 +414,7 @@ impl RangeInclusive { #[stable(feature = "inclusive_range_methods", since = "1.27.0")] #[rustc_const_stable(feature = "const_inclusive_range_methods", since = "1.32.0")] #[inline] - pub const fn start(&self) -> &Idx { + pub const fn start(&self) -> &Start { &self.start } @@ -437,7 +439,7 @@ impl RangeInclusive { #[stable(feature = "inclusive_range_methods", since = "1.27.0")] #[rustc_const_stable(feature = "const_inclusive_range_methods", since = "1.32.0")] #[inline] - pub const fn end(&self) -> &Idx { + pub const fn end(&self) -> &End { &self.end } @@ -454,7 +456,7 @@ impl RangeInclusive { #[stable(feature = "inclusive_range_methods", since = "1.27.0")] #[inline] #[rustc_const_unstable(feature = "const_range_bounds", issue = "108082")] - pub const fn into_inner(self) -> (Idx, Idx) { + pub const fn into_inner(self) -> (Start, End) { (self.start, self.end) } } @@ -474,7 +476,7 @@ impl RangeInclusive { } #[stable(feature = "inclusive_range", since = "1.26.0")] -impl fmt::Debug for RangeInclusive { +impl fmt::Debug for RangeInclusive { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { self.start.fmt(fmt)?; write!(fmt, "..=")?; @@ -486,7 +488,7 @@ impl fmt::Debug for RangeInclusive { } } -impl> RangeInclusive { +impl, End: PartialOrd> RangeInclusive { /// Returns `true` if `item` is contained in the range. /// /// # Examples @@ -521,10 +523,11 @@ impl> RangeInclusive { #[rustc_const_unstable(feature = "const_range", issue = "none")] pub const fn contains(&self, item: &U) -> bool where - Idx: [const] PartialOrd, - U: ?Sized + [const] PartialOrd, + Start: [const] PartialOrd, + End: [const] PartialOrd, + U: ?Sized + [const] PartialOrd + [const] PartialOrd, { - >::contains(self, item) + >::contains(self, item) } /// Returns `true` if the range contains no items. @@ -558,7 +561,8 @@ impl> RangeInclusive { #[rustc_const_unstable(feature = "const_range", issue = "none")] pub const fn is_empty(&self) -> bool where - Idx: [const] PartialOrd, + Start: [const] PartialOrd, + End: [const] PartialOrd, { self.exhausted || !(self.start <= self.end) } @@ -817,7 +821,7 @@ impl Bound<&T> { #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_diagnostic_item = "RangeBounds"] #[rustc_const_unstable(feature = "const_range", issue = "none")] -pub const trait RangeBounds { +pub const trait RangeBounds { /// Start index bound. /// /// Returns the start value as a `Bound`. @@ -832,7 +836,7 @@ pub const trait RangeBounds { /// assert_eq!((3..10).start_bound(), Included(&3)); /// ``` #[stable(feature = "collections_range", since = "1.28.0")] - fn start_bound(&self) -> Bound<&T>; + fn start_bound(&self) -> Bound<&Start>; /// End index bound. /// @@ -848,7 +852,7 @@ pub const trait RangeBounds { /// assert_eq!((3..10).end_bound(), Excluded(&10)); /// ``` #[stable(feature = "collections_range", since = "1.28.0")] - fn end_bound(&self) -> Bound<&T>; + fn end_bound(&self) -> Bound<&End>; /// Returns `true` if `item` is contained in the range. /// @@ -867,8 +871,9 @@ pub const trait RangeBounds { #[stable(feature = "range_contains", since = "1.35.0")] fn contains(&self, item: &U) -> bool where - T: [const] PartialOrd, - U: ?Sized + [const] PartialOrd, + Start: [const] PartialOrd, + End: [const] PartialOrd, + U: ?Sized + [const] PartialOrd + [const] PartialOrd, { (match self.start_bound() { Included(start) => start <= item, @@ -935,7 +940,8 @@ pub const trait RangeBounds { #[unstable(feature = "range_bounds_is_empty", issue = "137300")] fn is_empty(&self) -> bool where - T: [const] PartialOrd, + Start: [const] PartialOrd, + End: [const] PartialOrd, { !match (self.start_bound(), self.end_bound()) { (Unbounded, _) | (_, Unbounded) => true, @@ -1064,11 +1070,11 @@ impl const IntoBounds for RangeFull { #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_const_unstable(feature = "const_range", issue = "none")] -impl const RangeBounds for RangeFrom { - fn start_bound(&self) -> Bound<&T> { +impl const RangeBounds for RangeFrom { + fn start_bound(&self) -> Bound<&Start> { Included(&self.start) } - fn end_bound(&self) -> Bound<&T> { + fn end_bound(&self) -> Bound<&End> { Unbounded } } @@ -1083,11 +1089,11 @@ impl const IntoBounds for RangeFrom { #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_const_unstable(feature = "const_range", issue = "none")] -impl const RangeBounds for RangeTo { - fn start_bound(&self) -> Bound<&T> { +impl const RangeBounds for RangeTo { + fn start_bound(&self) -> Bound<&Start> { Unbounded } - fn end_bound(&self) -> Bound<&T> { + fn end_bound(&self) -> Bound<&End> { Excluded(&self.end) } } @@ -1102,11 +1108,11 @@ impl const IntoBounds for RangeTo { #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_const_unstable(feature = "const_range", issue = "none")] -impl const RangeBounds for Range { - fn start_bound(&self) -> Bound<&T> { +impl const RangeBounds for Range { + fn start_bound(&self) -> Bound<&Start> { Included(&self.start) } - fn end_bound(&self) -> Bound<&T> { + fn end_bound(&self) -> Bound<&End> { Excluded(&self.end) } } @@ -1121,11 +1127,11 @@ impl const IntoBounds for Range { #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_const_unstable(feature = "const_range", issue = "none")] -impl const RangeBounds for RangeInclusive { - fn start_bound(&self) -> Bound<&T> { +impl const RangeBounds for RangeInclusive { + fn start_bound(&self) -> Bound<&Start> { Included(&self.start) } - fn end_bound(&self) -> Bound<&T> { + fn end_bound(&self) -> Bound<&End> { if self.exhausted { // When the iterator is exhausted, we usually have start == end, // but we want the range to appear empty, containing nothing. @@ -1155,11 +1161,11 @@ impl const IntoBounds for RangeInclusive { #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_const_unstable(feature = "const_range", issue = "none")] -impl const RangeBounds for RangeToInclusive { - fn start_bound(&self) -> Bound<&T> { +impl const RangeBounds for RangeToInclusive { + fn start_bound(&self) -> Bound<&End> { Unbounded } - fn end_bound(&self) -> Bound<&T> { + fn end_bound(&self) -> Bound<&End> { Included(&self.end) } } @@ -1174,8 +1180,8 @@ impl const IntoBounds for RangeToInclusive { #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_const_unstable(feature = "const_range", issue = "none")] -impl const RangeBounds for (Bound, Bound) { - fn start_bound(&self) -> Bound<&T> { +impl const RangeBounds for (Bound, Bound) { + fn start_bound(&self) -> Bound<&Start> { match *self { (Included(ref start), _) => Included(start), (Excluded(ref start), _) => Excluded(start), @@ -1183,7 +1189,7 @@ impl const RangeBounds for (Bound, Bound) { } } - fn end_bound(&self) -> Bound<&T> { + fn end_bound(&self) -> Bound<&End> { match *self { (_, Included(ref end)) => Included(end), (_, Excluded(ref end)) => Excluded(end), @@ -1202,12 +1208,14 @@ impl const IntoBounds for (Bound, Bound) { #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_const_unstable(feature = "const_range", issue = "none")] -impl<'a, T: ?Sized + 'a> const RangeBounds for (Bound<&'a T>, Bound<&'a T>) { - fn start_bound(&self) -> Bound<&T> { +impl<'s, 'e, Start: ?Sized + 's, End: ?Sized + 'e> const RangeBounds + for (Bound<&'s Start>, Bound<&'e End>) +{ + fn start_bound(&self) -> Bound<&'s Start> { self.0 } - fn end_bound(&self) -> Bound<&T> { + fn end_bound(&self) -> Bound<&'e End> { self.1 } } @@ -1220,11 +1228,11 @@ impl<'a, T: ?Sized + 'a> const RangeBounds for (Bound<&'a T>, Bound<&'a T>) { /// i.e. replace `start..` with `(Bound::Included(start), Bound::Unbounded)`. #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_const_unstable(feature = "const_range", issue = "none")] -impl const RangeBounds for RangeFrom<&T> { - fn start_bound(&self) -> Bound<&T> { +impl const RangeBounds for RangeFrom<&Start> { + fn start_bound(&self) -> Bound<&Start> { Included(self.start) } - fn end_bound(&self) -> Bound<&T> { + fn end_bound(&self) -> Bound<&End> { Unbounded } } @@ -1237,11 +1245,11 @@ impl const RangeBounds for RangeFrom<&T> { /// i.e. replace `..end` with `(Bound::Unbounded, Bound::Excluded(end))`. #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_const_unstable(feature = "const_range", issue = "none")] -impl const RangeBounds for RangeTo<&T> { - fn start_bound(&self) -> Bound<&T> { +impl const RangeBounds for RangeTo<&End> { + fn start_bound(&self) -> Bound<&Start> { Unbounded } - fn end_bound(&self) -> Bound<&T> { + fn end_bound(&self) -> Bound<&End> { Excluded(self.end) } } @@ -1254,11 +1262,11 @@ impl const RangeBounds for RangeTo<&T> { /// i.e. replace `start..end` with `(Bound::Included(start), Bound::Excluded(end))`. #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_const_unstable(feature = "const_range", issue = "none")] -impl const RangeBounds for Range<&T> { - fn start_bound(&self) -> Bound<&T> { +impl<'s, 'e, Start: 's, End: 'e> const RangeBounds for Range<&'s Start, &'e End> { + fn start_bound(&self) -> Bound<&'s Start> { Included(self.start) } - fn end_bound(&self) -> Bound<&T> { + fn end_bound(&self) -> Bound<&'e End> { Excluded(self.end) } } @@ -1271,11 +1279,13 @@ impl const RangeBounds for Range<&T> { /// i.e. replace `start..=end` with `(Bound::Included(start), Bound::Included(end))`. #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_const_unstable(feature = "const_range", issue = "none")] -impl const RangeBounds for RangeInclusive<&T> { - fn start_bound(&self) -> Bound<&T> { +impl<'s, 'e, Start: 's, End: 'e> const RangeBounds + for RangeInclusive<&'s Start, &'e End> +{ + fn start_bound(&self) -> Bound<&'s Start> { Included(self.start) } - fn end_bound(&self) -> Bound<&T> { + fn end_bound(&self) -> Bound<&'e End> { Included(self.end) } } @@ -1288,11 +1298,11 @@ impl const RangeBounds for RangeInclusive<&T> { /// i.e. replace `..=end` with `(Bound::Unbounded, Bound::Included(end))`. #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_const_unstable(feature = "const_range", issue = "none")] -impl const RangeBounds for RangeToInclusive<&T> { - fn start_bound(&self) -> Bound<&T> { +impl const RangeBounds for RangeToInclusive<&End> { + fn start_bound(&self) -> Bound<&End> { Unbounded } - fn end_bound(&self) -> Bound<&T> { + fn end_bound(&self) -> Bound<&End> { Included(self.end) } } diff --git a/src/tools/clippy/clippy_lints/src/ranges.rs b/src/tools/clippy/clippy_lints/src/ranges.rs index ca0d41fca5248..53e936fe5a9d0 100644 --- a/src/tools/clippy/clippy_lints/src/ranges.rs +++ b/src/tools/clippy/clippy_lints/src/ranges.rs @@ -358,7 +358,8 @@ fn can_switch_ranges<'tcx>( cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, original: RangeLimits, - inner_ty: Ty<'tcx>, + inner_ty_x: Ty<'tcx>, + inner_ty_y: Ty<'tcx>, ) -> bool { let use_ctxt = expr_use_ctxt(cx, expr); let (Node::Expr(parent_expr), false) = (use_ctxt.node, use_ctxt.is_ty_unified) else { @@ -447,7 +448,7 @@ fn can_switch_ranges<'tcx>( && let switched_range_ty = cx .tcx .type_of(switched_range_def_id) - .instantiate(cx.tcx, &[inner_ty.into()]) + .instantiate(cx.tcx, &[inner_ty_x.into(), inner_ty_y.into()]) // Check that the switched range type can be used for indexing the original expression // through the `Index` or `IndexMut` trait. && let ty::Ref(_, outer_ty, mutability) = cx.typeck_results().expr_ty_adjusted(outer_expr).kind() @@ -505,7 +506,7 @@ fn check_range_switch<'tcx>( ) { if let Some(range) = higher::Range::hir(cx, expr) && let higher::Range { - start, + start: Some(start), end: Some(end), limits, span, @@ -513,15 +514,11 @@ fn check_range_switch<'tcx>( && span.can_be_used_for_suggestions() && limits == kind && let Some(y) = predicate(cx, end) - && can_switch_ranges(cx, expr, kind, cx.typeck_results().expr_ty(y)) + && can_switch_ranges(cx, expr, kind, cx.typeck_results().expr_ty(start), cx.typeck_results().expr_ty(y)) { span_lint_and_then(cx, lint, span, msg, |diag| { let mut app = Applicability::MachineApplicable; - let start = start.map_or(String::new(), |x| { - Sugg::hir_with_applicability(cx, x, "", &mut app) - .maybe_paren() - .to_string() - }); + let start = Sugg::hir_with_applicability(cx, start, "", &mut app).maybe_paren(); let end = Sugg::hir_with_applicability(cx, y, "", &mut app).maybe_paren(); match span.with_source_text(cx, |src| src.starts_with('(') && src.ends_with(')')) { Some(true) => { diff --git a/tests/ui/feature-gates/feature-gate-new_range.stderr b/tests/ui/feature-gates/feature-gate-new_range.stderr index b7f70d30bfa0b..38b7d0f9244e5 100644 --- a/tests/ui/feature-gates/feature-gate-new_range.stderr +++ b/tests/ui/feature-gates/feature-gate-new_range.stderr @@ -17,13 +17,13 @@ error[E0308]: mismatched types --> $DIR/feature-gate-new_range.rs:6:37 | LL | let b: core::range::Range = 2..3; - | ---------------------- ^^^^ expected `Range`, found `Range<{integer}>` + | ---------------------- ^^^^ expected `Range`, found `Range<{integer}, {integer}>` | | | expected due to this | = note: expected struct `std::range::Range` - found struct `std::ops::Range<{integer}>` -help: call `Into::into` on this expression to convert `std::ops::Range<{integer}>` into `std::range::Range` + found struct `std::ops::Range<{integer}, {integer}>` +help: call `Into::into` on this expression to convert `std::ops::Range<{integer}, {integer}>` into `std::range::Range` | LL | let b: core::range::Range = (2..3).into(); | + ++++++++ @@ -32,13 +32,13 @@ error[E0308]: mismatched types --> $DIR/feature-gate-new_range.rs:8:46 | LL | let c: core::range::RangeInclusive = 4..=5; - | ------------------------------- ^^^^^ expected `RangeInclusive`, found `RangeInclusive<{integer}>` + | ------------------------------- ^^^^^ expected `RangeInclusive`, found `RangeInclusive<{integer}, {integer}>` | | | expected due to this | = note: expected struct `std::range::RangeInclusive` - found struct `std::ops::RangeInclusive<{integer}>` -help: call `Into::into` on this expression to convert `std::ops::RangeInclusive<{integer}>` into `std::range::RangeInclusive` + found struct `std::ops::RangeInclusive<{integer}, {integer}>` +help: call `Into::into` on this expression to convert `std::ops::RangeInclusive<{integer}, {integer}>` into `std::range::RangeInclusive` | LL | let c: core::range::RangeInclusive = (4..=5).into(); | + ++++++++ diff --git a/tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision.stderr b/tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision.stderr index 5ee31a0a23b22..82a7383ed75dd 100644 --- a/tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision.stderr +++ b/tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision.stderr @@ -2,11 +2,11 @@ error[E0308]: mismatched types --> $DIR/exclusive_range_pattern_syntax_collision.rs:5:13 | LL | match [5..4, 99..105, 43..44] { - | ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]` + | ----------------------- this expression has type `[std::ops::Range<{integer}, {integer}>; 3]` LL | [_, 99.., _] => {}, - | ^^ expected `Range<{integer}>`, found integer + | ^^ expected `Range<{integer}, {integer}>`, found integer | - = note: expected struct `std::ops::Range<{integer}>` + = note: expected struct `std::ops::Range<{integer}, {integer}>` found type `{integer}` error: aborting due to 1 previous error diff --git a/tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision2.stderr b/tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision2.stderr index 9ad6d5363adcb..74f42c79d9e7c 100644 --- a/tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision2.stderr +++ b/tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision2.stderr @@ -8,11 +8,11 @@ error[E0308]: mismatched types --> $DIR/exclusive_range_pattern_syntax_collision2.rs:5:13 | LL | match [5..4, 99..105, 43..44] { - | ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]` + | ----------------------- this expression has type `[std::ops::Range<{integer}, {integer}>; 3]` LL | [_, 99..] => {}, - | ^^ expected `Range<{integer}>`, found integer + | ^^ expected `Range<{integer}, {integer}>`, found integer | - = note: expected struct `std::ops::Range<{integer}>` + = note: expected struct `std::ops::Range<{integer}, {integer}>` found type `{integer}` error: aborting due to 2 previous errors diff --git a/tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision3.stderr b/tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision3.stderr index 4a4a4c00b2e67..99bf52ef96e35 100644 --- a/tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision3.stderr +++ b/tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision3.stderr @@ -2,37 +2,37 @@ error[E0308]: mismatched types --> $DIR/exclusive_range_pattern_syntax_collision3.rs:3:12 | LL | match [5..4, 99..105, 43..44] { - | ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]` + | ----------------------- this expression has type `[std::ops::Range<{integer}, {integer}>; 3]` LL | [..9, 99..100, _] => {}, - | ^ expected `Range<{integer}>`, found integer + | ^ expected `Range<{integer}, {integer}>`, found integer | - = note: expected struct `std::ops::Range<{integer}>` + = note: expected struct `std::ops::Range<{integer}, {integer}>` found type `{integer}` error[E0308]: mismatched types --> $DIR/exclusive_range_pattern_syntax_collision3.rs:3:15 | LL | match [5..4, 99..105, 43..44] { - | ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]` + | ----------------------- this expression has type `[std::ops::Range<{integer}, {integer}>; 3]` LL | [..9, 99..100, _] => {}, | ^^ --- this is of type `{integer}` | | - | expected `Range<{integer}>`, found integer + | expected `Range<{integer}, {integer}>`, found integer | - = note: expected struct `std::ops::Range<{integer}>` + = note: expected struct `std::ops::Range<{integer}, {integer}>` found type `{integer}` error[E0308]: mismatched types --> $DIR/exclusive_range_pattern_syntax_collision3.rs:3:19 | LL | match [5..4, 99..105, 43..44] { - | ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]` + | ----------------------- this expression has type `[std::ops::Range<{integer}, {integer}>; 3]` LL | [..9, 99..100, _] => {}, - | -- ^^^ expected `Range<{integer}>`, found integer + | -- ^^^ expected `Range<{integer}, {integer}>`, found integer | | | this is of type `{integer}` | - = note: expected struct `std::ops::Range<{integer}>` + = note: expected struct `std::ops::Range<{integer}, {integer}>` found type `{integer}` error: aborting due to 3 previous errors diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr index 7912ed4d7071a..1d3fe8fa7340a 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr @@ -1,13 +1,13 @@ -error[E0277]: expected a `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` +error[E0277]: expected a `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` --> $DIR/closure-arg-type-mismatch-issue-45727.rs:6:29 | LL | let _ = (-10..=10).find(|x: i32| x.signum() == 0); - | ---- ^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnMut(&'a as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` - = note: expected a closure with signature `for<'a> fn(&'a as Iterator>::Item)` + = help: the trait `for<'a> FnMut(&'a as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` + = note: expected a closure with signature `for<'a> fn(&'a as Iterator>::Item)` found a closure with signature `fn(i32)` note: required by a bound in `find` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL @@ -18,16 +18,16 @@ error[E0271]: expected `RangeInclusive<{integer}>` to be an iterator that yields LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); | ^^^^ expected `&&i32`, found integer -error[E0277]: expected a `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` +error[E0277]: expected a `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` --> $DIR/closure-arg-type-mismatch-issue-45727.rs:9:29 | LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); - | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnMut(&'a as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` - = note: expected a closure with signature `for<'a> fn(&'a as Iterator>::Item)` + = help: the trait `for<'a> FnMut(&'a as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` + = note: expected a closure with signature `for<'a> fn(&'a as Iterator>::Item)` found a closure with signature `fn(&&&i32)` note: required by a bound in `find` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL diff --git a/tests/ui/never_type/issue-96335.stderr b/tests/ui/never_type/issue-96335.stderr index 1193973d5ee8c..65d1514bd8ad1 100644 --- a/tests/ui/never_type/issue-96335.stderr +++ b/tests/ui/never_type/issue-96335.stderr @@ -15,20 +15,5 @@ LL - 0.....{loop{}1}; LL + 0..=..{loop{}1}; | -error[E0308]: mismatched types - --> $DIR/issue-96335.rs:2:9 - | -LL | 0.....{loop{}1}; - | ----^^^^^^^^^^^ - | | | - | | expected integer, found `RangeTo<{integer}>` - | arguments to this function are incorrect - | - = note: expected type `{integer}` - found struct `RangeTo<{integer}>` -note: associated function defined here - --> $SRC_DIR/core/src/ops/range.rs:LL:COL - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/range/issue-54505-no-literals.stderr b/tests/ui/range/issue-54505-no-literals.stderr index 62e2fe4a83896..3d8c2f74bdecc 100644 --- a/tests/ui/range/issue-54505-no-literals.stderr +++ b/tests/ui/range/issue-54505-no-literals.stderr @@ -2,12 +2,12 @@ error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:16:16 | LL | take_range(std::ops::Range { start: 0, end: 1 }); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `Range<{integer}>` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `Range<{integer}, {integer}>` | | | arguments to this function are incorrect | = note: expected reference `&_` - found struct `std::ops::Range<{integer}>` + found struct `std::ops::Range<{integer}, {integer}>` note: function defined here --> $DIR/issue-54505-no-literals.rs:12:4 | @@ -22,12 +22,12 @@ error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:21:16 | LL | take_range(::std::ops::Range { start: 0, end: 1 }); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `Range<{integer}>` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `Range<{integer}, {integer}>` | | | arguments to this function are incorrect | = note: expected reference `&_` - found struct `std::ops::Range<{integer}>` + found struct `std::ops::Range<{integer}, {integer}>` note: function defined here --> $DIR/issue-54505-no-literals.rs:12:4 | @@ -122,12 +122,12 @@ error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:46:16 | LL | take_range(std::ops::RangeInclusive::new(0, 1)); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeInclusive<{integer}>` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeInclusive<{integer}, {integer}>` | | | arguments to this function are incorrect | = note: expected reference `&_` - found struct `std::ops::RangeInclusive<{integer}>` + found struct `std::ops::RangeInclusive<{integer}, {integer}>` note: function defined here --> $DIR/issue-54505-no-literals.rs:12:4 | @@ -142,12 +142,12 @@ error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:51:16 | LL | take_range(::std::ops::RangeInclusive::new(0, 1)); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeInclusive<{integer}>` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeInclusive<{integer}, {integer}>` | | | arguments to this function are incorrect | = note: expected reference `&_` - found struct `std::ops::RangeInclusive<{integer}>` + found struct `std::ops::RangeInclusive<{integer}, {integer}>` note: function defined here --> $DIR/issue-54505-no-literals.rs:12:4 | diff --git a/tests/ui/range/issue-54505-no-std.stderr b/tests/ui/range/issue-54505-no-std.stderr index 866a82afb7e2f..c74d5f69c1b48 100644 --- a/tests/ui/range/issue-54505-no-std.stderr +++ b/tests/ui/range/issue-54505-no-std.stderr @@ -2,12 +2,12 @@ error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:29:16 | LL | take_range(0..1); - | ---------- ^^^^ expected `&_`, found `Range<{integer}>` + | ---------- ^^^^ expected `&_`, found `Range<{integer}, {integer}>` | | | arguments to this function are incorrect | = note: expected reference `&_` - found struct `core::ops::Range<{integer}>` + found struct `core::ops::Range<{integer}, {integer}>` note: function defined here --> $DIR/issue-54505-no-std.rs:25:4 | @@ -67,12 +67,12 @@ error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:45:16 | LL | take_range(0..=1); - | ---------- ^^^^^ expected `&_`, found `RangeInclusive<{integer}>` + | ---------- ^^^^^ expected `&_`, found `RangeInclusive<{integer}, {integer}>` | | | arguments to this function are incorrect | = note: expected reference `&_` - found struct `core::ops::RangeInclusive<{integer}>` + found struct `core::ops::RangeInclusive<{integer}, {integer}>` note: function defined here --> $DIR/issue-54505-no-std.rs:25:4 | diff --git a/tests/ui/range/issue-54505.stderr b/tests/ui/range/issue-54505.stderr index 4d94c6c2d0942..e48265cc465e0 100644 --- a/tests/ui/range/issue-54505.stderr +++ b/tests/ui/range/issue-54505.stderr @@ -2,12 +2,12 @@ error[E0308]: mismatched types --> $DIR/issue-54505.rs:14:16 | LL | take_range(0..1); - | ---------- ^^^^ expected `&_`, found `Range<{integer}>` + | ---------- ^^^^ expected `&_`, found `Range<{integer}, {integer}>` | | | arguments to this function are incorrect | = note: expected reference `&_` - found struct `std::ops::Range<{integer}>` + found struct `std::ops::Range<{integer}, {integer}>` note: function defined here --> $DIR/issue-54505.rs:10:4 | @@ -67,12 +67,12 @@ error[E0308]: mismatched types --> $DIR/issue-54505.rs:30:16 | LL | take_range(0..=1); - | ---------- ^^^^^ expected `&_`, found `RangeInclusive<{integer}>` + | ---------- ^^^^^ expected `&_`, found `RangeInclusive<{integer}, {integer}>` | | | arguments to this function are incorrect | = note: expected reference `&_` - found struct `std::ops::RangeInclusive<{integer}>` + found struct `std::ops::RangeInclusive<{integer}, {integer}>` note: function defined here --> $DIR/issue-54505.rs:10:4 | diff --git a/tests/ui/range/issue-73553-misinterp-range-literal.stderr b/tests/ui/range/issue-73553-misinterp-range-literal.stderr index 15e55708c3785..f3e580997982a 100644 --- a/tests/ui/range/issue-73553-misinterp-range-literal.stderr +++ b/tests/ui/range/issue-73553-misinterp-range-literal.stderr @@ -22,12 +22,12 @@ error[E0308]: mismatched types --> $DIR/issue-73553-misinterp-range-literal.rs:14:10 | LL | demo(1..10); - | ---- ^^^^^ expected `&Range`, found `Range<{integer}>` + | ---- ^^^^^ expected `&Range`, found `Range<{integer}, {integer}>` | | | arguments to this function are incorrect | - = note: expected reference `&std::ops::Range` - found struct `std::ops::Range<{integer}>` + = note: expected reference `&std::ops::Range` + found struct `std::ops::Range<{integer}, {integer}>` note: function defined here --> $DIR/issue-73553-misinterp-range-literal.rs:3:4 | diff --git a/tests/ui/range/range-1.stderr b/tests/ui/range/range-1.stderr index d7d0f87ac991d..4686dfb8bd285 100644 --- a/tests/ui/range/range-1.stderr +++ b/tests/ui/range/range-1.stderr @@ -1,9 +1,3 @@ -error[E0308]: mismatched types - --> $DIR/range-1.rs:5:19 - | -LL | let _ = 0u32..10i32; - | ^^^^^ expected `u32`, found `i32` - error[E0277]: `std::ops::Range` is not an iterator --> $DIR/range-1.rs:9:14 | @@ -25,7 +19,6 @@ LL | let range = *arr..; note: required by an implicit `Sized` bound in `std::ops::RangeFrom` --> $SRC_DIR/core/src/ops/range.rs:LL:COL -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.e2021.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.e2021.stderr index 40a32880f4071..0bd5465dec493 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.e2021.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.e2021.stderr @@ -1078,25 +1078,16 @@ LL | use_expr!((let 0 = 1)); = note: only supported directly in conditions of `if` and `while` expressions = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:133:8 - | -LL | if true..(let 0 = 0) {} - | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:142:12 | LL | if let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:145:12 @@ -1104,10 +1095,10 @@ error[E0308]: mismatched types LL | if let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:151:12 @@ -1115,10 +1106,10 @@ error[E0308]: mismatched types LL | if let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` | | - | expected fn pointer, found `Range<_>` + | expected fn pointer, found `Range<_, _>` | = note: expected fn pointer `fn() -> bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:157:12 @@ -1126,10 +1117,10 @@ error[E0308]: mismatched types LL | if let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0277]: the `?` operator can only be applied to values that implement `Try` --> $DIR/disallowed-positions.rs:113:20 @@ -1139,25 +1130,16 @@ LL | if let 0 = 0? {} | = help: the nightly-only, unstable trait `Try` is not implemented for `{integer}` -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:224:11 - | -LL | while true..(let 0 = 0) {} - | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:233:15 | LL | while let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:236:15 @@ -1165,10 +1147,10 @@ error[E0308]: mismatched types LL | while let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:242:15 @@ -1176,10 +1158,10 @@ error[E0308]: mismatched types LL | while let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` | | - | expected fn pointer, found `Range<_>` + | expected fn pointer, found `Range<_, _>` | = note: expected fn pointer `fn() -> bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:248:15 @@ -1187,10 +1169,10 @@ error[E0308]: mismatched types LL | while let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0277]: the `?` operator can only be applied to values that implement `Try` --> $DIR/disallowed-positions.rs:204:23 @@ -1206,10 +1188,10 @@ error[E0308]: mismatched types LL | (let Range { start: _, end: _ } = true..true || false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0277]: the `?` operator can only be applied to values that implement `Try` --> $DIR/disallowed-positions.rs:308:17 @@ -1219,7 +1201,7 @@ LL | let 0 = 0?; | = help: the nightly-only, unstable trait `Try` is not implemented for `{integer}` -error: aborting due to 134 previous errors +error: aborting due to 132 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.e2024.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.e2024.stderr index 21167cf63d176..2cf3f0c25f634 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.e2024.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.e2024.stderr @@ -1024,25 +1024,16 @@ LL | use_expr!((let 0 = 1)); = note: only supported directly in conditions of `if` and `while` expressions = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:133:8 - | -LL | if true..(let 0 = 0) {} - | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:142:12 | LL | if let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:145:12 @@ -1050,10 +1041,10 @@ error[E0308]: mismatched types LL | if let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:151:12 @@ -1061,10 +1052,10 @@ error[E0308]: mismatched types LL | if let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` | | - | expected fn pointer, found `Range<_>` + | expected fn pointer, found `Range<_, _>` | = note: expected fn pointer `fn() -> bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:157:12 @@ -1072,10 +1063,10 @@ error[E0308]: mismatched types LL | if let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0277]: the `?` operator can only be applied to values that implement `Try` --> $DIR/disallowed-positions.rs:113:20 @@ -1085,25 +1076,16 @@ LL | if let 0 = 0? {} | = help: the nightly-only, unstable trait `Try` is not implemented for `{integer}` -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:224:11 - | -LL | while true..(let 0 = 0) {} - | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:233:15 | LL | while let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:236:15 @@ -1111,10 +1093,10 @@ error[E0308]: mismatched types LL | while let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:242:15 @@ -1122,10 +1104,10 @@ error[E0308]: mismatched types LL | while let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` | | - | expected fn pointer, found `Range<_>` + | expected fn pointer, found `Range<_, _>` | = note: expected fn pointer `fn() -> bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:248:15 @@ -1133,10 +1115,10 @@ error[E0308]: mismatched types LL | while let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0277]: the `?` operator can only be applied to values that implement `Try` --> $DIR/disallowed-positions.rs:204:23 @@ -1152,10 +1134,10 @@ error[E0308]: mismatched types LL | (let Range { start: _, end: _ } = true..true || false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` | | - | expected `bool`, found `Range<_>` + | expected `bool`, found `Range<_, _>` | = note: expected type `bool` - found struct `std::ops::Range<_>` + found struct `std::ops::Range<_, _>` error[E0277]: the `?` operator can only be applied to values that implement `Try` --> $DIR/disallowed-positions.rs:308:17 @@ -1165,7 +1147,7 @@ LL | let 0 = 0?; | = help: the nightly-only, unstable trait `Try` is not implemented for `{integer}` -error: aborting due to 125 previous errors +error: aborting due to 123 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr index 008e769cf0b24..9b853e00e6a56 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr @@ -1,5 +1,5 @@ error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:14:8 + --> $DIR/irrefutable-lets.rs:17:8 | LL | if let first = &opt && let Some(second) = first && let None = second.start {} | ^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | #![cfg_attr(disallowed, deny(irrefutable_let_patterns))] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: irrefutable `if let` patterns - --> $DIR/irrefutable-lets.rs:20:8 + --> $DIR/irrefutable-lets.rs:23:8 | LL | if let first = &opt && let (a, b) = (1, 2) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | if let first = &opt && let (a, b) = (1, 2) {} = help: consider replacing the `if let` with a `let` error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:23:8 + --> $DIR/irrefutable-lets.rs:26:8 | LL | if let first = &opt && let Some(second) = first && let None = second.start && let v = 0 {} | ^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | if let first = &opt && let Some(second) = first && let None = second.st = help: consider moving it outside of the construct error: trailing irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:23:83 + --> $DIR/irrefutable-lets.rs:26:83 | LL | if let first = &opt && let Some(second) = first && let None = second.start && let v = 0 {} | ^^^^^^^^^ @@ -40,7 +40,7 @@ LL | if let first = &opt && let Some(second) = first && let None = second.st = help: consider moving it into the body error: trailing irrefutable patterns in let chain - --> $DIR/irrefutable-lets.rs:27:37 + --> $DIR/irrefutable-lets.rs:30:37 | LL | if let Some(ref first) = opt && let second = first && let _third = second {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,16 +49,16 @@ LL | if let Some(ref first) = opt && let second = first && let _third = seco = help: consider moving them into the body error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:30:8 + --> $DIR/irrefutable-lets.rs:34:8 | -LL | if let Range { start: local_start, end: _ } = (None..Some(1)) && let None = local_start {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | if let Range { start: local_start, end: _ } = (None::>..Some(1)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this pattern will always match = help: consider moving it outside of the construct error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:33:8 + --> $DIR/irrefutable-lets.rs:38:8 | LL | if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {} = help: consider moving it outside of the construct error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:36:8 + --> $DIR/irrefutable-lets.rs:41:8 | LL | if let first = &opt && let None = Some(1) {} | ^^^^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | if let first = &opt && let None = Some(1) {} = help: consider moving it outside of the construct error: irrefutable `if let` guard patterns - --> $DIR/irrefutable-lets.rs:45:28 + --> $DIR/irrefutable-lets.rs:50:28 | LL | Some(ref first) if let second = first && let _third = second && let v = 4 + 4 => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL | Some(ref first) if let second = first && let _third = second && let = help: consider removing the guard and adding a `let` inside the match arm error: trailing irrefutable patterns in let chain - --> $DIR/irrefutable-lets.rs:60:16 + --> $DIR/irrefutable-lets.rs:65:16 | LL | && let v = local_end && let w = v => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -94,7 +94,7 @@ LL | && let v = local_end && let w = v => {}, = help: consider moving them into the body error: irrefutable `while let` patterns - --> $DIR/irrefutable-lets.rs:69:11 + --> $DIR/irrefutable-lets.rs:74:11 | LL | while let first = &opt && let (a, b) = (1, 2) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | while let first = &opt && let (a, b) = (1, 2) {} = help: consider instead using a `loop { ... }` with a `let` inside it error: trailing irrefutable patterns in let chain - --> $DIR/irrefutable-lets.rs:72:40 + --> $DIR/irrefutable-lets.rs:77:40 | LL | while let Some(ref first) = opt && let second = first && let _third = second {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +112,7 @@ LL | while let Some(ref first) = opt && let second = first && let _third = s = help: consider moving them into the body error: trailing irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:88:12 + --> $DIR/irrefutable-lets.rs:93:12 | LL | && let x = &opt | ^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | && let x = &opt = help: consider moving it into the body error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:94:12 + --> $DIR/irrefutable-lets.rs:99:12 | LL | if let x = opt.clone().map(|_| 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs index c8b9ac313ba3f..a59b659b9b3f4 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs @@ -9,7 +9,10 @@ use std::ops::Range; fn main() { - let opt = Some(None..Some(1)); + // Type explicitly given on LHS because it would obfuscate the irrefutable pattern + // since currently Range type has difficulty inferring types with one end not being + // a concrete type + let opt = Some(None::>..Some(1)); if let first = &opt && let Some(second) = first && let None = second.start {} //[disallowed]~^ ERROR leading irrefutable pattern in let chain @@ -27,7 +30,9 @@ fn main() { if let Some(ref first) = opt && let second = first && let _third = second {} //[disallowed]~^ ERROR trailing irrefutable patterns in let chain - if let Range { start: local_start, end: _ } = (None..Some(1)) && let None = local_start {} + // Type explicitly given on None for reasons mentioned in lines 12-14 + if let Range { start: local_start, end: _ } = (None::>..Some(1)) + && let None = local_start {} //[disallowed]~^ ERROR leading irrefutable pattern in let chain if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {} diff --git a/tests/ui/structs/struct-record-suggestion.stderr b/tests/ui/structs/struct-record-suggestion.stderr index 38274f8d9c0d5..d280d387b2b37 100644 --- a/tests/ui/structs/struct-record-suggestion.stderr +++ b/tests/ui/structs/struct-record-suggestion.stderr @@ -18,10 +18,10 @@ error[E0308]: mismatched types --> $DIR/struct-record-suggestion.rs:23:20 | LL | let q = B { b: 1..Default::default() }; - | ^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `Range<{integer}>` + | ^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `Range<{integer}, _>` | = note: expected type `u32` - found struct `std::ops::Range<{integer}>` + found struct `std::ops::Range<{integer}, _>` note: this expression may have been misinterpreted as a `..` range expression --> $DIR/struct-record-suggestion.rs:23:20 | diff --git a/tests/ui/suggestions/into-convert-range-issue-148344.stderr b/tests/ui/suggestions/into-convert-range-issue-148344.stderr index ce5342f5789b9..c1502ab757e77 100644 --- a/tests/ui/suggestions/into-convert-range-issue-148344.stderr +++ b/tests/ui/suggestions/into-convert-range-issue-148344.stderr @@ -2,13 +2,13 @@ error[E0308]: mismatched types --> $DIR/into-convert-range-issue-148344.rs:12:22 | LL | let _: Strange = 0..10; - | ------- ^^^^^ expected `Strange`, found `Range<{integer}>` + | ------- ^^^^^ expected `Strange`, found `Range<{integer}, {integer}>` | | | expected due to this | = note: expected struct `Strange` - found struct `std::ops::Range<{integer}>` -help: call `Into::into` on this expression to convert `std::ops::Range<{integer}>` into `Strange` + found struct `std::ops::Range<{integer}, {integer}>` +help: call `Into::into` on this expression to convert `std::ops::Range<{integer}, {integer}>` into `Strange` | LL | let _: Strange = (0..10).into(); | + ++++++++ diff --git a/tests/ui/suggestions/method-access-to-range-literal-typo.stderr b/tests/ui/suggestions/method-access-to-range-literal-typo.stderr index b1fb0254cd9cf..23f2902ef5866 100644 --- a/tests/ui/suggestions/method-access-to-range-literal-typo.stderr +++ b/tests/ui/suggestions/method-access-to-range-literal-typo.stderr @@ -26,23 +26,7 @@ LL - self.option..as_ref().map(|x| x) LL + self.option.as_ref().map(|x| x) | -error[E0308]: mismatched types - --> $DIR/method-access-to-range-literal-typo.rs:26:9 - | -LL | fn method2(&self) -> Option<&u8> { - | ----------- expected `Option<&u8>` because of return type -LL | self.option..foo().get(0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<&u8>`, found `Range>>` - | - = note: expected enum `Option<&u8>` - found struct `std::ops::Range>>` -help: you likely meant to write a method call instead of a range - | -LL - self.option..foo().get(0) -LL + self.option.foo().get(0) - | - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0308, E0425. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr b/tests/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr index ade3f3099a354..db0e379987e8d 100644 --- a/tests/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr +++ b/tests/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr @@ -2,12 +2,12 @@ error[E0308]: mismatched types --> $DIR/unnecessary_dot_for_floating_point_literal.rs:2:18 | LL | let _: f64 = 0..10; - | --- ^^^^^ expected `f64`, found `Range<{integer}>` + | --- ^^^^^ expected `f64`, found `Range<{integer}, {integer}>` | | | expected due to this | = note: expected type `f64` - found struct `std::ops::Range<{integer}>` + found struct `std::ops::Range<{integer}, {integer}>` help: remove the unnecessary `.` operator for a floating point literal | LL - let _: f64 = 0..10; @@ -50,12 +50,12 @@ error[E0308]: mismatched types --> $DIR/unnecessary_dot_for_floating_point_literal.rs:5:18 | LL | let _: f64 = std::ops::Range { start: 0, end: 1 }; - | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `f64`, found `Range<{integer}>` + | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `f64`, found `Range<{integer}, {integer}>` | | | expected due to this | = note: expected type `f64` - found struct `std::ops::Range<{integer}>` + found struct `std::ops::Range<{integer}, {integer}>` error: aborting due to 4 previous errors