@@ -12,10 +12,10 @@ use crate::normal_path::NormalPath;
12
12
/// Hashing and equality are determined by the module's path alone.
13
13
#[ derive( Debug , Clone , Eq ) ]
14
14
pub struct LoadedModule {
15
- /// The module's source file.
15
+ /// The module's source file, like `src/My/Cool/Module.hs` .
16
16
path : NormalPath ,
17
17
18
- /// The module's name.
18
+ /// The module's dotted name, like `My.Cool.Module` .
19
19
///
20
20
/// This is present if and only if the module is loaded by name.
21
21
///
@@ -41,14 +41,6 @@ impl LoadedModule {
41
41
}
42
42
}
43
43
44
- /// Get the name to use to refer to this module.
45
- pub fn name ( & self ) -> LoadedModuleName {
46
- match self . name . as_deref ( ) {
47
- Some ( name) => LoadedModuleName :: Name ( name) ,
48
- None => LoadedModuleName :: Path ( & self . path ) ,
49
- }
50
- }
51
-
52
44
/// Get the module's source path.
53
45
pub fn path ( & self ) -> & NormalPath {
54
46
& self . path
@@ -57,7 +49,13 @@ impl LoadedModule {
57
49
58
50
impl Display for LoadedModule {
59
51
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
60
- write ! ( f, "{}" , self . name( ) )
52
+ write ! (
53
+ f,
54
+ "{}" ,
55
+ self . name
56
+ . as_deref( )
57
+ . unwrap_or_else( || self . path. relative( ) . as_str( ) )
58
+ )
61
59
}
62
60
}
63
61
@@ -96,27 +94,3 @@ impl Borrow<Utf8Path> for LoadedModule {
96
94
& self . path
97
95
}
98
96
}
99
-
100
- /// The name to use to refer to a module loaded into a GHCi session.
101
- ///
102
- /// Entries in `:show targets` can be one of two types: module paths or module names (with `.` in
103
- /// place of path separators). Due to a `ghci` bug, the module can only be referred to as whichever
104
- /// form it was originally added as (see below), so we use this to track how we refer to modules.
105
- ///
106
- /// See: <https://gitlab.haskell.org/ghc/ghc/-/issues/13254#note_525037>
107
- #[ derive( Debug ) ]
108
- pub enum LoadedModuleName < ' a > {
109
- /// A path to a Haskell source file, like `src/My/Cool/Module.hs`.
110
- Path ( & ' a Utf8Path ) ,
111
- /// A dotted module name, like `My.Cool.Module`.
112
- Name ( & ' a str ) ,
113
- }
114
-
115
- impl < ' a > Display for LoadedModuleName < ' a > {
116
- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
117
- match self {
118
- LoadedModuleName :: Path ( path) => write ! ( f, "{path}" ) ,
119
- LoadedModuleName :: Name ( name) => write ! ( f, "{name}" ) ,
120
- }
121
- }
122
- }
0 commit comments