Skip to content

Commit b8c1f55

Browse files
committed
Merge pull request #26409 from brson/beta-backport
Plucked cherries for 1.1
2 parents 7991c0d + 04c7789 commit b8c1f55

File tree

7 files changed

+254
-78
lines changed

7 files changed

+254
-78
lines changed

RELEASES.md

+101-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Version 1.1.0 (July 2015)
2-
========================
1+
Version 1.1.0 (June 2015)
2+
=========================
33

4-
* NNNN changes, numerous bugfixes
4+
* ~850 changes, numerous bugfixes
55

6-
Libraries
7-
---------
6+
Highlights
7+
----------
88

99
* The [`std::fs` module has been expanded][fs-expand] to expand the set of
1010
functionality exposed:
@@ -13,8 +13,103 @@ Libraries
1313
* A `symlink_metadata` function has been added.
1414
* The `fs::Metadata` structure now lowers to its OS counterpart, providing
1515
access to all underlying information.
16+
* The compiler contains extended explanations of many errors. When it
17+
emits such an error it also suggests using the `--explain` flag to
18+
read the extended explanations, which are also [cataloged on the web
19+
site][err].
20+
* Thanks to multiple [improvements][sk] to [type checking][pre], as
21+
well as other work, the time to bootstrap the compiler decreased by
22+
32%.
23+
24+
Libraries
25+
---------
26+
27+
* The `str::split_whitespace` method splits a string on unicode
28+
whitespace boundaries.
29+
* On both Windows and Unix, new extension traits provide conversion of
30+
I/O types to and from the underlying system handles. On Unix, these
31+
traits are [`FrowRawFd`] and [`AsRawFd`], on Windows `FromRawHandle`
32+
and `AsRawHandle`. These are implemented for `File`, `TcpStream`,
33+
`TcpListener`, and `UpdSocket`. Further implementations for
34+
`std::process` will be stabilized later.
35+
* On Unix, [`std::os::unix::symlink`] creates symlinks. On
36+
Windows, symlinks can be created with
37+
`std::os::windows::symlink_dir` and
38+
`std::os::windows::symlink_file`.
39+
* The `mpsc::Receiver` type can now be converted into an iterator with
40+
`into_iter` on the [`IntoIterator`] trait.
41+
* `Ipv4Addr` can be created from `u32` with the `From<u32>`
42+
implementation of the [`From`] trait.
43+
* The `Debug` implementation for `RangeFull` [creates output that is
44+
more consistent with other implementations][rf].
45+
* [`Debug` is implemented for `File`][file].
46+
* The `Default` implementation for `Arc` [no longer requires `Sync +
47+
Send`][arc].
48+
* [The `Iterator` methods `count`, `nth`, and `last` have been
49+
overridden for slices to have O(1) performance instead of O(n)][si].
50+
* Incorrect handling of paths on Windows has been improved in both the
51+
compiler and the standard library.
52+
* [`AtomicPtr` gained a `Default` implementation][ap].
53+
* In accordance with Rust's policy on arithmetic overflow `abs` now
54+
[panics on overflow when debug assertions are enabled][abs].
55+
* The [`Cloned`] iterator, which was accidentally left unstable for
56+
1.0 [has been stabilized][c].
57+
* The [`Incoming`] iterator, which iterates over incoming TCP
58+
connections, and which was accidentally unnamable in 1.0, [is now
59+
properly exported][inc].
60+
* [`BinaryHeap`] no longer corrupts itself [when functions called by
61+
`sift_up` or `sift_down` panic][bh].
62+
* The [`split_off`] method of `LinkedList` [no longer corrupts
63+
the list in certain scenarios][ll].
64+
65+
Misc
66+
----
1667

