Skip to content

Commit b99fae1

Browse files
committed
---
yaml --- r: 234378 b: refs/heads/tmp c: 1bf060f h: refs/heads/master v: v3
1 parent f0dc721 commit b99fae1

File tree

11 files changed

+103
-31
lines changed

11 files changed

+103
-31
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: f7ffd502e57c0e53c77f47a7c80d2fdc67559fd3
28+
refs/heads/tmp: 1bf060ffb31ef6dc79543b4c10b975cd802020d0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: ab792abf1fcc28afbd315426213f6428da25c085
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/doc/trpl/method-syntax.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ can be awkward. Consider this code:
77
baz(bar(foo));
88
```
99

10-
We would read this left-to right, and so we see ‘baz bar foo’. But this isn’t the
10+
We would read this left-to-right, and so we see ‘baz bar foo’. But this isn’t the
1111
order that the functions would get called in, that’s inside-out: ‘foo bar baz’.
1212
Wouldn’t it be nice if we could do this instead?
1313

@@ -45,17 +45,17 @@ This will print `12.566371`.
4545

4646

4747

48-
We’ve made a struct that represents a circle. We then write an `impl` block,
48+
We’ve made a `struct` that represents a circle. We then write an `impl` block,
4949
and inside it, define a method, `area`.
5050

51-
Methods take a special first parameter, of which there are three variants:
51+
Methods take a special first parameter, of which there are three variants:
5252
`self`, `&self`, and `&mut self`. You can think of this first parameter as
5353
being the `foo` in `foo.bar()`. The three variants correspond to the three
5454
kinds of things `foo` could be: `self` if it’s just a value on the stack,
5555
`&self` if it’s a reference, and `&mut self` if it’s a mutable reference.
5656
Because we took the `&self` parameter to `area`, we can use it just like any
5757
other parameter. Because we know it’s a `Circle`, we can access the `radius`
58-
just like we would with any other struct.
58+
just like we would with any other `struct`.
5959

6060
We should default to using `&self`, as you should prefer borrowing over taking
6161
ownership, as well as taking immutable references over mutable ones. Here’s an
@@ -120,12 +120,12 @@ Check the return type:
120120
```rust
121121
# struct Circle;
122122
# impl Circle {
123-
fn grow(&self) -> Circle {
123+
fn grow(&self, increment: f64) -> Circle {
124124
# Circle } }
125125
```
126126

127127
We just say we’re returning a `Circle`. With this method, we can grow a new
128-
circle to any arbitrary size.
128+
`Circle` to any arbitrary size.
129129

130130
# Associated functions
131131

@@ -161,7 +161,7 @@ methods’.
161161

162162
# Builder Pattern
163163

164-
Let’s say that we want our users to be able to create Circles, but we will
164+
Let’s say that we want our users to be able to create `Circle`s, but we will
165165
allow them to only set the properties they care about. Otherwise, the `x`
166166
and `y` attributes will be `0.0`, and the `radius` will be `1.0`. Rust doesn’t
167167
have method overloading, named arguments, or variable arguments. We employ
@@ -224,7 +224,7 @@ fn main() {
224224
}
225225
```
226226

227-
What we’ve done here is make another struct, `CircleBuilder`. We’ve defined our
227+
What we’ve done here is make another `struct`, `CircleBuilder`. We’ve defined our
228228
builder methods on it. We’ve also defined our `area()` method on `Circle`. We
229229
also made one more method on `CircleBuilder`: `finalize()`. This method creates
230230
our final `Circle` from the builder. Now, we’ve used the type system to enforce

branches/tmp/src/librustc/diagnostics.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ E0002: r##"
4444
This error indicates that an empty match expression is invalid because the type
4545
it is matching on is non-empty (there exist values of this type). In safe code
4646
it is impossible to create an instance of an empty type, so empty match
47-
expressions are almost never desired. This error is typically fixed by adding
47+
expressions are almost never desired. This error is typically fixed by adding
4848
one or more cases to the match expression.
4949
5050
An example of an empty type is `enum Empty { }`. So, the following will work:
@@ -218,7 +218,14 @@ match x {
218218
E0010: r##"
219219
The value of statics and constants must be known at compile time, and they live
220220
for the entire lifetime of a program. Creating a boxed value allocates memory on
221-
the heap at runtime, and therefore cannot be done at compile time.
221+
the heap at runtime, and therefore cannot be done at compile time. Erroneous
222+
code example:
223+
224+
```
225+
#![feature(box_syntax)]
226+
227+
const CON : Box<i32> = box 0;
228+
```
222229
"##,
223230

224231
E0011: r##"
@@ -335,7 +342,6 @@ is not allowed.
335342
336343
If you really want global mutable state, try using `static mut` or a global
337344
`UnsafeCell`.
338-
339345
"##,
340346

341347
E0018: r##"
@@ -399,7 +405,13 @@ fn main() {
399405

400406
E0020: r##"
401407
This error indicates that an attempt was made to divide by zero (or take the
402-
remainder of a zero divisor) in a static or constant expression.
408+
remainder of a zero divisor) in a static or constant expression. Erroneous
409+
code example:
410+
411+
```
412+
const X: i32 = 42 / 0;
413+
// error: attempted to divide by zero in a constant expression
414+
```
403415
"##,
404416

405417
E0022: r##"

branches/tmp/src/librustc/middle/check_match.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) {
218218
span_err!(cx.tcx.sess, ex.span, E0002,
219219
"non-exhaustive patterns: type {} is non-empty",
220220
pat_ty);
221+
span_help!(cx.tcx.sess, ex.span,
222+
"Please ensure that all possible cases are being handled; \
223+
possibly adding wildcards or more match arms.");
221224
}
222225
// If the type *is* empty, it's vacuously exhaustive
223226
return;

branches/tmp/src/librustc_typeck/diagnostics.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2475,6 +2475,24 @@ struct Bar<S, T> { x: Foo<S, T> }
24752475
```
24762476
"##,
24772477

2478+
//NB: not currently reachable
2479+
E0247: r##"
2480+
This error indicates an attempt to use a module name where a type is expected.
2481+
For example:
2482+
2483+
```
2484+
mod MyMod {
2485+
mod MySubMod { }
2486+
}
2487+
2488+
fn do_something(x: MyMod::MySubMod) { }
2489+
```
2490+
2491+
In this example, we're attempting to take a parameter of type `MyMod::MySubMod`
2492+
in the do_something function. This is not legal: `MyMod::MySubMod` is a module
2493+
name, not a type.
2494+
"##,
2495+
24782496
E0248: r##"
24792497
This error indicates an attempt to use a value where a type is expected. For
24802498
example:
@@ -3291,7 +3309,6 @@ register_diagnostics! {
32913309
E0242, // internal error looking up a definition
32923310
E0245, // not a trait
32933311
// E0246, // invalid recursive type
3294-
E0247, // found module name used as a type
32953312
// E0319, // trait impls for defaulted traits allowed just for structs/enums
32963313
E0320, // recursive overflow during dropck
32973314
E0321, // extended coherence rules for defaulted traits violated

branches/tmp/src/libstd/sys/windows/backtrace.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ extern "system" {
6060
type SymFromAddrFn =
6161
extern "system" fn(libc::HANDLE, u64, *mut u64,
6262
*mut SYMBOL_INFO) -> libc::BOOL;
63+
type SymGetLineFromAddr64Fn =
64+
extern "system" fn(libc::HANDLE, u64, *mut u32,
65+
*mut IMAGEHLP_LINE64) -> libc::BOOL;
6366
type SymInitializeFn =
6467
extern "system" fn(libc::HANDLE, *mut libc::c_void,
6568
libc::BOOL) -> libc::BOOL;
@@ -99,6 +102,14 @@ struct SYMBOL_INFO {
99102
Name: [libc::c_char; MAX_SYM_NAME],
100103
}
101104

105+
#[repr(C)]
106+
struct IMAGEHLP_LINE64 {
107+
SizeOfStruct: u32,
108+
Key: *const libc::c_void,
109+
LineNumber: u32,
110+
Filename: *const libc::c_char,
111+
Address: u64,
112+
}
102113

103114
#[repr(C)]
104115
enum ADDRESS_MODE {

branches/tmp/src/libstd/sys/windows/printing/msvc.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use sys_common::backtrace::output;
11+
use sys_common::backtrace::{output, output_fileline};
1212
use ffi::CStr;
1313
use dynamic_lib::DynamicLibrary;
14-
use super::{SymFromAddrFn, SYMBOL_INFO, MAX_SYM_NAME};
14+
use super::{SymFromAddrFn, SymGetLineFromAddr64Fn, SYMBOL_INFO, MAX_SYM_NAME, IMAGEHLP_LINE64};
1515
use io;
1616
use io::prelude::*;
1717
use intrinsics;
@@ -20,6 +20,7 @@ use libc;
2020
pub fn print(w: &mut Write, i: isize, addr: u64, dbghelp: &DynamicLibrary, process: libc::HANDLE)
2121
-> io::Result<()> {
2222
let SymFromAddr = sym!(dbghelp, "SymFromAddr", SymFromAddrFn);
23+
let SymGetLineFromAddr64 = sym!(dbghelp, "SymGetLineFromAddr64", SymGetLineFromAddr64Fn);
2324

2425
let mut info: SYMBOL_INFO = unsafe { intrinsics::init() };
2526
info.MaxNameLen = MAX_SYM_NAME as libc::c_ulong;
@@ -29,7 +30,7 @@ pub fn print(w: &mut Write, i: isize, addr: u64, dbghelp: &DynamicLibrary, proce
2930
info.SizeOfStruct = 88;
3031

3132
let mut displacement = 0u64;
32-
let ret = SymFromAddr(process, addr as u64, &mut displacement, &mut info);
33+
let ret = SymFromAddr(process, addr, &mut displacement, &mut info);
3334

3435
let name = if ret == libc::TRUE {
3536
let ptr = info.Name.as_ptr() as *const libc::c_char;
@@ -38,5 +39,20 @@ pub fn print(w: &mut Write, i: isize, addr: u64, dbghelp: &DynamicLibrary, proce
3839
None
3940
};
4041

41-
output(w, i, addr as usize as *mut libc::c_void, name)
42+
try!(output(w, i, addr as usize as *mut libc::c_void, name));
43+
44+
// Now find out the filename and line number
45+
let mut line: IMAGEHLP_LINE64 = unsafe { intrinsics::init() };
46+
line.SizeOfStruct = ::mem::size_of::<IMAGEHLP_LINE64>() as u32;
47+
48+
let mut displacement = 0u32;
49+
let ret = SymGetLineFromAddr64(process, addr, &mut displacement, &mut line);
50+
if ret == libc::TRUE {
51+
output_fileline(w,
52+
unsafe { CStr::from_ptr(line.Filename).to_bytes() },
53+
line.LineNumber as libc::c_int,
54+
false)
55+
} else {
56+
Ok(())
57+
}
4258
}

branches/tmp/src/rustbook/book.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn parse_summary(input: &mut Read, src: &Path) -> Result<Book, Vec<String>>
102102
top_items.push(BookItem {
103103
title: "Introduction".to_string(),
104104
path: PathBuf::from("README.md"),
105-
path_to_root: PathBuf::from("."),
105+
path_to_root: PathBuf::from(""),
106106
children: vec!(),
107107
});
108108

branches/tmp/src/rustbook/build.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ fn write_toc(book: &Book, current_page: &BookItem, out: &mut Write) -> io::Resul
5252
current_page: &BookItem,
5353
out: &mut Write) -> io::Result<()> {
5454
let class_string = if item.path == current_page.path {
55-
"class='active'"
55+
"class='active'"
5656
} else {
57-
""
57+
""
5858
};
5959

6060
try!(writeln!(out, "<li><a {} href='{}'><b>{}</b> {}</a>",
61-
class_string,
62-
current_page.path_to_root.join(&item.path).with_extension("html").display(),
63-
section,
64-
item.title));
61+
class_string,
62+
current_page.path_to_root.join(&item.path).with_extension("html").display(),
63+
section,
64+
item.title));
6565
if !item.children.is_empty() {
6666
try!(writeln!(out, "<ul class='section'>"));
6767
let _ = walk_items(&item.children[..], section, current_page, out);

branches/tmp/src/test/run-pass/backtrace-debuginfo-aux.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ pub fn callback<F>(f: F) where F: FnOnce((&'static str, u32)) {
1515
f((file!(), line!()))
1616
}
1717

18-
#[inline(always)]
18+
// LLVM does not yet output the required debug info to support showing inlined
19+
// function calls in backtraces when targetting MSVC, so disable inlining in
20+
// this case.
21+
#[cfg_attr(not(target_env = "msvc"), inline(always))]
22+
#[cfg_attr(target_env = "msvc", inline(never))]
1923
pub fn callback_inlined<F>(f: F) where F: FnOnce((&'static str, u32)) {
2024
f((file!(), line!()))
2125
}

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ macro_rules! pos {
3232
not(target_os = "ios"),
3333
not(target_os = "android"),
3434
not(all(target_os = "linux", target_arch = "arm"))),
35-
all(windows, target_env = "gnu", not(target_arch = "x86"))))]
35+
all(windows, not(target_arch = "x86"))))]
3636
macro_rules! dump_and_die {
3737
($($pos:expr),*) => ({
3838
// FIXME(#18285): we cannot include the current position because
@@ -48,7 +48,7 @@ macro_rules! dump_and_die {
4848
not(target_os = "ios"),
4949
not(target_os = "android"),
5050
not(all(target_os = "linux", target_arch = "arm"))),
51-
all(windows, target_env = "gnu", not(target_arch = "x86")))))]
51+
all(windows, not(target_arch = "x86")))))]
5252
macro_rules! dump_and_die {
5353
($($pos:expr),*) => ({ let _ = [$($pos),*]; })
5454
}
@@ -69,7 +69,10 @@ type Pos = (&'static str, u32);
6969
// this goes to stdout and each line has to be occurred
7070
// in the following backtrace to stderr with a correct order.
7171
fn dump_filelines(filelines: &[Pos]) {
72-
for &(file, line) in filelines.iter().rev() {
72+
// Skip top frame for MSVC, because it sees the macro rather than
73+
// the containing function.
74+
let skip = if cfg!(target_env = "msvc") {1} else {0};
75+
for &(file, line) in filelines.iter().rev().skip(skip) {
7376
// extract a basename
7477
let basename = file.split(&['/', '\\'][..]).last().unwrap();
7578
println!("{}:{}", basename, line);
@@ -88,12 +91,18 @@ fn inner(counter: &mut i32, main_pos: Pos, outer_pos: Pos) {
8891
});
8992
}
9093

91-
#[inline(always)]
94+
// LLVM does not yet output the required debug info to support showing inlined
95+
// function calls in backtraces when targetting MSVC, so disable inlining in
96+
// this case.
97+
#[cfg_attr(not(target_env = "msvc"), inline(always))]
98+
#[cfg_attr(target_env = "msvc", inline(never))]
9299
fn inner_inlined(counter: &mut i32, main_pos: Pos, outer_pos: Pos) {
93100
check!(counter; main_pos, outer_pos);
94101
check!(counter; main_pos, outer_pos);
95102

96-
#[inline(always)]
103+
// Again, disable inlining for MSVC.
104+
#[cfg_attr(not(target_env = "msvc"), inline(always))]
105+
#[cfg_attr(target_env = "msvc", inline(never))]
97106
fn inner_further_inlined(counter: &mut i32, main_pos: Pos, outer_pos: Pos, inner_pos: Pos) {
98107
check!(counter; main_pos, outer_pos, inner_pos);
99108
}

0 commit comments

Comments
 (0)