Skip to content

Commit 6195be4

Browse files
GearsDatapackslpil
authored andcommitted
Revert changes from initial approach
1 parent 2753ad3 commit 6195be4

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

compiler-core/src/type_/environment.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,7 @@ impl Environment<'_> {
162162
// Process scope
163163
let result = process_scope(self, problems);
164164

165-
// We only check for unused entities if the scope was successfully
166-
// processed. If it was not then any seemingly unused entities may have
167-
// been used beyond the point where the error occurred, so we don't want
168-
// to incorrectly warn about them.
169-
let usage_tracking = if result.is_ok() {
170-
UsageTracking::TrackUnused
171-
} else {
172-
UsageTracking::IgnoreUnused
173-
};
174-
self.close_scope(initial, usage_tracking, problems);
165+
self.close_scope(initial, result.is_ok(), problems);
175166

176167
// Return result of typing the scope
177168
result
@@ -186,15 +177,19 @@ impl Environment<'_> {
186177
pub fn close_scope(
187178
&mut self,
188179
data: ScopeResetData,
189-
usage_tracking: UsageTracking,
180+
was_successful: bool,
190181
problems: &mut Problems,
191182
) {
192183
let unused = self
193184
.local_variable_usages
194185
.pop()
195186
.expect("There was no top entity scope.");
196187

197-
if let UsageTracking::TrackUnused = usage_tracking {
188+
// We only check for unused entities if the scope was successfully
189+
// processed. If it was not then any seemingly unused entities may have
190+
// been used beyond the point where the error occurred, so we don't want
191+
// to incorrectly warn about them.
192+
if was_successful {
198193
self.handle_unused_variables(unused, problems);
199194
}
200195
self.scope = data.local_values;
@@ -794,12 +789,6 @@ pub enum Imported {
794789
Value(EcoString),
795790
}
796791

797-
#[derive(Debug, Clone, Copy)]
798-
pub enum UsageTracking {
799-
TrackUnused,
800-
IgnoreUnused,
801-
}
802-
803792
/// Unify two types that should be the same.
804793
/// Any unbound type variables will be linked to the other type as they are the same.
805794
///

compiler-core/src/type_/expression.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,9 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
378378
// Process the scope
379379
let (result, was_successful) = process_scope(self);
380380

381-
let usage_tracking = if was_successful {
382-
UsageTracking::TrackUnused
383-
} else {
384-
UsageTracking::IgnoreUnused
385-
};
386381
// Close scope, discarding any scope local state
387382
self.environment
388-
.close_scope(environment_reset_data, usage_tracking, self.problems);
383+
.close_scope(environment_reset_data, was_successful, self.problems);
389384
self.hydrator.close_scope(hydrator_reset_data);
390385
result
391386
}

0 commit comments

Comments
 (0)