Skip to content

Commit 8f692e6

Browse files
committed
rustc: Future proof runtime injection
Rename and gensym the runtime on import, so that users can't refer to the `native` crate. This is unlikely to break code, but users should import the "native" crate directly. [breaking-change]
1 parent b9035c2 commit 8f692e6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/librustc/front/std_inject.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,15 @@ impl<'a> fold::Folder for StandardLibraryInjector<'a> {
8686
*ty == config::CrateTypeExecutable
8787
});
8888
if use_start(&krate) && any_exe {
89+
let visible_rt_name = "rt";
90+
let actual_rt_name = "native";
91+
// Gensym the ident so it can't be named
92+
let visible_rt_name = token::gensym_ident(visible_rt_name);
93+
let actual_rt_name = token::intern_and_get_ident(actual_rt_name);
94+
8995
vis.push(ast::ViewItem {
90-
node: ast::ViewItemExternCrate(token::str_to_ident("native"),
91-
None,
96+
node: ast::ViewItemExternCrate(visible_rt_name,
97+
Some((actual_rt_name, ast::CookedStr)),
9298
ast::DUMMY_NODE_ID),
9399
attrs: Vec::new(),
94100
vis: ast::Inherited,

0 commit comments

Comments
 (0)