Skip to content

Commit 4b007d8

Browse files
committed
---
yaml --- r: 274519 b: refs/heads/stable c: 5ed8e98 h: refs/heads/master i: 274517: f3de8f5 274515: f386593 274511: 67fc0de
1 parent a783ada commit 4b007d8

File tree

12 files changed

+129
-77
lines changed

12 files changed

+129
-77
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 54664f188403a5bb72634b5e3ba9b2f7b60b4d9f
32+
refs/heads/stable: 5ed8e98ea220d797c213a356f354b958f4ccfc49
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/librustc_resolve/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
14681468
match search_module.parent_link {
14691469
NoParentLink => {
14701470
// No more parents. This module was unresolved.
1471-
debug!("(resolving item in lexical scope) unresolved module");
1471+
debug!("(resolving item in lexical scope) unresolved module: no parent module");
14721472
return Failed(None);
14731473
}
14741474
ModuleParentLink(parent_module_node, _) => {
@@ -3109,7 +3109,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
31093109
}
31103110
Indeterminate => None,
31113111
Failed(err) => {
3112-
debug!("(resolving item path by identifier in lexical scope) failed to resolve {}",
3112+
debug!("(resolving item path by identifier in lexical scope) failed to \
3113+
resolve `{}`",
31133114
name);
31143115

31153116
if let Some((span, msg)) = err {

branches/stable/src/librustc_resolve/resolve_imports.rs

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use self::ImportDirectiveSubclass::*;
1212

1313
use DefModifiers;
14+
use DefOrModule;
1415
use Module;
1516
use Namespace::{self, TypeNS, ValueNS};
1617
use NameBinding;
@@ -50,7 +51,7 @@ pub enum Shadowable {
5051
}
5152

5253
/// One import directive.
53-
#[derive(Debug)]
54+
#[derive(Debug,Clone)]
5455
pub struct ImportDirective {
5556
pub module_path: Vec<Name>,
5657
pub subclass: ImportDirectiveSubclass,
@@ -140,9 +141,11 @@ impl<'a> ImportResolution<'a> {
140141
}
141142
}
142143

143-
struct ImportResolvingError {
144+
struct ImportResolvingError<'a> {
145+
/// Module where the error happened
146+
source_module: Module<'a>,
147+
import_directive: ImportDirective,
144148
span: Span,
145-
path: String,
146149
help: String,
147150
}
148151

@@ -181,9 +184,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
181184
// resolving failed
182185
if errors.len() > 0 {
183186
for e in errors {
184-
resolve_error(self.resolver,
185-
e.span,
186-
ResolutionError::UnresolvedImport(Some((&e.path, &e.help))));
187+
self.import_resolving_error(e)
187188
}
188189
} else {
189190
// Report unresolved imports only if no hard error was already reported
@@ -200,11 +201,55 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
200201
}
201202
}
202203

204+
/// Resolves an `ImportResolvingError` into the correct enum discriminant
205+
/// and passes that on to `resolve_error`.
206+
fn import_resolving_error(&self, e: ImportResolvingError) {
207+
// If it's a single failed import then create a "fake" import
208+
// resolution for it so that later resolve stages won't complain.
209+
if let SingleImport(target, _) = e.import_directive.subclass {
210+
let mut import_resolutions = e.source_module.import_resolutions.borrow_mut();
211+
212+
let resolution = import_resolutions.entry((target, ValueNS)).or_insert_with(|| {
213+
debug!("(resolving import error) adding import resolution for `{}`",
214+
target);
215+
216+
ImportResolution::new(e.import_directive.id,
217+
e.import_directive.is_public)
218+
});
219+
220+
if resolution.target.is_none() {
221+
debug!("(resolving import error) adding fake target to import resolution of `{}`",
222+
target);
223+
224+
let name_binding = NameBinding {
225+
modifiers: DefModifiers::IMPORTABLE,
226+
def_or_module: DefOrModule::Def(Def::Err),
227+
span: None,
228+
};
229+
230+
// Create a fake target pointing to a fake name binding in our
231+
// own module
232+
let target = Target::new(e.source_module,
233+
name_binding,
234+
Shadowable::Always);
235+
236+
resolution.target = Some(target);
237+
}
238+
}
239+
240+
let path = import_path_to_string(&e.import_directive.module_path,
241+
e.import_directive.subclass);
242+
243+
resolve_error(self.resolver,
244+
e.span,
245+
ResolutionError::UnresolvedImport(Some((&path, &e.help))));
246+
}
247+
203248
/// Attempts to resolve imports for the given module and all of its
204249
/// submodules.
205250
fn resolve_imports_for_module_subtree(&mut self,
206251
module_: Module<'b>)
207-
-> Vec<ImportResolvingError> {
252+
-> Vec<ImportResolvingError<'b>> {
208253
let mut errors = Vec::new();
209254
debug!("(resolving imports for module subtree) resolving {}",
210255
module_to_string(&*module_));
@@ -232,7 +277,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
232277
}
233278

234279
/// Attempts to resolve imports for the given module only.
235-
fn resolve_imports_for_module(&mut self, module: Module<'b>) -> Vec<ImportResolvingError> {
280+
fn resolve_imports_for_module(&mut self, module: Module<'b>) -> Vec<ImportResolvingError<'b>> {
236281
let mut errors = Vec::new();
237282

238283
if module.all_imports_resolved() {
@@ -254,9 +299,9 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
254299
None => (import_directive.span, String::new()),
255300
};
256301
errors.push(ImportResolvingError {
302+
source_module: module,
303+
import_directive: import_directive.clone(),
257304
span: span,
258-
path: import_path_to_string(&import_directive.module_path,
259-
import_directive.subclass),
260305
help: help,
261306
});
262307
}
@@ -784,7 +829,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
784829
namespace_name,
785830
name);
786831
span_err!(self.resolver.session, import_directive.span, E0251, "{}", msg);
787-
} else {
832+
} else {
788833
let target = Target::new(containing_module,
789834
name_binding.clone(),
790835
import_directive.shadowable);

branches/stable/src/librustc_trans/trans/debuginfo/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,6 @@ pub fn finalize(cx: &CrateContext) {
200200
2)
201201
}
202202

203-
// Indicate that we want CodeView debug information on MSVC
204-
if cx.sess().target.target.options.is_like_msvc {
205-
llvm::LLVMRustAddModuleFlag(cx.llmod(),
206-
"CodeView\0".as_ptr() as *const _,
207-
1)
208-
}
209-
210203
// Prevent bitcode readers from deleting the debug info.
211204
let ptr = "Debug Info Version\0".as_ptr();
212205
llvm::LLVMRustAddModuleFlag(cx.llmod(), ptr as *const _,

branches/stable/src/libstd/sys/unix/fs.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,20 @@ impl DirEntry {
211211
#[cfg(any(target_os = "macos",
212212
target_os = "ios",
213213
target_os = "netbsd",
214-
target_os = "openbsd",
215-
target_os = "freebsd",
214+
target_os = "openbsd"))]
215+
fn name_bytes(&self) -> &[u8] {
216+
unsafe {
217+
::slice::from_raw_parts(self.entry.d_name.as_ptr() as *const u8,
218+
self.entry.d_namlen as usize)
219+
}
220+
}
221+
#[cfg(any(target_os = "freebsd",
216222
target_os = "dragonfly",
217223
target_os = "bitrig"))]
218224
fn name_bytes(&self) -> &[u8] {
219225
unsafe {
220226
::slice::from_raw_parts(self.entry.d_name.as_ptr() as *const u8,
221-
self.entry.d_namlen as usize)
227+
self.entry.d_namelen as usize)
222228
}
223229
}
224230
#[cfg(any(target_os = "android",

