Skip to content

Commit b2bd2ef

Browse files
committed
---
yaml --- r: 228646 b: refs/heads/try c: 69ca012 h: refs/heads/master v: v3
1 parent 28cf393 commit b2bd2ef

File tree

11 files changed

+89
-42
lines changed

11 files changed

+89
-42
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 70e8220166744045780fd1c658f796df6a99a936
4+
refs/heads/try: 69ca0125641db798f072f9a0f5d838686255eb37
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/libcore/str/mod.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -871,12 +871,12 @@ impl<'a> DoubleEndedIterator for LinesAny<'a> {
871871
Section: Comparing strings
872872
*/
873873

874-
// share the implementation of the lang-item vs. non-lang-item
875-
// eq_slice.
874+
/// Bytewise slice equality
876875
/// NOTE: This function is (ab)used in rustc::middle::trans::_match
877876
/// to compare &[u8] byte slices that are not necessarily valid UTF-8.
877+
#[lang = "str_eq"]
878878
#[inline]
879-
fn eq_slice_(a: &str, b: &str) -> bool {
879+
fn eq_slice(a: &str, b: &str) -> bool {
880880
// NOTE: In theory n should be libc::size_t and not usize, but libc is not available here
881881
#[allow(improper_ctypes)]
882882
extern { fn memcmp(s1: *const i8, s2: *const i8, n: usize) -> i32; }
@@ -887,15 +887,6 @@ fn eq_slice_(a: &str, b: &str) -> bool {
887887
}
888888
}
889889

890-
/// Bytewise slice equality
891-
/// NOTE: This function is (ab)used in rustc::middle::trans::_match
892-
/// to compare &[u8] byte slices that are not necessarily valid UTF-8.
893-
#[lang = "str_eq"]
894-
#[inline]
895-
fn eq_slice(a: &str, b: &str) -> bool {
896-
eq_slice_(a, b)
897-
}
898-
899890
/*
900891
Section: Misc
901892
*/

branches/try/src/librustc/middle/resolve_lifetime.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn krate(sess: &Session, krate: &ast::Crate, def_map: &DefMap) -> NamedRegio
109109

110110
impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
111111
fn visit_item(&mut self, item: &ast::Item) {
112-
// Items save/restore the set of labels. This way innner items
112+
// Items save/restore the set of labels. This way inner items
113113
// can freely reuse names, be they loop labels or lifetimes.
114114
let saved = replace(&mut self.labels_in_fn, vec![]);
115115

@@ -151,6 +151,29 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
151151
replace(&mut self.labels_in_fn, saved);
152152
}
153153

154+
fn visit_foreign_item(&mut self, item: &ast::ForeignItem) {
155+
// Items save/restore the set of labels. This way inner items
156+
// can freely reuse names, be they loop labels or lifetimes.
157+
let saved = replace(&mut self.labels_in_fn, vec![]);
158+
159+
// Items always introduce a new root scope
160+
self.with(RootScope, |_, this| {
161+
match item.node {
162+
ast::ForeignItemFn(_, ref generics) => {
163+
this.visit_early_late(subst::FnSpace, generics, |this| {
164+
visit::walk_foreign_item(this, item);
165+
})
166+
}
167+
ast::ForeignItemStatic(..) => {
168+
visit::walk_foreign_item(this, item);
169+
}
170+
}
171+
});
172+
173+
// Done traversing the item; restore saved set of labels.
174+
replace(&mut self.labels_in_fn, saved);
175+
}
176+
154177
fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
155178
b: &'v ast::Block, s: Span, _: ast::NodeId) {
156179
match fk {

branches/try/src/librustc_trans/save/dump_csv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
478478

479479
let ctor_id = match def.ctor_id {
480480
Some(node_id) => node_id,
481-
None => -1,
481+
None => ast::DUMMY_NODE_ID,
482482
};
483483
let val = self.span.snippet(item.span);
484484
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Struct);
@@ -536,7 +536,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
536536
ast::StructVariantKind(ref struct_def) => {
537537
let ctor_id = match struct_def.ctor_id {
538538
Some(node_id) => node_id,
539-
None => -1,
539+
None => ast::DUMMY_NODE_ID,
540540
};
541541
self.fmt.struct_variant_str(variant.span,
542542
self.span.span_for_first_ident(variant.span),

branches/try/src/librustc_trans/trans/cleanup.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -774,20 +774,22 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
774774
// At this point, `popped_scopes` is empty, and so the final block
775775
// that we return to the user is `Cleanup(AST 24)`.
776776
while let Some(mut scope) = popped_scopes.pop() {
777-
let name = scope.block_name("clean");
778-
debug!("generating cleanups for {}", name);
779-
let bcx_in = self.new_block(label.is_unwind(),
780-
&name[..],
781-
None);
782-
let mut bcx_out = bcx_in;
783-
for cleanup in scope.cleanups.iter().rev() {
784-
bcx_out = cleanup.trans(bcx_out,
785-
scope.debug_loc);
786-
}
787-
build::Br(bcx_out, prev_llbb, DebugLoc::None);
788-
prev_llbb = bcx_in.llbb;
777+
if !scope.cleanups.is_empty() {
778+
let name = scope.block_name("clean");
779+
debug!("generating cleanups for {}", name);
780+
let bcx_in = self.new_block(label.is_unwind(),
781+
&name[..],
782+
None);
783+
let mut bcx_out = bcx_in;
784+
for cleanup in scope.cleanups.iter().rev() {
785+
bcx_out = cleanup.trans(bcx_out,
786+
scope.debug_loc);
787+
}
788+
build::Br(bcx_out, prev_llbb, DebugLoc::None);
789+
prev_llbb = bcx_in.llbb;
789790

790-
scope.add_cached_early_exit(label, prev_llbb);
791+
scope.add_cached_early_exit(label, prev_llbb);
792+
}
791793
self.push_scope(scope);
792794
}
793795

branches/try/src/librustc_typeck/astconv.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ use middle::subst::{FnSpace, TypeSpace, SelfSpace, Subst, Substs};
5959
use middle::traits;
6060
use middle::ty::{self, RegionEscape, Ty, ToPredicate, HasTypeFlags};
6161
use middle::ty_fold;
62+
use require_c_abi_if_variadic;
6263
use rscope::{self, UnelidableRscope, RegionScope, ElidableRscope, ExplicitRscope,
6364
ObjectLifetimeDefaultRscope, ShiftedRscope, BindingRscope,
6465
ElisionFailureInfo, ElidedLifetime};
@@ -1575,10 +1576,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
15751576
}
15761577
ast::TyParen(ref typ) => ast_ty_to_ty(this, rscope, &**typ),
15771578
ast::TyBareFn(ref bf) => {
1578-
if bf.decl.variadic && bf.abi != abi::C {
1579-
span_err!(tcx.sess, ast_ty.span, E0045,
1580-
"variadic function must have C calling convention");
1581-
}
1579+
require_c_abi_if_variadic(tcx, &bf.decl, bf.abi, ast_ty.span);
15821580
let bare_fn = ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl);
15831581
tcx.mk_fn(None, tcx.mk_bare_fn(bare_fn))
15841582
}

branches/try/src/librustc_typeck/check/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ use middle::ty::{Disr, ParamTy, ParameterEnvironment};
9797
use middle::ty::{self, HasTypeFlags, RegionEscape, ToPolyTraitRef, Ty};
9898
use middle::ty::{MethodCall, MethodCallee};
9999
use middle::ty_fold::{TypeFolder, TypeFoldable};
100+
use require_c_abi_if_variadic;
100101
use rscope::{ElisionFailureInfo, RegionScope};
101102
use session::Session;
102103
use {CrateCtxt, lookup_full_def, require_same_types};
@@ -685,10 +686,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
685686
}
686687

687688
if let ast::ForeignItemFn(ref fn_decl, _) = item.node {
688-
if fn_decl.variadic && m.abi != abi::C {
689-
span_err!(ccx.tcx.sess, item.span, E0045,
690-
"variadic function must have C calling convention");
691-
}
689+
require_c_abi_if_variadic(ccx.tcx, fn_decl, m.abi, item.span);
692690
}
693691
}
694692
}

