Skip to content

Commit 9c1cdea

Browse files
committed
Update to Rust 1.89
1 parent c1afb4b commit 9c1cdea

35 files changed

+270
-201
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
submodules: recursive
2121
- uses: actions-rs/toolchain@v1
2222
with:
23-
toolchain: 1.82
23+
toolchain: 1.89
2424
override: true
2525
components: rustfmt, clippy
2626
- name: Build
@@ -40,7 +40,7 @@ jobs:
4040
submodules: recursive
4141
- uses: actions-rs/toolchain@v1
4242
with:
43-
toolchain: 1.82
43+
toolchain: 1.89
4444
override: true
4545
components: rustfmt, clippy
4646
- name: format

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ name = "sus_compiler"
33
description = "Compiler for the SUS Hardware Design Language"
44
version = "0.3.0-devel"
55
authors = ["Lennart Van Hirtum <[email protected]>"]
6-
edition = "2021"
76
license = "GPL-3.0-or-later"
87
repository = "https://github.com/pc2/sus-compiler"
98
homepage = "https://github.com/pc2/sus-compiler"
109
readme = "README.md"
1110
keywords = ["sus", "fpga", "vlsi", "hdl", "verilog"]
1211
categories = ["compilers", "text-processing"]
13-
rust-version = "1.80"
12+
edition = "2024"
13+
rust-version = "1.89"
1414

1515
include = ["/src", "/std/*", "/README.md", "/LICENSE", "/CHANGELOG.md", "/build.rs", "/rustfmt.toml"]
1616

src/alloc.rs

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl<IndexMarker> UUIDRange<IndexMarker> {
131131
self.len() == 0
132132
}
133133
pub fn contains(&self, id: UUID<IndexMarker>) -> bool {
134-
self.0 .0 >= id.0 && self.1 .0 < id.0
134+
self.0.0 >= id.0 && self.1.0 < id.0
135135
}
136136
pub fn iter(&self) -> UUIDRangeIter<IndexMarker> {
137137
self.into_iter()
@@ -156,17 +156,17 @@ impl<IndexMarker> UUIDRange<IndexMarker> {
156156
})
157157
}
158158
pub fn len(&self) -> usize {
159-
self.1 .0 - self.0 .0
159+
self.1.0 - self.0.0
160160
}
161161
pub fn unwrap_len_1(&self) -> UUID<IndexMarker> {
162162
assert!(self.len() == 1);
163163
self.0
164164
}
165165
pub fn first(&self) -> Option<UUID<IndexMarker>> {
166-
(self.0 .0 < self.1 .0).then_some(self.0)
166+
(self.0.0 < self.1.0).then_some(self.0)
167167
}
168168
pub fn last(&self) -> Option<UUID<IndexMarker>> {
169-
(self.0 .0 < self.1 .0).then_some(UUID(self.1 .0 - 1, PhantomData))
169+
(self.0.0 < self.1.0).then_some(UUID(self.1.0 - 1, PhantomData))
170170
}
171171
}
172172

