File: .lake/packages/lean4/src/lean/Lean/Linter/UnusedVariables.lean

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.9
code: /-- Enables or disables all unused variable linter warnings -/
register_builtin_option linter.unusedVariables : Bool := {
  defValue := true,
  descr := "enable the 'unused variables' linter"
}
goal: IO (Lean.Option Bool)

full_name: Lean.Linter.linter.unusedVariables
code: /-- Enables or disables all unused variable linter warnings -/
register_builtin_option linter.unusedVariables : Bool := {
  defValue := true,
  descr := "enable the 'unused variables' linter"
}
goal: Lean.Option Bool

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.50
code: /-- Enables or disables unused variable linter warnings in function arguments -/
register_builtin_option linter.unusedVariables.funArgs : Bool := {
  defValue := true,
  descr := "enable the 'unused variables' linter to mark unused function arguments"
}
goal: IO (Lean.Option Bool)

full_name: Lean.Linter.linter.unusedVariables.funArgs
code: /-- Enables or disables unused variable linter warnings in function arguments -/
register_builtin_option linter.unusedVariables.funArgs : Bool := {
  defValue := true,
  descr := "enable the 'unused variables' linter to mark unused function arguments"
}
goal: Lean.Option Bool

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.91
code: /-- Enables or disables unused variable linter warnings in patterns -/
register_builtin_option linter.unusedVariables.patternVars : Bool := {
  defValue := true,
  descr := "enable the 'unused variables' linter to mark unused pattern variables"
}
goal: IO (Lean.Option Bool)

full_name: Lean.Linter.linter.unusedVariables.patternVars
code: /-- Enables or disables unused variable linter warnings in patterns -/
register_builtin_option linter.unusedVariables.patternVars : Bool := {
  defValue := true,
  descr := "enable the 'unused variables' linter to mark unused pattern variables"
}
goal: Lean.Option Bool

full_name: Lean.Linter.getLinterUnusedVariables
code: /-- Gets the status of `linter.unusedVariables` -/
def getLinterUnusedVariables (o : Options) : Bool 
goal: Bool

full_name: Lean.Linter.getLinterUnusedVariablesFunArgs
code: /-- Gets the status of `linter.unusedVariables.funArgs` -/
def getLinterUnusedVariablesFunArgs (o : Options) : Bool 
goal: Bool

full_name: Lean.Linter.getLinterUnusedVariablesPatternVars
code: /-- Gets the status of `linter.unusedVariables.patternVars` -/
def getLinterUnusedVariablesPatternVars (o : Options) : Bool 
goal: Bool

full_name: Lean.Linter.IgnoreFunction
code: /-- An `IgnoreFunction` receives:

* a `Syntax.ident` for the unused variable
* a `Syntax.Stack` with the location of this piece of syntax in the command
* The `Options` set locally to this syntax

and should return `true` to indicate that the lint should be suppressed,
or `false` to proceed with linting as usual (other `IgnoreFunction`s may still
say it is ignored). A variable is only linted if it is unused and no
`IgnoreFunction` returns `true` on this syntax.
-/
abbrev IgnoreFunction 
goal: Type

full_name: Lean.Linter.mkIgnoreFnImpl
code: /-- Interpret an `IgnoreFunction` from the environment. -/
unsafe def mkIgnoreFnImpl (constName : Name) : ImportM IgnoreFunction 
goal: Lean.ImportM Lean.Linter.IgnoreFunction

full_name: Lean.Linter.mkIgnoreFn
code: @[inherit_doc mkIgnoreFnImpl, implemented_by mkIgnoreFnImpl]
opaque mkIgnoreFn (constName : Name) : ImportM IgnoreFunction
goal: Lean.ImportM Lean.Linter.IgnoreFunction

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.347
code: /-- The list of builtin `IgnoreFunction`s. -/
builtin_initialize builtinUnusedVariablesIgnoreFnsRef : IO.Ref <| Array IgnoreFunction ← IO.mkRef #[]
goal: IO (IO.Ref (Array Lean.Linter.IgnoreFunction))

