Skip to content

Commit a97ecd3

Browse files
committed
Remove LoadedModuleName
1 parent aab5ece commit a97ecd3

File tree

1 file changed

+9
-35
lines changed

1 file changed

+9
-35
lines changed

src/ghci/loaded_module.rs

+9-35
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use crate::normal_path::NormalPath;
1212
/// Hashing and equality are determined by the module's path alone.
1313
#[derive(Debug, Clone, Eq)]
1414
pub struct LoadedModule {
15-
/// The module's source file.
15+
/// The module's source file, like `src/My/Cool/Module.hs`.
1616
path: NormalPath,
1717

18-
/// The module's name.
18+
/// The module's dotted name, like `My.Cool.Module`.
1919
///
2020
/// This is present if and only if the module is loaded by name.
2121
///
@@ -41,14 +41,6 @@ impl LoadedModule {
4141
}
4242
}
4343

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-
5244
/// Get the module's source path.
5345
pub fn path(&self) -> &NormalPath {
5446
&self.path
@@ -57,7 +49,13 @@ impl LoadedModule {
5749

5850
impl Display for LoadedModule {
5951
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+
)
6159
}
6260
}
6361

@@ -96,27 +94,3 @@ impl Borrow<Utf8Path> for LoadedModule {
9694
&self.path
9795
}
9896
}
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

Comments
 (0)