Skip to content

Commit e938e45

Browse files
authored
Upgrade rust edition to 2024 (#2577)
This PR upgrades the rust edition to 2024.
1 parent 0d39fa9 commit e938e45

File tree

290 files changed

+977
-820
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+977
-820
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ resolver = "2"
3535
authors = ["Microsoft"]
3636
homepage = "https://github.com/microsoft/qsharp"
3737
repository = "https://github.com/microsoft/qsharp"
38-
edition = "2021"
38+
edition = "2024"
3939
license = "MIT"
4040
version = "0.0.0"
4141

katas/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
mod tests;
66

77
use qsc::{
8-
interpret::{output::Receiver, Error, Interpreter, Value},
9-
target::Profile,
108
PackageType, SourceContents, SourceMap, SourceName,
9+
interpret::{Error, Interpreter, Value, output::Receiver},
10+
target::Profile,
1111
};
1212

1313
use qsc::LanguageFeatures;

katas/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
use qsc::interpret::{output::CursorReceiver, Error};
4+
use qsc::interpret::{Error, output::CursorReceiver};
55
use std::{
66
env, fs,
77
io::Cursor,

library/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ mod table_lookup;
1616

1717
use indoc::indoc;
1818
use qsc::{
19+
Backend, LanguageFeatures, PackageType, SourceMap, SparseSim,
1920
interpret::{self, GenericReceiver, Interpreter, Result, Value},
2021
target::Profile,
21-
Backend, LanguageFeatures, PackageType, SourceMap, SparseSim,
2222
};
2323

2424
/// # Panics

library/src/tests/arrays.rs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -825,19 +825,28 @@ fn check_unzipped() {
825825
"Microsoft.Quantum.Arrays.Unzipped([(5, true), (4, false), (3, true), (2, true), (1, false)])",
826826
&Value::Tuple(
827827
vec![
828-
Value::Array(vec![Value::Int(5), Value::Int(4), Value::Int(3), Value::Int(2), Value::Int(1)].into()),
828+
Value::Array(
829+
vec![
830+
Value::Int(5),
831+
Value::Int(4),
832+
Value::Int(3),
833+
Value::Int(2),
834+
Value::Int(1),
835+
]
836+
.into(),
837+
),
829838
Value::Array(
830839
vec![
831840
Value::Bool(true),
832841
Value::Bool(false),
833842
Value::Bool(true),
834843
Value::Bool(true),
835-
Value::Bool(false)
844+
Value::Bool(false),
836845
]
837-
.into()
846+
.into(),
838847
),
839848
]
840-
.into()
849+
.into(),
841850
),
842851
);
843852
test_expression(
@@ -850,13 +859,22 @@ fn check_unzipped() {
850859
Value::Bool(false),
851860
Value::Bool(true),
852861
Value::Bool(true),
853-
Value::Bool(false)
862+
Value::Bool(false),
863+
]
864+
.into(),
865+
),
866+
Value::Array(
867+
vec![
868+
Value::Int(5),
869+
Value::Int(4),
870+
Value::Int(3),
871+
Value::Int(2),
872+
Value::Int(1),
854873
]
855-
.into()
874+
.into(),
856875
),
857-
Value::Array(vec![Value::Int(5), Value::Int(4), Value::Int(3), Value::Int(2), Value::Int(1)].into()),
858876
]
859-
.into()
877+
.into(),
860878
),
861879
);
862880
}

library/src/tests/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use expect_test::expect;
77
use indoc::indoc;
8-
use qsc::{interpret::Value, target::Profile, SparseSim};
8+
use qsc::{SparseSim, interpret::Value, target::Profile};
99

1010
use super::{test_expression, test_expression_fails, test_expression_with_lib_and_profile_and_sim};
1111

library/src/tests/math.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,10 @@ fn check_gcd_l() {
524524
"Microsoft.Quantum.Math.GreatestCommonDivisorL(2L*3L*5L,2L*3L*7L)",
525525
&Value::BigInt(BigInt::from(2 * 3)),
526526
);
527-
test_expression("Microsoft.Quantum.Math.GreatestCommonDivisorL(222232244629420445529739893461909967206666939096499764990979600L,359579325206583560961765665172189099052367214309267232255589801L)", &Value::BigInt(
528-
BigInt::from(1)));
527+
test_expression(
528+
"Microsoft.Quantum.Math.GreatestCommonDivisorL(222232244629420445529739893461909967206666939096499764990979600L,359579325206583560961765665172189099052367214309267232255589801L)",
529+
&Value::BigInt(BigInt::from(1)),
530+
);
529531
}
530532

