Skip to content

Commit 1c05050

Browse files
committed
forbid namespaced crate names with more than two segments
1 parent 96df2a7 commit 1c05050

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

compiler/rustc_session/src/config/externs.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ pub(crate) fn split_extern_opt<'a>(
4343
}
4444
};
4545

46+
// Reject paths with more than two segments.
47+
if unstable_opts.namespaced_crates && crate_name.split("::").count() > 2 {
48+
return Err(early_dcx.early_struct_fatal(format!(
49+
"crate name `{crate_name}` passed to `--extern` has too many segments; namespaced crates currently support at most two segments"
50+
)));
51+
}
52+
4653
if !valid_crate_name(&crate_name, unstable_opts) {
4754
let mut error = early_dcx.early_struct_fatal(format!(
4855
"crate name `{crate_name}` passed to `--extern` is not a valid ASCII identifier"

0 commit comments

Comments
 (0)