diff options
| author | bors <bors@rust-lang.org> | 2014-05-04 03:41:50 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-05-04 03:41:50 -0700 |
| commit | de99da3fa5d234e5938b4d87dd264b01eb6e86ac (patch) | |
| tree | f0c2c8296caf4374fc315a58a3f918daf9601910 /src | |
| parent | 0f9a74fea47a7af15046ae2908af6db3ed368b1c (diff) | |
| parent | 92b741aad4e329c134544c460b50eb095c0e512e (diff) | |
| download | rust-de99da3fa5d234e5938b4d87dd264b01eb6e86ac.tar.gz rust-de99da3fa5d234e5938b4d87dd264b01eb6e86ac.zip | |
auto merge of #13898 : nikomatsakis/rust/type-bounds-b, r=acrichto
This is needed to bootstrap fix for #5723.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/front/feature_gate.rs | 11 | ||||
| -rw-r--r-- | src/librustc/middle/resolve.rs | 3 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/astconv.rs | 10 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/collect.rs | 14 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/infer/error_reporting.rs | 3 | ||||
| -rw-r--r-- | src/librustdoc/clean.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/regions-bound-lists-feature-gate.rs | 19 | ||||
| -rw-r--r-- | src/test/run-pass/regions-bound-lists-feature-gate.rs | 23 |
13 files changed, 91 insertions, 17 deletions
diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs index f9d2ac5afd8..925d9430ede 100644 --- a/src/librustc/front/feature_gate.rs +++ b/src/librustc/front/feature_gate.rs @@ -59,6 +59,10 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[ ("quad_precision_float", Active), + // A temporary feature gate used to enable parser extensions needed + // to bootstrap fix for #5723. + ("issue_5723_bootstrap", Active), + // These are used to test this portion of the compiler, they don't actually // mean anything ("test_accepted_feature", Accepted), @@ -80,14 +84,16 @@ enum Status { /// A set of features to be used by later passes. pub struct Features { pub default_type_params: Cell<bool>, - pub quad_precision_float: Cell<bool> + pub quad_precision_float: Cell<bool>, + pub issue_5723_bootstrap: Cell<bool>, } impl Features { pub fn new() -> Features { Features { default_type_params: Cell::new(false), - quad_precision_float: Cell::new(false) + quad_precision_float: Cell::new(false), + issue_5723_bootstrap: Cell::new(false), } } } @@ -367,4 +373,5 @@ pub fn check_crate(sess: &Session, krate: &ast::Crate) { sess.features.default_type_params.set(cx.has_feature("default_type_params")); sess.features.quad_precision_float.set(cx.has_feature("quad_precision_float")); + sess.features.issue_5723_bootstrap.set(cx.has_feature("issue_5723_bootstrap")); } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 8df94ea1428..95f18b75bec 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -3824,7 +3824,8 @@ impl<'a> Resolver<'a> { TraitTyParamBound(ref tref) => { self.resolve_trait_reference(id, tref, TraitBoundingTypeParameter) } - RegionTyParamBound => {} + StaticRegionTyParamBound => {} + OtherRegionTyParamBound(_) => {} } } diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index bd26e2e0c4d..1c5bea04a87 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -898,9 +898,17 @@ fn conv_builtin_bounds(tcx: &ty::ctxt, ast_bounds: &Option<OwnedSlice<ast::TyPar format!("only the builtin traits can be used \ as closure or object bounds")); } - ast::RegionTyParamBound => { + ast::StaticRegionTyParamBound => { builtin_bounds.add(ty::BoundStatic); } + ast::OtherRegionTyParamBound(span) => { + if !tcx.sess.features.issue_5723_bootstrap.get() { + tcx.sess.span_err( + span, + format!("only the 'static lifetime is \ + accepted here.")); + } + } } } builtin_bounds diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index c87776ba893..baad474844c 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -50,7 +50,8 @@ use std::rc::Rc; use collections::{HashMap, HashSet}; use syntax::abi; -use syntax::ast::{RegionTyParamBound, TraitTyParamBound}; +use syntax::ast::{StaticRegionTyParamBound, OtherRegionTyParamBound, + TraitTyParamBound}; use syntax::ast; use syntax::ast_map; use syntax::ast_util::{local_def, split_trait_methods}; @@ -1102,9 +1103,18 @@ fn ty_generics(ccx: &CrateCtxt, } } - RegionTyParamBound => { + StaticRegionTyParamBound => { param_bounds.builtin_bounds.add(ty::BoundStatic); } + + OtherRegionTyParamBound(span) => { + if !ccx.tcx.sess.features.issue_5723_bootstrap.get() { + ccx.tcx.sess.span_err( + span, + format!("only the 'static lifetime is \ + accepted here.")); + } + } } } diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index df102b8aadf..b87b6988a3a 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -893,7 +893,8 @@ impl<'a> Rebuilder<'a> { -> OwnedSlice<ast::TyParamBound> { ty_param_bounds.map(|tpb| { match tpb { - &ast::RegionTyParamBound => ast::RegionTyParamBound, + &ast::StaticRegionTyParamBound => ast::StaticRegionTyParamBound, + &ast::OtherRegionTyParamBound(s) => ast::OtherRegionTyParamBound(s), &ast::TraitTyParamBound(ref tr) => { let last_seg = tr.path.segments.last().unwrap(); let mut insert = Vec::new(); diff --git a/src/librustdoc/clean.rs b/src/librustdoc/clean.rs index 73812df252d..4c65a6c1488 100644 --- a/src/librustdoc/clean.rs +++ b/src/librustdoc/clean.rs @@ -349,7 +349,8 @@ pub enum TyParamBound { impl Clean<TyParamBound> for ast::TyParamBound { fn clean(&self) -> TyParamBound { match *self { - ast::RegionTyParamBound => RegionBound, + ast::StaticRegionTyParamBound => RegionBound, + ast::OtherRegionTyParamBound(_) => RegionBound, ast::TraitTyParamBound(ref t) => TraitBound(t.clean()), } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 49617a44a86..a5058de2c61 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -173,7 +173,8 @@ pub static DUMMY_NODE_ID: NodeId = -1; #[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)] pub enum TyParamBound { TraitTyParamBound(TraitRef), - RegionTyParamBound + StaticRegionTyParamBound, + OtherRegionTyParamBound(Span) // FIXME -- just here until work for #5723 lands } #[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)] diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 47ef23b82d2..685e08dd918 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -437,7 +437,8 @@ fn fold_ty_param_bound<T: Folder>(tpb: &TyParamBound, fld: &mut T) -> TyParamBound { match *tpb { TraitTyParamBound(ref ty) => TraitTyParamBound(fold_trait_ref(ty, fld)), - RegionTyParamBound => RegionTyParamBound + StaticRegionTyParamBound => StaticRegionTyParamBound, + OtherRegionTyParamBound(s) => OtherRegionTyParamBound(s) } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6989ceb0d79..bb21bb0b898 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -12,7 +12,7 @@ use abi; use ast::{BareFnTy, ClosureTy}; -use ast::{RegionTyParamBound, TraitTyParamBound}; +use ast::{StaticRegionTyParamBound, OtherRegionTyParamBound, TraitTyParamBound}; use ast::{Provided, Public, FnStyle}; use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue}; use ast::{BiBitAnd, BiBitOr, BiBitXor, Block}; @@ -3351,7 +3351,7 @@ impl<'a> Parser<'a> { token::LIFETIME(lifetime) => { let lifetime_interned_string = token::get_ident(lifetime); if lifetime_interned_string.equiv(&("static")) { - result.push(RegionTyParamBound); + result.push(StaticRegionTyParamBound); if allow_any_lifetime && ret_lifetime.is_none() { ret_lifetime = Some(ast::Lifetime { id: ast::DUMMY_NODE_ID, @@ -3366,8 +3366,7 @@ impl<'a> Parser<'a> { name: lifetime.name }); } else { - self.span_err(self.span, - "`'static` is the only permissible region bound here"); + result.push(OtherRegionTyParamBound(self.span)); } self.bump(); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index f5fe92c3e67..fb823522612 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -9,7 +9,8 @@ // except according to those terms. use abi; -use ast::{P, RegionTyParamBound, TraitTyParamBound, Required, Provided}; +use ast::{P, StaticRegionTyParamBound, OtherRegionTyParamBound, + TraitTyParamBound, Required, Provided}; use ast; use ast_util; use owned_slice::OwnedSlice; @@ -1881,7 +1882,8 @@ impl<'a> State<'a> { try!(match *bound { TraitTyParamBound(ref tref) => self.print_trait_ref(tref), - RegionTyParamBound => word(&mut self.s, "'static"), + StaticRegionTyParamBound => word(&mut self.s, "'static"), + OtherRegionTyParamBound(_) => Ok(()) }) } Ok(()) diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 260ba247092..f715b3a68ae 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -472,7 +472,8 @@ pub fn walk_ty_param_bounds<E: Clone, V: Visitor<E>>(visitor: &mut V, TraitTyParamBound(ref typ) => { walk_trait_ref_helper(visitor, typ, env.clone()) } - RegionTyParamBound => {} + StaticRegionTyParamBound => {} + OtherRegionTyParamBound(..) => {} } } } diff --git a/src/test/compile-fail/regions-bound-lists-feature-gate.rs b/src/test/compile-fail/regions-bound-lists-feature-gate.rs new file mode 100644 index 00000000000..05050b72e5e --- /dev/null +++ b/src/test/compile-fail/regions-bound-lists-feature-gate.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo { } + +fn foo<'a>(x: ~Foo:'a) { //~ ERROR only the 'static lifetime is accepted here +} + +fn bar<'a, T:'a>() { //~ ERROR only the 'static lifetime is accepted here +} + +fn main() { } diff --git a/src/test/run-pass/regions-bound-lists-feature-gate.rs b/src/test/run-pass/regions-bound-lists-feature-gate.rs new file mode 100644 index 00000000000..163e6670c9c --- /dev/null +++ b/src/test/run-pass/regions-bound-lists-feature-gate.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-pretty + +#![feature(issue_5723_bootstrap)] + +trait Foo { } + +fn foo<'a>(x: ~Foo:'a) { +} + +fn bar<'a, T:'a>() { +} + +pub fn main() { } |
