Skip to content

Commit 8122ad4

Browse files
GearsDatapackslpil
authored andcommitted
Remove unnecessary function
1 parent 3eddc98 commit 8122ad4

File tree

3 files changed

+16
-28
lines changed

3 files changed

+16
-28
lines changed

compiler-core/src/error.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(clippy::unwrap_used, clippy::expect_used)]
22
use crate::build::{Origin, Outcome, Runtime, Target};
33
use crate::diagnostic::{Diagnostic, ExtraLabel, Label, Location};
4-
use crate::strings::{to_snake_case, to_upper_camel_case, uppercase_first_letter};
4+
use crate::strings::{to_snake_case, to_upper_camel_case};
55
use crate::type_::collapse_links;
66
use crate::type_::error::{
77
InvalidImportKind, MissingAnnotation, ModuleValueUsageContext, Named, UnknownField,
@@ -3512,29 +3512,29 @@ See: https://tour.gleam.run/advanced-features/use/");
35123512

35133513
TypeError::BadName { location, name, kind } => {
35143514
let kind_str = kind.as_str();
3515-
let label = format!("This is not a valid {kind_str} name");
3515+
let label = format!("This is not a valid {} name", kind_str.to_lowercase());
35163516
let text = match kind {
35173517
Named::Type |
35183518
Named::TypeAlias |
35193519
Named::CustomTypeVariant => wrap_format!("Hint: {} names start with an uppercase \
35203520
letter and contain only lowercase letters, numbers, \
35213521
and uppercase letters.
3522-
Try: {}", uppercase_first_letter(kind_str), to_upper_camel_case(name)),
3522+
Try: {}", kind_str, to_upper_camel_case(name)),
35233523
Named::Variable |
35243524
Named::TypeVariable |
35253525
Named::Argument |
35263526
Named::Label |
35273527
Named::Constant |
35283528
Named::Function => wrap_format!("Hint: {} names start with a lowercase letter \
35293529
and contain a-z, 0-9, or _.
3530-
Try: {}", uppercase_first_letter(kind_str), to_snake_case(name)),
3530+
Try: {}", kind_str, to_snake_case(name)),
35313531
Named::Discard => wrap_format!("Hint: {} names start with _ and contain \
35323532
a-z, 0-9, or _.
3533-
Try: _{}", uppercase_first_letter(kind_str), to_snake_case(name)),
3533+
Try: _{}", kind_str, to_snake_case(name)),
35343534
};
35353535

35363536
Diagnostic {
3537-
title: format!("Invalid {kind_str} name"),
3537+
title: format!("Invalid {} name", kind_str.to_lowercase()),
35383538
text,
35393539
hint: None,
35403540
level: Level::Error,

compiler-core/src/strings.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,3 @@ pub fn to_upper_camel_case(string: &str) -> EcoString {
110110

111111
pascal_case
112112
}
113-
114-
pub fn uppercase_first_letter(string: &str) -> EcoString {
115-
let mut uppercased = EcoString::with_capacity(string.len());
116-
let mut chars = string.chars();
117-
if let Some(first) = chars.next() {
118-
uppercased.push(first.to_ascii_uppercase());
119-
}
120-
for char in chars {
121-
uppercased.push(char);
122-
}
123-
uppercased
124-
}

compiler-core/src/type_/error.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -690,16 +690,16 @@ pub enum Named {
690690
impl Named {
691691
pub fn as_str(self) -> &'static str {
692692
match self {
693-
Named::Type => "type",
694-
Named::TypeAlias => "type alias",
695-
Named::TypeVariable => "type variable",
696-
Named::CustomTypeVariant => "type variant",
697-
Named::Variable => "variable",
698-
Named::Argument => "argument",
699-
Named::Label => "label",
700-
Named::Constant => "constant",
701-
Named::Function => "function",
702-
Named::Discard => "discard",
693+
Named::Type => "Type",
694+
Named::TypeAlias => "Type alias",
695+
Named::TypeVariable => "Type variable",
696+
Named::CustomTypeVariant => "Type variant",
697+
Named::Variable => "Variable",
698+
Named::Argument => "Argument",
699+
Named::Label => "Label",
700+
Named::Constant => "Constant",
701+
Named::Function => "Function",
702+
Named::Discard => "Discard",
703703
}
704704
}
705705
}

0 commit comments

Comments
 (0)