branches/stable/src/libstd/sys/unix/stack_overflow.rs

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -135,38 +135,26 @@ mod imp {
135135
Handler { _data: MAIN_ALTSTACK };
136136
}
137137

138-
unsafe fn get_stackp() -> *mut libc::c_void {
139-
let stackp = mmap(ptr::null_mut(),
140-
SIGSTKSZ,
141-
PROT_READ | PROT_WRITE,
142-
MAP_PRIVATE | MAP_ANON,
143-
-1,
144-
0);
145-
if stackp == MAP_FAILED {
138+
pub unsafe fn make_handler() -> Handler {
139+
let alt_stack = mmap(ptr::null_mut(),
140+
SIGSTKSZ,
141+
PROT_READ | PROT_WRITE,
142+
MAP_PRIVATE | MAP_ANON,
143+
-1,
144+
0);
145+
if alt_stack == MAP_FAILED {
146146
panic!("failed to allocate an alternative stack");
147147
}
148-
stackp
149-
}
150148

151-
#[cfg(any(target_os = "linux",
152-
target_os = "macos",
153-
target_os = "bitrig",
154-
target_os = "netbsd",
155-
target_os = "openbsd"))]
156-
unsafe fn get_stack() -> libc::stack_t {
157-
libc::stack_t { ss_sp: get_stackp(), ss_flags: 0, ss_size: SIGSTKSZ }
158-
}
149+
let mut stack: libc::stack_t = mem::zeroed();
159150

160-
#[cfg(any(target_os = "freebsd",
161-
target_os = "dragonfly"))]
162-
unsafe fn get_stack() -> libc::stack_t {
163-
libc::stack_t { ss_sp: get_stackp() as *mut i8, ss_flags: 0, ss_size: SIGSTKSZ }
164-
}
151+
stack.ss_sp = alt_stack;
152+
stack.ss_flags = 0;
153+
stack.ss_size = SIGSTKSZ;
165154

