Skip to content

Commit 2dcda16

Browse files
committed
Move ordinalize() to rustc_lint
1 parent e7d1e2d commit 2dcda16

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

compiler/rustc_lint/src/context/diagnostics.rs

Lines changed: 14 additions & 0 deletions
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) => {
@@ -470,3 +473,14 @@ pub(super) fn builtin_message(diagnostic: &BuiltinLintDiag) -> DiagMessage {
470473
.into(),
471474
}
472475
}
476+
477+
/// Convert the given number into the corresponding ordinal
478+
pub(crate) fn ordinalize(v: usize) -> String {
479+
let suffix = match ((11..=13).contains(&(v % 100)), v % 10) {
480+
(false, 1) => "st",
481+
(false, 2) => "nd",
482+
(false, 3) => "rd",
483+
_ => "th",
484+
};
485+
format!("{v}{suffix}")
486+
}

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ use crate::{LexicalScopeBinding, NameBinding, NameBindingKind, PrivacyError, Vis
4444
use crate::{ParentScope, PathResult, ResolutionError, Resolver, Scope, ScopeSet};
4545
use crate::{Segment, UseError};
4646

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

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

0 commit comments

Comments
 (0)