full_name: Lean.Linter.builtinUnusedVariablesIgnoreFnsRef
code: /-- The list of builtin `IgnoreFunction`s. -/
builtin_initialize builtinUnusedVariablesIgnoreFnsRef : IO.Ref <| Array IgnoreFunction ← IO.mkRef #[]
goal: IO.Ref (Array Lean.Linter.IgnoreFunction)

full_name: Lean.Linter.addBuiltinUnusedVariablesIgnoreFn
code: /-- Adds a new builtin `IgnoreFunction`.
This function should only be used from within the `Lean` package. -/
def addBuiltinUnusedVariablesIgnoreFn (h : IgnoreFunction) : IO Unit 
goal: IO Unit

full_name: Lean.Linter.unusedVariablesIgnoreFnsExt
code: /-- An extension which keeps track of registered `IgnoreFunction`s. -/
builtin_initialize unusedVariablesIgnoreFnsExt :
  PersistentEnvExtension Name (Name × IgnoreFunction) (List Name × Array IgnoreFunction) ←
  registerPersistentEnvExtension {
    mkInitial       := return ([], ← builtinUnusedVariablesIgnoreFnsRef.get)
    addImportedFn   := fun as => do
      ([], ·) <$> as.foldlM (init := ← builtinUnusedVariablesIgnoreFnsRef.get) fun s as =>
        as.foldlM (init := s) fun s n => s.push <$> mkIgnoreFn n
    addEntryFn      := fun (entries, s) (n, h) => (n::entries, s.push h)
    exportEntriesFn := fun s => s.1.reverse.toArray
    statsFn := fun s => format "number of local entries: " ++ format s.1.length
  }
goal: Lean.PersistentEnvExtension Lean.Name (Lean.Name × Lean.Linter.IgnoreFunction)
  (List Lean.Name × Array Lean.Linter.IgnoreFunction)

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.396
code: /-- An extension which keeps track of registered `IgnoreFunction`s. -/
builtin_initialize unusedVariablesIgnoreFnsExt :
  PersistentEnvExtension Name (Name × IgnoreFunction) (List Name × Array IgnoreFunction) ←
  registerPersistentEnvExtension {
    mkInitial       := return ([], ← builtinUnusedVariablesIgnoreFnsRef.get)
    addImportedFn   := fun as => do
      ([], ·) <$> as.foldlM (init := ← builtinUnusedVariablesIgnoreFnsRef.get) fun s as =>
        as.foldlM (init := s) fun s n => s.push <$> mkIgnoreFn n
    addEntryFn      := fun (entries, s) (n, h) => (n::entries, s.push h)
    exportEntriesFn := fun s => s.1.reverse.toArray
    statsFn := fun s => format "number of local entries: " ++ format s.1.length
  }
goal: IO
  (Lean.PersistentEnvExtension Lean.Name (Lean.Name × Lean.Linter.IgnoreFunction)
    (List Lean.Name × Array Lean.Linter.IgnoreFunction))

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.613
code: /-- Adds the `@[{builtin_}unused_variables_ignore_fn]` attribute, which is applied
to declarations of type `IgnoreFunction` for use by the unused variables linter. -/
builtin_initialize
  let mkAttr (builtin : Bool) (name : Name) := registerBuiltinAttribute {
    name
    descr           := (if builtin then "(builtin) " else "") ++
      "Marks a function of type `Lean.Linter.IgnoreFunction` for suppressing unused variable warnings"
    applicationTime := .afterCompilation
    add             := fun decl stx kind => do
      Attribute.Builtin.ensureNoArgs stx
      unless kind == AttributeKind.global do throwError "invalid attribute '{name}', must be global"
      unless (← getConstInfo decl).type.isConstOf ``IgnoreFunction do
        throwError "invalid attribute '{name}', must be of type `Lean.Linter.IgnoreFunction`"
      let env ← getEnv
      if builtin then
        let h := mkConst decl
        declareBuiltin decl <| mkApp (mkConst ``addBuiltinUnusedVariablesIgnoreFn) h
      else
        setEnv <| unusedVariablesIgnoreFnsExt.addEntry env (decl, ← mkIgnoreFn decl)
  }
  mkAttr true `builtin_unused_variables_ignore_fn
  mkAttr false `unused_variables_ignore_fn
