Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #131792

Merged
merged 26 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b8615aa
Move existing rfc3627 tests to a dedicated folder
Nadrieril Sep 24, 2024
c22588b
Add `min_match_ergonomics_2024` feature gate
Nadrieril Sep 20, 2024
94ab726
Add 'from_ref' and 'from_mut' constructors to 'core::ptr::NonNull';
bjoernager Sep 25, 2024
4abbdfa
Prepare tests
Nadrieril Oct 6, 2024
4107322
Error on resetted binding mode in edition 2024
Nadrieril Oct 6, 2024
575033c
Also disallow `ref`/`ref mut` overriding the binding mode
Nadrieril Oct 7, 2024
4aaada4
Stabilize `min_match_ergonomics_2024`
Nadrieril Oct 7, 2024
2ef0a8f
Change error message
Nadrieril Oct 7, 2024
67b85e2
Add fast-path when computing the default visibility
Urgau Oct 14, 2024
50b8029
Always recurse on predicates in BestObligation
compiler-errors Oct 14, 2024
fd2038d
Make sure the alias is actually rigid
compiler-errors Oct 14, 2024
8528387
Be better at reporting alias errors
compiler-errors Oct 14, 2024
0ead25c
Register a dummy candidate for failed structural normalization during…
compiler-errors Oct 14, 2024
f956dc2
Bless tests
compiler-errors Oct 16, 2024
b2b4ad4
Fix explicit_iter_loop in rustc_serialize
practicalrs Oct 16, 2024
6d82559
rustdoc: Rename "object safe" to "dyn compatible"
fmease Oct 12, 2024
8991fd4
Ignore lint-non-snake-case-crate#proc_macro_ on targets without unwind
c6c7 Oct 15, 2024
682bca3
Fix mismatched quotation mark
dufucun Oct 16, 2024
1817de6
Rollup merge of #130822 - bjoernager:non-null-from-ref, r=dtolnay
matthiaskrgr Oct 16, 2024
c1ed1f1
Rollup merge of #131381 - Nadrieril:min-match-ergonomics, r=pnkfelix
matthiaskrgr Oct 16, 2024
7047748
Rollup merge of #131594 - fmease:rustdoc-mv-obj-safe-dyn-compat, r=no…
matthiaskrgr Oct 16, 2024
2560453
Rollup merge of #131686 - Urgau:fast-path-vis, r=lqd
matthiaskrgr Oct 16, 2024
aac91f7
Rollup merge of #131699 - compiler-errors:better-errors-for-projectio…
matthiaskrgr Oct 16, 2024
1014970
Rollup merge of #131757 - c6c7:fixup-lint-non-snake-case-crate, r=jie…
matthiaskrgr Oct 16, 2024
75f418f
Rollup merge of #131783 - practicalrs:fix_explicit_iter_loop, r=compi…
matthiaskrgr Oct 16, 2024
06cd22c
Rollup merge of #131788 - dufucun:master, r=lqd
matthiaskrgr Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change error message
  • Loading branch information
Nadrieril committed Oct 7, 2024
commit 2ef0a8fdfd5142e8a524f4dc9fff8c65d0bd7cc2
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ mir_build_pointer_pattern = function pointers and raw pointers not derived from

mir_build_privately_uninhabited = pattern `{$witness_1}` is currently uninhabited, but this variant contains private fields which may become inhabited in the future

mir_build_rust_2024_incompatible_pat = the semantics of this pattern will change in edition 2024
mir_build_rust_2024_incompatible_pat = patterns are not allowed to reset the default binding mode in edition 2024

mir_build_rustc_box_attribute_error = `#[rustc_box]` attribute used incorrectly
.attributes = no other attributes may be applied
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_mir_build/src/thir/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use tracing::{debug, instrument};

pub(crate) use self::check_match::check_match;
use crate::errors::*;
use crate::fluent_generated as fluent;
use crate::thir::util::UserAnnotatedTyHelpers;

struct PatCtxt<'a, 'tcx> {
Expand Down Expand Up @@ -58,10 +59,8 @@ pub(super) fn pat_from_hir<'a, 'tcx>(
debug!("pat_from_hir({:?}) = {:?}", pat, result);
if let Some(sugg) = pcx.rust_2024_migration_suggestion {
if sugg.is_hard_error {
let mut err = tcx.dcx().struct_span_err(
pat.span,
"patterns are not allowed to reset the default binding mode in rust 2024",
);
let mut err =
tcx.dcx().struct_span_err(pat.span, fluent::mir_build_rust_2024_incompatible_pat);
err.subdiagnostic(sugg);
err.emit();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ fn main() {
assert_type_eq(x, &mut 0u8);

let &Foo(mut x) = &Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);

let &mut Foo(mut x) = &mut Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);

let &Foo(ref x) = &Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);

let &mut Foo(ref x) = &mut Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);

Expand All @@ -55,22 +55,22 @@ fn main() {
assert_type_eq(x, &0u8);

let &Foo(&x) = &Foo(&0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);

let &Foo(&mut x) = &Foo(&mut 0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);

let &mut Foo(&x) = &mut Foo(&0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);

let &mut Foo(&mut x) = &mut Foo(&mut 0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);

Expand All @@ -79,25 +79,25 @@ fn main() {
}

if let &&&&&Some(&x) = &&&&&Some(&0u8) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}

if let &&&&&Some(&mut x) = &&&&&Some(&mut 0u8) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}

