You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Part of epic #7460. Closes the core of #12323. Depends on #7461 (lint slugs).
Goal
Generalise the existing ad-hoc #[allow(<slug>)] into a proper item-scoped lint-level mechanism supporting #[allow], #[warn], and #[deny], resolved through a single code path so it can later cover backend warnings too (#[expect] is intentionally out of scope for now).
Background — what exists today
SecondaryAttributeKind::Allow(String) already parses (parser/parser/attributes.rs) and is consumed ad-hoc at ~5 sites, each hand-rolling has_allow/is_allow:
dead_code on functions/structs/enums/traits — hir/def_collector/dc_mod.rs, elaborator/impls.rs
unused_variables, unused_mut on let statements — elaborator/statements.rs:223-225
Limitations: no central registry, typo'd slugs silently no-op, single name only (parse_single_name_attribute), allow only (no warn/deny), and no nesting/override semantics.
Scope
Attribute surface. Add warn/deny alongside allow (parser + SecondaryAttributeKind); support name lists #[allow(a, b)]. Attachment sites: items + let statements only for this issue — broader attachment (blocks/expressions/match arms) is deliberate follow-up.
Tag diagnostics. Add lint: Option<Lint> to CustomDiagnostic (noirc_errors/src/reporter.rs) and set it on the frontend "opinionated" warnings (unused var/item, unused mut, unnecessary pub/unsafe, unreachable code/match, unnecessary trait constraint, unbounded recursion, …). Uses the slugs from Attach a human-readable code for each error variant. #7461.
Lint-level source map. During elaboration/def-collection, record every lint attribute into a persisted structure { node span, lint, level, attr location } (analogous to the existing FunctionLocations that already rides into noirc_errors).
Single resolution point. Replace the scattered has_allow checks with one pass (in/around report_all): for each diagnostic with a lint, find the innermost enclosing lint-level entry containing the diagnostic's location and apply it — allow drops, warn keeps, deny upgrades kind to Error. Innermost wins → nesting + override for free.
Global-flag precedence. An item-level allow/denywins over the global --deny-warnings / --silence-warnings flags (rustc cap-lint intuition). Document the precedence.
Acceptance
#[allow(dead_code)] / #[allow(unused_variables)] / #[allow(unused_mut)] behave exactly as today (migrated, not regressed).
#[deny(unused_variables)] turns that warning into a compile error on the annotated item; #[warn(...)] overrides an outer #[allow(...)].
Part of epic #7460. Closes the core of #12323. Depends on #7461 (lint slugs).
Goal
Generalise the existing ad-hoc
#[allow(<slug>)]into a proper item-scoped lint-level mechanism supporting#[allow],#[warn], and#[deny], resolved through a single code path so it can later cover backend warnings too (#[expect]is intentionally out of scope for now).Background — what exists today
SecondaryAttributeKind::Allow(String)already parses (parser/parser/attributes.rs) and is consumed ad-hoc at ~5 sites, each hand-rollinghas_allow/is_allow:dead_codeon functions/structs/enums/traits —hir/def_collector/dc_mod.rs,elaborator/impls.rsunused_variables,unused_mutonletstatements —elaborator/statements.rs:223-225Limitations: no central registry, typo'd slugs silently no-op, single name only (
parse_single_name_attribute),allowonly (nowarn/deny), and no nesting/override semantics.Scope
warn/denyalongsideallow(parser +SecondaryAttributeKind); support name lists#[allow(a, b)]. Attachment sites: items +letstatements only for this issue — broader attachment (blocks/expressions/match arms) is deliberate follow-up.lint: Option<Lint>toCustomDiagnostic(noirc_errors/src/reporter.rs) and set it on the frontend "opinionated" warnings (unused var/item, unused mut, unnecessary pub/unsafe, unreachable code/match, unnecessary trait constraint, unbounded recursion, …). Uses the slugs from Attach a human-readable code for each error variant. #7461.{ node span, lint, level, attr location }(analogous to the existingFunctionLocationsthat already rides intonoirc_errors).has_allowchecks with one pass (in/aroundreport_all): for each diagnostic with a lint, find the innermost enclosing lint-level entry containing the diagnostic's location and apply it —allowdrops,warnkeeps,denyupgradeskindtoError. Innermost wins → nesting + override for free.allow/denywins over the global--deny-warnings/--silence-warningsflags (rustc cap-lint intuition). Document the precedence.Acceptance
#[allow(dead_code)]/#[allow(unused_variables)]/#[allow(unused_mut)]behave exactly as today (migrated, not regressed).#[deny(unused_variables)]turns that warning into a compile error on the annotated item;#[warn(...)]overrides an outer#[allow(...)].unknown_lintlint (from Attach a human-readable code for each error variant. #7461) instead of silently no-op'ing.#[allow(...)]suppresses even under--deny-warnings.Full design + file-by-file notes: https://gist.github.com/AztecBot/85187c49f6c5286d72df0980d8aed46a