166-
pub unsafe fn make_handler() -> Handler {
167-
let stack = get_stack();
168155
sigaltstack(&stack, ptr::null_mut());
169-
Handler { _data: stack.ss_sp as *mut libc::c_void }
156+
157+
Handler { _data: alt_stack }
170158
}
171159

172160
pub unsafe fn drop_handler(handler: &mut Handler) {

branches/stable/src/libtest/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,12 +939,18 @@ fn get_concurrency() -> usize {
939939
fn num_cpus() -> usize {
940940
let mut cpus: libc::c_uint = 0;
941941
let mut cpus_size = std::mem::size_of_val(&cpus);
942+
let mut mib = [libc::CTL_HW, libc::HW_AVAILCPU, 0, 0];
942943

943944
unsafe {
944-
cpus = libc::sysconf(libc::_SC_NPROCESSORS_ONLN) as libc::c_uint;
945+
libc::sysctl(mib.as_mut_ptr(),
946+
2,
947+
&mut cpus as *mut _ as *mut _,
948+
&mut cpus_size as *mut _ as *mut _,
949+
0 as *mut _,
950+
0);
945951
}
946952
if cpus < 1 {
947-
let mut mib = [libc::CTL_HW, libc::HW_NCPU, 0, 0];
953+
mib[1] = libc::HW_NCPU;
948954
unsafe {
949955
libc::sysctl(mib.as_mut_ptr(),
950956
2,

branches/stable/src/test/compile-fail/import-from-missing.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@ mod spam {
1515
pub fn ham() { }
1616
}
1717

18-
fn main() { ham(); eggs(); }
19-
//~^ ERROR unresolved name `eggs`
18+
fn main() {
19+
ham();
20+
// Expect eggs to pass because the compiler inserts a fake name for it
21+
eggs();
22+
}

branches/stable/src/test/compile-fail/import2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
use baz::zed::bar;
1212
//~^ ERROR unresolved import `baz::zed::bar`. Could not find `zed` in `baz`
1313

14-
1514
mod baz {}
1615
mod zed {
1716
pub fn bar() { println!("bar3"); }
1817
}
19-
fn main() { bar(); }
20-
//~^ ERROR unresolved name `bar`
18+
fn main() {
19+
bar();
20+
}

branches/stable/src/test/compile-fail/privacy3.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ pub fn foo() {}
2727
fn test1() {
2828
use bar::gpriv;
2929
//~^ ERROR unresolved import `bar::gpriv`. There is no `gpriv` in `bar`
30+
31+
// This should pass because the compiler will insert a fake name binding
32+
// for `gpriv`
3033
gpriv();
31-
//~^ ERROR unresolved name `gpriv`
3234
}
3335

3436
#[start] fn main(_: isize, _: *const *const u8) -> isize { 3 }

branches/stable/src/test/run-pass/backtrace-debuginfo.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// seemingly completely unrelated change.
1515
// Unfortunately, LLVM has no "disable" option for this, so we have to set
1616
// "enable" to 0 instead.
17-
1817
// compile-flags:-g -Cllvm-args=-enable-tail-merge=0
1918
// ignore-pretty as this critically relies on line numbers
2019

@@ -28,23 +27,30 @@ macro_rules! pos {
2827
() => ((file!(), line!()))
2928
}
3029

30+
#[cfg(all(unix,
31+
not(target_os = "macos"),
32+
not(target_os = "ios"),
33+
not(target_os = "android"),
34+
not(all(target_os = "linux", target_arch = "arm"))))]
3135
macro_rules! dump_and_die {
3236
($($pos:expr),*) => ({
3337
// FIXME(#18285): we cannot include the current position because
3438
// the macro span takes over the last frame's file/line.
35-
if cfg!(target_os = "macos") ||
36-
cfg!(target_os = "ios") ||
37-
cfg!(target_os = "android") ||
38-
cfg!(all(target_os = "linux", target_arch = "arm")) ||
39-
cfg!(all(windows, target_env = "gnu")) {
40-
// skip these platforms as this support isn't implemented yet.
41-
} else {
42-
dump_filelines(&[$($pos),*]);
43-
panic!();
44-
}
39+
dump_filelines(&[$($pos),*]);
40+
panic!();
4541
})
4642
}
4743

44+
// this does not work on Windows, Android, OSX or iOS
45+
#[cfg(not(all(unix,
46+
not(target_os = "macos"),
47+
not(target_os = "ios"),
48+
not(target_os = "android"),
49+
not(all(target_os = "linux", target_arch = "arm")))))]
50+
macro_rules! dump_and_die {
51+
($($pos:expr),*) => ({ let _ = [$($pos),*]; })
52+
}
53+
4854
// we can't use a function as it will alter the backtrace
4955
macro_rules! check {
5056
($counter:expr; $($pos:expr),*) => ({

0 commit comments

Comments
 (0)