Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ default-filter = "not (binary(behaviour_toolchain) | binary(behaviour_cli) | kin
[profile.ci]
default-filter = "not kind(example)"

# Serialise dylint UI tests that build lint libraries and use
# Serialize dylint UI tests that build lint libraries and use
# `#[serial]`. nextest runs each test in its own process, so the
# `serial_test` crate's in-process mutex has no effect. A test-group
# with max-threads = 1 prevents concurrent lint-library builds from
Expand Down Expand Up @@ -49,7 +49,7 @@ retries = { backoff = "exponential", count = 2, delay = "5s" }
slow-timeout = { period = "10m", terminate-after = 1 }

[[profile.default.overrides]]
# Serialise ignored exclusion integration tests when they are explicitly run.
# Serialize ignored exclusion integration tests when they are explicitly run.
# They build and stage the lint library before invoking `cargo dylint`, so they
# share the same target-directory race risk as the UI harnesses above.
filter = "binary(integration_exclusion)"
Expand Down
26 changes: 26 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
unstable_features = true
comment_width = 100
format_code_in_doc_comments = true
imports_granularity = "Crate"
imports_layout = "HorizontalVertical"
wrap_comments = true
group_imports = "StdExternalCrate"
use_try_shorthand = true
hex_literal_case = "Lower"
format_strings = true
format_macro_matchers = true
fn_single_line = true
condense_wildcard_suffixes = true
use_field_init_shorthand = true

# Dylint UI fixtures are test data, not source: their `.stderr` expectations
# match compiler output byte for byte, including line and column numbers.
# Reformatting them (for example `format_strings` splitting a long `reason`
# across lines) silently shifts those spans and breaks the UI tests. Fixtures
# under `ui/` are already immune because they are not Cargo targets; these are
# targets, so exclude them explicitly.
ignore = [
"crates/no_expect_outside_tests/examples",
"crates/no_unwrap_or_else_panic/examples",
"crates/rstest_helper_should_be_fixture/examples",
]
28 changes: 27 additions & 1 deletion Cargo.lock

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

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ clap = "4.5.38"
directories-next = "2.0.0"
dylint_linting = "6"
dylint_testing = "6"
libc = "0.2"
fluent-templates = "^0.15.0"
insta = { version = "1", features = ["json"] }
once_cell = "^1.21.3"
Expand Down Expand Up @@ -49,6 +48,10 @@ rustc_lexer = "0.1.0"
ra_ap_syntax = "=0.0.334"
whitaker_clones_core = { path = "crates/whitaker_clones_core", version = "0.2.7" }
whitaker_sarif = { path = "crates/whitaker_sarif", version = "0.2.7" }
# Path-only (no `version`): the crate is `publish = false`, and Cargo strips
# versionless dev-dependencies when packaging, so the published crates do not
# gain an unresolvable requirement.
whitaker_test_macros = { path = "crates/whitaker_test_macros" }
temp-env = "0.3.6"
tempfile = "3.19.1"
wait-timeout = "0.2.1"
Expand Down Expand Up @@ -100,6 +103,7 @@ rstest = { workspace = true }
rstest-bdd = { workspace = true }
rstest-bdd-macros = { workspace = true }
dylint_testing = { workspace = true }
whitaker_test_macros = { workspace = true }

[lints.clippy]
pedantic = { level = "warn", priority = -1 }
Expand Down
2 changes: 2 additions & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ fluent-templates = { workspace = true }
glob = "0.3.3"
log = { workspace = true }
once_cell = { workspace = true }
temp-env = { workspace = true }
tempfile = "3.14.0"
thiserror = { workspace = true }
unic-langid = { workspace = true }

[dev-dependencies]
whitaker_test_macros = { workspace = true }
# Testing: Behavioural specs use rstest-bdd 0.5.x (workspace pin). Capture any
# regressions with `make test` and coordinate with the maintainers per
# `docs/rstest-bdd-users-guide.md` before gating behaviour tests or backporting
Expand Down
2 changes: 1 addition & 1 deletion common/locales/cy/common.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-term-branch = cangen
-term-test-coverage = cwmpas profion

