about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-09-18 04:42:31 +0200
committerGitHub <noreply@github.com>2024-09-18 04:42:31 +0200
commit09b255d3d4fdfce05e5878f1e919d5ca84bc9962 (patch)
tree5653b057c14db34c33937e31180428c561ec9141 /tests
parentf7b4c72c8ffb320616bda27f70bb8e0a341673fb (diff)
parent741005792e4209145fce6b354602a00812d52186 (diff)
downloadrust-09b255d3d4fdfce05e5878f1e919d5ca84bc9962.tar.gz
rust-09b255d3d4fdfce05e5878f1e919d5ca84bc9962.zip
Rollup merge of #130116 - veera-sivarajan:freeze-suggestions, r=chenyukang
Implement a Method to Seal `DiagInner`'s Suggestions

This PR adds a method on `DiagInner` called `.seal_suggestions()` to prevent new suggestions from being added while preserving existing suggestions.

This is useful because currently there is no way to prevent new suggestions from being added to a diagnostic. `.disable_suggestions()` is the closest but it gets rid of all suggestions before and after the call.

Therefore, `.seal_suggestions()` can be used when, for example, misspelled keyword is detected and reported. In such cases, we may want to prevent other suggestions from being added to the diagnostic, as they would likely be meaningless once the misspelled keyword is identified. For context: https://github.com/rust-lang/rust/pull/129899#discussion_r1741307132

To store an additional state, the type of the `suggestions` field in `DiagInner` was changed into a three variant enum. While this change affects files across different crates, care was taken to preserve the existing code's semantics. This is validated by the fact that all UI tests pass without any modifications.

r? chenyukang
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr8
-rw-r--r--tests/ui/parser/misspelled-keywords/impl-trait.stderr4
-rw-r--r--tests/ui/parser/misspelled-keywords/ref.stderr4
3 files changed, 0 insertions, 16 deletions
diff --git a/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr
index 00f372bc008..c2c0faa21d1 100644
--- a/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr
+++ b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr
@@ -14,10 +14,6 @@ help: there is a keyword `mut` with a similar name
    |
 LL |     fn foo(&mut Self) {}
    |             ~~~
-help: declare the type after the parameter binding
-   |
-LL |     fn foo(<identifier>: <type>) {}
-   |            ~~~~~~~~~~~~~~~~~~~~
 
 error: unexpected lifetime `'static` in pattern
   --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:13
@@ -47,10 +43,6 @@ help: there is a keyword `mut` with a similar name
    |
 LL |     fn bar(&'static mut Self) {}
    |                     ~~~
-help: declare the type after the parameter binding
-   |
-LL |     fn bar(<identifier>: <type>) {}
-   |            ~~~~~~~~~~~~~~~~~~~~
 
 error: expected one of `:`, `@`, or `|`, found keyword `Self`
   --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:14:17
diff --git a/tests/ui/parser/misspelled-keywords/impl-trait.stderr b/tests/ui/parser/misspelled-keywords/impl-trait.stderr
index 15a8f99b8b1..02a0c808311 100644
--- a/tests/ui/parser/misspelled-keywords/impl-trait.stderr
+++ b/tests/ui/parser/misspelled-keywords/impl-trait.stderr
@@ -8,10 +8,6 @@ help: there is a keyword `impl` with a similar name
    |
 LL | fn code<T: impl Debug>() -> u8 {}
    |            ~~~~
-help: you might have meant to end the type parameters here
-   |
-LL | fn code<T: impll> Debug>() -> u8 {}
-   |                 +
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/parser/misspelled-keywords/ref.stderr b/tests/ui/parser/misspelled-keywords/ref.stderr
index 3a79b7bdb00..b8b52702314 100644
--- a/tests/ui/parser/misspelled-keywords/ref.stderr
+++ b/tests/ui/parser/misspelled-keywords/ref.stderr
@@ -8,10 +8,6 @@ help: there is a keyword `ref` with a similar name
    |
 LL |         Some(ref list) => println!("{list:?}"),
    |              ~~~
-help: missing `,`
-   |
-LL |         Some(refe, list) => println!("{list:?}"),
-   |                  +
 
 error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has 1 field
   --> $DIR/ref.rs:4:14