goal: IO Unit

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.972
code: /-- `variable (unused : Nat)` -/
builtin_initialize addBuiltinUnusedVariablesIgnoreFn (fun _ stack _ =>
    stack.matches [`null, none, `null, ``Lean.Parser.Command.variable])
goal: IO Unit

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.1007
code: /-- `structure Foo where unused : Nat` -/
builtin_initialize addBuiltinUnusedVariablesIgnoreFn (fun _ stack _ =>
  stack.matches [`null, none, `null, ``Lean.Parser.Command.structure])
goal: IO Unit

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.1042
code: /-- `inductive Foo where | unused : Foo` -/
builtin_initialize addBuiltinUnusedVariablesIgnoreFn (fun _ stack _ =>
  stack.matches [`null, none, `null, none, ``Lean.Parser.Command.inductive] &&
  (stack.get? 3 |>.any fun (stx, pos) =>
    pos == 0 &&
    [``Lean.Parser.Command.optDeclSig, ``Lean.Parser.Command.declSig].any (stx.isOfKind ·)))
goal: IO Unit

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.1135
code: /--
* `structure Foo where foo (unused : Nat) : Nat`
* `inductive Foo where | mk (unused : Nat) : Foo`
-/
builtin_initialize addBuiltinUnusedVariablesIgnoreFn (fun _ stack _ =>
  stack.matches [`null, none, `null, ``Lean.Parser.Command.optDeclSig, none] &&
  (stack.get? 4 |>.any fun (stx, _) =>
    [``Lean.Parser.Command.ctor, ``Lean.Parser.Command.structSimpleBinder].any (stx.isOfKind ·)))
goal: IO Unit

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.1222
code: /--
* `opaque foo (unused : Nat) : Nat`
* `axiom foo (unused : Nat) : Nat`
-/
builtin_initialize addBuiltinUnusedVariablesIgnoreFn (fun _ stack _ =>
  stack.matches [`null, none, `null, ``Lean.Parser.Command.declSig, none] &&
  (stack.get? 4 |>.any fun (stx, _) =>
    [``Lean.Parser.Command.opaque, ``Lean.Parser.Command.axiom].any (stx.isOfKind ·)))
goal: IO Unit

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.1309
code: /--
Definition with foreign definition
* `@[extern "bla"] def foo (unused : Nat) : Nat := ...`
* `@[implemented_by bla] def foo (unused : Nat) : Nat := ...`
-/
builtin_initialize addBuiltinUnusedVariablesIgnoreFn (fun _ stack _ =>
  stack.matches [`null, none, `null, none, none, ``Lean.Parser.Command.declaration] &&
  (stack.get? 3 |>.any fun (stx, _) =>
    stx.isOfKind ``Lean.Parser.Command.optDeclSig ||
    stx.isOfKind ``Lean.Parser.Command.declSig) &&
  (stack.get? 5 |>.any fun (stx, _) => match stx[0] with
    | `(Lean.Parser.Command.declModifiersT| $[$_:docComment]? @[$[$attrs:attr],*] $[$vis]? $[noncomputable]?) =>
      attrs.any (fun attr => attr.raw.isOfKind ``Parser.Attr.extern || attr matches `(attr| implemented_by $_))
    | _ => false))
