Skip to content

Commit 28c6d0b

Browse files
committed
Add the edition guide link from the match 2024 migration lint to the error as well
1 parent 77e9051 commit 28c6d0b

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

compiler/rustc_mir_build/src/thir/pattern/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ pub(super) fn pat_from_hir<'a, 'tcx>(
7070
if is_hard_error {
7171
let mut err =
7272
tcx.dcx().struct_span_err(spans, fluent::mir_build_rust_2024_incompatible_pat);
73+
if let Some(info) = lint::builtin::RUST_2024_INCOMPATIBLE_PAT.future_incompatible {
74+
// provide the same reference link as the lint
75+
err.note(format!("for more information, see {}", info.reference));
76+
}
7377
err.subdiagnostic(sugg);
7478
err.emit();
7579
} else {

tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {
210210
| |
211211
| requires binding by-value, but the implicit default is by-reference
212212
|
213+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
213214
= note: this error originates in the macro `migration_lint_macros::mixed_edition_pat` (in Nightly builds, run with -Z macro-backtrace for more info)
214215
help: make the implied reference pattern explicit
215216
|

tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr

+7
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ error: this pattern relies on behavior which may change in edition 2024
105105
LL | test_pat_on_type![(&x,): &(&T,)];
106106
| ^ cannot implicitly match against multiple layers of reference
107107
|
108+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
108109
help: make the implied reference pattern explicit
109110
|
110111
LL | test_pat_on_type![&(&x,): &(&T,)];
@@ -116,6 +117,7 @@ error: this pattern relies on behavior which may change in edition 2024
116117
LL | test_pat_on_type![(&mut x,): &(&mut T,)];
117118
| ^^^^ cannot implicitly match against multiple layers of reference
118119
|
120+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
119121
help: make the implied reference pattern explicit
120122
|
121123
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
127129
LL | test_pat_on_type![Foo { f: &(x,) }: &Foo];
128130
| ^ cannot implicitly match against multiple layers of reference
129131
|
132+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
130133
help: make the implied reference pattern explicit
131134
|
132135
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
138141
LL | test_pat_on_type![(mut x,): &(T,)];
139142
| ^^^ requires binding by-value, but the implicit default is by-reference
140143
|
144+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
141145
help: make the implied reference pattern explicit
142146
|
143147
LL | test_pat_on_type![&(mut x,): &(T,)];
@@ -149,6 +153,7 @@ error: this pattern relies on behavior which may change in edition 2024
149153
LL | test_pat_on_type![(ref x,): &(T,)];
150154
| ^^^ cannot override to bind by-reference when that is the implicit default
151155
|
156+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
152157
help: make the implied reference pattern explicit
153158
|
154159
LL | test_pat_on_type![&(ref x,): &(T,)];
@@ -160,6 +165,7 @@ error: this pattern relies on behavior which may change in edition 2024
160165
LL | test_pat_on_type![(ref mut x,): &mut (T,)];
161166
| ^^^^^^^ cannot override to bind by-reference when that is the implicit default
162167
|
168+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
163169
help: make the implied reference pattern explicit
164170
|
165171
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
171177
LL | (&x,) => x,
172178
| ^ cannot implicitly match against multiple layers of reference
173179
|
180+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
174181
help: make the implied reference pattern explicit
175182
|
176183
LL | &(&x,) => x,

0 commit comments

Comments
 (0)