Skip to content

feat: Implement Return Position Impl Trait In Traits correctly #19394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ tracing-subscriber = { version = "0.3.19", default-features = false, features =
triomphe = { version = "0.1.14", default-features = false, features = ["std"] }
url = "2.5.4"
xshell = "0.2.7"
thin-vec = "0.2.14"

# We need to freeze the version of the crate, as the raw-api feature is considered unstable
dashmap = { version = "=6.1.0", features = ["raw-api", "inline"] }
Expand Down
21 changes: 21 additions & 0 deletions crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use syntax::{Parse, SyntaxError, ast};
use triomphe::Arc;
pub use vfs::{AnchoredPath, AnchoredPathBuf, FileId, VfsPath, file_set::FileSet};

/// Prefer to use `impl_intern_key_ref!()`, which will not clone the value.
#[macro_export]
macro_rules! impl_intern_key {
($id:ident, $loc:ident) => {
Expand All @@ -47,6 +48,26 @@ macro_rules! impl_intern_key {
};
}

#[macro_export]
macro_rules! impl_intern_key_ref {
($id:ident, $loc:ident) => {
#[salsa_macros::interned(no_lifetime)]
pub struct $id {
#[return_ref]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next salsa will hopefully flip this to be the default mode (once someone implements it salsa-rs/salsa#719)

pub loc: $loc,
}

// If we derive this salsa prints the values recursively, and this causes us to blow.
impl ::std::fmt::Debug for $id {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.debug_tuple(stringify!($id))
.field(&format_args!("{:04x}", self.0.as_u32()))
.finish()
}
}
};
}

pub const DEFAULT_FILE_TEXT_LRU_CAP: u16 = 16;
pub const DEFAULT_PARSE_LRU_CAP: u16 = 128;
pub const DEFAULT_BORROWCK_LRU_CAP: u16 = 2024;
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mbe.workspace = true
cfg.workspace = true
tt.workspace = true
span.workspace = true
thin-vec = "0.2.14"
thin-vec.workspace = true

[dev-dependencies]
expect-test.workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/hir-ty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ rustc_apfloat = "0.2.2"
query-group.workspace = true
salsa.workspace = true
salsa-macros.workspace = true
thin-vec.workspace = true

ra-ap-rustc_abi.workspace = true
ra-ap-rustc_index.workspace = true
Expand Down
Loading
Loading