Skip to content

Commit

Permalink
chore: fix elided-named-lifetimes and ban it (#1341)
Browse files Browse the repository at this point in the history
<!-- ELLIPSIS_HIDDEN -->



> [!IMPORTANT]
> Set `elided_named_lifetimes` lint to `deny` across multiple Cargo.toml
files and adjust code for compliance.
> 
>   - **Lints**:
> - Set `elided_named_lifetimes` to `deny` in `Cargo.toml` for
`baml-core`, `baml-types`, `baml`, `diagnostics`, `jinja-runtime`,
`jinja`, `jsonish`, `llm-client`, `parser-database`, `prompt-parser`,
`schema-ast`, `baml-runtime`, `baml-schema-wasm`, `bstd`, `cli`,
`language_client_codegen`, `language_client_python`, and
`language_client_typescript`.
>   - **Code Changes**:
> - Add explicit lifetimes in `string_with_span()` and
`constant_with_span()` in `coerce_expression.rs`.
> - Modify `find_top_by_str()` in `walkers/mod.rs` to include explicit
lifetime.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup>
for 0bce130. It will automatically
update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->
  • Loading branch information
sxlijin authored Jan 17, 2025
1 parent 81ab2ba commit ba303f0
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 5 deletions.
1 change: 1 addition & 0 deletions engine/baml-lib/baml-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license-file.workspace = true

[lints.rust]
dead_code = "allow"
elided_named_lifetimes = "deny"
unused_imports = "allow"
unused_variables = "allow"

Expand Down
1 change: 1 addition & 0 deletions engine/baml-lib/baml-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license-file.workspace = true

[lints.rust]
dead_code = "deny"
elided_named_lifetimes = "deny"
unused_imports = "deny"
unused_variables = "deny"

Expand Down
6 changes: 6 additions & 0 deletions engine/baml-lib/baml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ description.workspace = true

license-file.workspace = true

[lints.rust]
dead_code = "allow"
elided_named_lifetimes = "deny"
unused_imports = "allow"
unused_variables = "allow"

[dependencies]
internal-baml-core = { path = "../baml-core" }
itertools = "0.13.0"
Expand Down
7 changes: 6 additions & 1 deletion engine/baml-lib/diagnostics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ name = "internal-baml-diagnostics"
version.workspace = true
authors.workspace = true
description.workspace = true

license-file.workspace = true

[lints.rust]
dead_code = "deny"
elided_named_lifetimes = "deny"
unused_imports = "deny"
unused_variables = "deny"

[dependencies]
colored = "2"
pest = "2.1.3"
Expand Down
1 change: 1 addition & 0 deletions engine/baml-lib/jinja-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license-file.workspace = true

[lints.rust]
dead_code = "allow"
elided_named_lifetimes = "deny"
unused_imports = "deny"
unused_variables = "deny"

Expand Down
1 change: 1 addition & 0 deletions engine/baml-lib/jinja/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license-file.workspace = true

[lints.rust]
dead_code = "deny"
elided_named_lifetimes = "deny"
unused_imports = "deny"
unused_variables = "deny"

Expand Down
1 change: 1 addition & 0 deletions engine/baml-lib/jsonish/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ license-file.workspace = true

[lints.rust]
dead_code = "allow"
elided_named_lifetimes = "deny"
unused_imports = "allow"
unused_variables = "allow"

Expand Down
1 change: 1 addition & 0 deletions engine/baml-lib/llm-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license-file.workspace = true

[lints.rust]
dead_code = "deny"
elided_named_lifetimes = "deny"
unused_imports = "deny"
unused_variables = "deny"

Expand Down
1 change: 1 addition & 0 deletions engine/baml-lib/parser-database/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ license-file.workspace = true

[lints.rust]
dead_code = "allow"
elided_named_lifetimes = "deny"
unused_imports = "allow"
unused_variables = "allow"

Expand Down
4 changes: 2 additions & 2 deletions engine/baml-lib/parser-database/src/coerce_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ pub mod coerce_opt {
expr.as_raw_string_value()
}

pub fn string_with_span<'a>(expr: &'a ast::Expression) -> Option<(&'a str, &ast::Span)> {
pub fn string_with_span<'a>(expr: &'a ast::Expression) -> Option<(&'a str, &'a ast::Span)> {
expr.as_string_value()
}