17-
[fs-expand]: https://github.com/rust-lang/rust/pull/25844
68+
* Type checking performance [has improved notably][sk] with
69+
[multiple improvements][pre].
70+
* The compiler [suggests code changes][ch] for more errors.
71+
* rustc and it's build system have experimental support for [building
72+
toolchains against MUSL][m] instead of glibc on Linux.
73+
* The compiler defines the `target_env` cfg value, which is used for
74+
distinguishing toolchains that are otherwise for the same
75+
platform. Presently this is set to `gnu` for common GNU Linux
76+
targets and for MinGW targets, and `musl` for MUSL Linux targets.
77+
* The [`cargo rustc`][crc] command invokes a build with custom flags
78+
to rustc.
79+
* [Android executables are always position independent][pie].
80+
* [The `drop_with_repr_extern` lint warns about mixing `repr(C)`
81+
with `Drop`][drop].
82+
83+
[`split_whitespace`]: http://doc.rust-lang.org/nightly/std/primitive.str.html#method.split_whitespace
84+
[`Iterator::cloned`]: http://doc.rust-lang.org/nightly/core/iter/trait.Iterator.html#method.cloned
85+
[`FromRawFd`]: http://doc.rust-lang.org/nightly/std/os/unix/io/trait.FromRawFd.html
86+
[`AsRawFd`]: http://doc.rust-lang.org/nightly/std/os/unix/io/trait.AsRawFd.html
87+
[`std::os::unix::symlink`]: http://doc.rust-lang.org/nightly/std/os/unix/fs/fn.symlink.html
88+
[`IntoIterator`]: http://doc.rust-lang.org/nightly/std/iter/trait.IntoIterator.html
89+
[`From`]: http://doc.rust-lang.org/nightly/std/convert/trait.From.html
90+
[rf]: https://github.com/rust-lang/rust/pull/24491
91+
[err]: http://doc.rust-lang.org/error-index.html
92+
[sk]: https://github.com/rust-lang/rust/pull/24615
93+
[pre]: https://github.com/rust-lang/rust/pull/25323
94+
[file]: https://github.com/rust-lang/rust/pull/24598
95+
[ch]: https://github.com/rust-lang/rust/pull/24683
96+
[arc]: https://github.com/rust-lang/rust/pull/24695
97+
[si]: https://github.com/rust-lang/rust/pull/24701
98+
[ap]: https://github.com/rust-lang/rust/pull/24834
99+
[m]: https://github.com/rust-lang/rust/pull/24777
100+
[fs]: https://github.com/rust-lang/rfcs/blob/master/text/1044-io-fs-2.1.md
101+
[crc]: https://github.com/rust-lang/cargo/pull/1568
102+
[pie]: https://github.com/rust-lang/rust/pull/24953
103+
[abs]: https://github.com/rust-lang/rust/pull/25441
104+
[c]: https://github.com/rust-lang/rust/pull/25496
105+
[`Cloned`]: http://doc.rust-lang.org/nightly/std/iter/struct.Cloned.html
106+
[`Incoming`]: http://doc.rust-lang.org/nightly/std/net/struct.Incoming.html
107+
[inc]: https://github.com/rust-lang/rust/pull/25522
108+
[bh]: https://github.com/rust-lang/rust/pull/25856
109+
[`BinaryHeap`]: http://doc.rust-lang.org/nightly/std/collections/struct.BinaryHeap.html
110+
[ll]: https://github.com/rust-lang/rust/pull/26022
111+
[`split_off`]: http://doc.rust-lang.org/nightly/collections/linked_list/struct.LinkedList.html#method.split_off
112+
[drop]: https://github.com/rust-lang/rust/pull/24935
18113

19114
Version 1.0.0 (May 2015)
20115
========================

src/librustc_trans/trans/cleanup.rs

+7
Original file line numberDiff line numberDiff line change
@@ -954,8 +954,15 @@ impl<'blk, 'tcx> CleanupScope<'blk, 'tcx> {
954954
}
955955
}
956956

957+
/// Manipulate cleanup scope for call arguments. Conceptually, each
958+
/// argument to a call is an lvalue, and performing the call moves each
959+
/// of the arguments into a new rvalue (which gets cleaned up by the
960+
/// callee). As an optimization, instead of actually performing all of
961+
/// those moves, trans just manipulates the cleanup scope to obtain the
962+
/// same effect.
957963
pub fn drop_non_lifetime_clean(&mut self) {
958964
self.cleanups.retain(|c| c.is_lifetime_end());
965+
self.clear_cached_exits();
959966
}
960967
}
961968

src/libsyntax/codemap.rs

+44-53
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//! within the CodeMap, which upon request can be converted to line and column
1818
//! information, source code snippets, etc.
1919
20-
pub use self::MacroFormat::*;
20+
pub use self::ExpnFormat::*;
2121

2222
use std::cell::RefCell;
2323
use std::ops::{Add, Sub};
@@ -226,17 +226,17 @@ pub struct FileMapAndBytePos { pub fm: Rc<FileMap>, pub pos: BytePos }
226226

227227

228228
// _____________________________________________________________________________
229-
// MacroFormat, NameAndSpan, ExpnInfo, ExpnId
229+
// ExpnFormat, NameAndSpan, ExpnInfo, ExpnId
230230
//
231231

