Skip to content

Commit c8aad75

Browse files
giacomocavalierilpil
authored andcommitted
clippy and better documentation
1 parent b419a13 commit c8aad75

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

compiler-core/src/type_/expression.rs

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
426426
} => Ok(self.infer_echo(location, keyword_end, expression, message)),
427427

428428
UntypedExpr::Var { location, name, .. } => {
429-
self.infer_var(name, location, ReferenceRegistration::RegisterReferences)
429+
self.infer_var(name, location, ReferenceRegistration::Register)
430430
}
431431

432432
UntypedExpr::Int {
@@ -1329,11 +1329,9 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
13291329
// If the left-hand-side of the record access is a variable, this might actually be
13301330
// module access. In that case, we only want to register a reference to the variable
13311331
// if we actually referencing it in the record access.
1332-
UntypedExpr::Var { location, name } => self.infer_var(
1333-
name,
1334-
location,
1335-
ReferenceRegistration::DoNotRegisterReferences,
1336-
),
1332+
UntypedExpr::Var { location, name } => {
1333+
self.infer_var(name, location, ReferenceRegistration::DoNotRegister)
1334+
}
13371335
_ => self.infer_or_error(container),
13381336
};
13391337
// TODO: is this clone avoidable? we need to box the record for inference in both
@@ -3523,12 +3521,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
35233521
name: &EcoString,
35243522
location: &SrcSpan,
35253523
) -> Result<ValueConstructor, Error> {
3526-
self.do_infer_value_constructor(
3527-
module,
3528-
name,
3529-
location,
3530-
ReferenceRegistration::RegisterReferences,
3531-
)
3524+
self.do_infer_value_constructor(module, name, location, ReferenceRegistration::Register)
35323525
}
35333526

35343527
fn do_infer_value_constructor(
@@ -3600,10 +3593,9 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
36003593
self.narrow_implementations(*location, &variant)?;
36013594

36023595
match register_reference {
3603-
ReferenceRegistration::DoNotRegisterReferences => (),
3596+
ReferenceRegistration::DoNotRegister => (),
36043597

3605-
ReferenceRegistration::RegisterReferences
3606-
| ReferenceRegistration::VariableArgumentReferences { .. } => {
3598+
ReferenceRegistration::Register | ReferenceRegistration::VariableArgument { .. } => {
36073599
self.register_value_constructor_reference(
36083600
name,
36093601
&variant,
@@ -3634,7 +3626,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
36343626
register_reference: &ReferenceRegistration,
36353627
) {
36363628
// If we are registering references for a call argument
3637-
let ReferenceRegistration::VariableArgumentReferences {
3629+
let ReferenceRegistration::VariableArgument {
36383630
called_function,
36393631
argument_index,
36403632
} = register_reference
@@ -3657,7 +3649,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
36573649

36583650
// If the called function is the same where the argument is defined,
36593651
// and the argument is passed unchanged.
3660-
if declaration_function.as_ref() == dbg!(Some(called_function))
3652+
if declaration_function.as_ref() == Some(called_function)
36613653
&& declaration_index == argument_index
36623654
{
36633655
self.environment.increment_recursive_usage(name);
@@ -4539,12 +4531,12 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
45394531
} = called_function
45404532
&& *module == self.environment.current_module
45414533
{
4542-
ReferenceRegistration::VariableArgumentReferences {
4534+
ReferenceRegistration::VariableArgument {
45434535
called_function: name.clone(),
45444536
argument_index,
45454537
}
45464538
} else {
4547-
ReferenceRegistration::RegisterReferences
4539+
ReferenceRegistration::Register
45484540
};
45494541

45504542
match self.infer_var(argument_name, argument_location, references) {
@@ -4823,14 +4815,17 @@ fn is_trusted_pure_module(environment: &Environment<'_>) -> bool {
48234815

48244816
#[derive(Debug, Clone)]
48254817
enum ReferenceRegistration {
4826-
RegisterReferences,
4827-
DoNotRegisterReferences,
4828-
4829-
/// If the variable is being passed to a function that is defined in the
4830-
/// current module, then this will have the name of the function and the
4831-
/// argument of the variable being passed as an argument
4832-
VariableArgumentReferences {
4818+
Register,
4819+
DoNotRegister,
4820+
4821+
/// A special case that happens if we're registering references for
4822+
/// a variable call argument being passed to a function defined in the
4823+
/// current module.
4824+
VariableArgument {
4825+
/// The name of the function being called, the function is defined in
4826+
/// the current module.
48334827
called_function: EcoString,
4828+
/// The position where the variable is being passed as an argument.
48344829
argument_index: usize,
48354830
},
48364831
}

0 commit comments

Comments
 (0)