if let &&&&&mut Some(&x) = &&&&&mut Some(&0u8) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}

if let &mut Some(&mut Some(&mut Some(ref mut x))) = &mut Some(&mut Some(&mut Some(0u8))) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &mut 0u8);
}
Expand All @@ -109,20 +109,20 @@ fn main() {
}

let &Struct { ref a, mut b, ref c } = &Struct { a: 0, b: 0, c: 0 };
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, 0u32);

let &Struct { a: &a, ref b, ref c } = &Struct { a: &0, b: &0, c: &0 };
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, 0u32);
assert_type_eq(b, &&0u32);
assert_type_eq(c, &&0u32);

if let &Struct { a: &Some(a), b: &Some(&b), c: &Some(ref c) } =
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
&(Struct { a: &Some(&0), b: &Some(&0), c: &Some(&0) })
{
Expand Down
30 changes: 15 additions & 15 deletions tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ fn main() {
assert_type_eq(x, &mut 0u8);

let Foo(mut x) = &Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);

let Foo(mut x) = &mut Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);

let Foo(ref x) = &Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);

let Foo(ref x) = &mut Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);

Expand All @@ -55,22 +55,22 @@ fn main() {
assert_type_eq(x, &0u8);

let Foo(&x) = &Foo(&0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);

let Foo(&mut x) = &Foo(&mut 0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);

let Foo(&x) = &mut Foo(&0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);

let Foo(&mut x) = &mut Foo(&mut 0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);

Expand All @@ -79,25 +79,25 @@ fn main() {
}

if let Some(&x) = &&&&&Some(&0u8) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}

if let Some(&mut x) = &&&&&Some(&mut 0u8) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}

if let Some(&x) = &&&&&mut Some(&0u8) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}

if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &mut 0u8);
}
Expand All @@ -109,20 +109,20 @@ fn main() {
}

let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 };
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, 0u32);

let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 };
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, 0u32);
assert_type_eq(b, &&0u32);
assert_type_eq(c, &&0u32);

if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } =
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
&(Struct { a: &Some(&0), b: &Some(&0), c: &Some(&0) })
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:25:9
|
LL | let Foo(mut x) = &Foo(0);
Expand All @@ -14,7 +14,7 @@ note: the lint level is defined here
LL | #![deny(rust_2024_incompatible_pat)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:30:9
|
LL | let Foo(mut x) = &mut Foo(0);
Expand All @@ -25,7 +25,7 @@ LL | let Foo(mut x) = &mut Foo(0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:35:9
|
LL | let Foo(ref x) = &Foo(0);
Expand All @@ -36,7 +36,7 @@ LL | let Foo(ref x) = &Foo(0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:40:9
|
LL | let Foo(ref x) = &mut Foo(0);
Expand All @@ -47,7 +47,7 @@ LL | let Foo(ref x) = &mut Foo(0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:57:9
|
LL | let Foo(&x) = &Foo(&0);
Expand All @@ -58,7 +58,7 @@ LL | let Foo(&x) = &Foo(&0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:62:9
|
LL | let Foo(&mut x) = &Foo(&mut 0);
Expand All @@ -69,7 +69,7 @@ LL | let Foo(&mut x) = &Foo(&mut 0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:67:9
|
LL | let Foo(&x) = &mut Foo(&0);
Expand All @@ -80,7 +80,7 @@ LL | let Foo(&x) = &mut Foo(&0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:72:9
|
LL | let Foo(&mut x) = &mut Foo(&mut 0);
Expand All @@ -91,7 +91,7 @@ LL | let Foo(&mut x) = &mut Foo(&mut 0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:81:12
|
LL | if let Some(&x) = &&&&&Some(&0u8) {
Expand All @@ -102,7 +102,7 @@ LL | if let Some(&x) = &&&&&Some(&0u8) {
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:87:12
|
LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) {
Expand All @@ -113,7 +113,7 @@ LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) {
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:93:12
|
LL | if let Some(&x) = &&&&&mut Some(&0u8) {
Expand All @@ -124,7 +124,7 @@ LL | if let Some(&x) = &&&&&mut Some(&0u8) {
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:99:12
|
LL | if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) {
Expand All @@ -137,7 +137,7 @@ help: desugar the match ergonomics
LL | if let &mut Some(&mut Some(&mut Some(ref mut x))) = &mut Some(&mut Some(&mut Some(0u8))) {
| ++++ ++++ +++++++

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:111:9
|
LL | let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 };
Expand All @@ -150,7 +150,7 @@ help: desugar the match ergonomics
LL | let &Struct { ref a, mut b, ref c } = &Struct { a: 0, b: 0, c: 0 };
| + +++ +++

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:117:9
|
LL | let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 };
Expand All @@ -163,7 +163,7 @@ help: desugar the match ergonomics
LL | let &Struct { a: &a, ref b, ref c } = &Struct { a: &0, b: &0, c: &0 };
| + +++

error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:124:12
|
LL | if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } =
Expand All @@ -176,7 +176,7 @@ help: desugar the match ergonomics
LL | if let &Struct { a: &Some(a), b: &Some(&b), c: &Some(ref c) } =
| + + + +++

error: patterns are not allowed to reset the default binding mode in rust 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:137:9
|
LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {
Expand Down
Loading
Loading