Skip to content

Commit 20d8ba0

Browse files
Target features
1 parent 5fa4230 commit 20d8ba0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

β€Žtext/3437-implementable-trait-alias.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,3 +1028,35 @@ where
10281028
Self::eq: const,
10291029
Self::ne: const; // 🚲🏠
10301030
```
1031+
1032+
Additionally, if we could write bounds for the target features required by a
1033+
function, that could also be leveraged by implementable aliases:
1034+
1035+
```rust
1036+
trait FrobWithAvx2 {
1037+
#[target_feature(enable = "avx2")]
1038+
fn frob(self);
1039+
}
1040+
1041+
trait FrobWithNoTargetFeatures = FrobWithAvx2
1042+
where
1043+
Self::frob: needs_target_features!(""); // 🚲🏠
1044+
```
1045+
1046+
Additional language extensions might be necessary to handle cases where the set
1047+
of target features a trait implementation may or may not use is large or open:
1048+
1049+
```rust
1050+
trait FrobWithUnknownTargetFeatures {
1051+
#[target_feature(enable = "*")] // 🚲🏠
1052+
fn frob(self);
1053+
}
1054+
1055+
trait FrobWithAvx2 = FrobWithUnknownTargetFeatures;
1056+
where
1057+
Self::frob: needs_target_features!("avx2"); // 🚲🏠
1058+
1059+
trait FrobWithNoTargetFeatures = FrobWithAvx2
1060+
where
1061+
Self::frob: needs_target_features!(""); // 🚲🏠
1062+
```

0 commit comments

Comments
Β (0)