diff --git a/Cargo.toml b/Cargo.toml index d6d4d8e8..e1ff5816 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ members = [ [workspace.package] version = "1.11.0" authors = ["Tad Hardesty "] -edition = "2021" +edition = "2024" [profile.dev] opt-level = 1 diff --git a/crates/builtins-proc-macro/Cargo.toml b/crates/builtins-proc-macro/Cargo.toml index 4f9b7b8e..05d83506 100644 --- a/crates/builtins-proc-macro/Cargo.toml +++ b/crates/builtins-proc-macro/Cargo.toml @@ -2,7 +2,7 @@ name = "builtins-proc-macro" version = "0.0.0" authors = ["Tad Hardesty "] -edition = "2021" +edition.workspace = true [lib] proc-macro = true diff --git a/crates/dap-types/Cargo.toml b/crates/dap-types/Cargo.toml index 41ed3fa1..8392f773 100644 --- a/crates/dap-types/Cargo.toml +++ b/crates/dap-types/Cargo.toml @@ -2,7 +2,7 @@ name = "dap-types" version = "0.0.0" authors = ["Tad Hardesty "] -edition = "2021" +edition.workspace = true [dependencies] serde = "1.0.213" diff --git a/crates/dm-langserver/src/debugger/launched.rs b/crates/dm-langserver/src/debugger/launched.rs index 299aedfe..14ea1e5b 100644 --- a/crates/dm-langserver/src/debugger/launched.rs +++ b/crates/dm-langserver/src/debugger/launched.rs @@ -213,7 +213,7 @@ mod raw { } pub unsafe fn kill(handle: Handle) -> bool { - libc::kill(handle, libc::SIGKILL) != -1 + unsafe { libc::kill(handle, libc::SIGKILL) != -1 } } } @@ -228,12 +228,12 @@ mod raw { } pub unsafe fn kill(handle: Handle) -> bool { - extern "system" { + unsafe extern "system" { fn TerminateProcess( hProcess: std::os::windows::raw::HANDLE, uExitCode: std::os::raw::c_uint, ) -> std::os::raw::c_int; } - TerminateProcess(handle, 1) != 0 + unsafe { TerminateProcess(handle, 1) != 0 } } } diff --git a/crates/dm-langserver/src/find_references.rs b/crates/dm-langserver/src/find_references.rs index 553b2b2b..9f446d23 100644 --- a/crates/dm-langserver/src/find_references.rs +++ b/crates/dm-langserver/src/find_references.rs @@ -2,9 +2,9 @@ use foldhash::{HashMap, HashMapExt}; +use dm::Location; use dm::ast::*; use dm::objtree::*; -use dm::Location; pub struct ReferencesTable { uses: HashMap, @@ -270,7 +270,7 @@ impl<'o> WalkProc<'o> { self.visit_expression(condition.location, &condition.elem, None); }, Statement::If { arms, else_arm } => { - for (condition, ref block) in arms.iter() { + for (condition, block) in arms.iter() { self.visit_expression(condition.location, &condition.elem, None); self.visit_block(block); } @@ -351,7 +351,7 @@ impl<'o> WalkProc<'o> { default, } => { self.visit_expression(location, input, None); - for (case, ref block) in cases.iter() { + for (case, block) in cases.iter() { for case_part in case.elem.iter() { match case_part { dm::ast::Case::Exact(expr) => { @@ -541,7 +541,7 @@ impl<'o> WalkProc<'o> { StaticType::None }, Term::InterpString(_, parts) => { - for (ref expr, _) in parts.iter() { + for (expr, _) in parts.iter() { if let Some(expr) = expr { self.visit_expression(location, expr, None); } @@ -603,7 +603,7 @@ impl<'o> WalkProc<'o> { Term::Locate { args, in_list } => { // TODO: use /proc/locate self.visit_arguments(location, args); - if let Some(ref expr) = in_list { + if let Some(expr) = in_list { self.visit_expression(location, expr, None); } StaticType::None @@ -615,7 +615,7 @@ impl<'o> WalkProc<'o> { } => { // TODO: use /proc/input self.visit_arguments(location, args); - if let Some(ref expr) = in_list { + if let Some(expr) = in_list { self.visit_expression(location, expr, None); } StaticType::None @@ -623,7 +623,7 @@ impl<'o> WalkProc<'o> { Term::Pick(args) => { // TODO: use /proc/pick for (weight, value) in args.iter() { - if let Some(ref weight) = weight { + if let Some(weight) = weight { self.visit_expression(location, weight, None); } self.visit_expression(location, value, None); diff --git a/crates/dm-langserver/src/main.rs b/crates/dm-langserver/src/main.rs index b0e5227d..77db1db0 100644 --- a/crates/dm-langserver/src/main.rs +++ b/crates/dm-langserver/src/main.rs @@ -35,22 +35,26 @@ mod jrpc_io; mod symbol_search; use crate::extras::{QueryObjectTree, Reparse, SetTraceVsc, StartDebugger}; +use dm::FileId; use dm::annotation::{Annotation, AnnotationTree}; use dm::ast::Ident; use dm::objtree::TypeRef; -use dm::FileId; use foldhash::{HashMap, HashMapExt, HashSet, HashSetExt}; use jsonrpc::{Call, Output, Response}; use lsp_types::{notification::*, request::*, *}; -use std::collections::hash_map::Entry; use std::collections::VecDeque; +use std::collections::hash_map::Entry; use std::path::PathBuf; use std::rc::Rc; use std::sync::{Arc, Mutex}; use url::Url; fn main() { - std::env::set_var("RUST_BACKTRACE", "1"); + // TODO: use [std::panic::set_backtrace_style] when stable: https://github.com/rust-lang/rust/issues/93346 + #[allow(unsafe_code)] + unsafe { + std::env::set_var("RUST_BACKTRACE", "1"); + } eprintln!( "dm-langserver {} Copyright (C) 2017-2025 Tad Hardesty", @@ -838,7 +842,7 @@ impl Engine { { let mut found = None; let mut proc_name = None; - if_annotation! { Annotation::ProcBody(ref proc_path, ref idx) in iter; { + if_annotation! { Annotation::ProcBody(proc_path, idx) in iter; { // chop off proc name and 'proc/' or 'verb/' if it's there // TODO: factor this logic somewhere let mut proc_path = &proc_path[..]; @@ -2043,8 +2047,9 @@ impl Engine { let iter = annotations.get_location(location); let mut result = None; - if_annotation! { Annotation::ProcArguments(priors, proc_name, mut idx) in iter; { + if_annotation! { Annotation::ProcArguments(priors, proc_name, idx) in iter; { // take the specific argument we're working on + let mut idx = *idx; if_annotation! { Annotation::ProcArgument(i) in iter; { idx = *i; }} @@ -2155,7 +2160,7 @@ impl Engine { let range = span_to_range(start..end); let selection_range = location_to_range(start); match annotation { - Annotation::TreeBlock(ref path) => { + Annotation::TreeBlock(path) => { if path.is_empty() { continue; } @@ -2171,7 +2176,7 @@ impl Engine { children: Some(find_document_symbols(iter, end, path.len())), }); }, - Annotation::Variable(ref path) => { + Annotation::Variable(path) => { let (name, detail) = name_and_detail(path, skip_front); result.push(DocumentSymbol { name, @@ -2184,7 +2189,7 @@ impl Engine { children: None, }); }, - Annotation::ProcBody(ref path, _) => { + Annotation::ProcBody(path, _) => { if path.is_empty() { continue; } @@ -2207,7 +2212,7 @@ impl Engine { children: Some(find_document_symbols(iter, end, 0)), }); }, - Annotation::LocalVarScope(_, ref name) => { + Annotation::LocalVarScope(_, name) => { result.push(DocumentSymbol { name: name.to_string(), detail: None, @@ -2219,7 +2224,7 @@ impl Engine { children: None, }); }, - Annotation::MacroDefinition(ref name) => result.push(DocumentSymbol { + Annotation::MacroDefinition(name) => result.push(DocumentSymbol { name: name.to_string(), detail: None, kind: SymbolKind::CONSTANT, diff --git a/crates/dmm-tools/Cargo.toml b/crates/dmm-tools/Cargo.toml index c61bab25..1ed1ee3d 100644 --- a/crates/dmm-tools/Cargo.toml +++ b/crates/dmm-tools/Cargo.toml @@ -2,7 +2,7 @@ name = "dmm-tools" version = "0.1.0" authors = ["Tad Hardesty "] -edition = "2021" +edition.workspace = true [dependencies] inflate = "0.4.5" diff --git a/crates/dreamchecker/src/lib.rs b/crates/dreamchecker/src/lib.rs index 655a3a4e..7f5d0b3f 100644 --- a/crates/dreamchecker/src/lib.rs +++ b/crates/dreamchecker/src/lib.rs @@ -1731,7 +1731,7 @@ impl<'o, 's> AnalyzeProc<'o, 's> { Statement::If { arms, else_arm } => { let mut allterm = ControlFlow::alltrue(); let mut alwaystrue = false; - for (condition, ref block) in arms.iter() { + for (condition, block) in arms.iter() { let mut scoped_locals = local_vars.clone(); self.visit_control_condition(condition.location, &condition.elem); if alwaystrue { @@ -1948,7 +1948,7 @@ impl<'o, 's> AnalyzeProc<'o, 's> { let mut allterm = ControlFlow::alltrue(); self.visit_control_condition(location, input); self.visit_expression(location, input, None, local_vars); - for (case, ref block) in cases.iter() { + for (case, block) in cases.iter() { let mut scoped_locals = local_vars.clone(); if let [dm::ast::Case::Exact(Expression::BinaryOp { op: BinaryOp::Or, .. @@ -2440,7 +2440,7 @@ impl<'o, 's> AnalyzeProc<'o, 's> { } }, Term::InterpString(_, parts) => { - for (ref expr, _) in parts.iter() { + for (expr, _) in parts.iter() { if let Some(expr) = expr { self.visit_expression(location, expr, None, local_vars); } @@ -2568,7 +2568,7 @@ impl<'o, 's> AnalyzeProc<'o, 's> { } // TODO: deal with in_list self.visit_arguments(location, args, local_vars); - if let Some(ref expr) = in_list { + if let Some(expr) = in_list { self.visit_expression(location, expr, None, local_vars); } @@ -2605,7 +2605,7 @@ impl<'o, 's> AnalyzeProc<'o, 's> { }, Term::Locate { args, in_list } => { self.visit_arguments(location, args, local_vars); - if let Some(ref expr) = in_list { + if let Some(expr) = in_list { self.visit_expression(location, expr, None, local_vars); } @@ -2618,7 +2618,7 @@ impl<'o, 's> AnalyzeProc<'o, 's> { }, Term::Pick(choices) => { for (weight, choice) in choices.iter() { - if let Some(ref weight) = weight { + if let Some(weight) = weight { self.visit_expression(location, weight, None, local_vars); } self.visit_expression(location, choice, None, local_vars); diff --git a/crates/dreamchecker/src/switch_rand_range.rs b/crates/dreamchecker/src/switch_rand_range.rs index 9c2c1fda..770b3b8e 100644 --- a/crates/dreamchecker/src/switch_rand_range.rs +++ b/crates/dreamchecker/src/switch_rand_range.rs @@ -69,7 +69,7 @@ pub fn check_switch_rand_range( fn get_case_range(case: &Case, location: Location) -> Option<(f32, f32)> { match case { - Case::Exact(ref value) => { + Case::Exact(value) => { let value = value .to_owned() .simple_evaluate(location) @@ -77,7 +77,7 @@ fn get_case_range(case: &Case, location: Location) -> Option<(f32, f32)> { .to_float()?; Some((value, value)) }, - Case::Range(ref min, ref max) => { + Case::Range(min, max) => { let min = min.to_owned().simple_evaluate(location).ok()?.to_float()?; let max = max.to_owned().simple_evaluate(location).ok()?.to_float()?; Some((min, max)) diff --git a/crates/dreammaker/Cargo.toml b/crates/dreammaker/Cargo.toml index 21ea687e..e6be0bdd 100644 --- a/crates/dreammaker/Cargo.toml +++ b/crates/dreammaker/Cargo.toml @@ -2,7 +2,7 @@ name = "dreammaker" version = "0.1.0" authors = ["Tad Hardesty "] -edition = "2021" +edition.workspace = true [dependencies] interval-tree = { path = "../interval-tree" } diff --git a/crates/dreammaker/src/constants.rs b/crates/dreammaker/src/constants.rs index d6a89df9..71535357 100644 --- a/crates/dreammaker/src/constants.rs +++ b/crates/dreammaker/src/constants.rs @@ -257,7 +257,7 @@ impl Constant { pub fn eq_resource(&self, resource: &str) -> bool { match self { - Constant::String(ref s) | Constant::Resource(ref s) => &**s == resource, + Constant::String(s) | Constant::Resource(s) => &**s == resource, _ => false, } } @@ -332,7 +332,7 @@ impl From for Constant { impl PartialEq for Constant { fn eq(&self, other: &str) -> bool { match self { - Constant::String(ref s) | Constant::Resource(ref s) => &**s == other, + Constant::String(s) | Constant::Resource(s) => &**s == other, _ => false, } } @@ -866,7 +866,7 @@ impl<'a> ConstantFolder<'a> { ))); } match args[0].as_term() { - Some(Term::Ident(ref ident)) => Constant::from(defines.contains_key(ident)), + Some(Term::Ident(ident)) => Constant::from(defines.contains_key(ident)), _ => { return Err(self .error("malformed defined() call, argument given isn't an Ident.")) diff --git a/crates/dreammaker/src/objtree.rs b/crates/dreammaker/src/objtree.rs index ba3b201c..9c3f4336 100644 --- a/crates/dreammaker/src/objtree.rs +++ b/crates/dreammaker/src/objtree.rs @@ -739,7 +739,7 @@ impl ObjectTree { // ------------------------------------------------------------------------ // Access - pub fn node_indices(&self) -> impl Iterator { + pub fn node_indices(&self) -> impl Iterator + use<> { (0..self.graph.len()).map(NodeIndex::new) } @@ -986,7 +986,7 @@ impl ObjectTreeBuilder { Ok(Constant::String(s)) => { parent_type = s; }, - Ok(Constant::Prefab(ref pop)) if pop.vars.is_empty() => { + Ok(Constant::Prefab(pop)) if pop.vars.is_empty() => { parent_type_buf = String::new(); for piece in pop.path.iter() { parent_type_buf.push('/'); diff --git a/crates/dreammaker/src/parser.rs b/crates/dreammaker/src/parser.rs index 5a52566f..4b189fc1 100644 --- a/crates/dreammaker/src/parser.rs +++ b/crates/dreammaker/src/parser.rs @@ -1854,7 +1854,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> { // check for a label `ident:` if let Statement::Expr(ref expr) = result { - if let Some(Term::Ident(ref name)) = expr.as_term() { + if let Some(Term::Ident(name)) = expr.as_term() { if let Some(()) = self.exact(Token::Punct(Punctuation::Colon))? { // it's a label! check for a block return spanned(Statement::Label { @@ -2363,7 +2363,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> { self.expected("proc call"); let term = take_match!(self { // term :: 'new' (prefab | (ident field*))? arglist? - Token::Ident(ref i, _) if i == "new" => { + Token::Ident(i, _) if i == "new" => { // It's not entirely clear what is supposed to be valid here. // Some things definitely are: // * new() @@ -2425,24 +2425,24 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> { // TODO: list arguments are actually subtly different, but // we're going to pretend they're not to make code simpler, and // anyone relying on the difference needs to fix their garbage - Token::Ident(ref i, _) if i == "list" => match self.arguments(&[], &ident!("list"))? { + Token::Ident(i, _) if i == "list" => match self.arguments(&[], &ident!("list"))? { Some(args) => Term::List(args), None => Term::Ident(i.to_owned()), }, - Token::Ident(ref i, _) if i == "alist" => match self.arguments(&[], &ident!("alist"))? { + Token::Ident(i, _) if i == "alist" => match self.arguments(&[], &ident!("alist"))? { Some(args) => Term::List(args), None => Term::Ident(i.to_owned()), }, // term :: 'call' arglist arglist - Token::Ident(ref i, _) if i == "call" => Term::DynamicCall( + Token::Ident(i, _) if i == "call" => Term::DynamicCall( require!(self.arguments(&[], &ident!("call"))), require!(self.arguments(&[], &ident!("call*"))), ), // term :: 'call_ext' ([library,] function) arglist - Token::Ident(ref i, _) if i == "call_ext" => { + Token::Ident(i, _) if i == "call_ext" => { require!(self.exact(Token::Punct(Punctuation::LParen))); let first = require!(self.expression()); let second = if self.exact(Token::Punct(Punctuation::Comma))?.is_some() { @@ -2470,7 +2470,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> { }, // term :: 'input' arglist input_specifier - Token::Ident(ref i, _) if i == "input" => match self.arguments(&[], &ident!("input"))? { + Token::Ident(i, _) if i == "input" => match self.arguments(&[], &ident!("input"))? { Some(args) => { let (input_type, in_list) = require!(self.input_specifier()); Term::Input { @@ -2483,7 +2483,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> { }, // term :: 'locate' arglist ('in' expression)? - Token::Ident(ref i, _) if i == "locate" => match self.arguments(&[], &ident!("locate"))? { + Token::Ident(i, _) if i == "locate" => match self.arguments(&[], &ident!("locate"))? { Some(args) => { // warn against this mistake if let Some(&Expression::BinaryOp { op: BinaryOp::In, .. } ) = args.first() { @@ -2509,34 +2509,34 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> { }, // term :: 'pick' pick_arglist - Token::Ident(ref i, _) if i == "pick" => match self.pick_arguments()? { + Token::Ident(i, _) if i == "pick" => match self.pick_arguments()? { Some(args) => Term::Pick(args), None => Term::Ident(i.to_owned()), }, - Token::Ident(ref i, _) if i == "null" => Term::Null, + Token::Ident(i, _) if i == "null" => Term::Null, // term :: 'as' '(' input_type ')' - Token::Ident(ref i, _) if i == "as" => { + Token::Ident(i, _) if i == "as" => { require!(self.exact(Token::Punct(Punctuation::LParen))); let input_type = self.input_type()?.unwrap_or_else(InputType::empty); require!(self.exact(Token::Punct(Punctuation::RParen))); Term::As(input_type) }, // term :: __PROC__ - Token::Ident(ref i, _) if i == "__PROC__" => { + Token::Ident(i, _) if i == "__PROC__" => { // We cannot replace with the proc path yet, you don't need one it's fine Term::__PROC__ }, // term :: __TYPE__ - Token::Ident(ref i, _) if i == "__TYPE__" => { + Token::Ident(i, _) if i == "__TYPE__" => { // We cannot replace with the typepath yet, so we'll hand back a term we can parse later Term::__TYPE__ }, // term :: __IMPLIED_TYPE__ - Token::Ident(ref i, _) if i == "__IMPLIED_TYPE__" => { + Token::Ident(i, _) if i == "__IMPLIED_TYPE__" => { // We cannot replace with the typepath yet, so we'll hand back a term we can parse later Term::__IMPLIED_TYPE__ }, diff --git a/crates/dreammaker/src/preprocessor.rs b/crates/dreammaker/src/preprocessor.rs index 3ff4f40e..d4ebe36c 100644 --- a/crates/dreammaker/src/preprocessor.rs +++ b/crates/dreammaker/src/preprocessor.rs @@ -317,7 +317,7 @@ struct IncludeStack<'ctx> { impl<'ctx> IncludeStack<'ctx> { fn top_file_path(&self) -> &Path { for each in self.stack.iter().rev() { - if let Include::File { ref path, .. } = each { + if let Include::File { path, .. } = each { return path; } } diff --git a/crates/interval-tree/Cargo.toml b/crates/interval-tree/Cargo.toml index e0f7a601..67253488 100644 --- a/crates/interval-tree/Cargo.toml +++ b/crates/interval-tree/Cargo.toml @@ -6,7 +6,7 @@ description = "A simple Interval Tree implementation" repository = "https://github.com/SpaceManiac/SpacemanDMM/tree/master/crates/interval-tree" keywords = ["datastructure", "interval", "tree", "map"] license-file = "LICENSE" -edition = "2021" +edition.workspace = true [dev-dependencies] rand = "0.10.1" diff --git a/crates/spaceman-dmm/Cargo.toml b/crates/spaceman-dmm/Cargo.toml index ade18655..736f3365 100644 --- a/crates/spaceman-dmm/Cargo.toml +++ b/crates/spaceman-dmm/Cargo.toml @@ -2,7 +2,7 @@ name = "spaceman-dmm" version = "0.1.0" authors = ["Tad Hardesty "] -edition = "2021" +edition.workspace = true [[bin]] name = "editor"