Skip to content

Commit 94ae363

Browse files
committed
Cleanup
1 parent 0501985 commit 94ae363

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/Lean/Attributes.lean

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,21 @@ def registerTagAttribute (name : Name) (descr : String)
172172

173173
namespace TagAttribute
174174

175+
/-- Sets the attribute (without running `validate`) -/
176+
def setTag [Monad m] [MonadError m] [MonadEnv m] (attr : TagAttribute) (decl : Name) : m Unit := do
177+
let env ← getEnv
178+
unless (env.getModuleIdxFor? decl).isNone do
179+
throwError "invalid attribute '{attr.attr.name}', declaration {.ofConstName decl} is in an imported module"
180+
unless env.asyncMayContain decl do
181+
throwError "invalid attribute '{attr.attr.name}', declaration {.ofConstName decl} is not from the present async context {env.asyncPrefix?}"
182+
modifyEnv fun env => attr.ext.addEntry env decl
183+
175184
def hasTag (attr : TagAttribute) (env : Environment) (decl : Name) : Bool :=
176185
match env.getModuleIdxFor? decl with
177186
| some modIdx => (attr.ext.getModuleEntries env modIdx).binSearchContains decl Name.quickLt
178187
| none =>
179-
-- TODO: Is findStateAsync not always correct?
180188
if attr.ext.toEnvExtension.asyncMode matches .async then
181-
(attr.ext.findStateAsync env decl).contains decl ||
182-
(attr.ext.getState env (asyncMode := .local)).contains decl
189+
(attr.ext.findStateAsync env decl).contains decl
183190
else
184191
(attr.ext.getState env).contains decl
185192

src/Lean/Meta/Tactic/Simp/RflEnvExt.lean

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,4 @@ def inferRflAttr (declName : Name) : MetaM Unit := do
6767
else
6868
pure false
6969
if isRfl then
70-
unless (← getEnv).asyncMayContain declName do
71-
throwError "inferRflAttr: declaration {.ofConstName declName} is not from the present async context {(← getEnv).asyncPrefix?}"
72-
modifyEnv fun env => rflAttr.ext.addEntry env declName
70+
rflAttr.setTag declName

0 commit comments

Comments
 (0)