Skip to content

Commit

Permalink
Rollup merge of rust-lang#59462 - taiki-e:no-core, r=petrochenkov
Browse files Browse the repository at this point in the history
Fix error in Rust 2018 + no_core environment

Minimized reproduction: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=5b9f6c3026ec9d856699fa6dbd4361f0

This is a fix for the error that occurred in rust-lang#58702.

r? @Centril
  • Loading branch information
Centril committed Mar 29, 2019
2 parents 38af98e + 362d243 commit 647d09f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,12 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
components: &[&str],
is_value: bool
) -> hir::Path {
let segments = iter::once(keywords::PathRoot.ident())
let root = if crate_root.is_some() {
keywords::PathRoot
} else {
keywords::Crate
};
let segments = iter::once(root.ident())
.chain(
crate_root.into_iter()
.chain(components.iter().cloned())
Expand Down
18 changes: 18 additions & 0 deletions src/test/run-pass/no-core-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![allow(dead_code, unused_imports)]
#![feature(no_core)]
#![no_core]
// edition:2018

extern crate std;
extern crate core;
use core::{prelude::v1::*, *};

fn foo() {
for _ in &[()] {}
}

fn bar() -> Option<()> {
None?
}

fn main() {}

0 comments on commit 647d09f

Please sign in to comment.