summaryrefslogtreecommitdiffstats
path: root/tests/ui/range
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/range')
-rw-r--r--tests/ui/range/exclusive-range-patterns-2021.rs14
-rw-r--r--tests/ui/range/exclusive-range-patterns-2021.stderr27
-rw-r--r--tests/ui/range/issue-54505-no-literals.fixed75
-rw-r--r--tests/ui/range/issue-54505-no-literals.rs75
-rw-r--r--tests/ui/range/issue-54505-no-literals.stderr219
-rw-r--r--tests/ui/range/issue-54505-no-std.rs58
-rw-r--r--tests/ui/range/issue-54505-no-std.stderr123
-rw-r--r--tests/ui/range/issue-54505.fixed43
-rw-r--r--tests/ui/range/issue-54505.rs43
-rw-r--r--tests/ui/range/issue-54505.stderr111
-rw-r--r--tests/ui/range/issue-73553-misinterp-range-literal.rs16
-rw-r--r--tests/ui/range/issue-73553-misinterp-range-literal.stderr39
-rw-r--r--tests/ui/range/range-1.rs16
-rw-r--r--tests/ui/range/range-1.stderr39
-rw-r--r--tests/ui/range/range-inclusive-pattern-precedence.fixed21
-rw-r--r--tests/ui/range/range-inclusive-pattern-precedence.rs21
-rw-r--r--tests/ui/range/range-inclusive-pattern-precedence.stderr22
-rw-r--r--tests/ui/range/range-inclusive-pattern-precedence2.rs20
-rw-r--r--tests/ui/range/range-inclusive-pattern-precedence2.stderr22
-rw-r--r--tests/ui/range/range-pattern-out-of-bounds-issue-68972.rs13
-rw-r--r--tests/ui/range/range-pattern-out-of-bounds-issue-68972.stderr26
-rw-r--r--tests/ui/range/range_traits-1.rs25
-rw-r--r--tests/ui/range/range_traits-1.stderr141
-rw-r--r--tests/ui/range/range_traits-2.rs6
-rw-r--r--tests/ui/range/range_traits-2.stderr13
-rw-r--r--tests/ui/range/range_traits-3.rs6
-rw-r--r--tests/ui/range/range_traits-3.stderr13
-rw-r--r--tests/ui/range/range_traits-4.rs9
-rw-r--r--tests/ui/range/range_traits-5.rs9
-rw-r--r--tests/ui/range/range_traits-6.rs6
-rw-r--r--tests/ui/range/range_traits-6.stderr13
-rw-r--r--tests/ui/range/range_traits-7.rs9
32 files changed, 1293 insertions, 0 deletions
diff --git a/tests/ui/range/exclusive-range-patterns-2021.rs b/tests/ui/range/exclusive-range-patterns-2021.rs
new file mode 100644
index 000000000..de69c9bf2
--- /dev/null
+++ b/tests/ui/range/exclusive-range-patterns-2021.rs
@@ -0,0 +1,14 @@
+// edition:2021
+
+fn main() {
+ let n = 2;
+ match n {
+ 0...3 => {}
+ //~^ ERROR `...` range patterns are deprecated
+ 4...10 => {}
+ //~^ ERROR `...` range patterns are deprecated
+ (11...100) => {}
+ //~^ ERROR `...` range patterns are deprecated
+ _ => {}
+ }
+}
diff --git a/tests/ui/range/exclusive-range-patterns-2021.stderr b/tests/ui/range/exclusive-range-patterns-2021.stderr
new file mode 100644
index 000000000..a96743704
--- /dev/null
+++ b/tests/ui/range/exclusive-range-patterns-2021.stderr
@@ -0,0 +1,27 @@
+error[E0783]: `...` range patterns are deprecated
+ --> $DIR/exclusive-range-patterns-2021.rs:6:9
+ |
+LL | 0...3 => {}
+ | ^---^
+ | |
+ | help: use `..=` for an inclusive range
+
+error[E0783]: `...` range patterns are deprecated
+ --> $DIR/exclusive-range-patterns-2021.rs:8:9
+ |
+LL | 4...10 => {}
+ | ^---^^
+ | |
+ | help: use `..=` for an inclusive range
+
+error[E0783]: `...` range patterns are deprecated
+ --> $DIR/exclusive-range-patterns-2021.rs:10:10
+ |
+LL | (11...100) => {}
+ | ^^---^^^
+ | |
+ | help: use `..=` for an inclusive range
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0783`.
diff --git a/tests/ui/range/issue-54505-no-literals.fixed b/tests/ui/range/issue-54505-no-literals.fixed
new file mode 100644
index 000000000..4d8f67182
--- /dev/null
+++ b/tests/ui/range/issue-54505-no-literals.fixed
@@ -0,0 +1,75 @@
+// run-rustfix
+
+// Regression test for changes introduced while fixing #54505
+
+// This test uses non-literals for Ranges
+// (expecting no parens with borrow suggestion)
+
+use std::ops::RangeBounds;
+
+
+// take a reference to any built-in range
+fn take_range(_r: &impl RangeBounds<i8>) {}
+
+
+fn main() {
+ take_range(&std::ops::Range { start: 0, end: 1 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &std::ops::Range { start: 0, end: 1 }
+
+ take_range(&::std::ops::Range { start: 0, end: 1 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &::std::ops::Range { start: 0, end: 1 }
+
+ take_range(&std::ops::RangeFrom { start: 1 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &std::ops::RangeFrom { start: 1 }
+
+ take_range(&::std::ops::RangeFrom { start: 1 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &::std::ops::RangeFrom { start: 1 }
+
+ take_range(&std::ops::RangeFull {});
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &std::ops::RangeFull {}
+
+ take_range(&::std::ops::RangeFull {});
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &::std::ops::RangeFull {}
+
+ take_range(&std::ops::RangeInclusive::new(0, 1));
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &std::ops::RangeInclusive::new(0, 1)
+
+ take_range(&::std::ops::RangeInclusive::new(0, 1));
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &::std::ops::RangeInclusive::new(0, 1)
+
+ take_range(&std::ops::RangeTo { end: 5 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &std::ops::RangeTo { end: 5 }
+
+ take_range(&::std::ops::RangeTo { end: 5 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &::std::ops::RangeTo { end: 5 }
+
+ take_range(&std::ops::RangeToInclusive { end: 5 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &std::ops::RangeToInclusive { end: 5 }
+
+ take_range(&::std::ops::RangeToInclusive { end: 5 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &::std::ops::RangeToInclusive { end: 5 }
+}
diff --git a/tests/ui/range/issue-54505-no-literals.rs b/tests/ui/range/issue-54505-no-literals.rs
new file mode 100644
index 000000000..dc21dcbc2
--- /dev/null
+++ b/tests/ui/range/issue-54505-no-literals.rs
@@ -0,0 +1,75 @@
+// run-rustfix
+
+// Regression test for changes introduced while fixing #54505
+
+// This test uses non-literals for Ranges
+// (expecting no parens with borrow suggestion)
+
+use std::ops::RangeBounds;
+
+
+// take a reference to any built-in range
+fn take_range(_r: &impl RangeBounds<i8>) {}
+
+
+fn main() {
+ take_range(std::ops::Range { start: 0, end: 1 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &std::ops::Range { start: 0, end: 1 }
+
+ take_range(::std::ops::Range { start: 0, end: 1 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &::std::ops::Range { start: 0, end: 1 }
+
+ take_range(std::ops::RangeFrom { start: 1 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &std::ops::RangeFrom { start: 1 }
+
+ take_range(::std::ops::RangeFrom { start: 1 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &::std::ops::RangeFrom { start: 1 }
+
+ take_range(std::ops::RangeFull {});
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &std::ops::RangeFull {}
+
+ take_range(::std::ops::RangeFull {});
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &::std::ops::RangeFull {}
+
+ take_range(std::ops::RangeInclusive::new(0, 1));
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &std::ops::RangeInclusive::new(0, 1)
+
+ take_range(::std::ops::RangeInclusive::new(0, 1));
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &::std::ops::RangeInclusive::new(0, 1)
+
+ take_range(std::ops::RangeTo { end: 5 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &std::ops::RangeTo { end: 5 }
+
+ take_range(::std::ops::RangeTo { end: 5 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &::std::ops::RangeTo { end: 5 }
+
+ take_range(std::ops::RangeToInclusive { end: 5 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &std::ops::RangeToInclusive { end: 5 }
+
+ take_range(::std::ops::RangeToInclusive { end: 5 });
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &::std::ops::RangeToInclusive { end: 5 }
+}
diff --git a/tests/ui/range/issue-54505-no-literals.stderr b/tests/ui/range/issue-54505-no-literals.stderr
new file mode 100644
index 000000000..070dc8445
--- /dev/null
+++ b/tests/ui/range/issue-54505-no-literals.stderr
@@ -0,0 +1,219 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-literals.rs:16:16
+ |
+LL | take_range(std::ops::Range { start: 0, end: 1 });
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected reference, found struct `Range`
+ | | help: consider borrowing here: `&std::ops::Range { start: 0, end: 1 }`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `std::ops::Range<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-literals.rs:12:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-literals.rs:21:16
+ |
+LL | take_range(::std::ops::Range { start: 0, end: 1 });
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected reference, found struct `Range`
+ | | help: consider borrowing here: `&::std::ops::Range { start: 0, end: 1 }`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `std::ops::Range<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-literals.rs:12:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-literals.rs:26:16
+ |
+LL | take_range(std::ops::RangeFrom { start: 1 });
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected reference, found struct `RangeFrom`
+ | | help: consider borrowing here: `&std::ops::RangeFrom { start: 1 }`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeFrom<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-literals.rs:12:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-literals.rs:31:16
+ |
+LL | take_range(::std::ops::RangeFrom { start: 1 });
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected reference, found struct `RangeFrom`
+ | | help: consider borrowing here: `&::std::ops::RangeFrom { start: 1 }`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeFrom<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-literals.rs:12:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-literals.rs:36:16
+ |
+LL | take_range(std::ops::RangeFull {});
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected reference, found struct `RangeFull`
+ | | help: consider borrowing here: `&std::ops::RangeFull {}`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeFull`
+note: function defined here
+ --> $DIR/issue-54505-no-literals.rs:12:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-literals.rs:41:16
+ |
+LL | take_range(::std::ops::RangeFull {});
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected reference, found struct `RangeFull`
+ | | help: consider borrowing here: `&::std::ops::RangeFull {}`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeFull`
+note: function defined here
+ --> $DIR/issue-54505-no-literals.rs:12:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-literals.rs:46:16
+ |
+LL | take_range(std::ops::RangeInclusive::new(0, 1));
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected reference, found struct `RangeInclusive`
+ | | help: consider borrowing here: `&std::ops::RangeInclusive::new(0, 1)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeInclusive<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-literals.rs:12:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-literals.rs:51:16
+ |
+LL | take_range(::std::ops::RangeInclusive::new(0, 1));
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected reference, found struct `RangeInclusive`
+ | | help: consider borrowing here: `&::std::ops::RangeInclusive::new(0, 1)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeInclusive<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-literals.rs:12:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-literals.rs:56:16
+ |
+LL | take_range(std::ops::RangeTo { end: 5 });
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected reference, found struct `RangeTo`
+ | | help: consider borrowing here: `&std::ops::RangeTo { end: 5 }`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeTo<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-literals.rs:12:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-literals.rs:61:16
+ |
+LL | take_range(::std::ops::RangeTo { end: 5 });
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected reference, found struct `RangeTo`
+ | | help: consider borrowing here: `&::std::ops::RangeTo { end: 5 }`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeTo<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-literals.rs:12:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-literals.rs:66:16
+ |
+LL | take_range(std::ops::RangeToInclusive { end: 5 });
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected reference, found struct `RangeToInclusive`
+ | | help: consider borrowing here: `&std::ops::RangeToInclusive { end: 5 }`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeToInclusive<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-literals.rs:12:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-literals.rs:71:16
+ |
+LL | take_range(::std::ops::RangeToInclusive { end: 5 });
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected reference, found struct `RangeToInclusive`
+ | | help: consider borrowing here: `&::std::ops::RangeToInclusive { end: 5 }`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeToInclusive<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-literals.rs:12:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error: aborting due to 12 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/range/issue-54505-no-std.rs b/tests/ui/range/issue-54505-no-std.rs
new file mode 100644
index 000000000..9f378b483
--- /dev/null
+++ b/tests/ui/range/issue-54505-no-std.rs
@@ -0,0 +1,58 @@
+// Regression test for #54505 - range borrowing suggestion had
+// incorrect syntax (missing parentheses).
+
+// This test doesn't use std
+// (so all Ranges resolve to core::ops::Range...)
+
+#![no_std]
+#![feature(lang_items)]
+
+use core::ops::RangeBounds;
+
+#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
+#[lang = "eh_personality"]
+extern "C" fn eh_personality() {}
+#[cfg(target_os = "emscripten")]
+#[lang = "eh_catch_typeinfo"]
+static EH_CATCH_TYPEINFO: u8 = 0;
+
+#[panic_handler]
+fn panic_handler() {}
+//~^ ERROR return type should be `!`
+//~| ERROR function should have one argument
+
+// take a reference to any built-in range
+fn take_range(_r: &impl RangeBounds<i8>) {}
+
+
+fn main() {
+ take_range(0..1);
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(0..1)
+
+ take_range(1..);
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(1..)
+
+ take_range(..);
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(..)
+
+ take_range(0..=1);
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(0..=1)
+
+ take_range(..5);
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(..5)
+
+ take_range(..=42);
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(..=42)
+}
diff --git a/tests/ui/range/issue-54505-no-std.stderr b/tests/ui/range/issue-54505-no-std.stderr
new file mode 100644
index 000000000..9fb0e54a8
--- /dev/null
+++ b/tests/ui/range/issue-54505-no-std.stderr
@@ -0,0 +1,123 @@
+error: return type should be `!`
+ --> $DIR/issue-54505-no-std.rs:20:20
+ |
+LL | fn panic_handler() {}
+ | ^
+
+error: function should have one argument
+ --> $DIR/issue-54505-no-std.rs:20:1
+ |
+LL | fn panic_handler() {}
+ | ^^^^^^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-std.rs:29:16
+ |
+LL | take_range(0..1);
+ | ---------- ^^^^
+ | | |
+ | | expected reference, found struct `Range`
+ | | help: consider borrowing here: `&(0..1)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `Range<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-std.rs:25:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-std.rs:34:16
+ |
+LL | take_range(1..);
+ | ---------- ^^^
+ | | |
+ | | expected reference, found struct `RangeFrom`
+ | | help: consider borrowing here: `&(1..)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeFrom<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-std.rs:25:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-std.rs:39:16
+ |
+LL | take_range(..);
+ | ---------- ^^
+ | | |
+ | | expected reference, found struct `RangeFull`
+ | | help: consider borrowing here: `&(..)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeFull`
+note: function defined here
+ --> $DIR/issue-54505-no-std.rs:25:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-std.rs:44:16
+ |
+LL | take_range(0..=1);
+ | ---------- ^^^^^
+ | | |
+ | | expected reference, found struct `RangeInclusive`
+ | | help: consider borrowing here: `&(0..=1)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeInclusive<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-std.rs:25:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-std.rs:49:16
+ |
+LL | take_range(..5);
+ | ---------- ^^^
+ | | |
+ | | expected reference, found struct `RangeTo`
+ | | help: consider borrowing here: `&(..5)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeTo<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-std.rs:25:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505-no-std.rs:54:16
+ |
+LL | take_range(..=42);
+ | ---------- ^^^^^
+ | | |
+ | | expected reference, found struct `RangeToInclusive`
+ | | help: consider borrowing here: `&(..=42)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeToInclusive<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505-no-std.rs:25:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error: aborting due to 8 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/range/issue-54505.fixed b/tests/ui/range/issue-54505.fixed
new file mode 100644
index 000000000..f8298c0b5
--- /dev/null
+++ b/tests/ui/range/issue-54505.fixed
@@ -0,0 +1,43 @@
+// run-rustfix
+
+// Regression test for #54505 - range borrowing suggestion had
+// incorrect syntax (missing parentheses).
+
+use std::ops::RangeBounds;
+
+
+// take a reference to any built-in range
+fn take_range(_r: &impl RangeBounds<i8>) {}
+
+
+fn main() {
+ take_range(&(0..1));
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(0..1)
+
+ take_range(&(1..));
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(1..)
+
+ take_range(&(..));
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(..)
+
+ take_range(&(0..=1));
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(0..=1)
+
+ take_range(&(..5));
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(..5)
+
+ take_range(&(..=42));
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(..=42)
+}
diff --git a/tests/ui/range/issue-54505.rs b/tests/ui/range/issue-54505.rs
new file mode 100644
index 000000000..03673252d
--- /dev/null
+++ b/tests/ui/range/issue-54505.rs
@@ -0,0 +1,43 @@
+// run-rustfix
+
+// Regression test for #54505 - range borrowing suggestion had
+// incorrect syntax (missing parentheses).
+
+use std::ops::RangeBounds;
+
+
+// take a reference to any built-in range
+fn take_range(_r: &impl RangeBounds<i8>) {}
+
+
+fn main() {
+ take_range(0..1);
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(0..1)
+
+ take_range(1..);
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(1..)
+
+ take_range(..);
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(..)
+
+ take_range(0..=1);
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(0..=1)
+
+ take_range(..5);
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(..5)
+
+ take_range(..=42);
+ //~^ ERROR mismatched types [E0308]
+ //~| HELP consider borrowing here
+ //~| SUGGESTION &(..=42)
+}
diff --git a/tests/ui/range/issue-54505.stderr b/tests/ui/range/issue-54505.stderr
new file mode 100644
index 000000000..9eec16940
--- /dev/null
+++ b/tests/ui/range/issue-54505.stderr
@@ -0,0 +1,111 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-54505.rs:14:16
+ |
+LL | take_range(0..1);
+ | ---------- ^^^^
+ | | |
+ | | expected reference, found struct `Range`
+ | | help: consider borrowing here: `&(0..1)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `std::ops::Range<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505.rs:10:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505.rs:19:16
+ |
+LL | take_range(1..);
+ | ---------- ^^^
+ | | |
+ | | expected reference, found struct `RangeFrom`
+ | | help: consider borrowing here: `&(1..)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeFrom<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505.rs:10:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505.rs:24:16
+ |
+LL | take_range(..);
+ | ---------- ^^
+ | | |
+ | | expected reference, found struct `RangeFull`
+ | | help: consider borrowing here: `&(..)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeFull`
+note: function defined here
+ --> $DIR/issue-54505.rs:10:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505.rs:29:16
+ |
+LL | take_range(0..=1);
+ | ---------- ^^^^^
+ | | |
+ | | expected reference, found struct `RangeInclusive`
+ | | help: consider borrowing here: `&(0..=1)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeInclusive<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505.rs:10:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505.rs:34:16
+ |
+LL | take_range(..5);
+ | ---------- ^^^
+ | | |
+ | | expected reference, found struct `RangeTo`
+ | | help: consider borrowing here: `&(..5)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeTo<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505.rs:10:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-54505.rs:39:16
+ |
+LL | take_range(..=42);
+ | ---------- ^^^^^
+ | | |
+ | | expected reference, found struct `RangeToInclusive`
+ | | help: consider borrowing here: `&(..=42)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&_`
+ found struct `RangeToInclusive<{integer}>`
+note: function defined here
+ --> $DIR/issue-54505.rs:10:4
+ |
+LL | fn take_range(_r: &impl RangeBounds<i8>) {}
+ | ^^^^^^^^^^ -------------------------
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/range/issue-73553-misinterp-range-literal.rs b/tests/ui/range/issue-73553-misinterp-range-literal.rs
new file mode 100644
index 000000000..e65dba0a0
--- /dev/null
+++ b/tests/ui/range/issue-73553-misinterp-range-literal.rs
@@ -0,0 +1,16 @@
+type Range = std::ops::Range<usize>;
+
+fn demo(r: &Range) {
+ println!("{:?}", r);
+}
+
+fn tell(x: usize) -> usize {
+ x
+}
+
+fn main() {
+ demo(tell(1)..tell(10));
+ //~^ ERROR mismatched types
+ demo(1..10);
+ //~^ ERROR mismatched types
+}
diff --git a/tests/ui/range/issue-73553-misinterp-range-literal.stderr b/tests/ui/range/issue-73553-misinterp-range-literal.stderr
new file mode 100644
index 000000000..d08d9b134
--- /dev/null
+++ b/tests/ui/range/issue-73553-misinterp-range-literal.stderr
@@ -0,0 +1,39 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-73553-misinterp-range-literal.rs:12:10
+ |
+LL | demo(tell(1)..tell(10));
+ | ---- ^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected `&Range<usize>`, found struct `Range`
+ | | help: consider borrowing here: `&(tell(1)..tell(10))`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&std::ops::Range<usize>`
+ found struct `std::ops::Range<usize>`
+note: function defined here
+ --> $DIR/issue-73553-misinterp-range-literal.rs:3:4
+ |
+LL | fn demo(r: &Range) {
+ | ^^^^ ---------
+
+error[E0308]: mismatched types
+ --> $DIR/issue-73553-misinterp-range-literal.rs:14:10
+ |
+LL | demo(1..10);
+ | ---- ^^^^^
+ | | |
+ | | expected `&Range<usize>`, found struct `Range`
+ | | help: consider borrowing here: `&(1..10)`
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&std::ops::Range<usize>`
+ found struct `std::ops::Range<{integer}>`
+note: function defined here
+ --> $DIR/issue-73553-misinterp-range-literal.rs:3:4
+ |
+LL | fn demo(r: &Range) {
+ | ^^^^ ---------
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/range/range-1.rs b/tests/ui/range/range-1.rs
new file mode 100644
index 000000000..192426fe2
--- /dev/null
+++ b/tests/ui/range/range-1.rs
@@ -0,0 +1,16 @@
+// Test range syntax - type errors.
+
+pub fn main() {
+ // Mixed types.
+ let _ = 0u32..10i32;
+ //~^ ERROR mismatched types
+
+ // Bool => does not implement iterator.
+ for i in false..true {}
+ //~^ ERROR `bool: Step` is not satisfied
+
+ // Unsized type.
+ let arr: &[_] = &[1, 2, 3];
+ let range = *arr..;
+ //~^ ERROR the size for values of type
+}
diff --git a/tests/ui/range/range-1.stderr b/tests/ui/range/range-1.stderr
new file mode 100644
index 000000000..395639036
--- /dev/null
+++ b/tests/ui/range/range-1.stderr
@@ -0,0 +1,39 @@
+error[E0308]: mismatched types
+ --> $DIR/range-1.rs:5:19
+ |
+LL | let _ = 0u32..10i32;
+ | ^^^^^ expected `u32`, found `i32`
+
+error[E0277]: the trait bound `bool: Step` is not satisfied
+ --> $DIR/range-1.rs:9:14
+ |
+LL | for i in false..true {}
+ | ^^^^^^^^^^^ the trait `Step` is not implemented for `bool`
+ |
+ = help: the following other types implement trait `Step`:
+ char
+ i128
+ i16
+ i32
+ i64
+ i8
+ isize
+ u128
+ and 5 others
+ = note: required for `std::ops::Range<bool>` to implement `Iterator`
+ = note: required for `std::ops::Range<bool>` to implement `IntoIterator`
+
+error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
+ --> $DIR/range-1.rs:14:17
+ |
+LL | let range = *arr..;
+ | ^^^^ doesn't have a size known at compile-time
+ |
+ = help: the trait `Sized` is not implemented for `[{integer}]`
+note: required by a bound in `RangeFrom`
+ --> $SRC_DIR/core/src/ops/range.rs:LL:COL
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0277, E0308.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/tests/ui/range/range-inclusive-pattern-precedence.fixed b/tests/ui/range/range-inclusive-pattern-precedence.fixed
new file mode 100644
index 000000000..38104bab7
--- /dev/null
+++ b/tests/ui/range/range-inclusive-pattern-precedence.fixed
@@ -0,0 +1,21 @@
+// In expression, `&a..=b` is treated as `(&a)..=(b)` and `box a..=b` is
+// `(box a)..=(b)`. In a pattern, however, `&a..=b` means `&(a..=b)`. This may
+// lead to confusion.
+
+// run-rustfix
+
+#![warn(ellipsis_inclusive_range_patterns)]
+
+pub fn main() {
+ match &12 {
+ &(0..=9) => {}
+ //~^ WARN `...` range patterns are deprecated
+ //~| WARN this is accepted in the current edition
+ //~| HELP use `..=` for an inclusive range
+ &(10..=15) => {}
+ //~^ ERROR the range pattern here has ambiguous interpretation
+ //~| HELP add parentheses to clarify the precedence
+ &(16..=20) => {}
+ _ => {}
+ }
+}
diff --git a/tests/ui/range/range-inclusive-pattern-precedence.rs b/tests/ui/range/range-inclusive-pattern-precedence.rs
new file mode 100644
index 000000000..b294e436f
--- /dev/null
+++ b/tests/ui/range/range-inclusive-pattern-precedence.rs
@@ -0,0 +1,21 @@
+// In expression, `&a..=b` is treated as `(&a)..=(b)` and `box a..=b` is
+// `(box a)..=(b)`. In a pattern, however, `&a..=b` means `&(a..=b)`. This may
+// lead to confusion.
+
+// run-rustfix
+
+#![warn(ellipsis_inclusive_range_patterns)]
+
+pub fn main() {
+ match &12 {
+ &0...9 => {}
+ //~^ WARN `...` range patterns are deprecated
+ //~| WARN this is accepted in the current edition
+ //~| HELP use `..=` for an inclusive range
+ &10..=15 => {}
+ //~^ ERROR the range pattern here has ambiguous interpretation
+ //~| HELP add parentheses to clarify the precedence
+ &(16..=20) => {}
+ _ => {}
+ }
+}
diff --git a/tests/ui/range/range-inclusive-pattern-precedence.stderr b/tests/ui/range/range-inclusive-pattern-precedence.stderr
new file mode 100644
index 000000000..f6788d034
--- /dev/null
+++ b/tests/ui/range/range-inclusive-pattern-precedence.stderr
@@ -0,0 +1,22 @@
+error: the range pattern here has ambiguous interpretation
+ --> $DIR/range-inclusive-pattern-precedence.rs:15:10
+ |
+LL | &10..=15 => {}
+ | ^^^^^^^ help: add parentheses to clarify the precedence: `(10..=15)`
+
+warning: `...` range patterns are deprecated
+ --> $DIR/range-inclusive-pattern-precedence.rs:11:9
+ |
+LL | &0...9 => {}
+ | ^^^^^^ help: use `..=` for an inclusive range: `&(0..=9)`
+ |
+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
+note: the lint level is defined here
+ --> $DIR/range-inclusive-pattern-precedence.rs:7:9
+ |
+LL | #![warn(ellipsis_inclusive_range_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error; 1 warning emitted
+
diff --git a/tests/ui/range/range-inclusive-pattern-precedence2.rs b/tests/ui/range/range-inclusive-pattern-precedence2.rs
new file mode 100644
index 000000000..bede9c579
--- /dev/null
+++ b/tests/ui/range/range-inclusive-pattern-precedence2.rs
@@ -0,0 +1,20 @@
+// We are going to disallow `&a..=b` and `box a..=b` in a pattern. However, the
+// older ... syntax is still allowed as a stability guarantee.
+
+#![feature(box_patterns)]
+#![warn(ellipsis_inclusive_range_patterns)]
+
+fn main() {
+ match Box::new(12) {
+ // FIXME: can we add suggestions like `&(0..=9)`?
+ box 0...9 => {}
+ //~^ WARN `...` range patterns are deprecated
+ //~| WARN this is accepted in the current edition
+ //~| HELP use `..=` for an inclusive range
+ box 10..=15 => {}
+ //~^ ERROR the range pattern here has ambiguous interpretation
+ //~^^ HELP add parentheses to clarify the precedence
+ box (16..=20) => {}
+ _ => {}
+ }
+}
diff --git a/tests/ui/range/range-inclusive-pattern-precedence2.stderr b/tests/ui/range/range-inclusive-pattern-precedence2.stderr
new file mode 100644
index 000000000..bb4e3a13a
--- /dev/null
+++ b/tests/ui/range/range-inclusive-pattern-precedence2.stderr
@@ -0,0 +1,22 @@
+error: the range pattern here has ambiguous interpretation
+ --> $DIR/range-inclusive-pattern-precedence2.rs:14:13
+ |
+LL | box 10..=15 => {}
+ | ^^^^^^^ help: add parentheses to clarify the precedence: `(10..=15)`
+
+warning: `...` range patterns are deprecated
+ --> $DIR/range-inclusive-pattern-precedence2.rs:10:14
+ |
+LL | box 0...9 => {}
+ | ^^^ help: use `..=` for an inclusive range
+ |
+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
+note: the lint level is defined here
+ --> $DIR/range-inclusive-pattern-precedence2.rs:5:9
+ |
+LL | #![warn(ellipsis_inclusive_range_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error; 1 warning emitted
+
diff --git a/tests/ui/range/range-pattern-out-of-bounds-issue-68972.rs b/tests/ui/range/range-pattern-out-of-bounds-issue-68972.rs
new file mode 100644
index 000000000..d02caff1f
--- /dev/null
+++ b/tests/ui/range/range-pattern-out-of-bounds-issue-68972.rs
@@ -0,0 +1,13 @@
+#![feature(exclusive_range_pattern)]
+#![allow(unreachable_patterns)]
+fn main() {
+ match 0u8 {
+ 251..257 => {}
+ //~^ ERROR literal out of range
+ //~| ERROR literal out of range
+ 251..=256 => {}
+ //~^ ERROR literal out of range
+ //~| ERROR literal out of range
+ _ => {}
+ }
+}
diff --git a/tests/ui/range/range-pattern-out-of-bounds-issue-68972.stderr b/tests/ui/range/range-pattern-out-of-bounds-issue-68972.stderr
new file mode 100644
index 000000000..7b8309b9b
--- /dev/null
+++ b/tests/ui/range/range-pattern-out-of-bounds-issue-68972.stderr
@@ -0,0 +1,26 @@
+error: literal out of range for `u8`
+ --> $DIR/range-pattern-out-of-bounds-issue-68972.rs:5:14
+ |
+LL | 251..257 => {}
+ | ^^^ this value doesn't fit in `u8` whose maximum value is `255`
+
+error: literal out of range for `u8`
+ --> $DIR/range-pattern-out-of-bounds-issue-68972.rs:8:15
+ |
+LL | 251..=256 => {}
+ | ^^^ this value doesn't fit in `u8` whose maximum value is `255`
+
+error: literal out of range for `u8`
+ --> $DIR/range-pattern-out-of-bounds-issue-68972.rs:5:14
+ |
+LL | 251..257 => {}
+ | ^^^ this value doesn't fit in `u8` whose maximum value is `255`
+
+error: literal out of range for `u8`
+ --> $DIR/range-pattern-out-of-bounds-issue-68972.rs:8:15
+ |
+LL | 251..=256 => {}
+ | ^^^ this value doesn't fit in `u8` whose maximum value is `255`
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/range/range_traits-1.rs b/tests/ui/range/range_traits-1.rs
new file mode 100644
index 000000000..e28e47435
--- /dev/null
+++ b/tests/ui/range/range_traits-1.rs
@@ -0,0 +1,25 @@
+use std::ops::*;
+
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+struct AllTheRanges {
+ a: Range<usize>,
+ //~^ ERROR can't compare
+ //~| ERROR Ord
+ b: RangeTo<usize>,
+ //~^ ERROR can't compare
+ //~| ERROR Ord
+ c: RangeFrom<usize>,
+ //~^ ERROR can't compare
+ //~| ERROR Ord
+ d: RangeFull,
+ //~^ ERROR can't compare
+ //~| ERROR Ord
+ e: RangeInclusive<usize>,
+ //~^ ERROR can't compare
+ //~| ERROR Ord
+ f: RangeToInclusive<usize>,
+ //~^ ERROR can't compare
+ //~| ERROR Ord
+}
+
+fn main() {}
diff --git a/tests/ui/range/range_traits-1.stderr b/tests/ui/range/range_traits-1.stderr
new file mode 100644
index 000000000..617afc995
--- /dev/null
+++ b/tests/ui/range/range_traits-1.stderr
@@ -0,0 +1,141 @@
+error[E0277]: can't compare `std::ops::Range<usize>` with `std::ops::Range<usize>`
+ --> $DIR/range_traits-1.rs:5:5
+ |
+LL | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+ | ---------- in this derive macro expansion
+LL | struct AllTheRanges {
+LL | a: Range<usize>,
+ | ^^^^^^^^^^^^^^^ no implementation for `std::ops::Range<usize> < std::ops::Range<usize>` and `std::ops::Range<usize> > std::ops::Range<usize>`
+ |
+ = help: the trait `PartialOrd` is not implemented for `std::ops::Range<usize>`
+ = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: can't compare `std::ops::RangeTo<usize>` with `std::ops::RangeTo<usize>`
+ --> $DIR/range_traits-1.rs:8:5
+ |
+LL | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+ | ---------- in this derive macro expansion
+...
+LL | b: RangeTo<usize>,
+ | ^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeTo<usize> < std::ops::RangeTo<usize>` and `std::ops::RangeTo<usize> > std::ops::RangeTo<usize>`
+ |
+ = help: the trait `PartialOrd` is not implemented for `std::ops::RangeTo<usize>`
+ = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: can't compare `std::ops::RangeFrom<usize>` with `std::ops::RangeFrom<usize>`
+ --> $DIR/range_traits-1.rs:11:5
+ |
+LL | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+ | ---------- in this derive macro expansion
+...
+LL | c: RangeFrom<usize>,
+ | ^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeFrom<usize> < std::ops::RangeFrom<usize>` and `std::ops::RangeFrom<usize> > std::ops::RangeFrom<usize>`
+ |
+ = help: the trait `PartialOrd` is not implemented for `std::ops::RangeFrom<usize>`
+ = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: can't compare `std::ops::RangeFull` with `std::ops::RangeFull`
+ --> $DIR/range_traits-1.rs:14:5
+ |
+LL | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+ | ---------- in this derive macro expansion
+...
+LL | d: RangeFull,
+ | ^^^^^^^^^^^^ no implementation for `std::ops::RangeFull < std::ops::RangeFull` and `std::ops::RangeFull > std::ops::RangeFull`
+ |
+ = help: the trait `PartialOrd` is not implemented for `std::ops::RangeFull`
+ = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: can't compare `std::ops::RangeInclusive<usize>` with `std::ops::RangeInclusive<usize>`
+ --> $DIR/range_traits-1.rs:17:5
+ |
+LL | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+ | ---------- in this derive macro expansion
+...
+LL | e: RangeInclusive<usize>,
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeInclusive<usize> < std::ops::RangeInclusive<usize>` and `std::ops::RangeInclusive<usize> > std::ops::RangeInclusive<usize>`
+ |
+ = help: the trait `PartialOrd` is not implemented for `std::ops::RangeInclusive<usize>`
+ = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: can't compare `std::ops::RangeToInclusive<usize>` with `std::ops::RangeToInclusive<usize>`
+ --> $DIR/range_traits-1.rs:20:5
+ |
+LL | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+ | ---------- in this derive macro expansion
+...
+LL | f: RangeToInclusive<usize>,
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeToInclusive<usize> < std::ops::RangeToInclusive<usize>` and `std::ops::RangeToInclusive<usize> > std::ops::RangeToInclusive<usize>`
+ |
+ = help: the trait `PartialOrd` is not implemented for `std::ops::RangeToInclusive<usize>`
+ = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: the trait bound `std::ops::Range<usize>: Ord` is not satisfied
+ --> $DIR/range_traits-1.rs:5:5
+ |
+LL | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+ | --- in this derive macro expansion
+LL | struct AllTheRanges {
+LL | a: Range<usize>,
+ | ^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::Range<usize>`
+ |
+ = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: the trait bound `std::ops::RangeTo<usize>: Ord` is not satisfied
+ --> $DIR/range_traits-1.rs:8:5
+ |
+LL | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+ | --- in this derive macro expansion
+...
+LL | b: RangeTo<usize>,
+ | ^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeTo<usize>`
+ |
+ = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: the trait bound `std::ops::RangeFrom<usize>: Ord` is not satisfied
+ --> $DIR/range_traits-1.rs:11:5
+ |
+LL | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+ | --- in this derive macro expansion
+...
+LL | c: RangeFrom<usize>,
+ | ^^^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeFrom<usize>`
+ |
+ = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: the trait bound `std::ops::RangeFull: Ord` is not satisfied
+ --> $DIR/range_traits-1.rs:14:5
+ |
+LL | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+ | --- in this derive macro expansion
+...
+LL | d: RangeFull,
+ | ^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeFull`
+ |
+ = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: the trait bound `std::ops::RangeInclusive<usize>: Ord` is not satisfied
+ --> $DIR/range_traits-1.rs:17:5
+ |
+LL | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+ | --- in this derive macro expansion
+...
+LL | e: RangeInclusive<usize>,
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeInclusive<usize>`
+ |
+ = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: the trait bound `std::ops::RangeToInclusive<usize>: Ord` is not satisfied
+ --> $DIR/range_traits-1.rs:20:5
+ |
+LL | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+ | --- in this derive macro expansion
+...
+LL | f: RangeToInclusive<usize>,
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeToInclusive<usize>`
+ |
+ = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 12 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/range/range_traits-2.rs b/tests/ui/range/range_traits-2.rs
new file mode 100644
index 000000000..234d7a64d
--- /dev/null
+++ b/tests/ui/range/range_traits-2.rs
@@ -0,0 +1,6 @@
+use std::ops::*;
+
+#[derive(Copy, Clone)] //~ ERROR Copy
+struct R(Range<usize>);
+
+fn main() {}
diff --git a/tests/ui/range/range_traits-2.stderr b/tests/ui/range/range_traits-2.stderr
new file mode 100644
index 000000000..61facba53
--- /dev/null
+++ b/tests/ui/range/range_traits-2.stderr
@@ -0,0 +1,13 @@
+error[E0204]: the trait `Copy` may not be implemented for this type
+ --> $DIR/range_traits-2.rs:3:10
+ |
+LL | #[derive(Copy, Clone)]
+ | ^^^^
+LL | struct R(Range<usize>);
+ | ------------ this field does not implement `Copy`
+ |
+ = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0204`.
diff --git a/tests/ui/range/range_traits-3.rs b/tests/ui/range/range_traits-3.rs
new file mode 100644
index 000000000..2d597cce5
--- /dev/null
+++ b/tests/ui/range/range_traits-3.rs
@@ -0,0 +1,6 @@
+use std::ops::*;
+
+#[derive(Copy, Clone)] //~ ERROR Copy
+struct R(RangeFrom<usize>);
+
+fn main() {}
diff --git a/tests/ui/range/range_traits-3.stderr b/tests/ui/range/range_traits-3.stderr
new file mode 100644
index 000000000..e54d17b32
--- /dev/null
+++ b/tests/ui/range/range_traits-3.stderr
@@ -0,0 +1,13 @@
+error[E0204]: the trait `Copy` may not be implemented for this type
+ --> $DIR/range_traits-3.rs:3:10
+ |
+LL | #[derive(Copy, Clone)]
+ | ^^^^
+LL | struct R(RangeFrom<usize>);
+ | ---------------- this field does not implement `Copy`
+ |
+ = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0204`.
diff --git a/tests/ui/range/range_traits-4.rs b/tests/ui/range/range_traits-4.rs
new file mode 100644
index 000000000..b8e88559b
--- /dev/null
+++ b/tests/ui/range/range_traits-4.rs
@@ -0,0 +1,9 @@
+// build-pass (FIXME(62277): could be check-pass?)
+
+use std::ops::*;
+
+#[derive(Copy, Clone)]
+struct R(RangeTo<usize>);
+
+
+fn main() {}
diff --git a/tests/ui/range/range_traits-5.rs b/tests/ui/range/range_traits-5.rs
new file mode 100644
index 000000000..4aec7a415
--- /dev/null
+++ b/tests/ui/range/range_traits-5.rs
@@ -0,0 +1,9 @@
+// build-pass (FIXME(62277): could be check-pass?)
+
+use std::ops::*;
+
+#[derive(Copy, Clone)]
+struct R(RangeFull);
+
+
+fn main() {}
diff --git a/tests/ui/range/range_traits-6.rs b/tests/ui/range/range_traits-6.rs
new file mode 100644
index 000000000..bce106bbf
--- /dev/null
+++ b/tests/ui/range/range_traits-6.rs
@@ -0,0 +1,6 @@
+use std::ops::*;
+
+#[derive(Copy, Clone)] //~ ERROR Copy
+struct R(RangeInclusive<usize>);
+
+fn main() {}
diff --git a/tests/ui/range/range_traits-6.stderr b/tests/ui/range/range_traits-6.stderr
new file mode 100644
index 000000000..addc525f1
--- /dev/null
+++ b/tests/ui/range/range_traits-6.stderr
@@ -0,0 +1,13 @@
+error[E0204]: the trait `Copy` may not be implemented for this type
+ --> $DIR/range_traits-6.rs:3:10
+ |
+LL | #[derive(Copy, Clone)]
+ | ^^^^
+LL | struct R(RangeInclusive<usize>);
+ | --------------------- this field does not implement `Copy`
+ |
+ = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0204`.
diff --git a/tests/ui/range/range_traits-7.rs b/tests/ui/range/range_traits-7.rs
new file mode 100644
index 000000000..c7b310562
--- /dev/null
+++ b/tests/ui/range/range_traits-7.rs
@@ -0,0 +1,9 @@
+// build-pass (FIXME(62277): could be check-pass?)
+
+use std::ops::*;
+
+#[derive(Copy, Clone)]
+struct R(RangeToInclusive<usize>);
+
+
+fn main() {}