Skip to content

Commit 8045865

Browse files
committed
Auto merge of rust-lang#70370 - petrochenkov:nosmatch, r=Centril
Remove attribute `#[structural_match]` and any references to it A small remaining part of rust-lang#63438.
2 parents 150322f + 7332305 commit 8045865

21 files changed

+43
-48
lines changed

src/libcore/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@
134134
#![feature(f16c_target_feature)]
135135
#![feature(hexagon_target_feature)]
136136
#![feature(const_transmute)]
137-
#![feature(structural_match)]
138137
#![feature(abi_unadjusted)]
139138
#![feature(adx_target_feature)]
140139
#![feature(maybe_uninit_slice)]

src/libcore/marker.rs

-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ macro_rules! impls {
660660
///
661661
/// [drop check]: ../../nomicon/dropck.html
662662
#[lang = "phantom_data"]
663-
#[structural_match]
664663
#[stable(feature = "rust1", since = "1.0.0")]
665664
pub struct PhantomData<T: ?Sized>;
666665

src/librustc/ty/relate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
518518

519519
// Currently, the values that can be unified are primitive types,
520520
// and those that derive both `PartialEq` and `Eq`, corresponding
521-
// to `structural_match` types.
521+
// to structural-match types.
522522
let new_const_val = match (eagerly_eval(a), eagerly_eval(b)) {
523523
(ty::ConstKind::Infer(_), _) | (_, ty::ConstKind::Infer(_)) => {
524524
// The caller should handle these cases!

src/librustc_error_codes/error_codes/E0741.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Only `structural_match` types (that is, types that derive `PartialEq` and `Eq`)
1+
Only structural-match types (that is, types that derive `PartialEq` and `Eq`)
22
may be used as the types of const generic parameters.
33

44
```compile_fail,E0741

src/librustc_feature/active.rs

+2
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ declare_features! (
173173
// no-tracking-issue-end
174174

175175
/// Allows using `#[structural_match]` which indicates that a type is structurally matchable.
176+
/// FIXME: Subsumed by trait `StructuralPartialEq`, cannot move to removed until a library
177+
/// feature with the same name exists.
176178
(active, structural_match, "1.8.0", Some(31434), None),
177179

178180
/// Allows using the `may_dangle` attribute (RFC 1327).

src/librustc_feature/builtin_attrs.rs

-5
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
376376
// ==========================================================================
377377

378378
gated!(fundamental, Whitelisted, template!(Word), experimental!(fundamental)),
379-
gated!(
380-
// RFC #1445.
381-
structural_match, Whitelisted, template!(Word),
382-
"the semantics of constant patterns is not yet settled",
383-
),
384379
gated!(
385380
may_dangle, Normal, template!(Word), dropck_eyepatch,
386381
"`may_dangle` has unstable semantics and may be removed in the future",

src/librustc_session/lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ declare_lint! {
452452
pub INDIRECT_STRUCTURAL_MATCH,
453453
// defaulting to allow until rust-lang/rust#62614 is fixed.
454454
Allow,
455-
"pattern with const indirectly referencing non-`#[structural_match]` type",
455+
"pattern with const indirectly referencing non-structural-match type",
456456
@future_incompatible = FutureIncompatibleInfo {
457457
reference: "issue #62411 <https://github.com/rust-lang/rust/issues/62411>",
458458
edition: None,

src/librustc_trait_selection/traits/structural_match.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ pub enum NonStructuralMatchTy<'tcx> {
1414
}
1515

1616
/// This method traverses the structure of `ty`, trying to find an
17-
/// instance of an ADT (i.e. struct or enum) that was declared without
18-
/// the `#[structural_match]` attribute, or a generic type parameter
19-
/// (which cannot be determined to be `structural_match`).
17+
/// instance of an ADT (i.e. struct or enum) that doesn't implement
18+
/// the structural-match traits, or a generic type parameter
19+
/// (which cannot be determined to be structural-match).
2020
///
2121
/// The "structure of a type" includes all components that would be
2222
/// considered when doing a pattern match on a constant of that
@@ -30,8 +30,8 @@ pub enum NonStructuralMatchTy<'tcx> {
3030
/// instantiated generic like `PhantomData<T>`.
3131
///
3232
/// The reason we do this search is Rust currently require all ADTs
33-
/// reachable from a constant's type to be annotated with
34-
/// `#[structural_match]`, an attribute which essentially says that
33+
/// reachable from a constant's type to implement the
34+
/// structural-match traits, which essentially say that
3535
/// the implementation of `PartialEq::eq` behaves *equivalently* to a
3636
/// comparison against the unfolded structure.
3737
///

src/test/ui/const-generics/const-param-type-depends-on-type-param.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
33

44
// Currently, const parameters cannot depend on type parameters, because there is no way to
5-
// enforce the `structural_match` property on an arbitrary type parameter. This restriction
5+
// enforce the structural-match property on an arbitrary type parameter. This restriction
66
// may be relaxed in the future. See https://github.com/rust-lang/rfcs/pull/2000 for more
77
// details.
88

src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is part of a set of tests exploring the different ways a
2-
// `#[structural_match]` ADT might try to hold a
3-
// non-`#[structural_match]` in hidden manner that lets matches
2+
// structural-match ADT might try to hold a
3+
// non-structural-match in hidden manner that lets matches
44
// through that we had intended to reject.
55
//
66
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339

src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is part of a set of tests exploring the different ways a
2-
// `#[structural_match]` ADT might try to hold a
3-
// non-`#[structural_match]` in hidden manner that lets matches
2+
// structural-match ADT might try to hold a
3+
// non-structural-match in hidden manner that lets matches
44
// through that we had intended to reject.
55
//
66
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339

src/test/ui/rfc1445/cant-hide-behind-doubly-indirect-embedded.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is part of a set of tests exploring the different ways a
2-
// `#[structural_match]` ADT might try to hold a
3-
// non-`#[structural_match]` in hidden manner that lets matches
2+
// structural-match ADT might try to hold a
3+
// non-structural-match in hidden manner that lets matches
44
// through that we had intended to reject.
55
//
66
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339

src/test/ui/rfc1445/cant-hide-behind-doubly-indirect-param.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is part of a set of tests exploring the different ways a
2-
// `#[structural_match]` ADT might try to hold a
3-
// non-`#[structural_match]` in hidden manner that lets matches
2+
// structural-match ADT might try to hold a
3+
// non-structural-match in hidden manner that lets matches
44
// through that we had intended to reject.
55
//
66
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339

src/test/ui/rfc1445/cant-hide-behind-indirect-struct-embedded.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is part of a set of tests exploring the different ways a
2-
// `#[structural_match]` ADT might try to hold a
3-
// non-`#[structural_match]` in hidden manner that lets matches
2+
// structural-match ADT might try to hold a
3+
// non-structural-match in hidden manner that lets matches
44
// through that we had intended to reject.
55
//
66
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339

src/test/ui/rfc1445/cant-hide-behind-indirect-struct-param.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is part of a set of tests exploring the different ways a
2-
// `#[structural_match]` ADT might try to hold a
3-
// non-`#[structural_match]` in hidden manner that lets matches
2+
// structural-match ADT might try to hold a
3+
// non-structural-match in hidden manner that lets matches
44
// through that we had intended to reject.
55
//
66
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339

src/test/ui/rfc1445/feature-gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Test that structural match is only permitted with a feature gate,
1+
// Test that use of structural-match traits is only permitted with a feature gate,
22
// and that if a feature gate is supplied, it permits the type to be
33
// used in a match.
44

src/test/ui/rfc1445/fn-ptr-is-structurally-matchable.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -36,79 +36,79 @@ fn main() {
3636
// a singleton type of the fn itself that the type inference would
3737
// otherwise assign.
3838

39-
// Check that fn() is #[structural_match]
39+
// Check that fn() is structural-match
4040
const CFN1: Wrap<fn()> = Wrap(trivial);
4141
let input: Wrap<fn()> = Wrap(trivial);
4242
match Wrap(input) {
4343
Wrap(CFN1) => count += 1,
4444
Wrap(_) => {}
4545
};
4646

47-
// Check that fn(T) is #[structural_match] when T is too.
47+
// Check that fn(T) is structural-match when T is too.
4848
const CFN2: Wrap<fn(SM)> = Wrap(sm_to);
4949
let input: Wrap<fn(SM)> = Wrap(sm_to);
5050
match Wrap(input) {
5151
Wrap(CFN2) => count += 1,
5252
Wrap(_) => {}
5353
};
5454

55-
// Check that fn() -> T is #[structural_match] when T is too.
55+
// Check that fn() -> T is structural-match when T is too.
5656
const CFN3: Wrap<fn() -> SM> = Wrap(to_sm);
5757
let input: Wrap<fn() -> SM> = Wrap(to_sm);
5858
match Wrap(input) {
5959
Wrap(CFN3) => count += 1,
6060
Wrap(_) => {}
6161
};
6262

63-
// Check that fn(T) is #[structural_match] even if T is not.
63+
// Check that fn(T) is structural-match even if T is not.
6464
const CFN4: Wrap<fn(NotSM)> = Wrap(not_sm_to);
6565
let input: Wrap<fn(NotSM)> = Wrap(not_sm_to);
6666
match Wrap(input) {
6767
Wrap(CFN4) => count += 1,
6868
Wrap(_) => {}
6969
};
7070

71-
// Check that fn() -> T is #[structural_match] even if T is not.
71+
// Check that fn() -> T is structural-match even if T is not.
7272
const CFN5: Wrap<fn() -> NotSM> = Wrap(to_not_sm);
7373
let input: Wrap<fn() -> NotSM> = Wrap(to_not_sm);
7474
match Wrap(input) {
7575
Wrap(CFN5) => count += 1,
7676
Wrap(_) => {}
7777
};
7878

79-
// Check that fn(&T) is #[structural_match] when T is too.
79+
// Check that fn(&T) is structural-match when T is too.
8080
const CFN6: Wrap<fn(&SM)> = Wrap(r_sm_to);
8181
let input: Wrap<fn(&SM)> = Wrap(r_sm_to);
8282
match Wrap(input) {
8383
Wrap(CFN6) => count += 1,
8484
Wrap(_) => {}
8585
};
8686

87-
// Check that fn() -> &T is #[structural_match] when T is too.
87+
// Check that fn() -> &T is structural-match when T is too.
8888
const CFN7: Wrap<fn(&()) -> &SM> = Wrap(r_to_r_sm);
8989
let input: Wrap<fn(&()) -> &SM> = Wrap(r_to_r_sm);
9090
match Wrap(input) {
9191
Wrap(CFN7) => count += 1,
9292
Wrap(_) => {}
9393
};
9494

95-
// Check that fn(T) is #[structural_match] even if T is not.
95+
// Check that fn(T) is structural-match even if T is not.
9696
const CFN8: Wrap<fn(&NotSM)> = Wrap(r_not_sm_to);
9797
let input: Wrap<fn(&NotSM)> = Wrap(r_not_sm_to);
9898
match Wrap(input) {
9999
Wrap(CFN8) => count += 1,
100100
Wrap(_) => {}
101101
};
102102

103-
// Check that fn() -> T is #[structural_match] even if T is not.
103+
// Check that fn() -> T is structural-match even if T is not.
104104
const CFN9: Wrap<fn(&()) -> &NotSM> = Wrap(r_to_r_not_sm);
105105
let input: Wrap<fn(&()) -> &NotSM> = Wrap(r_to_r_not_sm);
106106
match Wrap(input) {
107107
Wrap(CFN9) => count += 1,
108108
Wrap(_) => {}
109109
};
110110

111-
// Check that a type which has fn ptrs is `#[structural_match]`.
111+
// Check that a type which has fn ptrs is structural-match.
112112
#[derive(PartialEq, Eq)]
113113
struct Foo {
114114
alpha: fn(NotSM),

src/test/ui/rfc1445/issue-61188-match-slice-forbidden-without-eq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Issue 61188 pointed out a case where we hit an ICE during code gen:
22
// the compiler assumed that `PartialEq` was always implemented on any
33
// use of a `const` item in a pattern context, but the pre-existing
4-
// checking for the presence of `#[structural_match]` was too shallow
4+
// structural-match checking was too shallow
55
// (see rust-lang/rust#62307), and so we hit cases where we were
66
// trying to dispatch to `PartialEq` on types that did not implement
77
// that trait.

src/test/ui/rfc1445/issue-62307-match-ref-ref-forbidden-without-eq.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// resolve the question of what semantics is used for such matching.
99
// (See RFC 1445 for more details and discussion.)
1010

11-
// Issue 62307 pointed out a case where the checking for
12-
// `#[structural_match]` was too shallow.
11+
// Issue 62307 pointed out a case where the structural-match checking
12+
// was too shallow.
1313
#![warn(indirect_structural_match)]
1414
// run-pass
1515

src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Issue 62307 pointed out a case where the checking for
2-
// `#[structural_match]` was too shallow.
1+
// Issue 62307 pointed out a case where the structural-match checking
2+
// was too shallow.
33
//
44
// Here we check similar behavior for non-empty arrays of types that
55
// do not derive `Eq`.

src/test/ui/rfc1445/phantom-data-is-structurally-matchable.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ fn main() {
1414
#[derive(PartialEq, Eq)]
1515
struct SM;
1616

17-
// Check that SM is #[structural_match]:
17+
// Check that SM is structural-match:
1818
const CSM: SM = SM;
1919
match SM {
2020
CSM => count += 1,
2121
};
2222

23-
// Check that PhantomData<T> is #[structural_match] even if T is not.
23+
// Check that PhantomData<T> is structural-match even if T is not.
2424
const CPD1: PhantomData<NotSM> = PhantomData;
2525
match PhantomData {
2626
CPD1 => count += 1,
2727
};
2828

29-
// Check that PhantomData<T> is #[structural_match] when T is.
29+
// Check that PhantomData<T> is structural-match when T is.
3030
const CPD2: PhantomData<SM> = PhantomData;
3131
match PhantomData {
3232
CPD2 => count += 1,
3333
};
3434

35-
// Check that a type which has a PhantomData is `#[structural_match]`.
35+
// Check that a type which has a PhantomData is structural-match.
3636
#[derive(PartialEq, Eq, Default)]
3737
struct Foo {
3838
alpha: PhantomData<NotSM>,

0 commit comments

Comments
 (0)