Auto merge of #123088 - tgross35:f16-f128-pattern-analysis, r=Nadrieril · rust-lang/rust@aabbf84 (original) (raw)

`@@ -4,6 +4,8 @@

`

4

4

`` // via .contains(...) and make sure the dynamic semantics match.

``

5

5

``

6

6

`#![allow(unreachable_patterns)]

`

``

7

`+

#![feature(f128)]

`

``

8

`+

#![feature(f16)]

`

7

9

``

8

10

`macro_rules! yes {

`

9

11

`($scrutinee:expr, (((t:tt)+) => {

`

`@@ -39,6 +41,17 @@ fn range_to_inclusive() {

`

39

41

`assert!(yes!('a', ..='a'));

`

40

42

`assert!(!yes!('b', ..='a'));

`

41

43

``

``

44

`` +

// f16; ..=X

``

``

45

`+

// FIXME(f16_f128): remove gate when ABI issues are resolved

`

``

46

`+

#[cfg(all(target_arch = "aarch64", target_os = "linux"))]

`

``

47

`+

{

`

``

48

`+

// FIXME(f16_f128): enable infinity tests when constants are available

`

``

49

`+

// assert!(yes!(f16::NEG_INFINITY, ..=f16::NEG_INFINITY));

`

``

50

`+

// assert!(yes!(f16::NEG_INFINITY, ..=1.0f16));

`

``

51

`+

assert!(yes!(1.5f16, ..=1.5f16));

`

``

52

`+

assert!(!yes!(1.6f16, ..=-1.5f16));

`

``

53

`+

}

`

``

54

+

42

55

`` // f32; ..=X

``

43

56

`assert!(yes!(f32::NEG_INFINITY, ..=f32::NEG_INFINITY));

`

44

57

`assert!(yes!(f32::NEG_INFINITY, ..=1.0f32));

`

`@@ -50,6 +63,17 @@ fn range_to_inclusive() {

`

50

63

`assert!(yes!(f64::NEG_INFINITY, ..=1.0f64));

`

51

64

`assert!(yes!(1.5f64, ..=1.5f64));

`

52

65

`assert!(!yes!(1.6f64, ..=-1.5f64));

`

``

66

+

``

67

`` +

// f128; ..=X

``

``

68

`+

// FIXME(f16_f128): remove gate when ABI issues are resolved

`

``

69

`+

#[cfg(all(target_arch = "aarch64", target_os = "linux"))]

`

``

70

`+

{

`

``

71

`+

// FIXME(f16_f128): enable infinity tests when constants are available

`

``

72

`+

// assert!(yes!(f128::NEG_INFINITY, ..=f128::NEG_INFINITY));

`

``

73

`+

// assert!(yes!(f128::NEG_INFINITY, ..=1.0f128));

`

``

74

`+

assert!(yes!(1.5f128, ..=1.5f128));

`

``

75

`+

assert!(!yes!(1.6f128, ..=-1.5f128));

`

``

76

`+

}

`

53

77

`}

`

54

78

``

55

79

`fn range_to() {

`

`@@ -83,6 +107,18 @@ fn range_to() {

`

83

107

`assert!(!yes!('a', ..'a'));

`

84

108

`assert!(!yes!('b', ..'a'));

`

85

109

``

``

110

`` +

// f16; ..X

``

``

111

`+

// FIXME(f16_f128): remove gate when ABI issues are resolved

`

``

112

`+

#[cfg(all(target_arch = "aarch64", target_os = "linux"))]

`

``

113

`+

{

`

``

114

`+

// FIXME(f16_f128): enable infinity tests when constants are available

`

``

115

`+

// assert!(yes!(f16::NEG_INFINITY, ..1.0f16));

`

``

116

`+

assert!(!yes!(1.5f16, ..1.5f16));

`

``

117

`+

const E16: f16 = 1.5f16 + f16::EPSILON;

`

``

118

`+

assert!(yes!(1.5f16, ..E16));

`

``

119

`+

assert!(!yes!(1.6f16, ..1.5f16));

`

``

120

`+

}

`

``

121

+

86

122

`` // f32; ..X

``

87

123

`assert!(yes!(f32::NEG_INFINITY, ..1.0f32));

`

88

124

`assert!(!yes!(1.5f32, ..1.5f32));

`

`@@ -96,6 +132,18 @@ fn range_to() {

`

