Skip to content

Commit 6f2c3fc

Browse files
adomanibjoernkjoshanssen
authored andcommitted
fix: remove check for oleans in assert_not_imported (#15839)
See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/assert_not_imported) for a discussion of the issues arising from looking for `olean`s, rather than `lean`s. As a test, this PR also incorporates some uses of `assert_not_imported` to verify that CI and `!bench` work!
1 parent 2a4c10c commit 6f2c3fc

File tree

6 files changed

+8
-20
lines changed

6 files changed

+8
-20
lines changed

Mathlib/Algebra/BigOperators/Group/List.lean

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ of elements of a list and `List.alternatingProd`, `List.alternatingSum`, their a
2121
counterparts.
2222
-/
2323

24-
-- Make sure we haven't imported `Data.Nat.Order.Basic`
25-
assert_not_exists OrderedSub
26-
assert_not_exists Ring
24+
assert_not_imported Mathlib.Algebra.Order.Group.Nat
2725

2826
variable {ι α β M N P G : Type*}
2927

Mathlib/Algebra/Field/Defs.lean

+2-3
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ a `GroupWithZero` lemma instead.
4343
field, division ring, skew field, skew-field, skewfield
4444
-/
4545

46+
assert_not_imported Mathlib.Tactic.Common
47+
4648
-- `NeZero` should not be needed in the basic algebraic hierarchy.
4749
assert_not_exists NeZero
4850

49-
-- Check that we have not imported `Mathlib.Tactic.Common` yet.
50-
assert_not_exists Mathlib.Tactic.scopedNS
51-
5251
assert_not_exists MonoidHom
5352

5453
open Function Set

Mathlib/Data/List/Chain.lean

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ A graph-specialized version is in development and will hopefully be added under
1818
sometime soon.
1919
-/
2020

21-
-- Make sure we haven't imported `Data.Nat.Order.Basic`
22-
assert_not_exists OrderedSub
21+
assert_not_imported Mathlib.Algebra.Order.Group.Nat
2322

2423
universe u v
2524

Mathlib/Data/List/GetD.lean

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ import Mathlib.Util.AssertExists
1313
This file provides theorems for working with the `getD` and `getI` functions. These are used to
1414
access an element of a list by numerical index, with a default value as a fallback when the index
1515
is out of range.
16-
1716
-/
1817

19-
-- Make sure we haven't imported `Data.Nat.Order.Basic`
20-
assert_not_exists OrderedSub
18+
assert_not_imported Mathlib.Algebra.Order.Group.Nat
2119

2220
namespace List
2321

Mathlib/Util/AssertExists.lean

+2-4
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,10 @@ elab "assert_not_exists " n:ident : command => do
7272
/-- `assert_not_imported m₁ m₂ ... mₙ` checks that each one of the modules `m₁ m₂ ... mₙ` is not
7373
among the transitive imports of the current file.
7474
75-
It also checks that each one of `m₁ m₂ ... mₙ` is actually the name of an existing module, just
76-
one that is not currently imported!
75+
The command does not currently check whether the modules `m₁ m₂ ... mₙ` actually exist.
7776
-/
77+
-- TODO: make sure that each one of `m₁ m₂ ... mₙ` is the name of an actually existing module!
7878
elab "assert_not_imported " ids:ident+ : command => do
7979
let mods := (← getEnv).allImportedModuleNames
8080
for id in ids do
8181
if mods.contains id.getId then logWarningAt id m!"the module '{id}' is (transitively) imported"
82-
if let none ← (← searchPathRef.get).findModuleWithExt "olean" id.getId then
83-
logErrorAt id m!"the module '{id}' does not exist"

test/AssertExists.lean

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import Mathlib.Util.AssertExists
22

3-
/--
4-
warning: the module 'Lean.Elab.Command' is (transitively) imported
5-
---
6-
error: the module 'I_do_not_exist' does not exist
7-
-/
3+
/-- warning: the module 'Lean.Elab.Command' is (transitively) imported -/
84
#guard_msgs in
95
assert_not_imported
106
Mathlib.Tactic.Common

0 commit comments

Comments
 (0)