Skip to content

Commit 85ac5dd

Browse files
committed
no-core-2.rs
1 parent 15935fe commit 85ac5dd

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tests/ui/no_std/no-core-edition2018-syntax.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1+
//! Test that `#![no_core]` doesn't break modern Rust syntax in edition 2018.
2+
//!
3+
//! When you use `#![no_core]`, you lose the automatic prelude, but you can still
4+
//! get everything back by manually importing `use core::{prelude::v1::*, *}`.
5+
//! This test makes sure that after doing that, things like `for` loops and the
6+
//! `?` operator still work as expected.
7+
18
//@ run-pass
9+
//@ edition:2018
210

311
#![allow(dead_code, unused_imports)]
412
#![feature(no_core)]
513
#![no_core]
6-
//@ edition:2018
714

8-
extern crate std;
915
extern crate core;
10-
use core::{prelude::v1::*, *};
16+
extern crate std;
17+
use core::prelude::v1::*;
18+
use core::*;
1119

12-
fn foo() {
20+
fn test_for_loop() {
1321
for _ in &[()] {}
1422
}
1523

16-
fn bar() -> Option<()> {
24+
fn test_question_mark_operator() -> Option<()> {
1725
None?
1826
}
1927

0 commit comments

Comments
 (0)