Skip to content

Commit 05e4cb6

Browse files
committed
Revert "Fix macros to work with rust 1.46"
This reverts commit 3aa5e3e.
1 parent 05aee0f commit 05e4cb6

File tree

2 files changed

+3
-32
lines changed

2 files changed

+3
-32
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ readme = "README.md"
88
repository = "https://github.com/ruma/js_int"
99
keywords = ["integer", "no_std"]
1010
categories = ["no-std"]
11-
rust-version = "1.46.0"
11+
rust-version = "1.57.0"
1212

1313
[dependencies.serde]
1414
version = "1.0"

src/macros.rs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,7 @@ macro_rules! int {
55
($n:expr) => {{
66
const VALUE: $crate::Int = match $crate::Int::new($n) {
77
Some(int) => int,
8-
None => {
9-
// Hack to emulate a panic in this case.
10-
// Inspired by the [`static_assertions`](https://github.com/nvzqz/static-assertions) package.
11-
// Improvements to be made with higher MSRVs:
12-
// * 1.48: Replace the number comparison with `Option::is_none`
13-
// * 1.57: Use `panic!()` directly.
14-
// * 1.83: Replace manual `panic!()` with `Option::expect`
15-
const _: [(); 0 - !{
16-
const ASSERT: bool = $n >= $crate::MIN_SAFE_INT && $n <= $crate::MAX_SAFE_INT;
17-
ASSERT
18-
} as usize] = [];
19-
// This loop should not run, but it produces a never type that keeps the match
20-
// arms having the same type (since never conforms to any type)
21-
loop {}
22-
}
8+
None => panic!("Number is outside the range of an Int"),
239
};
2410
VALUE
2511
}};
@@ -32,22 +18,7 @@ macro_rules! uint {
3218
($n:expr) => {{
3319
const VALUE: $crate::UInt = match $crate::UInt::new($n) {
3420
Some(int) => int,
35-
None => {
36-
// Hack to emulate a panic in this case.
37-
// Inspired by the [`static_assertions`](https://github.com/nvzqz/static-assertions) package.
38-
// Improvements to be made with higher MSRVs:
39-
// * 1.48: Replace the number comparison with `Option::is_none`
40-
// * 1.57: Use `panic!()` directly.
41-
// * 1.83: Replace manual `panic!()` with `Option::expect`
42-
#[allow(unknown_lints, unused_comparisons)]
43-
const _: [(); 0 - !{
44-
const ASSERT: bool = $n <= $crate::MAX_SAFE_UINT;
45-
ASSERT
46-
} as usize] = [];
47-
// This loop should not run, but it produces a never type that keeps the match
48-
// arms having the same type (since never conforms to any type)
49-
loop {}
50-
}
21+
None => panic!("Number is outside the range of an Int"),
5122
};
5223
VALUE
5324
}};

0 commit comments

Comments
 (0)