531533
#[test]
@@ -624,11 +626,23 @@ fn check_cfc_l() {
624626
);
625627
test_expression(
626628
"Microsoft.Quantum.Math.ContinuedFractionConvergentL((170141183460469231731687303715884105727L,331780596164137120496034969018767441441L), 2L)",
627-
&Value::Tuple(vec![Value::BigInt(BigInt::from(1)), Value::BigInt(BigInt::from(2))].into()),
629+
&Value::Tuple(
630+
vec![
631+
Value::BigInt(BigInt::from(1)),
632+
Value::BigInt(BigInt::from(2)),
633+
]
634+
.into(),
635+
),
628636
);
629637
test_expression(
630638
"Microsoft.Quantum.Math.ContinuedFractionConvergentL((170141183460469231731687303715884105727L,331780596164137120496034969018767441441L), 1000000L)",
631-
&Value::Tuple(vec![Value::BigInt(BigInt::from(33_781)), Value::BigInt(BigInt::from(65_874))].into()),
639+
&Value::Tuple(
640+
vec![
641+
Value::BigInt(BigInt::from(33_781)),
642+
Value::BigInt(BigInt::from(65_874)),
643+
]
644+
.into(),
645+
),
632646
);
633647
}
634648

source/allocator/mimalloc-sys/build.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,17 @@ fn compile_mimalloc() {
3131
let src_dir = mimalloc_vendor_dir.join("src");
3232
let static_file = src_dir.join("static.c");
3333

34-
assert!(include_dir.exists(), "include_dir: {include_dir:?}");
35-
assert!(src_dir.exists(), "src_dir: {src_dir:?}");
36-
assert!(static_file.exists(), "static_file: {static_file:?}");
34+
assert!(
35+
include_dir.exists(),
36+
"include_dir: {}",
37+
include_dir.display()
38+
);
39+
assert!(src_dir.exists(), "src_dir: {}", src_dir.display());
40+
assert!(
41+
static_file.exists(),
42+
"static_file: {}",
43+
static_file.display()
44+
);
3745

3846
build.include(include_dir);
3947
build.include(src_dir);

source/allocator/mimalloc-sys/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::ffi::c_void;
55
pub static MI_ALIGNMENT_MAX: usize = 1024 * 1024; // 1 MiB
66

77
// Define core functions from mimalloc needed for the allocator
8-
extern "C" {
8+
unsafe extern "C" {
99
/// Allocate size bytes aligned by alignment.
1010
/// size: the number of bytes to allocate
1111
/// alignment: the minimal alignment of the allocated memory. Must be less than `MI_ALIGNMENT_MAX`

source/allocator/src/mimalloc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ unsafe impl GlobalAlloc for Mimalloc {
1212
#[inline]
1313
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
1414
debug_assert!(layout.align() < mimalloc_sys::MI_ALIGNMENT_MAX);
15-
mi_malloc_aligned(layout.size(), layout.align()).cast::<u8>()
15+
unsafe { mi_malloc_aligned(layout.size(), layout.align()).cast::<u8>() }
1616
}
1717

1818
#[inline]
1919
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
20-
mi_free(ptr.cast::<c_void>());
20+
unsafe { mi_free(ptr.cast::<c_void>()) };
2121
}
2222

2323
#[inline]
2424
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
2525
debug_assert!(layout.align() < mimalloc_sys::MI_ALIGNMENT_MAX);
26-
mi_zalloc_aligned(layout.size(), layout.align()).cast::<u8>()
26+
unsafe { mi_zalloc_aligned(layout.size(), layout.align()).cast::<u8>() }
2727
}
2828

2929
#[inline]
3030
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
3131
debug_assert!(layout.align() < mimalloc_sys::MI_ALIGNMENT_MAX);
32-
mi_realloc_aligned(ptr.cast::<c_void>(), new_size, layout.align()).cast::<u8>()
32+
unsafe { mi_realloc_aligned(ptr.cast::<c_void>(), new_size, layout.align()).cast::<u8>() }
3333
}
3434
}
3535

0 commit comments

Comments
 (0)