96

132

`const E64: f64 = 1.5f64 + f64::EPSILON;

`

97

133

`assert!(yes!(1.5f64, ..E64));

`

98

134

`assert!(!yes!(1.6f64, ..1.5f64));

`

``

135

+

``

136

`` +

// f128; ..X

``

``

137

`+

// FIXME(f16_f128): remove gate when ABI issues are resolved

`

``

138

`+

#[cfg(all(target_arch = "aarch64", target_os = "linux"))]

`

``

139

`+

{

`

``

140

`+

// FIXME(f16_f128): enable infinity tests when constants are available

`

``

141

`+

// assert!(yes!(f128::NEG_INFINITY, ..1.0f128));

`

``

142

`+

assert!(!yes!(1.5f128, ..1.5f128));

`

``

143

`+

const E128: f128 = 1.5f128 + f128::EPSILON;

`

``

144

`+

assert!(yes!(1.5f128, ..E128));

`

``

145

`+

assert!(!yes!(1.6f128, ..1.5f128));

`

``

146

`+

}

`

99

147

`}

`

100

148

``

101

149

`fn range_from() {

`

`@@ -129,6 +177,21 @@ fn range_from() {

`

129

177

`assert!(!yes!('a', 'b'..));

`

130

178

`assert!(yes!(core::char::MAX, core::char::MAX..));

`

131

179

``

``

180

`` +

// f16; X..

``

``

181

`+

// FIXME(f16_f128): remove gate when ABI issues are resolved

`

``

182

`+

#[cfg(all(target_arch = "aarch64", target_os = "linux"))]

`

``

183

`+

{

`

``

184

`+

// FIXME(f16_f128): enable infinity tests when constants are available

`

``

185

`+

// assert!(yes!(f16::NEG_INFINITY, f16::NEG_INFINITY..));

`

``

186

`+

// assert!(yes!(f16::INFINITY, f16::NEG_INFINITY..));

`

``

187

`+

// assert!(!yes!(f16::NEG_INFINITY, 1.0f16..));

`

``

188

`+

// assert!(yes!(f16::INFINITY, 1.0f16..));

`

``

189

`+

assert!(!yes!(1.0f16 - f16::EPSILON, 1.0f16..));

`

``

190

`+

assert!(yes!(1.0f16, 1.0f16..));

`

``

191

`+

// assert!(yes!(f16::INFINITY, 1.0f16..));

`

``

192

`+

// assert!(yes!(f16::INFINITY, f16::INFINITY..));

`

``

193

`+

}

`

``

194

+

132

195

`` // f32; X..

``

133

196

`assert!(yes!(f32::NEG_INFINITY, f32::NEG_INFINITY..));

`

134

197

`assert!(yes!(f32::INFINITY, f32::NEG_INFINITY..));

`

`@@ -148,6 +211,21 @@ fn range_from() {

`

148

211

`assert!(yes!(1.0f64, 1.0f64..));

`

149

212

`assert!(yes!(f64::INFINITY, 1.0f64..));

`

150

213

`assert!(yes!(f64::INFINITY, f64::INFINITY..));

`

``

214

+

``

215

`` +

// f128; X..

``

``

216

`+

// FIXME(f16_f128): remove gate when ABI issues are resolved

`

``

217

`+

#[cfg(all(target_arch = "aarch64", target_os = "linux"))]

`

``

218

`+

{

`

``

219

`+

// FIXME(f16_f128): enable infinity tests when constants are available

`

``

220

`+

// assert!(yes!(f128::NEG_INFINITY, f128::NEG_INFINITY..));

`

``

221

`+

// assert!(yes!(f128::INFINITY, f128::NEG_INFINITY..));

`

``

222

`+

// assert!(!yes!(f128::NEG_INFINITY, 1.0f128..));

`

``

223

`+

// assert!(yes!(f128::INFINITY, 1.0f128..));

`

``

224

`+

assert!(!yes!(1.0f128 - f128::EPSILON, 1.0f128..));

`

``

225

`+

assert!(yes!(1.0f128, 1.0f128..));

`

``

226

`+

// assert!(yes!(f128::INFINITY, 1.0f128..));

`

``

227

`+

// assert!(yes!(f128::INFINITY, f128::INFINITY..));

`

``

228

`+

}

`

151

229

`}

`

152

230

``

153

231

`fn main() {

`