rust/src/test/ui/pattern
Yuki Okushi 52afa3a70c
Rollup merge of #97964 - WaffleLapkin:fix_borrow_par_suggestions, r=compiler-errors
Fix suggestions for `&a: T` parameters

I've accidentally discovered that we have broken suggestions for `&a: T` parameters:
```rust
fn f(&mut bar: u32) {}

fn main() {
    let _ = |&mut a| ();
}
```
```text
error[E0308]: mismatched types
 --> ./t.rs:1:6
  |
1 | fn f(&mut bar: u32) {}
  |      ^^^^^^^^-----
  |      |         |
  |      |         expected due to this
  |      expected `u32`, found `&mut _`
  |      help: did you mean `bar`: `&u32`
  |
  = note:           expected type `u32`
          found mutable reference `&mut _`

error[E0308]: mismatched types
 --> ./t.rs:4:23
  |
4 |     let _: fn(u32) = |&mut a| ();
  |                       ^^^^^--
  |                       |    |
  |                       |    expected due to this
  |                       expected `u32`, found `&mut _`
  |                       help: did you mean `a`: `&u32`
  |
  = note:           expected type `u32`
          found mutable reference `&mut _`
```

It's hard to see, but
1. The help span is overlapping with "expected" spans
2. It suggests `fn f( &u32) {}` (no `mut` and lost parameter name) and `|&u32 ()` (no closing `|` and lost parameter name)

I've tried to fix this.

