Skip to content

Commit

Permalink
chore: deprecate Lean.HashMap and Lean.HashSet (#4954)
Browse files Browse the repository at this point in the history
This restores all of the imports of `Lean.Data.HashMap` and
`Lean.Data.HashSet` so that users actually see the deprecation warnings
instead of a "declaration not found" error.
  • Loading branch information
TwoFX authored Aug 8, 2024
1 parent c24d218 commit b144107
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Lean/Compiler/IR/EmitLLVM.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Siddharth Bhat
-/
prelude
import Lean.Data.HashMap
import Lean.Runtime
import Lean.Compiler.NameMangling
import Lean.Compiler.ExportAttr
Expand Down
9 changes: 9 additions & 0 deletions src/Lean/Data/HashMap.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Author: Leonardo de Moura
prelude
import Init.Data.Nat.Power2
import Lean.Data.AssocList
import Std.Data.HashMap.Basic
import Std.Data.HashMap.Raw
namespace Lean

def HashMapBucket (α : Type u) (β : Type v) :=
Expand Down Expand Up @@ -269,4 +271,11 @@ def ofListWith (l : List (α × β)) (f : β → β → β) : HashMap α β :=
| none => m.insert p.fst p.snd
| some v => m.insert p.fst $ f v p.snd)

attribute [deprecated Std.HashMap] HashMap
attribute [deprecated Std.HashMap.Raw] HashMapImp
attribute [deprecated Std.HashMap.Raw.empty] mkHashMapImp
attribute [deprecated Std.HashMap.empty] mkHashMap
attribute [deprecated Std.HashMap.empty] HashMap.empty
attribute [deprecated Std.HashMap.ofList] HashMap.ofList

end Lean.HashMap
8 changes: 8 additions & 0 deletions src/Lean/Data/HashSet.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Author: Leonardo de Moura
prelude
import Init.Data.Nat.Power2
import Init.Data.List.Control
import Std.Data.HashSet.Basic
import Std.Data.HashSet.Raw
namespace Lean
universe u v w

Expand Down Expand Up @@ -217,3 +219,9 @@ def insertMany [ForIn Id ρ α] (s : HashSet α) (as : ρ) : HashSet α := Id.ru
def merge {α : Type u} [BEq α] [Hashable α] (s t : HashSet α) : HashSet α :=
t.fold (init := s) fun s a => s.insert a
-- We don't use `insertMany` here because it gives weird universes.

attribute [deprecated Std.HashSet] HashSet
attribute [deprecated Std.HashSet.Raw] HashSetImp
attribute [deprecated Std.HashSet.Raw.empty] mkHashSetImp
attribute [deprecated Std.HashSet.empty] mkHashSet
attribute [deprecated Std.HashSet.empty] HashSet.empty
1 change: 1 addition & 0 deletions src/Lean/Data/NameMap.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Author: Leonardo de Moura
-/
prelude
import Std.Data.HashSet.Basic
import Lean.Data.HashSet
import Lean.Data.RBMap
import Lean.Data.RBTree
import Lean.Data.SSet
Expand Down
1 change: 1 addition & 0 deletions src/Lean/Data/SMap.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Authors: Leonardo de Moura
-/
prelude
import Std.Data.HashMap.Basic
import Lean.Data.HashMap
import Lean.Data.PersistentHashMap
universe u v w w'

Expand Down
1 change: 1 addition & 0 deletions src/Lean/Environment.lean
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Init.Control.StateRef
import Init.Data.Array.BinSearch
import Init.Data.Stream
import Lean.ImportingFlag
import Lean.Data.HashMap
import Lean.Data.SMap
import Lean.Declaration
import Lean.LocalContext
Expand Down
2 changes: 2 additions & 0 deletions src/Lean/Level.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Authors: Leonardo de Moura
-/
prelude
import Init.Data.Array.QSort
import Lean.Data.HashMap
import Lean.Data.HashSet
import Lean.Data.PersistentHashMap
import Lean.Data.PersistentHashSet
import Lean.Hygiene
Expand Down
1 change: 1 addition & 0 deletions src/Lean/Meta/Canonicalizer.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
prelude
import Lean.Data.HashMap
import Lean.Util.ShareCommon
import Lean.Meta.Basic
import Lean.Meta.FunInfo
Expand Down
1 change: 1 addition & 0 deletions src/Lean/Util/Diff.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Authors: David Thrane Christiansen
-/
prelude
import Init.Data
import Lean.Data.HashMap
import Std.Data.HashMap.Basic
import Init.Omega

Expand Down
1 change: 1 addition & 0 deletions src/Lean/Util/MonadCache.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Authors: Leonardo de Moura
-/
prelude
import Init.Control.StateRef
import Lean.Data.HashMap
import Std.Data.HashMap.Basic

namespace Lean
Expand Down
2 changes: 2 additions & 0 deletions src/Lean/Util/PtrSet.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Authors: Leonardo de Moura
-/
prelude
import Init.Data.Hashable
import Lean.Data.HashSet
import Lean.Data.HashMap
import Std.Data.HashSet.Basic
import Std.Data.HashMap.Basic

Expand Down
1 change: 1 addition & 0 deletions src/Lean/Util/SCC.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Authors: Leonardo de Moura
-/
prelude
import Init.Data.List.Control
import Lean.Data.HashMap
import Std.Data.HashMap.Basic
namespace Lean.SCC
/-!
Expand Down
1 change: 1 addition & 0 deletions src/Lean/Util/ShareCommon.lean
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Lean.Data.PersistentHashSet
open ShareCommon
namespace Lean.ShareCommon

set_option linter.deprecated false in
def objectFactory :=
StateFactory.mk {
Map := HashMap, mkMap := (mkHashMap ·), mapFind? := (·.find?), mapInsert := (·.insert)
Expand Down
1 change: 1 addition & 0 deletions src/lake/Lake/Util/OrdHashSet.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Copyright (c) 2022 Mac Malone. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mac Malone
-/
import Lean.Data.HashSet
import Std.Data.HashSet.Basic

open Lean
Expand Down

0 comments on commit b144107

Please sign in to comment.