From 2daf600d4713f6feacef795fac923f5826925efb Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Sat, 8 Mar 2025 13:52:45 +1300 Subject: Ignore source units that have already been included There is the possibility that the same source file could be discovered twice, if the same folder is included multiple times as a library folder or if symbolic links are used that link to already-included files. These duplicate source files are now ignored, to prevent erroneous 'duplicate definition' errors from being generated. --- src/source_unit.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/source_unit.rs') diff --git a/src/source_unit.rs b/src/source_unit.rs index 9c51ccb..28cc854 100644 --- a/src/source_unit.rs +++ b/src/source_unit.rs @@ -118,6 +118,17 @@ impl SourceUnit { } } +impl PartialEq for SourceUnit { + fn eq(&self, other: &SourceUnit) -> bool { + if let Ok(this_path) = self.main.path.canonicalize() { + if let Ok(other_path) = other.main.path.canonicalize() { + return this_path == other_path; + } + } + return false; + } +} + pub struct SourceFile { pub path: PathBuf, -- cgit v1.2.3-70-g09d2