pub fn constant_with_span<'a>(expr: &'a ast::Expression) -> Option<(&'a str, &ast::Span)> {
pub fn constant_with_span<'a>(expr: &'a ast::Expression) -> Option<(&'a str, &'a ast::Span)> {
expr.as_constant_value()
}

Expand Down
2 changes: 1 addition & 1 deletion engine/baml-lib/parser-database/src/walkers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<'db> crate::ParserDatabase {
})
}

fn find_top_by_str(&'db self, name: &str) -> Option<&TopId> {
fn find_top_by_str(&'db self, name: &str) -> Option<&'db TopId> {
self.interner
.lookup(name)
.and_then(|name_id| self.names.tops.get(&name_id))
Expand Down
6 changes: 6 additions & 0 deletions engine/baml-lib/prompt-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ authors.workspace = true
description.workspace = true
license-file.workspace = true

[lints.rust]
dead_code = "deny"
elided_named_lifetimes = "deny"
unused_imports = "deny"
unused_variables = "deny"

[dependencies]
internal-baml-diagnostics = { path = "../diagnostics" }
internal-baml-schema-ast = { path = "../schema-ast" }
Expand Down
1 change: 1 addition & 0 deletions engine/baml-lib/schema-ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license-file.workspace = true

[lints.rust]
dead_code = "deny"
elided_named_lifetimes = "deny"
unused_imports = "allow"
unused_variables = "deny"

Expand Down
1 change: 1 addition & 0 deletions engine/baml-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ anyhow.workspace = true

[lints.rust]
dead_code = "allow"
elided_named_lifetimes = "deny"
unused_imports = "allow"
unused_variables = "allow"

Expand Down
3 changes: 3 additions & 0 deletions engine/baml-schema-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ license-file.workspace = true
[lib]
crate-type = ["cdylib", "rlib"]

[lints.rust]
elided_named_lifetimes = "deny"

[dependencies]
anyhow.workspace = true
baml-runtime = { path = "../baml-runtime", features = [
Expand Down
1 change: 1 addition & 0 deletions engine/bstd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RSTEST_TIMEOUT = "10"

[lints.rust]
dead_code = "deny"
elided_named_lifetimes = "deny"
unused_imports = "deny"
unused_variables = "deny"

Expand Down
1 change: 1 addition & 0 deletions engine/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ anyhow.workspace = true

[lints.rust]
dead_code = "deny"
elided_named_lifetimes = "deny"
unused_imports = "deny"
unused_variables = "deny"

Expand Down
3 changes: 2 additions & 1 deletion engine/language_client_codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license-file.workspace = true

[lints.rust]
dead_code = "allow"
elided_named_lifetimes = "deny"
unused_imports = "allow"
unused_variables = "allow"

Expand All @@ -30,4 +31,4 @@ sugar_path = "1.2.0"
walkdir.workspace = true
semver = "1.0.23"
colored = "2.1.0"
itertools = "0.13.0"
itertools = "0.13.0"
1 change: 1 addition & 0 deletions engine/language_client_python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ crate-type = ["cdylib"]

[lints.rust]
dead_code = "deny"
elided_named_lifetimes = "deny"
unused_imports = "deny"
unused_must_use = "deny"
unused_variables = "deny"
Expand Down
1 change: 1 addition & 0 deletions engine/language_client_typescript/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ crate-type = ["cdylib"]

[lints.rust]
dead_code = "deny"
elided_named_lifetimes = "deny"
unused_imports = "allow"
unused_variables = "allow"

Expand Down

0 comments on commit ba303f0

Please sign in to comment.