Skip to content

Commit 846df20

Browse files
committed
Fix 2018 edition expanded pretty printing
1 parent beb2f5b commit 846df20

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/libsyntax/print/pprust.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,14 @@ pub fn print_crate<'a>(cm: &'a SourceMap,
128128
let fake_attr = attr::mk_attr_inner(list);
129129
s.print_attribute(&fake_attr);
130130

131-
// #![no_std]
132-
let no_std_meta = attr::mk_word_item(ast::Ident::with_dummy_span(sym::no_std));
133-
let fake_attr = attr::mk_attr_inner(no_std_meta);
134-
s.print_attribute(&fake_attr);
131+
// Currently on Rust 2018 we don't have `extern crate std;` at the crate
132+
// root, so this is not needed, and actually breaks things.
133+
if sess.edition == syntax_pos::edition::Edition::Edition2015 {
134+
// #![no_std]
135+
let no_std_meta = attr::mk_word_item(ast::Ident::with_dummy_span(sym::no_std));
136+
let fake_attr = attr::mk_attr_inner(no_std_meta);
137+
s.print_attribute(&fake_attr);
138+
}
135139
}
136140

137141
s.print_mod(&krate.module, &krate.attrs);

0 commit comments

Comments
 (0)