Skip to content

Commit a6694d2

Browse files
committed
Move ordinalize() to rustc_lint
1 parent a84331b commit a6694d2

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

compiler/rustc_lint/src/context/diagnostics.rs

+14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ use rustc_span::BytePos;
1111

1212
mod check_cfg;
1313

14+
#[cfg(test)]
15+
mod tests;
16+
1417
pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiag, diag: &mut Diag<'_, ()>) {
1518
match diagnostic {
1619
BuiltinLintDiag::UnicodeTextFlow(span, content) => {
@@ -472,3 +475,14 @@ pub(super) fn builtin_message(diagnostic: &BuiltinLintDiag) -> DiagMessage {
472475
.into(),
473476
}
474477
}
478+
479+
/// Convert the given number into the corresponding ordinal
480+
pub(crate) fn ordinalize(v: usize) -> String {
481+
let suffix = match ((11..=13).contains(&(v % 100)), v % 10) {
482+
(false, 1) => "st",
483+
(false, 2) => "nd",
484+
(false, 3) => "rd",
485+
_ => "th",
486+
};
487+
format!("{v}{suffix}")
488+
}

compiler/rustc_resolve/src/diagnostics.rs

-14
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ use crate::{LexicalScopeBinding, NameBinding, NameBindingKind, PrivacyError, Vis
4343
use crate::{ParentScope, PathResult, ResolutionError, Resolver, Scope, ScopeSet};
4444
use crate::{Segment, UseError};
4545

46-
#[cfg(test)]
47-
mod tests;
48-
4946
type Res = def::Res<ast::NodeId>;
5047

5148
/// A vector of spans and replacements, a message and applicability.
@@ -3020,14 +3017,3 @@ fn is_span_suitable_for_use_injection(s: Span) -> bool {
30203017
// import or other generated ones
30213018
!s.from_expansion()
30223019
}
3023-
3024-
/// Convert the given number into the corresponding ordinal
3025-
pub(crate) fn ordinalize(v: usize) -> String {
3026-
let suffix = match ((11..=13).contains(&(v % 100)), v % 10) {
3027-
(false, 1) => "st",
3028-
(false, 2) => "nd",
3029-
(false, 3) => "rd",
3030-
_ => "th",
3031-
};
3032-
format!("{v}{suffix}")
3033-
}

0 commit comments

Comments
 (0)