Skip to content

Commit 106c348

Browse files
committed
class ... := too
1 parent 0c12735 commit 106c348

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Diff for: src/Lean/Elab/Structure.lean

+3-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ private def expandFields (structStx : Syntax) (structModifiers : Modifiers) (str
141141
if structStx[5][0].isToken ":=" then
142142
-- https://github.com/leanprover/lean4/issues/5236
143143
if Linter.getLinterValue Linter.linter.deprecated (← getOptions) then
144-
withRef structStx[0] <| withRef structStx[5][0] <| logWarning <| .tagged ``Linter.deprecatedAttr "\
145-
'structure ... :=' has been deprecated in favor of 'structure ... where'.\n\
144+
let cmd := if structStx[0].getKind == ``Parser.Command.classTk then "class" else "structure"
145+
withRef structStx[0] <| withRef structStx[5][0] <| logWarning <| .tagged ``Linter.deprecatedAttr s!"\
146+
'{cmd} ... :=' has been deprecated in favor of '{cmd} ... where'.\n\
146147
You can disable this warning with 'set_option linter.deprecated false'."
147148
let fieldBinders := if structStx[5].isNone then #[] else structStx[5][2][0].getArgs
148149
fieldBinders.foldlM (init := #[]) fun (views : Array StructFieldView) fieldBinder => withRef fieldBinder do

Diff for: tests/lean/linterMissingDocs.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ structure Foo where
5353
{mk4 mk5 : Nat}
5454
[mk6 mk7 : Nat]
5555

56-
class Bar (α : Prop) := mk ::
56+
class Bar (α : Prop) where mk ::
5757
(foo bar := 1)
5858

5959
class Bar2 (α : Prop) where

Diff for: tests/lean/run/5236.lean

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Deprecate `:=` for `inductive` and `structure`
33
-/
44

5+
set_option linter.deprecated true
6+
57
/--
68
warning: 'inductive ... :=' has been deprecated in favor of 'inductive ... where'.
79
You can disable this warning with 'set_option linter.deprecated false'.
@@ -18,3 +20,11 @@ You can disable this warning with 'set_option linter.deprecated false'.
1820
#guard_msgs in
1921
structure S :=
2022
(n : Nat)
23+
24+
/--
25+
warning: 'class ... :=' has been deprecated in favor of 'class ... where'.
26+
You can disable this warning with 'set_option linter.deprecated false'.
27+
-/
28+
#guard_msgs in
29+
class C :=
30+
(n : Nat)

0 commit comments

Comments
 (0)