about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRowan S-L <r@fawkes.io>2024-01-19 13:37:18 -0500
committerRowan S-L <r@fawkes.io>2024-01-19 13:38:24 -0500
commit1c77f8738fdb33412bbd6ae83c16fe9cc6356815 (patch)
tree8eea5b32e4657c1c061f72bbba0da217e0e7d9d4
parent32ec40c68533f325a3c8fe787b77ef5c9e209b23 (diff)
downloadrust-1c77f8738fdb33412bbd6ae83c16fe9cc6356815.tar.gz
rust-1c77f8738fdb33412bbd6ae83c16fe9cc6356815.zip
add help message for `exclusive_range_pattern` error
-rw-r--r--compiler/rustc_ast_passes/src/feature_gate.rs3
-rw-r--r--tests/ui/feature-gates/feature-gate-exclusive-range-pattern.stderr1
-rw-r--r--tests/ui/half-open-range-patterns/range_pat_interactions1.stderr2
-rw-r--r--tests/ui/half-open-range-patterns/range_pat_interactions3.stderr4
-rw-r--r--tests/ui/half-open-range-patterns/slice_pattern_syntax_problem1.stderr2
5 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs
index 192e458775a..82236d2e306 100644
--- a/compiler/rustc_ast_passes/src/feature_gate.rs
+++ b/compiler/rustc_ast_passes/src/feature_gate.rs
@@ -398,7 +398,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
                     &self,
                     exclusive_range_pattern,
                     pattern.span,
-                    "exclusive range pattern syntax is experimental"
+                    "exclusive range pattern syntax is experimental",
+                    "use an inclusive range pattern, like N..=M"
                 );
             }
             _ => {}
diff --git a/tests/ui/feature-gates/feature-gate-exclusive-range-pattern.stderr b/tests/ui/feature-gates/feature-gate-exclusive-range-pattern.stderr
index d05971fb052..5e3d34aa9f3 100644
--- a/tests/ui/feature-gates/feature-gate-exclusive-range-pattern.stderr
+++ b/tests/ui/feature-gates/feature-gate-exclusive-range-pattern.stderr
@@ -7,6 +7,7 @@ LL |         0 .. 3 => {}
    = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
    = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = help: use an inclusive range pattern, like N..=M
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/half-open-range-patterns/range_pat_interactions1.stderr b/tests/ui/half-open-range-patterns/range_pat_interactions1.stderr
index e2fab14ffc2..cf3bde9705b 100644
--- a/tests/ui/half-open-range-patterns/range_pat_interactions1.stderr
+++ b/tests/ui/half-open-range-patterns/range_pat_interactions1.stderr
@@ -21,6 +21,7 @@ LL |         if let n @ 2..3|4 = x {
    = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
    = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = help: use an inclusive range pattern, like N..=M
 
 error[E0658]: exclusive range pattern syntax is experimental
   --> $DIR/range_pat_interactions1.rs:14:23
@@ -31,6 +32,7 @@ LL |         } else if let 2..3 | 4 = x {
    = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
    = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = help: use an inclusive range pattern, like N..=M
 
 error: aborting due to 4 previous errors
 
diff --git a/tests/ui/half-open-range-patterns/range_pat_interactions3.stderr b/tests/ui/half-open-range-patterns/range_pat_interactions3.stderr
index fe233496261..51cc22e7d56 100644
--- a/tests/ui/half-open-range-patterns/range_pat_interactions3.stderr
+++ b/tests/ui/half-open-range-patterns/range_pat_interactions3.stderr
@@ -17,6 +17,7 @@ LL |             1 | -3..0 => first_or.push(x),
    = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
    = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = help: use an inclusive range pattern, like N..=M
 
 error[E0658]: exclusive range pattern syntax is experimental
   --> $DIR/range_pat_interactions3.rs:12:18
@@ -27,6 +28,7 @@ LL |             y @ (0..5 | 6) => or_two.push(y),
    = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
    = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = help: use an inclusive range pattern, like N..=M
 
 error[E0658]: exclusive range pattern syntax is experimental
   --> $DIR/range_pat_interactions3.rs:14:17
@@ -37,6 +39,7 @@ LL |             y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
    = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
    = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = help: use an inclusive range pattern, like N..=M
 
 error[E0658]: exclusive range pattern syntax is experimental
   --> $DIR/range_pat_interactions3.rs:18:17
@@ -47,6 +50,7 @@ LL |             y @ ..-7 => assert_eq!(y, -8),
    = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
    = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = help: use an inclusive range pattern, like N..=M
 
 error: aborting due to 5 previous errors
 
diff --git a/tests/ui/half-open-range-patterns/slice_pattern_syntax_problem1.stderr b/tests/ui/half-open-range-patterns/slice_pattern_syntax_problem1.stderr
index 5edd877bee0..be8f3aa5051 100644
--- a/tests/ui/half-open-range-patterns/slice_pattern_syntax_problem1.stderr
+++ b/tests/ui/half-open-range-patterns/slice_pattern_syntax_problem1.stderr
@@ -17,6 +17,7 @@ LL |     let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;
    = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
    = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = help: use an inclusive range pattern, like N..=M
 
 error[E0658]: exclusive range pattern syntax is experimental
   --> $DIR/slice_pattern_syntax_problem1.rs:4:32
@@ -27,6 +28,7 @@ LL |     let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;
    = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
    = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = help: use an inclusive range pattern, like N..=M
 
 error: aborting due to 3 previous errors