Skip to content

Commit

Permalink
Update tests for new TRPL chapter order
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskrycho committed Nov 6, 2024
1 parent 067d952 commit 71d9ad3
Show file tree
Hide file tree
Showing 57 changed files with 138 additions and 138 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ fn report_unexpected_variant_res(
.with_code(err_code);
match res {
Res::Def(DefKind::Fn | DefKind::AssocFn, _) if err_code == E0164 => {
let patterns_url = "https://doc.rust-lang.org/book/ch18-00-patterns.html";
let patterns_url = "https://doc.rust-lang.org/book/ch19-00-patterns.html";
err.with_span_label(span, "`fn` calls are not allowed in patterns")
.with_help(format!("for more information, visit {patterns_url}"))
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
let PathSource::TupleStruct(_, _) = source else { return };
let Some(Res::Def(DefKind::Fn, _)) = res else { return };
err.primary_message("expected a pattern, found a function call");
err.note("function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html>");
err.note("function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>");
}

fn suggest_changing_type_to_const_param(
Expand Down
14 changes: 7 additions & 7 deletions tests/ui/closures/2229_closure_analysis/bad-pattern.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let 0 = v1;
| ^ pattern `1_u32..=u32::MAX` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `u32`
help: you might want to use `if let` to ignore the variant that isn't matched
|
Expand All @@ -23,7 +23,7 @@ LL | let (0 | 1) = v1;
| ^^^^^ pattern `2_u32..=u32::MAX` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `u32`
help: you might want to use `if let` to ignore the variant that isn't matched
|
Expand All @@ -37,7 +37,7 @@ LL | let 1.. = v1;
| ^^^ pattern `0_u32` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `u32`
help: you might want to use `if let` to ignore the variant that isn't matched
|
Expand All @@ -51,7 +51,7 @@ LL | let [0, 0, 0, 0] = v2;
| ^^^^^^^^^^^^ pattern `[1_u32..=u32::MAX, _, _, _]` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `[u32; 4]`
help: you might want to use `if let` to ignore the variant that isn't matched
|
Expand All @@ -65,7 +65,7 @@ LL | let [0] = v4;
| ^^^ patterns `&[]` and `&[_, _, ..]` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `&[u32]`
help: you might want to use `if let` to ignore the variants that aren't matched
|
Expand All @@ -79,7 +79,7 @@ LL | let Refutable::A = v3;
| ^^^^^^^^^^^^ pattern `Refutable::B` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
note: `Refutable` defined here
--> $DIR/bad-pattern.rs:4:6
|
Expand All @@ -105,7 +105,7 @@ LL | let PAT = v1;
| help: introduce a variable instead: `PAT_var`
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `u32`

error: aborting due to 7 previous errors
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/const-match-check.eval1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | A = { let 0 = 0; 0 },
| ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `i32`
help: you might want to use `if let` to ignore the variants that aren't matched
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/const-match-check.eval2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let x: [i32; { let 0 = 0; 0 }] = [];
| ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `i32`
help: you might want to use `if let` to ignore the variants that aren't matched
|
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/consts/const-match-check.matchck.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | const X: i32 = { let 0 = 0; 0 };
| ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `i32`
help: you might want to use `if let` to ignore the variants that aren't matched
|
Expand All @@ -23,7 +23,7 @@ LL | static Y: i32 = { let 0 = 0; 0 };
| ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `i32`
help: you might want to use `if let` to ignore the variants that aren't matched
|
Expand All @@ -41,7 +41,7 @@ LL | const X: i32 = { let 0 = 0; 0 };
| ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `i32`
help: you might want to use `if let` to ignore the variants that aren't matched
|
Expand All @@ -59,7 +59,7 @@ LL | const X: i32 = { let 0 = 0; 0 };
| ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `i32`
help: you might want to use `if let` to ignore the variants that aren't matched
|
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/consts/const-pattern-irrefutable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | let a = 4;
| help: introduce a variable instead: `a_var`
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `u8`

error[E0005]: refutable pattern in local binding
Expand All @@ -23,7 +23,7 @@ LL | let c = 4;
| help: introduce a variable instead: `c_var`
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `u8`

error[E0005]: refutable pattern in local binding
Expand All @@ -37,7 +37,7 @@ LL | let d = 4;
| help: introduce a variable instead: `d_var`
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `u8`

error: aborting due to 3 previous errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | None = Some(3);
| ^^^^ pattern `Some(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `Option<i32>`
help: you might want to use `if let` to ignore the variant that isn't matched
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/empty/empty-never-array.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let Helper::U(u) = Helper::T(t, []);
| ^^^^^^^^^^^^ pattern `Helper::T(_, _)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
note: `Helper<T, U>` defined here
--> $DIR/empty-never-array.rs:3:6
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0005.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let Some(y) = x;
| ^^^^^^^ pattern `None` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `Option<i32>`
help: you might want to use `let else` to handle the variant that isn't matched
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let Ok(_x) = &foo();
| ^^^^^^ pattern `&Err(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `&Result<u32, !>`
help: you might want to use `let else` to handle the variant that isn't matched
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `[i32::MIN..=2_i32, ..]` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `[i32; 8]`
help: you might want to use `let else` to handle the variant that isn't matched
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ LL | mac!(0);
| ------- in this macro invocation
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `i32`
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ LL | mac!(0);
| ------- in this macro invocation
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `i32`
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)

Expand All @@ -108,7 +108,7 @@ LL | mac!(0);
| ------- in this macro invocation
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `i32`
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: expected a pattern range bound, found an expression
LL | 0..5+1 => errors_only.push(x),
| ^^^ not a pattern
|
= note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html>
= note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>
help: consider extracting the expression into a `const`
|
LL + const VAL: /* Type */ = 5+1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ error: expected a pattern range bound, found an expression
LL | 0..=(5+1) => errors_only.push(x),
| ^^^ not a pattern
|
= note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html>
= note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>
help: consider extracting the expression into a `const`
|
LL + const VAL: /* Type */ = 5+1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `[i32::MIN..=2_i32, ..]` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `[i32; 8]`
help: you might want to use `let else` to handle the variant that isn't matched
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-55587.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0164]: expected tuple struct or tuple variant, found associated function
LL | let Path::new();
| ^^^^^^^^^^^ `fn` calls are not allowed in patterns
|
= help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html
= help: for more information, visit https://doc.rust-lang.org/book/ch19-00-patterns.html

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let Some(x);
| ^^^^^^^ pattern `None` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `Option<i32>`

error: aborting due to 1 previous error
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/loops/loop-else-break-with-value.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LL | let Some(1) = loop {
| ^^^^^^^ pattern `None` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `Option<i32>`
help: you might want to use `if let` to ignore the variant that isn't matched
|
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/match/match-fn-call.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ error[E0164]: expected tuple struct or tuple variant, found associated function
LL | Path::new("foo") => println!("foo"),
| ^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
|
= help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html
= help: for more information, visit https://doc.rust-lang.org/book/ch19-00-patterns.html

error[E0164]: expected tuple struct or tuple variant, found associated function `Path::new`
--> $DIR/match-fn-call.rs:8:9
|
LL | Path::new("bar") => println!("bar"),
| ^^^^^^^^^^^^^^^^ `fn` calls are not allowed in patterns
|
= help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html
= help: for more information, visit https://doc.rust-lang.org/book/ch19-00-patterns.html

error: aborting due to 2 previous errors

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/mir/issue-112269.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | let x: i32 = 3;
| help: introduce a variable instead: `x_var`
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `i32`

error[E0005]: refutable pattern in local binding
Expand All @@ -23,7 +23,7 @@ LL | let y = 4;
| help: introduce a variable instead: `y_var`
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
= note: the matched value is of type `i32`

error: aborting due to 2 previous errors
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/never_type/exhaustive_patterns.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let Either::A(()) = foo();
| ^^^^^^^^^^^^^ pattern `Either::B(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
note: `Either<(), !>` defined here
--> $DIR/exhaustive_patterns.rs:9:6
|
Expand Down
Loading

0 comments on commit 71d9ad3

Please sign in to comment.