branches/try/src/librustc_typeck/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ fn lookup_full_def(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) -> def::Def {
176176
}
177177
}
178178

179+
fn require_c_abi_if_variadic(tcx: &ty::ctxt,
180+
decl: &ast::FnDecl,
181+
abi: abi::Abi,
182+
span: Span) {
183+
if decl.variadic && abi != abi::C {
184+
span_err!(tcx.sess, span, E0045,
185+
"variadic function must have C calling convention");
186+
}
187+
}
188+
179189
fn require_same_types<'a, 'tcx, M>(tcx: &ty::ctxt<'tcx>,
180190
maybe_infcx: Option<&infer::InferCtxt<'a, 'tcx>>,
181191
t1_is_expected: bool,

branches/try/src/libstd/num/f32.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
1515
#![stable(feature = "rust1", since = "1.0.0")]
1616
#![allow(missing_docs)]
17-
#![allow(unsigned_negation)]
1817

1918
use prelude::v1::*;
2019

branches/try/src/libsyntax/parse/parser.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,14 +2738,15 @@ impl<'a> Parser<'a> {
27382738
// (much lower than other prefix expressions) to be consistent
27392739
// with the postfix-form 'expr..'
27402740
let lo = self.span.lo;
2741+
let mut hi = self.span.hi;
27412742
try!(self.bump());
27422743
let opt_end = if self.is_at_start_of_range_notation_rhs() {
27432744
let end = try!(self.parse_binops());
2745+
hi = end.span.hi;
27442746
Some(end)
27452747
} else {
27462748
None
27472749
};
2748-
let hi = self.span.hi;
27492750
let ex = self.mk_range(None, opt_end);
27502751
Ok(self.mk_expr(lo, hi, ex))
27512752
}
@@ -2787,17 +2788,17 @@ impl<'a> Parser<'a> {
27872788
}
27882789
// A range expression, either `expr..expr` or `expr..`.
27892790
token::DotDot => {
2791+
let lo = lhs.span.lo;
2792+
let mut hi = self.span.hi;
27902793
try!(self.bump());
27912794

27922795
let opt_end = if self.is_at_start_of_range_notation_rhs() {
27932796
let end = try!(self.parse_binops());
2797+
hi = end.span.hi;
27942798
Some(end)
27952799
} else {
27962800
None
27972801
};
2798-
2799-
let lo = lhs.span.lo;
2800-
let hi = self.span.hi;
28012802
let range = self.mk_range(Some(lhs), opt_end);
28022803
return Ok(self.mk_expr(lo, hi, range));
28032804
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2015 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+
// Test to make sure the names of the lifetimes are correctly resolved
12+
// in extern blocks.
13+
14+
extern {
15+
pub fn life<'a>(x:&'a i32);
16+
pub fn life2<'b>(x:&'a i32, y:&'b i32); //~ ERROR use of undeclared lifetime name `'a`
17+
pub fn life3<'a>(x:&'a i32, y:&i32) -> &'a i32;
18+
pub fn life4<'b>(x: for<'c> fn(&'a i32)); //~ ERROR use of undeclared lifetime name `'a`
19+
pub fn life5<'b>(x: for<'c> fn(&'b i32));
20+
pub fn life6<'b>(x: for<'c> fn(&'c i32));
21+
pub fn life7<'b>() -> for<'c> fn(&'a i32); //~ ERROR use of undeclared lifetime name `'a`
22+
pub fn life8<'b>() -> for<'c> fn(&'b i32);
23+
pub fn life9<'b>() -> for<'c> fn(&'c i32);
24+
}
25+
fn main() {}

0 commit comments

Comments
 (0)