r? ``@compiler-errors``
2022-06-16 07:24:39 +09:00
..
auxiliary Add cross-crate tuple field count error test 2021-08-21 16:15:09 -07:00
bindings-after-at Edit explanation of test for nested type ascriptions 2021-10-11 12:56:55 -05:00
move-ref-patterns Auto merge of #85305 - MarcusDunn:master, r=pnkfelix 2021-07-27 05:53:31 +00:00
usefulness Make [e]println macros eagerly drop temporaries (for backport) 2022-04-27 13:22:41 -07:00
for-loop-bad-item.rs Note pattern mismatch coming from for-loop desugaring 2022-05-29 13:01:59 -07:00
for-loop-bad-item.stderr Fix suggestions for &a: T parameters 2022-06-10 23:43:01 +04:00
ignore-all-the-things.rs Move some tests to more reasonable directories 2021-11-18 12:09:34 -03:00
integer-range-binding.rs Improve integer range tests 2020-11-21 01:38:42 +00:00
issue-6449.rs Move some tests to more reasonable directories - 2 2021-01-16 19:46:54 -03:00
issue-8351-1.rs Move some tests to more reasonable directories 2021-11-06 15:35:20 -03:00
issue-8351-2.rs Move some tests to more reasonable directories 2021-11-06 15:35:20 -03:00
issue-10392.rs Move some tests to more reasonable directories - 5 2021-03-20 11:41:24 -03:00
issue-11577.rs Move some tests to more reasonable directories 2021-11-06 15:35:20 -03:00
issue-12582.rs Move some tests to more reasonable directories - 2 2021-01-16 19:46:54 -03:00
issue-14221.rs Move some tests to more reasonable directories - 2 2021-01-16 19:46:54 -03:00
issue-14221.stderr Move some tests to more reasonable directories - 2 2021-01-16 19:46:54 -03:00
issue-15080.rs Move some tests to more reasonable directories 2021-11-06 15:35:20 -03:00
issue-22546.rs Move some tests to more reasonable directories - 2 2021-01-16 19:46:54 -03:00
issue-27320.rs Move tests 2022-05-20 10:53:58 -03:00
issue-66270-pat-struct-parser-recovery.rs
issue-66270-pat-struct-parser-recovery.stderr
issue-67037-pat-tup-scrut-ty-diff-less-fields.rs Some "parenthesis" and "parentheses" fixes 2021-10-17 12:04:01 +02:00
issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr Adjust spans 2021-08-25 14:40:06 -07:00
issue-67776-match-same-name-enum-variant-refs.rs
issue-67776-match-same-name-enum-variant-refs.stderr
issue-68393-let-pat-assoc-constant.rs
issue-68393-let-pat-assoc-constant.stderr
issue-72565.rs Add a regression test for issue-72565 2020-10-01 14:10:33 +09:00
issue-72565.stderr Add a regression test for issue-72565 2020-10-01 14:10:33 +09:00
issue-72574-1.rs Move some tests to more reasonable places 2022-04-26 23:38:04 -03:00
issue-72574-1.stderr Move some tests to more reasonable places 2022-04-26 23:38:04 -03:00
issue-72574-2.rs Move some tests to more reasonable directories 2021-11-06 15:35:20 -03:00
issue-72574-2.stderr Move some tests to more reasonable directories 2021-11-06 15:35:20 -03:00
issue-74539.rs
issue-74539.stderr Adjust spans 2021-08-25 14:40:06 -07:00
issue-74702.rs
issue-74702.stderr Point (again) to more expressions with their type, even if not fully resolved 2022-03-27 02:20:17 +00:00
issue-74954.rs
issue-80186-mut-binding-help-suggestion.rs Fix pretty printing an AST representing &(mut ident) 2020-12-20 13:11:07 +01:00
issue-80186-mut-binding-help-suggestion.stderr Fix pretty printing an AST representing &(mut ident) 2020-12-20 13:11:07 +01:00
issue-88074-pat-range-type-inference-err.rs Add a range pattern inference failing test 2021-09-10 21:28:11 +01:00
issue-88074-pat-range-type-inference-err.stderr Add a range pattern inference failing test 2021-09-10 21:28:11 +01:00
issue-88074-pat-range-type-inference.rs Add ui test for issue 88074 2021-09-10 21:28:11 +01:00
issue-92074-macro-ice.rs Move PatKind::Lit checking from ast_validation to ast lowering 2022-01-01 15:10:43 -05:00
issue-92074-macro-ice.stderr Move PatKind::Lit checking from ast_validation to ast lowering 2022-01-01 15:10:43 -05:00
issue-95878.rs Delay a bug when we see SelfCtor in ref pattern 2022-04-10 20:55:10 -07:00
issue-95878.stderr Delay a bug when we see SelfCtor in ref pattern 2022-04-10 20:55:10 -07:00
non-constant-in-const-path.rs Refactor PatternError structure 2021-06-19 11:47:15 +09:00
non-constant-in-const-path.stderr Refactor PatternError structure 2021-06-19 11:47:15 +09:00
non-structural-match-types.rs Split inline const to two feature gates 2021-11-22 22:17:03 +00:00
non-structural-match-types.stderr Restore impl Future<Output = Type> to async blocks 2022-03-30 19:26:35 -07:00
pat-shadow-in-nested-binding.rs
pat-shadow-in-nested-binding.stderr
pat-struct-field-expr-has-type.rs
pat-struct-field-expr-has-type.stderr path trimming: ignore type aliases 2021-02-06 12:03:48 +02:00
pat-tuple-bad-type.rs add new emit_inference_failure_err 2022-06-02 10:19:15 +02:00
pat-tuple-bad-type.stderr add new emit_inference_failure_err 2022-06-02 10:19:15 +02:00
pat-tuple-field-count-cross.rs Add cross-crate tuple field count error test 2021-08-21 16:15:09 -07:00
pat-tuple-field-count-cross.stderr Bless tests. 2022-06-10 20:16:35 +02:00
pat-tuple-overfield.rs Adjust spans 2021-08-25 14:40:06 -07:00
pat-tuple-overfield.stderr Point (again) to more expressions with their type, even if not fully resolved 2022-03-27 02:20:17 +00:00
pat-tuple-underfield.rs Adjust spans 2021-08-25 14:40:06 -07:00
pat-tuple-underfield.stderr Adjust spans 2021-08-25 14:40:06 -07:00
pat-type-err-formal-param.rs
pat-type-err-formal-param.stderr
pat-type-err-let-stmt.rs
pat-type-err-let-stmt.stderr Update tests. 2021-11-16 19:52:59 +01:00
patkind-litrange-no-expr.rs Perform type inference in range pattern 2021-09-10 21:28:11 +01:00
patkind-litrange-no-expr.stderr Perform type inference in range pattern 2021-09-10 21:28:11 +01:00
pattern-binding-disambiguation.rs
pattern-binding-disambiguation.stderr
pattern-error-continue.rs
pattern-error-continue.stderr Implementation for 65853 2022-04-16 02:26:56 -04:00
pattern-ident-path-generics.rs
pattern-ident-path-generics.stderr
pattern-tyvar-2.rs Improve wording of "cannot multiply" type error 2020-10-17 22:19:25 -07:00
pattern-tyvar-2.stderr Improve wording of "cannot multiply" type error 2020-10-17 22:19:25 -07:00
pattern-tyvar.rs
pattern-tyvar.stderr
rest-pat-semantic-disallowed.rs
rest-pat-semantic-disallowed.stderr add new emit_inference_failure_err 2022-06-02 10:19:15 +02:00
rest-pat-syntactic.rs
size-and-align.rs Move some tests to more reasonable directories - 2 2021-01-16 19:46:54 -03:00