Skip to content

Commit 1e29dc5

Browse files
committed
---
yaml --- r: 277883 b: refs/heads/auto c: 9e17622 h: refs/heads/master i: 277881: ea5c742 277879: 360f8e4
1 parent 672aa5a commit 1e29dc5

File tree

7 files changed

+93
-24
lines changed

7 files changed

+93
-24
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 6bc93183183d070bf355bbd5714209fd00631e1e
11+
refs/heads/auto: 9e17622449ae4280463f00dfc4b1a5f7e25f9ad0
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/libcollections/btree/map.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,15 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
16541654
Vacant(entry) => entry.insert(default()),
16551655
}
16561656
}
1657+
1658+
/// Returns a reference to this entry's key.
1659+
#[unstable(feature = "map_entry_keys", issue = "32281")]
1660+
pub fn key(&self) -> &K {
1661+
match *self {
1662+
Occupied(ref entry) => entry.key(),
1663+
Vacant(ref entry) => entry.key(),
1664+
}
1665+
}
16571666
}
16581667

16591668
impl<'a, K: Ord, V> VacantEntry<'a, K, V> {

branches/auto/src/librustc_driver/driver.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -645,21 +645,6 @@ pub fn phase_2_configure_and_expand(sess: &Session,
645645
ret
646646
});
647647

648-
// Needs to go *after* expansion to be able to check the results
649-
// of macro expansion. This runs before #[cfg] to try to catch as
650-
// much as possible (e.g. help the programmer avoid platform
651-
// specific differences)
652-
time(time_passes, "complete gated feature checking 1", || {
653-
sess.track_errors(|| {
654-
let features = syntax::feature_gate::check_crate(sess.codemap(),
655-
&sess.parse_sess.span_diagnostic,
656-
&krate,
657-
&attributes,
658-
sess.opts.unstable_features);
659-
*sess.features.borrow_mut() = features;
660-
})
661-
})?;
662-
663648
// JBC: make CFG processing part of expansion to avoid this problem:
664649

665650
// strip again, in case expansion added anything with a #[cfg].
@@ -698,10 +683,8 @@ pub fn phase_2_configure_and_expand(sess: &Session,
698683
"checking for inline asm in case the target doesn't support it",
699684
|| no_asm::check_crate(sess, &krate));
700685

701-
// One final feature gating of the true AST that gets compiled
702-
// later, to make sure we've got everything (e.g. configuration
703-
// can insert new attributes via `cfg_attr`)
704-
time(time_passes, "complete gated feature checking 2", || {
686+
// Needs to go *after* expansion to be able to check the results of macro expansion.
687+
time(time_passes, "complete gated feature checking", || {
705688
sess.track_errors(|| {
706689
let features = syntax::feature_gate::check_crate(sess.codemap(),
707690
&sess.parse_sess.span_diagnostic,

branches/auto/src/librustc_resolve/diagnostics.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,51 @@ use something_which_doesnt_exist;
948948
Please verify you didn't misspell the import's name.
949949
"##,
950950

951+
E0434: r##"
952+
This error indicates that a variable usage inside an inner function is invalid
953+
because the variable comes from a dynamic environment. Inner functions do not
954+
have access to their containing environment.
955+
956+
Example of erroneous code:
957+
958+
```compile_fail
959+
fn foo() {
960+
let y = 5;
961+
fn bar() -> u32 {
962+
y // error: can't capture dynamic environment in a fn item; use the
963+
// || { ... } closure form instead.
964+
}
965+
}
966+
```
967+
968+
Functions do not capture local variables. To fix this error, you can replace the
969+
function with a closure:
970+
971+
```
972+
fn foo() {
973+
let y = 5;
974+
let bar = || {
975+
y
976+
};
977+
}
978+
```
979+
980+
or replace the captured variable with a constant or a static item:
981+
982+
```
983+
fn foo() {
984+
static mut X: u32 = 4;
985+
const Y: u32 = 5;
986+
fn bar() -> u32 {
987+
unsafe {
988+
X = 3;
989+
}
990+
Y
991+
}
992+
}
993+
```
994+
"##,
995+
951996
E0435: r##"
952997
A non-constant value was used to initialise a constant. Example of erroneous
953998
code:
@@ -1044,5 +1089,4 @@ register_diagnostics! {
10441089
E0421, // unresolved associated const
10451090
E0427, // cannot use `ref` binding mode with ...
10461091
E0429, // `self` imports are only allowed within a { } list
1047-
E0434, // can't capture dynamic environment in a fn item
10481092
}

branches/auto/src/libstd/collections/hash/map.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,15 @@ impl<'a, K, V> Entry<'a, K, V> {
15331533
Vacant(entry) => entry.insert(default()),
15341534
}
15351535
}
1536+
1537+
/// Returns a reference to this entry's key.
1538+
#[unstable(feature = "map_entry_keys", issue = "32281")]
1539+
pub fn key(&self) -> &K {
1540+
match *self {
1541+
Occupied(ref entry) => entry.key(),
1542+
Vacant(ref entry) => entry.key(),
1543+
}
1544+
}
15361545
}
15371546

15381547
impl<'a, K, V> OccupiedEntry<'a, K, V> {

branches/auto/src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,7 @@ macro_rules! with_exts_frame {
327327
// When we enter a module, record it, for the sake of `module!`
328328
pub fn expand_item(it: P<ast::Item>, fld: &mut MacroExpander)
329329
-> SmallVector<P<ast::Item>> {
330-
let it = expand_item_multi_modifier(Annotatable::Item(it), fld);
331-
332-
expand_annotatable(it, fld)
330+
expand_annotatable(Annotatable::Item(it), fld)
333331
.into_iter().map(|i| i.expect_item()).collect()
334332
}
335333

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
13+
macro_rules! mac {
14+
{} => {
15+
#[cfg(attr)]
16+
mod m {
17+
#[lang_item]
18+
fn f() {}
19+
}
20+
}
21+
}
22+
23+
mac! {}
24+
25+
#[rustc_error]
26+
fn main() {} //~ ERROR compilation successful

0 commit comments

Comments
 (0)