232-
/// The syntax with which a macro was invoked.
233-
#[derive(Clone, Copy, Hash, Debug)]
234-
pub enum MacroFormat {
232+
/// The source of expansion.
233+
#[derive(Clone, Copy, Hash, Debug, PartialEq, Eq)]
234+
pub enum ExpnFormat {
235235
/// e.g. #[derive(...)] <item>
236236
MacroAttribute,
237237
/// e.g. `format!()`
238238
MacroBang,
239-
/// Expansion performed by the compiler (libsyntax::expand).
239+
/// Syntax sugar expansion performed by the compiler (libsyntax::expand).
240240
CompilerExpansion,
241241
}
242242

@@ -246,7 +246,7 @@ pub struct NameAndSpan {
246246
/// with this Span.
247247
pub name: String,
248248
/// The format with which the macro was invoked.
249-
pub format: MacroFormat,
249+
pub format: ExpnFormat,
250250
/// Whether the macro is allowed to use #[unstable]/feature-gated
251251
/// features internally without forcing the whole crate to opt-in
252252
/// to them.
@@ -257,11 +257,11 @@ pub struct NameAndSpan {
257257
pub span: Option<Span>
258258
}
259259

260-
/// Extra information for tracking macro expansion of spans
260+
/// Extra information for tracking spans of macro and syntax sugar expansion
261261
#[derive(Hash, Debug)]
262262
pub struct ExpnInfo {
263-
/// The location of the actual macro invocation, e.g. `let x =
264-
/// foo!();`
263+
/// The location of the actual macro invocation or syntax sugar , e.g.
264+
/// `let x = foo!();` or `if let Some(y) = x {}`
265265
///
266266
/// This may recursively refer to other macro invocations, e.g. if
267267
/// `foo!()` invoked `bar!()` internally, and there was an
@@ -270,12 +270,7 @@ pub struct ExpnInfo {
270270
/// call_site span would have its own ExpnInfo, with the call_site
271271
/// pointing to the `foo!` invocation.
272272
pub call_site: Span,
273-
/// Information about the macro and its definition.
274-
///
275-
/// The `callee` of the inner expression in the `call_site`
276-
/// example would point to the `macro_rules! bar { ... }` and that
277-
/// of the `bar!()` invocation would point to the `macro_rules!
278-
/// foo { ... }`.
273+
/// Information about the expansion.
279274
pub callee: NameAndSpan
280275
}
281276

@@ -633,7 +628,39 @@ impl CodeMap {
633628

634629
/// Lookup source information about a BytePos
635630
pub fn lookup_char_pos(&self, pos: BytePos) -> Loc {
636-
self.lookup_pos(pos)
631+
let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos);
632+
let line = a + 1; // Line numbers start at 1
633+
let chpos = self.bytepos_to_file_charpos(pos);
634+
let linebpos = (*f.lines.borrow())[a];
635+
let linechpos = self.bytepos_to_file_charpos(linebpos);
636+
debug!("byte pos {:?} is on the line at byte pos {:?}",
637+
pos, linebpos);
638+
debug!("char pos {:?} is on the line at char pos {:?}",
639+
chpos, linechpos);
640+
debug!("byte is on line: {}", line);
641+
assert!(chpos >= linechpos);
642+
Loc {
643+
file: f,
644+
line: line,
645+
col: chpos - linechpos
646+
}
647+
}
648+
649+
fn lookup_line(&self, pos: BytePos) -> FileMapAndLine {
650+
let idx = self.lookup_filemap_idx(pos);
651+
652+
let files = self.files.borrow();
653+
let f = (*files)[idx].clone();
654+
let mut a = 0;
655+
{
656+
let lines = f.lines.borrow();
657+
let mut b = lines.len();
658+
while b - a > 1 {
659+
let m = (a + b) / 2;
660+
if (*lines)[m] > pos { b = m; } else { a = m; }
661+
}
662+
}
663+
FileMapAndLine {fm: f, line: a}
637664
}
638665

639666
pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt {
@@ -833,42 +860,6 @@ impl CodeMap {
833860
return a;
834861
}
835862

836-
fn lookup_line(&self, pos: BytePos) -> FileMapAndLine {
837-
let idx = self.lookup_filemap_idx(pos);
838-
839-
let files = self.files.borrow();
840-
let f = (*files)[idx].clone();
841-
let mut a = 0;
842-
{
843-
let lines = f.lines.borrow();
844-
let mut b = lines.len();
845-
while b - a > 1 {
846-
let m = (a + b) / 2;
847-
if (*lines)[m] > pos { b = m; } else { a = m; }
848-
}
849-
}
850-
FileMapAndLine {fm: f, line: a}
851-
}
852-
853-
fn lookup_pos(&self, pos: BytePos) -> Loc {
854-
let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos);
855-
let line = a + 1; // Line numbers start at 1
856-
let chpos = self.bytepos_to_file_charpos(pos);
857-
let linebpos = (*f.lines.borrow())[a];
858-
let linechpos = self.bytepos_to_file_charpos(linebpos);
859-
debug!("byte pos {:?} is on the line at byte pos {:?}",
860-
pos, linebpos);
861-
debug!("char pos {:?} is on the line at char pos {:?}",
862-
chpos, linechpos);
863-
debug!("byte is on line: {}", line);
864-
assert!(chpos >= linechpos);
865-
Loc {
866-
file: f,
867-
line: line,
868-
col: chpos - linechpos
869-
}
870-
}
871-
872863
pub fn record_expansion(&self, expn_info: ExpnInfo) -> ExpnId {
873864
let mut expansions = self.expansions.borrow_mut();
874865
expansions.push(expn_info);

src/libsyntax/ext/base.rs

+23-16
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub use self::SyntaxExtension::*;
1313
use ast;
1414
use ast::Name;
1515
use codemap;
16-
use codemap::{CodeMap, Span, ExpnId, ExpnInfo, NO_EXPANSION};
16+
use codemap::{CodeMap, Span, ExpnId, ExpnInfo, NO_EXPANSION, CompilerExpansion};
1717
use ext;
1818
use ext::expand;
1919
use ext::tt::macro_rules;
@@ -658,6 +658,8 @@ impl<'a> ExtCtxt<'a> {
658658
})
659659
}
660660
pub fn backtrace(&self) -> ExpnId { self.backtrace }
661+
662+
/// Original span that caused the current exapnsion to happen.
661663
pub fn original_span(&self) -> Span {
662664
let mut expn_id = self.backtrace;
663665
let mut call_site = None;
@@ -672,26 +674,31 @@ impl<'a> ExtCtxt<'a> {
672674
}
673675
call_site.expect("missing expansion backtrace")
674676
}
675-
pub fn original_span_in_file(&self) -> Span {
677+
678+
/// Returns span for the macro which originally caused the current expansion to happen.
679+
///
680+
/// Stops backtracing at include! boundary.
681+
pub fn expansion_cause(&self) -> Span {
676682
let mut expn_id = self.backtrace;
677-
let mut call_site = None;
683+
let mut last_macro = None;
678684
loop {
679-
let expn_info = self.codemap().with_expn_info(expn_id, |ei| {
680-
ei.map(|ei| (ei.call_site, ei.callee.name == "include"))
681-
});
682-
match expn_info {
683-
None => break,
684-
Some((cs, is_include)) => {
685-
if is_include {
686-
// Don't recurse into file using "include!".
687-
break;
685+
if self.codemap().with_expn_info(expn_id, |info| {
686+
info.map_or(None, |i| {
687+
if i.callee.name == "include" {
688+
// Stop going up the backtrace once include! is encountered
689+
return None;
688690
}
689-
call_site = Some(cs);
690-
expn_id = cs.expn_id;
691-
}
691+
expn_id = i.call_site.expn_id;
692+
if i.callee.format != CompilerExpansion {
693+
last_macro = Some(i.call_site)
694+
}
695+
return Some(());
696+
})
697+
}).is_none() {
698+
break
692699
}
693700
}
694-
call_site.expect("missing expansion backtrace")
701+
last_macro.expect("missing expansion backtrace")
695702
}
696703

697704
pub fn mod_push(&mut self, i: ast::Ident) { self.mod_path.push(i); }

src/libsyntax/ext/source_util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
3434
-> Box<base::MacResult+'static> {
3535
base::check_zero_tts(cx, sp, tts, "line!");
3636

37-
let topmost = cx.original_span_in_file();
37+
let topmost = cx.expansion_cause();
3838
let loc = cx.codemap().lookup_char_pos(topmost.lo);
3939

4040
base::MacEager::expr(cx.expr_u32(topmost, loc.line as u32))
@@ -45,7 +45,7 @@ pub fn expand_column(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
4545
-> Box<base::MacResult+'static> {
4646
base::check_zero_tts(cx, sp, tts, "column!");
4747

48-
let topmost = cx.original_span_in_file();
48+
let topmost = cx.expansion_cause();
4949
let loc = cx.codemap().lookup_char_pos(topmost.lo);
5050

5151
base::MacEager::expr(cx.expr_u32(topmost, loc.col.to_usize() as u32))
@@ -58,7 +58,7 @@ pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
5858
-> Box<base::MacResult+'static> {
5959
base::check_zero_tts(cx, sp, tts, "file!");
6060

61-
let topmost = cx.original_span_in_file();
61+
let topmost = cx.expansion_cause();
6262
let loc = cx.codemap().lookup_char_pos(topmost.lo);
6363
let filename = token::intern_and_get_ident(&loc.file.name);
6464
base::MacEager::expr(cx.expr_str(topmost, filename))

0 commit comments

Comments
 (0)