# Borrowed English nouns typically pluralise with -iau (Modern Welsh, Gareth
# Borrowed English nouns typically pluralize with -iau (Modern Welsh, Gareth
# King §2.8), so we render "lint" as "lintiau" in aggregated messaging.
common-lint-count =
{ $lint ->
Expand Down
2 changes: 1 addition & 1 deletion common/locales/en-GB/no_expect_outside_tests.ftl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Restrict expect calls outside test contexts.

no_expect_outside_tests = Avoid calling expect on { $receiver } outside test-only code.
.note = The call originates within { $context } which is not recognised as a test.
.note = The call originates within { $context } which is not recognized as a test.
.help = { $handling ->
[option] Handle the `None` variant of { $receiver } or move the code into a test.
[result] Handle the `Err` variant of { $receiver } or move the code into a test.
Expand Down
33 changes: 10 additions & 23 deletions common/src/attributes/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl Attribute {
/// assert!(attribute.is_outer());
/// ```
#[must_use]
pub fn new(path: AttributePath, kind: AttributeKind) -> Self {
pub const fn new(path: AttributePath, kind: AttributeKind) -> Self {
Self {
path,
kind,
Expand Down Expand Up @@ -87,9 +87,7 @@ impl Attribute {
/// assert!(attribute.path().is_doc());
/// ```
#[must_use]
pub fn path(&self) -> &AttributePath {
&self.path
}
pub const fn path(&self) -> &AttributePath { &self.path }

/// Returns the attachment kind (inner or outer).
///
Expand All @@ -102,9 +100,7 @@ impl Attribute {
/// assert!(attribute.kind().is_inner());
/// ```
#[must_use]
pub const fn kind(&self) -> AttributeKind {
self.kind
}
pub const fn kind(&self) -> AttributeKind { self.kind }

/// Returns the attribute arguments.
///
Expand All @@ -121,9 +117,7 @@ impl Attribute {
/// assert_eq!(attribute.arguments(), &["dead_code"]);
/// ```
#[must_use]
pub fn arguments(&self) -> &[String] {
&self.arguments
}
pub fn arguments(&self) -> &[String] { &self.arguments }

/// Indicates whether the attribute is a doc comment (`#[doc = ...]`).
///
Expand All @@ -136,9 +130,7 @@ impl Attribute {
/// assert!(attribute.is_doc());
/// ```
#[must_use]
pub fn is_doc(&self) -> bool {
self.path.is_doc()
}
pub fn is_doc(&self) -> bool { self.path.is_doc() }

/// Indicates whether the attribute marks a test-like context.
///
Expand All @@ -157,9 +149,7 @@ impl Attribute {
/// assert!(rstest.is_test_like());
/// ```
#[must_use]
pub fn is_test_like(&self) -> bool {
self.is_test_like_with(&[])
}
pub fn is_test_like(&self) -> bool { self.is_test_like_with(&[]) }

/// Indicates whether the attribute marks a test-like context when supplied
/// with additional recognized paths.
Expand Down Expand Up @@ -205,9 +195,7 @@ impl Attribute {
/// assert!(attribute.is_inner());
/// ```
#[must_use]
pub const fn is_inner(&self) -> bool {
self.kind.is_inner()
}
pub const fn is_inner(&self) -> bool { self.kind.is_inner() }

/// Returns `true` when the attribute is an outer attribute.
///
Expand All @@ -220,9 +208,7 @@ impl Attribute {
/// assert!(attribute.is_outer());
/// ```
#[must_use]
pub const fn is_outer(&self) -> bool {
self.kind.is_outer()
}
pub const fn is_outer(&self) -> bool { self.kind.is_outer() }
}

fn matches_builtin_test_like_path(path: &AttributePath) -> bool {
Expand All @@ -246,9 +232,10 @@ fn is_prelude_test_attribute(path: &AttributePath) -> bool {

#[cfg(test)]
mod tests {
use super::*;
use rstest::rstest;

use super::*;

#[rstest]
#[case::core_v1("core::prelude::v1::test", true)]
#[case::absolute_core_v1("::core::prelude::v1::test", true)]
Expand Down
Loading
Loading