diff options
| author | dianne <diannes.gm@gmail.com> | 2024-12-17 12:35:45 -0800 |
|---|---|---|
| committer | dianne <diannes.gm@gmail.com> | 2024-12-17 15:21:28 -0800 |
| commit | 28c6d0b55ba4369ea8e1073228c1b9821ea231d2 (patch) | |
| tree | 25a39b710e8b01209cc8c75a5f4678d8b6ff6f81 | |
| parent | 77e9051e22c89585f0e96f3476edbe664a80ccc0 (diff) | |
| download | rust-28c6d0b55ba4369ea8e1073228c1b9821ea231d2.tar.gz rust-28c6d0b55ba4369ea8e1073228c1b9821ea231d2.zip | |
Add the edition guide link from the match 2024 migration lint to the error as well
3 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 62bbb31440f..bdf243c87b6 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -70,6 +70,10 @@ pub(super) fn pat_from_hir<'a, 'tcx>( if is_hard_error { let mut err = tcx.dcx().struct_span_err(spans, fluent::mir_build_rust_2024_incompatible_pat); + if let Some(info) = lint::builtin::RUST_2024_INCOMPATIBLE_PAT.future_incompatible { + // provide the same reference link as the lint + err.note(format!("for more information, see {}", info.reference)); + } err.subdiagnostic(sugg); err.emit(); } else { diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr index 73b0e4b67d9..83346b9dd4a 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr @@ -210,6 +210,7 @@ LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => { | | | requires binding by-value, but the implicit default is by-reference | + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> = note: this error originates in the macro `migration_lint_macros::mixed_edition_pat` (in Nightly builds, run with -Z macro-backtrace for more info) help: make the implied reference pattern explicit | diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr index 38de6e34cbc..affdca1d449 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr @@ -105,6 +105,7 @@ error: this pattern relies on behavior which may change in edition 2024 LL | test_pat_on_type![(&x,): &(&T,)]; | ^ cannot implicitly match against multiple layers of reference | + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> help: make the implied reference pattern explicit | LL | test_pat_on_type![&(&x,): &(&T,)]; @@ -116,6 +117,7 @@ error: this pattern relies on behavior which may change in edition 2024 LL | test_pat_on_type![(&mut x,): &(&mut T,)]; | ^^^^ cannot implicitly match against multiple layers of reference | + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> help: make the implied reference pattern explicit | LL | test_pat_on_type![&(&mut x,): &(&mut T,)]; @@ -127,6 +129,7 @@ error: this pattern relies on behavior which may change in edition 2024 LL | test_pat_on_type![Foo { f: &(x,) }: &Foo]; | ^ cannot implicitly match against multiple layers of reference | + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> help: make the implied reference pattern explicit | LL | test_pat_on_type![&Foo { f: &(x,) }: &Foo]; @@ -138,6 +141,7 @@ error: this pattern relies on behavior which may change in edition 2024 LL | test_pat_on_type![(mut x,): &(T,)]; | ^^^ requires binding by-value, but the implicit default is by-reference | + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> help: make the implied reference pattern explicit | LL | test_pat_on_type![&(mut x,): &(T,)]; @@ -149,6 +153,7 @@ error: this pattern relies on behavior which may change in edition 2024 LL | test_pat_on_type![(ref x,): &(T,)]; | ^^^ cannot override to bind by-reference when that is the implicit default | + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> help: make the implied reference pattern explicit | LL | test_pat_on_type![&(ref x,): &(T,)]; @@ -160,6 +165,7 @@ error: this pattern relies on behavior which may change in edition 2024 LL | test_pat_on_type![(ref mut x,): &mut (T,)]; | ^^^^^^^ cannot override to bind by-reference when that is the implicit default | + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> help: make the implied reference pattern explicit | LL | test_pat_on_type![&mut (ref mut x,): &mut (T,)]; @@ -171,6 +177,7 @@ error: this pattern relies on behavior which may change in edition 2024 LL | (&x,) => x, | ^ cannot implicitly match against multiple layers of reference | + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> help: make the implied reference pattern explicit | LL | &(&x,) => x, |
