From bd26b03317e7af180266a95bba35bdb62f23a6f2 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:44:51 +0200 Subject: [PATCH] chore: remove unnecessary use of specialization --- Cargo.toml | 13 +++++++++++-- crates/interface/src/lib.rs | 1 - crates/interface/src/source_map/mod.rs | 2 +- crates/interface/src/symbol.rs | 21 +-------------------- crates/sema/src/lib.rs | 2 +- crates/sulk/src/utils.rs | 11 ++++------- tools/tester/src/errors.rs | 8 -------- 7 files changed, 18 insertions(+), 40 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2402f271..d53576f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ resolver = "2" [workspace.package] version = "0.0.0" edition = "2021" -rust-version = "1.74" +rust-version = "1.74" # MSRV authors = ["DaniPopes <57450786+DaniPopes@users.noreply.github.com>"] license = "MIT OR Apache-2.0" repository = "https://github.com/paradigmxyz/sulk" @@ -37,11 +37,19 @@ unnameable-types = "warn" [workspace.lints.rustdoc] all = "warn" +# Speed up compilation time for dev builds by reducing emitted debug info. +# NOTE: Debuggers may provide less useful information with this setting. +# Uncomment this section if you're using a debugger. +[profile.dev] +# https://davidlattimore.github.io/posts/2024/02/04/speeding-up-the-rust-edit-build-run-cycle.html +debug = "line-tables-only" +split-debuginfo = "unpacked" + [profile.release] opt-level = 3 lto = "thin" debug = "line-tables-only" -strip = true +strip = "debuginfo" # "symbols" for less binary size but no backtraces panic = "abort" codegen-units = 16 @@ -50,6 +58,7 @@ codegen-units = 16 [profile.profiling] inherits = "release" debug = 2 +split-debuginfo = "unpacked" strip = false [profile.bench] diff --git a/crates/interface/src/lib.rs b/crates/interface/src/lib.rs index 4ee9ef40..f6ab2923 100644 --- a/crates/interface/src/lib.rs +++ b/crates/interface/src/lib.rs @@ -16,7 +16,6 @@ html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256" )] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -#![cfg_attr(feature = "nightly", feature(min_specialization))] #[macro_use] extern crate tracing; diff --git a/crates/interface/src/source_map/mod.rs b/crates/interface/src/source_map/mod.rs index 423d32c1..a3738c93 100644 --- a/crates/interface/src/source_map/mod.rs +++ b/crates/interface/src/source_map/mod.rs @@ -193,7 +193,7 @@ impl SourceMap { file_id: StableSourceFileId, mut file: SourceFile, ) -> Result, OffsetOverflowError> { - debug!(name=%file.name.display(), len=file.src.len(), "adding to source map"); + debug!(name=%file.name.display(), len=file.src.len(), loc=file.count_lines(), "adding to source map"); let mut files = self.files.write(); diff --git a/crates/interface/src/symbol.rs b/crates/interface/src/symbol.rs index 8afc28d4..f130422c 100644 --- a/crates/interface/src/symbol.rs +++ b/crates/interface/src/symbol.rs @@ -57,15 +57,6 @@ impl fmt::Display for Ident { } } -#[cfg(feature = "nightly")] -#[allow(clippy::to_string_trait_impl)] // Specialization: https://github.com/rust-lang/rust-clippy/issues/12263 -impl ToString for Ident { - #[inline] - fn to_string(&self) -> String { - self.name.to_string() - } -} - impl Ident { /// Constructs a new identifier from a symbol and a span. #[inline] @@ -93,7 +84,6 @@ impl Ident { /// "Specialization" of [`ToString`] using [`as_str`](Self::as_str). #[inline] #[allow(clippy::inherent_to_string_shadow_display)] - #[cfg(not(feature = "nightly"))] pub fn to_string(&self) -> String { self.as_str().to_string() } @@ -191,7 +181,6 @@ impl Symbol { /// "Specialization" of [`ToString`] using [`as_str`](Self::as_str). #[inline] #[allow(clippy::inherent_to_string_shadow_display)] - #[cfg(not(feature = "nightly"))] pub fn to_string(&self) -> String { self.as_str().to_string() } @@ -323,15 +312,6 @@ impl fmt::Display for Symbol { } } -#[cfg(feature = "nightly")] -#[allow(clippy::to_string_trait_impl)] // Specialization: https://github.com/rust-lang/rust-clippy/issues/12263 -impl ToString for Symbol { - #[inline] - fn to_string(&self) -> String { - self.as_str().to_string() - } -} - type InternerInner = LassoInterner; /// Symbol interner. @@ -360,6 +340,7 @@ impl Interner { } } +// TODO: We could finalize the interner after parsing to a `RodeoResolver`, making it read-only. struct LassoInterner(lasso::ThreadedRodeo); impl LassoInterner { diff --git a/crates/sema/src/lib.rs b/crates/sema/src/lib.rs index f626da49..1672310f 100644 --- a/crates/sema/src/lib.rs +++ b/crates/sema/src/lib.rs @@ -184,7 +184,7 @@ impl<'a> Resolver<'a> { let mut start = 0; loop { let base = start; - let Some(to_parse) = sources.0.raw.get_mut(start..) else { break }; + let to_parse = &mut sources.0.raw[start..]; if to_parse.is_empty() { break; } diff --git a/crates/sulk/src/utils.rs b/crates/sulk/src/utils.rs index deeafbe8..8e36647c 100644 --- a/crates/sulk/src/utils.rs +++ b/crates/sulk/src/utils.rs @@ -25,14 +25,11 @@ fn try_init_logger() -> std::result::Result<(), impl std::fmt::Display> { } pub(crate) fn install_panic_hook() { - // If the user has not explicitly overridden "RUST_BACKTRACE", then produce full backtraces. - // When a compiler ICE happens, we want to gather as much information as possible to present in - // the issue opened by the user. - if std::env::var_os("RUST_BACKTRACE").is_none() { - std::env::set_var("RUST_BACKTRACE", "full"); - } - update_hook(|default_hook, info| { + if std::env::var_os("RUST_BACKTRACE").is_none() { + std::env::set_var("RUST_BACKTRACE", "1"); + } + default_hook(info); // Separate the output with an empty line. diff --git a/tools/tester/src/errors.rs b/tools/tester/src/errors.rs index 230005d6..2ecb2d65 100644 --- a/tools/tester/src/errors.rs +++ b/tools/tester/src/errors.rs @@ -210,13 +210,5 @@ fn parse_expected( (which, line_num) }; - // debug!( - // "line={} tag={:?} which={:?} kind={:?} msg={:?}", - // line_num, - // whole_match.as_str(), - // which, - // kind, - // msg - // ); Some((which, Error { line_num, kind, msg, solc_kind: None })) }