goal: IO Unit

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.2425
code: /--
Dependent arrow
* `def foo : (unused : Nat) → Nat := id`
-/
builtin_initialize addBuiltinUnusedVariablesIgnoreFn (fun _ stack _ =>
  stack.matches [`null, ``Lean.Parser.Term.explicitBinder, ``Lean.Parser.Term.depArrow])
goal: IO Unit

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.2458
code: /--
Function argument in let declaration (when `linter.unusedVariables.funArgs` is false)
* `def foo := let x (unused : Nat) := 1; x`
-/
builtin_initialize addBuiltinUnusedVariablesIgnoreFn (fun _ stack opts =>
  !getLinterUnusedVariablesFunArgs opts &&
  stack.matches [`null, none, `null, ``Lean.Parser.Term.letIdDecl, none] &&
  (stack.get? 3 |>.any fun (_, pos) => pos == 1) &&
  (stack.get? 5 |>.any fun (stx, _) => !stx.isOfKind ``Lean.Parser.Command.whereStructField))
goal: IO Unit

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.2578
code: /--
Function argument in declaration signature (when `linter.unusedVariables.funArgs` is false)
* `def foo (unused : Nat) := 1`
-/
builtin_initialize addBuiltinUnusedVariablesIgnoreFn (fun _ stack opts =>
  !getLinterUnusedVariablesFunArgs opts &&
  stack.matches [`null, none, `null, none] &&
  (stack.get? 3 |>.any fun (stx, pos) =>
    pos == 0 &&
    [``Lean.Parser.Command.optDeclSig, ``Lean.Parser.Command.declSig].any (stx.isOfKind ·)))
goal: IO Unit

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.2676
code: /--
Function argument in function definition (when `linter.unusedVariables.funArgs` is false)
* `def foo := fun (unused : Nat) => 1`
-/
builtin_initialize addBuiltinUnusedVariablesIgnoreFn (fun _ stack opts =>
  !getLinterUnusedVariablesFunArgs opts &&
  (stack.matches [`null, ``Lean.Parser.Term.basicFun] ||
  stack.matches [``Lean.Parser.Term.typeAscription, `null, ``Lean.Parser.Term.basicFun]))
goal: IO Unit

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.2729
code: /--
In pattern (when `linter.unusedVariables.patternVars` is false)
* `def foo := match 0 with | unused => 1`
-/
builtin_initialize addBuiltinUnusedVariablesIgnoreFn (fun _ stack opts =>
  !getLinterUnusedVariablesPatternVars opts &&
  stack.any fun (stx, pos) =>
    (stx.isOfKind ``Lean.Parser.Term.matchAlt && pos == 1) ||
    (stx.isOfKind ``Lean.Parser.Tactic.inductionAltLHS && pos == 2))
goal: IO Unit

full_name: Lean.Linter.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.2808
code: /-- `#guard_msgs in cmd` itself runs linters in `cmd` (via `elabCommandTopLevel`), so do not run them again. -/
builtin_initialize addBuiltinUnusedVariablesIgnoreFn (fun _ stack _ =>
    stack.any fun (stx, _) => stx.isOfKind ``Lean.guardMsgsCmd)
goal: IO Unit

full_name: Lean.Linter.getUnusedVariablesIgnoreFns
code: /-- Get the current list of `IgnoreFunction`s. -/
def getUnusedVariablesIgnoreFns : CommandElabM (Array IgnoreFunction) 
goal: Lean.Elab.Command.CommandElabM (Array Lean.Linter.IgnoreFunction)

full_name: Lean.Linter.UnusedVariables.insertObjImpl
code: /-- Collect into a heterogeneous collection of objects with external storage. This uses
pointer identity and does not store the objects, so it is important not to store the last
pointer to an object in the map, or it can be freed and reused, resulting in incorrect behavior.

Returns `true` if the object was not already in the set. -/
unsafe def insertObjImpl {α : Type} (set : IO.Ref (HashSet USize)) (a : α) : IO Bool 
goal: IO Bool

full_name: Lean.Linter.UnusedVariables.insertObj
code: @[inherit_doc insertObjImpl, implemented_by insertObjImpl]
opaque insertObj {α : Type} (set : IO.Ref (HashSet USize)) (a : α) : IO Bool
goal: IO Bool

full_name: Lean.Linter.UnusedVariables.visitAssignments.visitExpr
code: /--
Collects into `fvarUses` all `fvar`s occurring in the `Expr`s in `assignments`.
This implementation respects subterm sharing in both the `PersistentHashMap` and the `Expr`
to ensure that pointer-equal subobjects are not visited multiple times, which is important
in practice because these expressions are very frequently highly shared.
-/
partial def visitAssignments (set : IO.Ref (HashSet USize))
    (fvarUses : IO.Ref (HashSet FVarId))
    (assignments : Array (PersistentHashMap MVarId Expr)) : IO Unit 
goal: Lean.MonadCacheT Lean.Expr Unit IO Unit

full_name: Lean.Linter.UnusedVariables.visitAssignments
code: /--
Collects into `fvarUses` all `fvar`s occurring in the `Expr`s in `assignments`.
This implementation respects subterm sharing in both the `PersistentHashMap` and the `Expr`
to ensure that pointer-equal subobjects are not visited multiple times, which is important
in practice because these expressions are very frequently highly shared.
-/
partial def visitAssignments (set : IO.Ref (HashSet USize))
    (fvarUses : IO.Ref (HashSet FVarId))
    (assignments : Array (PersistentHashMap MVarId Expr)) : IO Unit 
goal: IO Unit

full_name: Lean.Linter.UnusedVariables.visitAssignments.visitNode
code: /--
Collects into `fvarUses` all `fvar`s occurring in the `Expr`s in `assignments`.
This implementation respects subterm sharing in both the `PersistentHashMap` and the `Expr`
to ensure that pointer-equal subobjects are not visited multiple times, which is important
in practice because these expressions are very frequently highly shared.
-/
partial def visitAssignments (set : IO.Ref (HashSet USize))
    (fvarUses : IO.Ref (HashSet FVarId))
    (assignments : Array (PersistentHashMap MVarId Expr)) : IO Unit 
goal: Lean.MonadCacheT Lean.Expr Unit IO Unit

full_name: Lean.Linter.UnusedVariables.visitAssignments.visitEntry
code: /--
Collects into `fvarUses` all `fvar`s occurring in the `Expr`s in `assignments`.
This implementation respects subterm sharing in both the `PersistentHashMap` and the `Expr`
to ensure that pointer-equal subobjects are not visited multiple times, which is important
in practice because these expressions are very frequently highly shared.
-/
partial def visitAssignments (set : IO.Ref (HashSet USize))
    (fvarUses : IO.Ref (HashSet FVarId))
    (assignments : Array (PersistentHashMap MVarId Expr)) : IO Unit 
goal: Lean.MonadCacheT Lean.Expr Unit IO Unit

full_name: Lean.Linter.UnusedVariables.followAliases
code: /-- Given `aliases` as a map from an alias to what it aliases, we get the original
term by recursion. This has no cycle detection, so if `aliases` contains a loop
then this function will recurse infinitely. -/
partial def followAliases (aliases : HashMap FVarId FVarId) (x : FVarId) : FVarId 
goal: Lean.FVarId

full_name: Lean.Linter.UnusedVariables.FVarDefinition.userName
code: /-- Information regarding an `FVarId` definition. -/
structure FVarDefinition where
  /-- The user-provided name of the `FVarId` -/
  userName : Name
  /-- A (usually `.ident`) syntax for the defined variable -/
  stx : Syntax
  /-- The options set locally to this part of the syntax (used by `IgnoreFn`) -/
  opts : Options
  /-- The list of all `FVarId`s that are considered as being defined at this position.
  This can have more than one element if multiple variables are declared by the same
  syntax, such as the `h` in `if h : c then ... else ...`. We only report an unused variable
  at this span if all variables in `aliases` are unused. -/
  aliases : Array FVarId
goal: Lean.Name

full_name: Lean.Linter.UnusedVariables.FVarDefinition
code: /-- Information regarding an `FVarId` definition. -/
structure FVarDefinition where
  /-- The user-provided name of the `FVarId` -/
  userName : Name
  /-- A (usually `.ident`) syntax for the defined variable -/
  stx : Syntax
  /-- The options set locally to this part of the syntax (used by `IgnoreFn`) -/
  opts : Options
  /-- The list of all `FVarId`s that are considered as being defined at this position.
  This can have more than one element if multiple variables are declared by the same
  syntax, such as the `h` in `if h : c then ... else ...`. We only report an unused variable
  at this span if all variables in `aliases` are unused. -/
  aliases : Array FVarId
goal: Type

full_name: Lean.Linter.UnusedVariables.FVarDefinition.opts
code: /-- Information regarding an `FVarId` definition. -/
structure FVarDefinition where
  /-- The user-provided name of the `FVarId` -/
  userName : Name
  /-- A (usually `.ident`) syntax for the defined variable -/
  stx : Syntax
  /-- The options set locally to this part of the syntax (used by `IgnoreFn`) -/
  opts : Options
  /-- The list of all `FVarId`s that are considered as being defined at this position.
  This can have more than one element if multiple variables are declared by the same
  syntax, such as the `h` in `if h : c then ... else ...`. We only report an unused variable
  at this span if all variables in `aliases` are unused. -/
  aliases : Array FVarId
goal: Lean.Options

full_name: Lean.Linter.UnusedVariables.FVarDefinition.aliases
code: /-- Information regarding an `FVarId` definition. -/
structure FVarDefinition where
  /-- The user-provided name of the `FVarId` -/
  userName : Name
  /-- A (usually `.ident`) syntax for the defined variable -/
  stx : Syntax
  /-- The options set locally to this part of the syntax (used by `IgnoreFn`) -/
  opts : Options
  /-- The list of all `FVarId`s that are considered as being defined at this position.
  This can have more than one element if multiple variables are declared by the same
  syntax, such as the `h` in `if h : c then ... else ...`. We only report an unused variable
  at this span if all variables in `aliases` are unused. -/
  aliases : Array FVarId
goal: Array Lean.FVarId

full_name: Lean.Linter.UnusedVariables.FVarDefinition.stx
code: /-- Information regarding an `FVarId` definition. -/
structure FVarDefinition where
  /-- The user-provided name of the `FVarId` -/
  userName : Name
  /-- A (usually `.ident`) syntax for the defined variable -/
  stx : Syntax
  /-- The options set locally to this part of the syntax (used by `IgnoreFn`) -/
  opts : Options
  /-- The list of all `FVarId`s that are considered as being defined at this position.
  This can have more than one element if multiple variables are declared by the same
  syntax, such as the `h` in `if h : c then ... else ...`. We only report an unused variable
  at this span if all variables in `aliases` are unused. -/
  aliases : Array FVarId
goal: Lean.Syntax

full_name: Lean.Linter.UnusedVariables.References.fvarAliases
code: /-- The main data structure used to collect information from the info tree regarding unused
variables. -/
structure References where
  /-- The set of all (ranges corresponding to) global definitions that are made in the syntax.
  For example in `mutual def foo := ...  def bar := ... where baz := ... end` this would be
  the spans for `foo`, `bar`, and `baz`. Global definitions are always treated as used.
  (It would be nice to be able to detect unused global definitions but this requires more
  information than the linter framework can provide.) -/
  constDecls : HashSet String.Range := .empty
  /-- The collection of all local declarations, organized by the span of the declaration.
  We collapse all declarations declared at the same position into a single record using
  `FVarDefinition.aliases`. -/
  fvarDefs : HashMap String.Range FVarDefinition := .empty
  /-- The set of `FVarId`s that are used directly. These may or may not be aliases. -/
  fvarUses : HashSet FVarId := .empty
  /-- A mapping from alias to original FVarId. We don't guarantee that the value is not itself
  an alias, but we use `followAliases` when adding new elements to try to avoid long chains. -/
  -- TODO: use a `UnionFind` data structure here
  fvarAliases : HashMap FVarId FVarId := .empty
  /-- Collection of all `MetavarContext`s following the execution of a tactic. We trawl these
  if needed to find additional `fvarUses`. -/
  assignments : Array (PersistentHashMap MVarId Expr) := #[]
goal: Lean.HashMap Lean.FVarId Lean.FVarId

full_name: Lean.Linter.UnusedVariables.References.assignments
code: /-- The main data structure used to collect information from the info tree regarding unused
variables. -/
structure References where
  /-- The set of all (ranges corresponding to) global definitions that are made in the syntax.
  For example in `mutual def foo := ...  def bar := ... where baz := ... end` this would be
  the spans for `foo`, `bar`, and `baz`. Global definitions are always treated as used.
  (It would be nice to be able to detect unused global definitions but this requires more
  information than the linter framework can provide.) -/
  constDecls : HashSet String.Range := .empty
  /-- The collection of all local declarations, organized by the span of the declaration.
  We collapse all declarations declared at the same position into a single record using
  `FVarDefinition.aliases`. -/
  fvarDefs : HashMap String.Range FVarDefinition := .empty
  /-- The set of `FVarId`s that are used directly. These may or may not be aliases. -/
  fvarUses : HashSet FVarId := .empty
  /-- A mapping from alias to original FVarId. We don't guarantee that the value is not itself
  an alias, but we use `followAliases` when adding new elements to try to avoid long chains. -/
  -- TODO: use a `UnionFind` data structure here
  fvarAliases : HashMap FVarId FVarId := .empty
  /-- Collection of all `MetavarContext`s following the execution of a tactic. We trawl these
  if needed to find additional `fvarUses`. -/
  assignments : Array (PersistentHashMap MVarId Expr) := #[]
goal: Array (Lean.PersistentHashMap Lean.MVarId Lean.Expr)

full_name: Lean.Linter.UnusedVariables.References.fvarUses
code: /-- The main data structure used to collect information from the info tree regarding unused
variables. -/
structure References where
  /-- The set of all (ranges corresponding to) global definitions that are made in the syntax.
  For example in `mutual def foo := ...  def bar := ... where baz := ... end` this would be
  the spans for `foo`, `bar`, and `baz`. Global definitions are always treated as used.
  (It would be nice to be able to detect unused global definitions but this requires more
  information than the linter framework can provide.) -/
  constDecls : HashSet String.Range := .empty
  /-- The collection of all local declarations, organized by the span of the declaration.
  We collapse all declarations declared at the same position into a single record using
  `FVarDefinition.aliases`. -/
  fvarDefs : HashMap String.Range FVarDefinition := .empty
  /-- The set of `FVarId`s that are used directly. These may or may not be aliases. -/
  fvarUses : HashSet FVarId := .empty
  /-- A mapping from alias to original FVarId. We don't guarantee that the value is not itself
  an alias, but we use `followAliases` when adding new elements to try to avoid long chains. -/
  -- TODO: use a `UnionFind` data structure here
  fvarAliases : HashMap FVarId FVarId := .empty
  /-- Collection of all `MetavarContext`s following the execution of a tactic. We trawl these
  if needed to find additional `fvarUses`. -/
  assignments : Array (PersistentHashMap MVarId Expr) := #[]
goal: Lean.HashSet Lean.FVarId

full_name: Lean.Linter.UnusedVariables.References.fvarDefs
code: /-- The main data structure used to collect information from the info tree regarding unused
variables. -/
structure References where
  /-- The set of all (ranges corresponding to) global definitions that are made in the syntax.
  For example in `mutual def foo := ...  def bar := ... where baz := ... end` this would be
  the spans for `foo`, `bar`, and `baz`. Global definitions are always treated as used.
  (It would be nice to be able to detect unused global definitions but this requires more
  information than the linter framework can provide.) -/
  constDecls : HashSet String.Range := .empty
  /-- The collection of all local declarations, organized by the span of the declaration.
  We collapse all declarations declared at the same position into a single record using
  `FVarDefinition.aliases`. -/
  fvarDefs : HashMap String.Range FVarDefinition := .empty
  /-- The set of `FVarId`s that are used directly. These may or may not be aliases. -/
  fvarUses : HashSet FVarId := .empty
  /-- A mapping from alias to original FVarId. We don't guarantee that the value is not itself
  an alias, but we use `followAliases` when adding new elements to try to avoid long chains. -/
  -- TODO: use a `UnionFind` data structure here
  fvarAliases : HashMap FVarId FVarId := .empty
  /-- Collection of all `MetavarContext`s following the execution of a tactic. We trawl these
  if needed to find additional `fvarUses`. -/
  assignments : Array (PersistentHashMap MVarId Expr) := #[]
goal: Lean.HashMap String.Range Lean.Linter.UnusedVariables.FVarDefinition

full_name: Lean.Linter.UnusedVariables.References.constDecls
code: /-- The main data structure used to collect information from the info tree regarding unused
variables. -/
structure References where
  /-- The set of all (ranges corresponding to) global definitions that are made in the syntax.
  For example in `mutual def foo := ...  def bar := ... where baz := ... end` this would be
  the spans for `foo`, `bar`, and `baz`. Global definitions are always treated as used.
  (It would be nice to be able to detect unused global definitions but this requires more
  information than the linter framework can provide.) -/
  constDecls : HashSet String.Range := .empty
  /-- The collection of all local declarations, organized by the span of the declaration.
  We collapse all declarations declared at the same position into a single record using
  `FVarDefinition.aliases`. -/
  fvarDefs : HashMap String.Range FVarDefinition := .empty
  /-- The set of `FVarId`s that are used directly. These may or may not be aliases. -/
  fvarUses : HashSet FVarId := .empty
  /-- A mapping from alias to original FVarId. We don't guarantee that the value is not itself
  an alias, but we use `followAliases` when adding new elements to try to avoid long chains. -/
  -- TODO: use a `UnionFind` data structure here
  fvarAliases : HashMap FVarId FVarId := .empty
  /-- Collection of all `MetavarContext`s following the execution of a tactic. We trawl these
  if needed to find additional `fvarUses`. -/
  assignments : Array (PersistentHashMap MVarId Expr) := #[]
goal: Lean.HashSet String.Range

full_name: Lean.Linter.UnusedVariables.References
code: /-- The main data structure used to collect information from the info tree regarding unused
variables. -/
structure References where
  /-- The set of all (ranges corresponding to) global definitions that are made in the syntax.
  For example in `mutual def foo := ...  def bar := ... where baz := ... end` this would be
  the spans for `foo`, `bar`, and `baz`. Global definitions are always treated as used.
  (It would be nice to be able to detect unused global definitions but this requires more
  information than the linter framework can provide.) -/
  constDecls : HashSet String.Range := .empty
  /-- The collection of all local declarations, organized by the span of the declaration.
  We collapse all declarations declared at the same position into a single record using
  `FVarDefinition.aliases`. -/
  fvarDefs : HashMap String.Range FVarDefinition := .empty
  /-- The set of `FVarId`s that are used directly. These may or may not be aliases. -/
  fvarUses : HashSet FVarId := .empty
  /-- A mapping from alias to original FVarId. We don't guarantee that the value is not itself
  an alias, but we use `followAliases` when adding new elements to try to avoid long chains. -/
  -- TODO: use a `UnionFind` data structure here
  fvarAliases : HashMap FVarId FVarId := .empty
  /-- Collection of all `MetavarContext`s following the execution of a tactic. We trawl these
  if needed to find additional `fvarUses`. -/
  assignments : Array (PersistentHashMap MVarId Expr) := #[]
goal: Type

full_name: Lean.Linter.UnusedVariables.collectReferences.skipDeclIdIfPresent
code: /-- Collect information from the `infoTrees` into `References`.
See `References` for more information about the return value. -/
def collectReferences (infoTrees : Array Elab.InfoTree) (cmdStxRange : String.Range) :
    StateRefT References IO Unit 
goal: Lean.Syntax

full_name: Lean.Linter.UnusedVariables.collectReferences
code: /-- Collect information from the `infoTrees` into `References`.
See `References` for more information about the return value. -/
def collectReferences (infoTrees : Array Elab.InfoTree) (cmdStxRange : String.Range) :
    StateRefT References IO Unit 
goal: StateRefT' IO.RealWorld Lean.Linter.UnusedVariables.References IO Unit

full_name: Lean.Linter.UnusedVariables.unusedVariables
code: /-- Reports unused variable warnings on each command. Use `linter.unusedVariables` to disable. -/
def unusedVariables : Linter 
goal: Lean.Linter

full_name: Lean.Linter.UnusedVariables.initFn._@..lake.packages.lean4.src.lean.Lean.Linter.UnusedVariables._hyg.5801
code: builtin_initialize addLinter unusedVariables
goal: IO Unit

full_name: Lean.MessageData.isUnusedVariableWarning
code: /-- Returns true if this is a message produced by the unused variable linter.
This is used to give these messages an additional "faded" style in the editor. -/
def MessageData.isUnusedVariableWarning (msg : MessageData) : Bool 
goal: Bool