Skip to content

Commit 5dd073e

Browse files
committed
Encourage developers not to use periods in target names
They can cause issues in e.g. cargo.
1 parent 9340e5c commit 5dd073e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/doc/rustc/src/target-tier-policy.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ approved by the appropriate team for that shared code before acceptance.
158158
the name of the target makes people extremely likely to form incorrect
159159
beliefs about what it targets, the name should be changed or augmented to
160160
disambiguate it.
161+
- If possible, use only letters, numbers, dashes and underscores for the name.
162+
Periods (`.`) are known to cause issues in Cargo.
161163
- Tier 3 targets may have unusual requirements to build or use, but must not
162164
create legal issues or impose onerous legal terms for the Rust project or for
163165
Rust developers or users.

src/tools/tier-check/src/main.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,23 @@ fn main() {
4444
target, filename, src
4545
);
4646
}
47-
if !missing.is_empty() || !extra.is_empty() {
47+
// Check target names for unwanted characters like `.` that can cause problems e.g. in Cargo.
48+
// See also Tier 3 target policy.
49+
// If desired, target names can ignore this check.
50+
let ignore_target_names =
51+
vec!["thumbv8m.base-none-eabi", "thumbv8m.main-none-eabi", "thumbv8m.main-none-eabihf"];
52+
let mut invalid_target_name_found = false;
53+
for target in &target_list {
54+
if !ignore_target_names.contains(target)
55+
&& !target.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')
56+
{
57+
invalid_target_name_found = true;
58+
eprintln!(
59+
"error: Target name `{target}` contains other characters than ASCII alphanumeric (a-z, A-Z, 0-9), dash (-) or underscore (_)."
60+
);
61+
}
62+
}
63+
if !missing.is_empty() || !extra.is_empty() || invalid_target_name_found {
4864
std::process::exit(1);
4965
}
5066
}

0 commit comments

Comments
 (0)