Skip to content

Commit

Permalink
chore: remove unnecessary use of specialization
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Jul 1, 2024
1 parent e3cf771 commit bd26b03
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 40 deletions.
13 changes: 11 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand All @@ -50,6 +58,7 @@ codegen-units = 16
[profile.profiling]
inherits = "release"
debug = 2
split-debuginfo = "unpacked"
strip = false

[profile.bench]
Expand Down
1 change: 0 additions & 1 deletion crates/interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/interface/src/source_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl SourceMap {
file_id: StableSourceFileId,
mut file: SourceFile,
) -> Result<Lrc<SourceFile>, 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();

Expand Down
21 changes: 1 addition & 20 deletions crates/interface/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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<Symbol, sulk_data_structures::map::FxBuildHasher>);

impl LassoInterner {
Expand Down
2 changes: 1 addition & 1 deletion crates/sema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 4 additions & 7 deletions crates/sulk/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 0 additions & 8 deletions tools/tester/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }))
}

0 comments on commit bd26b03

Please sign in to comment.