Skip to content

Commit 0fc9303

Browse files
authored
chore: reduce namespace pollution (#14384)
This PR moves more declarations out of public namespaces which did not belong there.
1 parent 3c080a4 commit 0fc9303

12 files changed

Lines changed: 32 additions & 16 deletions

File tree

src/Lean/Data/FuzzyMatching.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import Lean.Server.Completion.CompletionUtils
2121
public section
2222

2323
namespace Lean
24+
25+
open Lean
26+
2427
namespace FuzzyMatching
2528

2629
section Utils

src/Lean/Data/JsonRpc.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,9 @@ def MessageKind.ofMessage : Message → MessageKind
420420

421421
end Lean.JsonRpc
422422

423-
namespace IO.FS.Stream
423+
namespace Lean.IO.FS.Stream
424424

425+
open _root_.IO
425426
open Lean
426427
open Lean.JsonRpc
427428

@@ -493,4 +494,4 @@ section
493494
h.writeMessage e
494495
end
495496

496-
end IO.FS.Stream
497+
end Lean.IO.FS.Stream

src/Lean/Data/Position.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,5 @@ def lineStart (map : FileMap) (line : Nat) : String.Pos.Raw :=
119119
end FileMap
120120
end Lean
121121

122-
def String.toFileMap (s : String) : Lean.FileMap :=
122+
def Lean.String.toFileMap (s : String) : Lean.FileMap :=
123123
Lean.FileMap.ofString s

src/Lean/Elab/DocString/Builtin/Postponed.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ set_option linter.missingDocs true
1313

1414
public section
1515

16+
namespace Lean
17+
1618
/-- Enables the deferred checks recorded while elaborating Verso docstrings, such as forward
1719
references. -/
1820
register_builtin_option linter.doc.deferred : Bool := {
1921
defValue := true
2022
descr := "if true, run the deferred checks recorded while elaborating Verso docstrings"
2123
}
2224

25+
end Lean
26+
2327
namespace Lean.Doc
2428
open Lean Elab Term
2529

src/Lean/Elab/Parallel.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ information.
6262

6363
public section
6464

65-
namespace Std.Iterators.Types
65+
namespace Std.Iterators.Types.Internal
6666

6767
/--
6868
Internal state for an iterator over tasks.
@@ -87,11 +87,11 @@ private instance {α : Type} : Iterator (TaskIterator α) BaseIO α where
8787
.yield ⟨{ tasks := remaining }⟩ result,
8888
trivial⟩
8989

90-
end Std.Iterators.Types
90+
end Std.Iterators.Types.Internal
9191

9292
namespace IO
9393

94-
open Std Std.Iterators.Types
94+
open Std Std.Iterators.Types.Internal
9595

9696
/--
9797
Creates an iterator over a list of tasks that yields results in completion order.

src/Lean/Elab/ParseImportsFast.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ public import Lean.Parser.Module
1111
public section
1212

1313
namespace Lean
14+
15+
open Lean
16+
1417
namespace ParseImports
1518

1619
structure State where

src/Lean/Server/Completion/CompletionCollectors.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public import Lean.Server.RequestCancellation
1515
public section
1616

1717
namespace Lean.Server.Completion
18-
open Elab
18+
open Lean Elab
1919
open Lean.Lsp
2020
open Meta
2121
open FuzzyMatching

src/Lean/Server/Completion/CompletionUtils.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public import Lean.Meta.WHNF
1010

1111
public section
1212

13-
partial def String.charactersIn (a b : String) : Bool :=
13+
partial def Lean.String.charactersIn (a b : String) : Bool :=
1414
goFastScalar ⟨0⟩ ⟨0
1515
where
1616
/-

src/Lean/Server/Utils.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public import Lean.Server.InfoUtils
1515

1616
public section
1717

18-
open IO FS
18+
open Lean IO FS
1919

2020
namespace Lean.IO
2121

src/Lean/SubExpr.lean

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,16 @@ protected def toString (p : Pos) : String :=
123123
|> String.intercalate "/"
124124
|> ("/" ++ ·)
125125

126-
open Except in
127126
private def ofStringCoord : String → Except String Nat
128-
| "0" => ok 0 | "1" => ok 1 | "2" => ok 2 | "3" => ok 3
129-
| c => error s!"Invalid coordinate {c}"
127+
| "0" => .ok 0 | "1" => .ok 1 | "2" => .ok 2 | "3" => .ok 3
128+
| c => .error s!"Invalid coordinate {c}"
130129

131-
open Except in
132130
protected def fromString? : String → Except String Pos
133-
| "/" => Except.ok Pos.root
131+
| "/" => .ok Pos.root
134132
| s =>
135133
match String.split s '/' |>.toStringList with
136134
| "" :: tail => Pos.ofArray <$> tail.toArray.mapM ofStringCoord
137-
| ss => error s!"malformed {ss}"
135+
| ss => .error s!"malformed {ss}"
138136

139137
protected def fromString! (s : String) : Pos :=
140138
match Pos.fromString? s with

0 commit comments

Comments
 (0)