Skip to content

Commit 4517a8f

Browse files
committed
---
yaml --- r: 235708 b: refs/heads/stable c: b221349 h: refs/heads/master v: v3
1 parent d3af90d commit 4517a8f

File tree

8 files changed

+72
-21
lines changed

8 files changed

+72
-21
lines changed

[refs]

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

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

Lines changed: 12 additions & 3 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-
/// Bytewise slice equality
874+
// share the implementation of the lang-item vs. non-lang-item
875+
// eq_slice.
875876
/// NOTE: This function is (ab)used in rustc::middle::trans::_match
876877
/// 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,6 +887,15 @@ 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+
890899
/*
891900
Section: Misc
892901
*/

branches/stable/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/stable/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 => ast::DUMMY_NODE_ID,
481+
None => -1,
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 => ast::DUMMY_NODE_ID,
539+
None => -1,
540540
};
541541
self.fmt.struct_variant_str(variant.span,
542542
self.span.span_for_first_ident(variant.span),

branches/stable/src/librustc_typeck/astconv.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ 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;
6362
use rscope::{self, UnelidableRscope, RegionScope, ElidableRscope, ExplicitRscope,
6463
ObjectLifetimeDefaultRscope, ShiftedRscope, BindingRscope,
6564
ElisionFailureInfo, ElidedLifetime};
@@ -1576,7 +1575,10 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
15761575
}
15771576
ast::TyParen(ref typ) => ast_ty_to_ty(this, rscope, &**typ),
15781577
ast::TyBareFn(ref bf) => {
1579-
require_c_abi_if_variadic(tcx, &bf.decl, bf.abi, ast_ty.span);
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+
}
15801582
let bare_fn = ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl);
15811583
tcx.mk_fn(None, tcx.mk_bare_fn(bare_fn))
15821584
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ 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;
101100
use rscope::{ElisionFailureInfo, RegionScope};
102101
use session::Session;
103102
use {CrateCtxt, lookup_full_def, require_same_types};
@@ -686,7 +685,10 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
686685
}
687686

688687
if let ast::ForeignItemFn(ref fn_decl, _) = item.node {
689-
require_c_abi_if_variadic(ccx.tcx, fn_decl, m.abi, item.span);
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+
}
690692
}
691693
}
692694
}

branches/stable/src/librustc_typeck/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,6 @@ 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-
189179
fn require_same_types<'a, 'tcx, M>(tcx: &ty::ctxt<'tcx>,
190180
maybe_infcx: Option<&infer::InferCtxt<'a, 'tcx>>,
191181
t1_is_expected: bool,
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)