@@ -215,11 +215,11 @@ impl<IndexMarker> Iterator for UUIDRangeIter<IndexMarker> {
215215
type Item = UUID<IndexMarker>;
216216

217217
fn next(&mut self) -> Option<Self::Item> {
218-
if self.0 .0 == self.1 .0 {
218+
if self.0.0 == self.1.0 {
219219
None
220220
} else {
221-
let result = UUID(self.0 .0, PhantomData);
222-
self.0 .0 += 1;
221+
let result = UUID(self.0.0, PhantomData);
222+
self.0.0 += 1;
223223
Some(result)
224224
}
225225
}
@@ -231,18 +231,18 @@ impl<IndexMarker> Iterator for UUIDRangeIter<IndexMarker> {
231231

232232
impl<IndexMarker> ExactSizeIterator for UUIDRangeIter<IndexMarker> {
233233
fn len(&self) -> usize {
234-
self.1 .0 - self.0 .0
234+
self.1.0 - self.0.0
235235
}
236236
}
237237

238238
impl<IndexMarker> UUIDRangeIter<IndexMarker> {
239239
pub fn skip_to(&mut self, to: UUID<IndexMarker>) {
240-
assert!(to.0 >= self.0 .0);
241-
assert!(to.0 <= self.1 .0);
240+
assert!(to.0 >= self.0.0);
241+
assert!(to.0 <= self.1.0);
242242
self.0 = to;
243243
}
244244
pub fn len(&self) -> usize {
245-
self.1 .0 - self.0 .0
245+
self.1.0 - self.0.0
246246
}
247247
pub fn is_empty(&self) -> bool {
248248
self.len() == 0
@@ -647,7 +647,10 @@ impl<T, IndexMarker> FlatAlloc<T, IndexMarker> {
647647
IndexMarker: UUIDMarker,
648648
{
649649
let found_id = self.alloc(value);
650-
assert_eq!(id, found_id, "There was an element inserted between a call to [FlatAlloc::get_next_alloc_id] and [FlatAlloc::alloc_next_alloc_id]")
650+
assert_eq!(
651+
id, found_id,
652+
"There was an element inserted between a call to [FlatAlloc::get_next_alloc_id] and [FlatAlloc::alloc_next_alloc_id]"
653+
)
651654
}
652655
pub fn len(&self) -> usize {
653656
self.data.len()
@@ -948,12 +951,12 @@ pub struct ZippedIterator<
948951
}
949952

950953
impl<
951-
IDMarker,
952-
OA,
953-
OB,
954-
IterA: Iterator<Item = (UUID<IDMarker>, OA)>,
955-
IterB: Iterator<Item = (UUID<IDMarker>, OB)>,
956-
> Iterator for ZippedIterator<IDMarker, OA, OB, IterA, IterB>
954+
IDMarker,
955+
OA,
956+
OB,
957+
IterA: Iterator<Item = (UUID<IDMarker>, OA)>,
958+
IterB: Iterator<Item = (UUID<IDMarker>, OB)>,
959+
> Iterator for ZippedIterator<IDMarker, OA, OB, IterA, IterB>
957960
{
958961
type Item = (UUID<IDMarker>, OA, OB);
959962

@@ -996,14 +999,14 @@ pub struct ZippedIterator3<
996999
}
9971000

9981001
impl<
999-
IDMarker,
1000-
OA,
1001-
OB,
1002-
OC,
1003-
IterA: Iterator<Item = (UUID<IDMarker>, OA)>,
1004-
IterB: Iterator<Item = (UUID<IDMarker>, OB)>,
1005-
IterC: Iterator<Item = (UUID<IDMarker>, OC)>,
1006-
> Iterator for ZippedIterator3<IDMarker, OA, OB, OC, IterA, IterB, IterC>
1002+
IDMarker,
1003+
OA,
1004+
OB,
1005+
OC,
1006+
IterA: Iterator<Item = (UUID<IDMarker>, OA)>,
1007+
IterB: Iterator<Item = (UUID<IDMarker>, OB)>,
1008+
IterC: Iterator<Item = (UUID<IDMarker>, OC)>,
1009+
> Iterator for ZippedIterator3<IDMarker, OA, OB, OC, IterA, IterB, IterC>
10071010
{
10081011
type Item = (UUID<IDMarker>, OA, OB, OC);
10091012

src/codegen/vhdl.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::{
2+
FlatAlloc, InstantiatedModule, Linker, Module, WireIDMarker,
23
flattening::{DeclarationKind, Direction, Instruction},
34
linker::IsExtern,
45
typing::concrete_type::ConcreteType,
5-
FlatAlloc, InstantiatedModule, Linker, Module, WireIDMarker,
66
};
77
use std::fmt::Write;
88
use std::ops::Deref;
@@ -140,10 +140,9 @@ impl<Stream: std::fmt::Write> CodeGenerationContext<'_, '_, Stream> {
140140
.filter(|(_, wire)| {
141141
if let Instruction::Declaration(wire_decl) =
142142
&self.md.link_info.instructions[wire.original_instruction]
143+
&& let DeclarationKind::Port { .. } = wire_decl.decl_kind
143144
{
144-
if let DeclarationKind::Port { .. } = wire_decl.decl_kind {
145-
return false;
146-
}
145+
return false;
147146
}
148147
true
149148
})

src/compiler_top.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use std::path::{Path, PathBuf};
33

44
use crate::config::EarlyExitUpTo;
55
use crate::flattening::typecheck::{perform_lints, typecheck};
6+
use crate::linker::GlobalObj;
67
use crate::linker::checkpoint::{
78
AFTER_FLATTEN_CP, AFTER_INITIAL_PARSE_CP, AFTER_LINTS_CP, AFTER_TYPE_CHECK_CP,
89
};
9-
use crate::linker::GlobalObj;
1010
use crate::prelude::*;
1111
use crate::typing::concrete_type::ConcreteGlobalReference;
1212

@@ -138,10 +138,12 @@ impl Linker {
138138
info_mngr: &mut ExtraInfoManager,
139139
) -> FileUUID {
140140
// File doesn't yet exist
141-
assert!(!self
142-
.files
143-
.iter()
144-
.any(|fd| fd.1.file_identifier == file_identifier));
141+
assert!(
142+
!self
143+
.files
144+
.iter()
145+
.any(|fd| fd.1.file_identifier == file_identifier)
146+
);
145147

146148
let mut parser = Parser::new();
147149
parser.set_language(&tree_sitter_sus::language()).unwrap();

src/debug.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::{
22
cell::RefCell,
33
ops::Range,
44
sync::{
5-
atomic::{AtomicBool, AtomicPtr},
65
Arc, LazyLock, Mutex,
6+
atomic::{AtomicBool, AtomicPtr},
77
},
88
thread,
99
time::{Duration, Instant},
@@ -69,7 +69,10 @@ fn print_most_recent_spans(file_data: &FileData, history: &SpanDebuggerStackElem
6969
}
7070
}
7171

72-
println!("Panic unwinding. Printing the last {} spans. BEWARE: These spans may not correspond to this file, thus incorrect spans are possible!", spans_to_print.len());
72+
println!(
73+
"Panic unwinding. Printing the last {} spans. BEWARE: These spans may not correspond to this file, thus incorrect spans are possible!",
74+
spans_to_print.len()
75+
);
7376
pretty_print_spans_in_reverse_order(file_data, spans_to_print);
7477
}
7578

@@ -304,12 +307,13 @@ fn spawn_watchdog_thread() {
304307
if duration.is_zero() {
305308
return; // No watchdog
306309
}
307-
thread::spawn(move || loop {
308-
thread::sleep(Duration::from_millis(50));
310+
thread::spawn(move || {
311+
loop {
312+
thread::sleep(Duration::from_millis(50));
309313

310-
let mut timers = WATCHDOG.lock().unwrap();
311-
let now = Instant::now();
312-
timers.retain(|entry| {
314+
let mut timers = WATCHDOG.lock().unwrap();
315+
let now = Instant::now();
316+
timers.retain(|entry| {
313317
let deadline = entry.started_at + duration;
314318
if deadline <= now && entry.alive.load(std::sync::atomic::Ordering::SeqCst) {
315319
println!("⏰⏰⏰⏰⏰⏰⏰⏰⏰"); // To show in stdout when this happens too
@@ -324,6 +328,7 @@ fn spawn_watchdog_thread() {
324328
deadline > now
325329
}
326330
});
331+
}
327332
});
328333
}
329334

src/dev_aid/ariadne_interface.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ pub fn compile_all(file_paths: Vec<PathBuf>) -> (Linker, FileSourcesManager) {
8888
Ok(file_text) => file_text,
8989
Err(reason) => {
9090
let file_path_disp = file_path.display();
91-
panic!("Could not open file '{file_path_disp}' for syntax highlighting because {reason}")
91+
panic!(
92+
"Could not open file '{file_path_disp}' for syntax highlighting because {reason}"
93+
)
9294
}
9395
};
9496

src/dev_aid/dot_graphs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{borrow::Cow, path::PathBuf};
22

3-
use dot::{render, Edges, GraphWalk, Id, LabelText, Labeller, Nodes, Style};
3+
use dot::{Edges, GraphWalk, Id, LabelText, Labeller, Nodes, Style, render};
44

55
use crate::{
66
alloc::FlatAlloc,

src/dev_aid/lsp/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::{
2424
linker::FileData,
2525
};
2626

27-
use tree_walk::{get_selected_object, InGlobal, LocationInfo};
27+
use tree_walk::{InGlobal, LocationInfo, get_selected_object};
2828

2929
use self::tree_walk::RefersTo;
3030

@@ -287,10 +287,10 @@ fn for_each_local_reference_in_global(
287287
) -> Vec<Span> {
288288
let mut ref_locations = Vec::new();
289289
tree_walk::visit_all_in_module(linker, obj_id, |span, info| {
290-
if let LocationInfo::InGlobal(_, _, f_id, _) = info {
291-
if local == f_id {
292-
ref_locations.push(span);
293-
}
290+
if let LocationInfo::InGlobal(_, _, f_id, _) = info
291+
&& local == f_id
292+
{
293+
ref_locations.push(span);
294294
}
295295
});
296296
ref_locations
@@ -626,7 +626,9 @@ fn main_loop(
626626
}
627627

628628
pub fn lsp_main() -> Result<(), Box<dyn Error + Sync + Send>> {
629-
std::env::set_var("RUST_BACKTRACE", "1"); // Enable backtrace because I can't set it in Env vars
629+
unsafe {
630+
std::env::set_var("RUST_BACKTRACE", "1");
631+
} // Enable backtrace because I can't set it in Env vars
630632

631633
println!("starting LSP server");
632634

src/errors.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::flattening::{
1010
Declaration, DomainInfo, Instruction, Interface, InterfaceDeclaration, Module, Port,
1111
SubModuleInstance,
1212
};
13-
use crate::linker::{checkpoint::ErrorCheckpoint, FileData, LinkInfo};
13+
use crate::linker::{FileData, LinkInfo, checkpoint::ErrorCheckpoint};
1414

1515
#[derive(Debug, Clone, PartialEq, Eq)]
1616
pub enum ErrorLevel {
@@ -63,7 +63,7 @@ impl ErrorStore {
6363
}
6464

6565
pub fn take(&mut self) -> Self {
66-
std::mem::replace(self, ErrorStore::new())
66+
std::mem::take(self)
6767
}
6868

6969
pub fn checkpoint(&self) -> ErrorCheckpoint {
@@ -375,7 +375,9 @@ impl ErrorInfoObject for Instruction {
375375
Instruction::Declaration(decl) => decl.make_info(file),
376376
Instruction::Interface(decl) => decl.make_info(file),
377377
Instruction::Expression(_) => None,
378-
_ => unreachable!("At least there shouldn't be cases where we're referring to something other than SubModule or Declaration")
378+
_ => unreachable!(
379+
"At least there shouldn't be cases where we're referring to something other than SubModule or Declaration"
380+
),
379381
}
380382
}
381383
}

0 commit comments

Comments
 (0)