diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 127d6dbc774..15b0be7b4bc 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -72,7 +72,7 @@ they contained the following prologue: /* Reexported core operators */ -pub use kinds::{Const, Copy, Owned, Durable}; +pub use kinds::{Const, Copy, Owned}; pub use ops::{Drop}; pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not}; pub use ops::{BitAnd, BitOr, BitXor}; diff --git a/src/libcore/kinds.rs b/src/libcore/kinds.rs index 82ba0d42ce0..eeafc4cf786 100644 --- a/src/libcore/kinds.rs +++ b/src/libcore/kinds.rs @@ -30,8 +30,6 @@ The 4 kinds are * Const - types that are deeply immutable. Const types are used for freezable data structures. -* Durable - types that do not contain borrowed pointers. - `Copy` types include both implicitly copyable types that the compiler will copy automatically and non-implicitly copyable types that require the `copy` keyword to copy. Types that do not implement `Copy` may @@ -55,6 +53,7 @@ pub trait Const { } #[lang="durable"] +#[cfg(stage0)] pub trait Durable { // Empty. } diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index 10b36d38d43..d263d2cdbee 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -13,7 +13,7 @@ /* Reexported core operators */ pub use either::{Either, Left, Right}; -pub use kinds::{Const, Copy, Owned, Durable}; +pub use kinds::{Const, Copy, Owned}; pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not}; pub use ops::{BitAnd, BitOr, BitXor}; pub use ops::{Drop}; diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index dff5908c047..d4b02a0ad9b 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -49,7 +49,7 @@ pub type LocalDataKey<'self,T> = &'self fn(v: @T); * Remove a task-local data value from the table, returning the * reference that was originally created to insert it. */ -pub unsafe fn local_data_pop( +pub unsafe fn local_data_pop( key: LocalDataKey) -> Option<@T> { local_pop(Handle::new(), key) @@ -58,7 +58,7 @@ pub unsafe fn local_data_pop( * Retrieve a task-local data value. It will also be kept alive in the * table until explicitly removed. */ -pub unsafe fn local_data_get( +pub unsafe fn local_data_get( key: LocalDataKey) -> Option<@T> { local_get(Handle::new(), key) @@ -67,7 +67,7 @@ pub unsafe fn local_data_get( * Store a value in task-local data. If this key already has a value, * that value is overwritten (and its destructor is run). */ -pub unsafe fn local_data_set( +pub unsafe fn local_data_set( key: LocalDataKey, data: @T) { local_set(Handle::new(), key, data) @@ -76,7 +76,7 @@ pub unsafe fn local_data_set( * Modify a task-local data value. If the function returns 'None', the * data is removed (and its reference dropped). */ -pub unsafe fn local_data_modify( +pub unsafe fn local_data_modify( key: LocalDataKey, modify_fn: &fn(Option<@T>) -> Option<@T>) { @@ -215,3 +215,12 @@ fn test_tls_cleanup_on_failure() { fail!(); } } + +#[test] +fn test_static_pointer() { + unsafe { + fn key(_x: @&'static int) { } + static VALUE: int = 0; + local_data_set(key, @&VALUE); + } +} \ No newline at end of file diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index 10a40887e57..7240e0ca0a5 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -44,7 +44,7 @@ impl Handle { } pub trait LocalData { } -impl LocalData for @T { } +impl LocalData for @T { } impl Eq for @LocalData { fn eq(&self, other: &@LocalData) -> bool { @@ -131,7 +131,7 @@ unsafe fn get_newsched_local_map(local: *mut LocalStorage) -> TaskLocalMap { } } -unsafe fn key_to_key_value(key: LocalDataKey) -> *libc::c_void { +unsafe fn key_to_key_value(key: LocalDataKey) -> *libc::c_void { // Keys are closures, which are (fnptr,envptr) pairs. Use fnptr. // Use reintepret_cast -- transmute would leak (forget) the closure. let pair: (*libc::c_void, *libc::c_void) = cast::transmute_copy(&key); @@ -139,7 +139,7 @@ unsafe fn key_to_key_value(key: LocalDataKey) -> *libc::c_void { } // If returning Some(..), returns with @T with the map's reference. Careful! -unsafe fn local_data_lookup( +unsafe fn local_data_lookup( map: TaskLocalMap, key: LocalDataKey) -> Option<(uint, *libc::c_void)> { @@ -157,7 +157,7 @@ unsafe fn local_data_lookup( } } -unsafe fn local_get_helper( +unsafe fn local_get_helper( handle: Handle, key: LocalDataKey, do_pop: bool) -> Option<@T> { @@ -179,21 +179,21 @@ unsafe fn local_get_helper( } -pub unsafe fn local_pop( +pub unsafe fn local_pop( handle: Handle, key: LocalDataKey) -> Option<@T> { local_get_helper(handle, key, true) } -pub unsafe fn local_get( +pub unsafe fn local_get( handle: Handle, key: LocalDataKey) -> Option<@T> { local_get_helper(handle, key, false) } -pub unsafe fn local_set( +pub unsafe fn local_set( handle: Handle, key: LocalDataKey, data: @T) { let map = get_local_map(handle); @@ -225,7 +225,7 @@ pub unsafe fn local_set( } } -pub unsafe fn local_modify( +pub unsafe fn local_modify( handle: Handle, key: LocalDataKey, modify_fn: &fn(Option<@T>) -> Option<@T>) { diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 001218ea0cf..c94dc3046df 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -34,56 +34,55 @@ pub enum LangItem { ConstTraitLangItem, // 0 CopyTraitLangItem, // 1 OwnedTraitLangItem, // 2 - DurableTraitLangItem, // 3 - DropTraitLangItem, // 4 + DropTraitLangItem, // 3 - AddTraitLangItem, // 5 - SubTraitLangItem, // 6 - MulTraitLangItem, // 7 - DivTraitLangItem, // 8 - RemTraitLangItem, // 9 - NegTraitLangItem, // 10 - NotTraitLangItem, // 11 - BitXorTraitLangItem, // 12 - BitAndTraitLangItem, // 13 - BitOrTraitLangItem, // 14 - ShlTraitLangItem, // 15 - ShrTraitLangItem, // 16 - IndexTraitLangItem, // 17 + AddTraitLangItem, // 4 + SubTraitLangItem, // 5 + MulTraitLangItem, // 6 + DivTraitLangItem, // 7 + RemTraitLangItem, // 8 + NegTraitLangItem, // 9 + NotTraitLangItem, // 10 + BitXorTraitLangItem, // 11 + BitAndTraitLangItem, // 12 + BitOrTraitLangItem, // 13 + ShlTraitLangItem, // 14 + ShrTraitLangItem, // 15 + IndexTraitLangItem, // 16 - EqTraitLangItem, // 18 - OrdTraitLangItem, // 19 + EqTraitLangItem, // 17 + OrdTraitLangItem, // 18 - StrEqFnLangItem, // 20 - UniqStrEqFnLangItem, // 21 - AnnihilateFnLangItem, // 22 - LogTypeFnLangItem, // 23 - FailFnLangItem, // 24 - FailBoundsCheckFnLangItem, // 25 - ExchangeMallocFnLangItem, // 26 - ExchangeFreeFnLangItem, // 27 - MallocFnLangItem, // 28 - FreeFnLangItem, // 29 - BorrowAsImmFnLangItem, // 30 - BorrowAsMutFnLangItem, // 31 - ReturnToMutFnLangItem, // 32 - CheckNotBorrowedFnLangItem, // 33 - StrDupUniqFnLangItem, // 34 - RecordBorrowFnLangItem, // 35 - UnrecordBorrowFnLangItem, // 36 + StrEqFnLangItem, // 19 + UniqStrEqFnLangItem, // 20 + AnnihilateFnLangItem, // 21 + LogTypeFnLangItem, // 22 + FailFnLangItem, // 23 + FailBoundsCheckFnLangItem, // 24 + ExchangeMallocFnLangItem, // 25 + ExchangeFreeFnLangItem, // 26 + MallocFnLangItem, // 27 + FreeFnLangItem, // 28 + BorrowAsImmFnLangItem, // 29 + BorrowAsMutFnLangItem, // 30 + ReturnToMutFnLangItem, // 31 + CheckNotBorrowedFnLangItem, // 32 + StrDupUniqFnLangItem, // 33 + RecordBorrowFnLangItem, // 34 + UnrecordBorrowFnLangItem, // 35 - StartFnLangItem, // 37 + StartFnLangItem, // 36 } pub struct LanguageItems { - items: [Option, ..38] + items: [Option, ..37] } pub impl LanguageItems { pub fn new() -> LanguageItems { LanguageItems { - items: [ None, ..38 ] + items: [ None, ..37 ] } } @@ -100,45 +99,44 @@ pub impl LanguageItems { 0 => "const", 1 => "copy", 2 => "owned", - 3 => "durable", - 4 => "drop", + 3 => "drop", - 5 => "add", - 6 => "sub", - 7 => "mul", - 8 => "div", - 9 => "rem", - 10 => "neg", - 11 => "not", - 12 => "bitxor", - 13 => "bitand", - 14 => "bitor", - 15 => "shl", - 16 => "shr", - 17 => "index", - 18 => "eq", - 19 => "ord", + 4 => "add", + 5 => "sub", + 6 => "mul", + 7 => "div", + 8 => "rem", + 9 => "neg", + 10 => "not", + 11 => "bitxor", + 12 => "bitand", + 13 => "bitor", + 14 => "shl", + 15 => "shr", + 16 => "index", + 17 => "eq", + 18 => "ord", - 20 => "str_eq", - 21 => "uniq_str_eq", - 22 => "annihilate", - 23 => "log_type", - 24 => "fail_", - 25 => "fail_bounds_check", - 26 => "exchange_malloc", - 27 => "exchange_free", - 28 => "malloc", - 29 => "free", - 30 => "borrow_as_imm", - 31 => "borrow_as_mut", - 32 => "return_to_mut", - 33 => "check_not_borrowed", - 34 => "strdup_uniq", - 35 => "record_borrow", - 36 => "unrecord_borrow", + 19 => "str_eq", + 20 => "uniq_str_eq", + 21 => "annihilate", + 22 => "log_type", + 23 => "fail_", + 24 => "fail_bounds_check", + 25 => "exchange_malloc", + 26 => "exchange_free", + 27 => "malloc", + 28 => "free", + 29 => "borrow_as_imm", + 30 => "borrow_as_mut", + 31 => "return_to_mut", + 32 => "check_not_borrowed", + 33 => "strdup_uniq", + 34 => "record_borrow", + 35 => "unrecord_borrow", - 37 => "start", + 36 => "start", _ => "???" } @@ -155,9 +153,6 @@ pub impl LanguageItems { pub fn owned_trait(&const self) -> def_id { self.items[OwnedTraitLangItem as uint].get() } - pub fn durable_trait(&const self) -> def_id { - self.items[DurableTraitLangItem as uint].get() - } pub fn drop_trait(&const self) -> def_id { self.items[DropTraitLangItem as uint].get() @@ -274,7 +269,6 @@ fn LanguageItemCollector(crate: @crate, item_refs.insert(@~"const", ConstTraitLangItem as uint); item_refs.insert(@~"copy", CopyTraitLangItem as uint); item_refs.insert(@~"owned", OwnedTraitLangItem as uint); - item_refs.insert(@~"durable", DurableTraitLangItem as uint); item_refs.insert(@~"drop", DropTraitLangItem as uint); diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 7ef77646f52..0baad7e7b7a 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -101,7 +101,7 @@ pub fn get_region_reporting_err( } } -pub fn ast_region_to_region( +pub fn ast_region_to_region( self: &AC, rscope: &RS, default_span: span, @@ -126,7 +126,7 @@ pub fn ast_region_to_region( get_region_reporting_err(self.tcx(), span, opt_lifetime, res) } -fn ast_path_substs( +fn ast_path_substs( self: &AC, rscope: &RS, def_id: ast::def_id, @@ -180,7 +180,7 @@ fn ast_path_substs( substs {self_r:self_r, self_ty:self_ty, tps:tps} } -pub fn ast_path_to_substs_and_ty( +pub fn ast_path_to_substs_and_ty( self: &AC, rscope: &RS, did: ast::def_id, @@ -197,7 +197,7 @@ pub fn ast_path_to_substs_and_ty( ty_param_substs_and_ty { substs: substs, ty: ty } } -pub fn ast_path_to_trait_ref( +pub fn ast_path_to_trait_ref( self: &AC, rscope: &RS, trait_def_id: ast::def_id, @@ -221,7 +221,7 @@ pub fn ast_path_to_trait_ref( } -pub fn ast_path_to_ty( +pub fn ast_path_to_ty( self: &AC, rscope: &RS, did: ast::def_id, @@ -243,10 +243,10 @@ pub static NO_TPS: uint = 2; // Parses the programmer's textual representation of a type into our // internal notion of a type. `getter` is a function that returns the type // corresponding to a definition ID: -pub fn ast_ty_to_ty( +pub fn ast_ty_to_ty( self: &AC, rscope: &RS, ast_ty: @ast::Ty) -> ty::t { - fn ast_mt_to_mt( + fn ast_mt_to_mt( self: &AC, rscope: &RS, mt: &ast::mt) -> ty::mt { ty::mt {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl} @@ -255,7 +255,7 @@ pub fn ast_ty_to_ty( // Handle @, ~, and & being able to mean estrs and evecs. // If a_seq_ty is a str or a vec, make it an estr/evec. // Also handle first-class trait types. - fn mk_pointer( + fn mk_pointer( self: &AC, rscope: &RS, a_seq_ty: &ast::mt, @@ -497,7 +497,7 @@ pub fn ast_ty_to_ty( } pub fn ty_of_arg( + RS:region_scope + Copy + 'static>( self: &AC, rscope: &RS, a: ast::arg, @@ -549,7 +549,7 @@ struct SelfInfo { self_transform: ast::self_ty } -pub fn ty_of_method( +pub fn ty_of_method( self: &AC, rscope: &RS, purity: ast::purity, @@ -567,7 +567,7 @@ pub fn ty_of_method( (a.get(), b) } -pub fn ty_of_bare_fn( +pub fn ty_of_bare_fn( self: &AC, rscope: &RS, purity: ast::purity, @@ -580,7 +580,7 @@ pub fn ty_of_bare_fn( b } -fn ty_of_method_or_bare_fn( +fn ty_of_method_or_bare_fn( self: &AC, rscope: &RS, purity: ast::purity, @@ -616,7 +616,7 @@ fn ty_of_method_or_bare_fn( output: output_ty} }); - fn transform_self_ty( + fn transform_self_ty( self: &AC, rscope: &RS, self_info: &SelfInfo) -> Option @@ -649,7 +649,7 @@ fn ty_of_method_or_bare_fn( } } -pub fn ty_of_closure( +pub fn ty_of_closure( self: &AC, rscope: &RS, sigil: ast::Sigil, diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 1c3896ef5b9..33153bde5ac 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -116,7 +116,7 @@ pub fn collect_item_types(ccx: @mut CrateCtxt, crate: @ast::crate) { } impl CrateCtxt { - fn to_ty( + fn to_ty( &self, rs: &RS, ast_ty: @ast::Ty) -> ty::t { ast_ty_to_ty(self, rs, ast_ty) @@ -1179,7 +1179,7 @@ pub fn ty_generics(ccx: &CrateCtxt, * enum consisting of a newtyped Ty or a region) to ty's * notion of ty param bounds, which can either be user-defined * traits, or one of the four built-in traits (formerly known - * as kinds): Const, Copy, Durable, and Send. + * as kinds): Const, Copy, and Send. */ @ast_bounds.flat_map_to_vec(|b| { @@ -1194,8 +1194,6 @@ pub fn ty_generics(ccx: &CrateCtxt, ~[ty::bound_copy] } else if trait_ref.def_id == li.const_trait() { ~[ty::bound_const] - } else if trait_ref.def_id == li.durable_trait() { - ~[ty::bound_durable] } else { // Must be a user-defined trait ~[ty::bound_trait(trait_ref)] diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index 65f5b910f37..316792f688f 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -266,7 +266,7 @@ pub struct binding_rscope { region_param_names: RegionParamNames, } -pub fn in_binding_rscope( +pub fn in_binding_rscope( self: &RS, region_param_names: RegionParamNames) -> binding_rscope { diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 65e71869a1f..4c7f2edc6b0 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -148,7 +148,7 @@ fn get<'r, T>(elts: &'r [Option], i: uint) -> &'r T { mod tests { use super::*; use core::cmp::Eq; - use core::kinds::{Durable, Copy}; + use core::kinds::Copy; #[test] fn test_simple() { @@ -232,7 +232,7 @@ mod tests { } #[cfg(test)] - fn test_parameterized(a: T, b: T, c: T, d: T) { + fn test_parameterized(a: T, b: T, c: T, d: T) { let mut deq = Deque::new(); assert!(deq.len() == 0); deq.add_front(a); diff --git a/src/test/auxiliary/issue4516_ty_param_lib.rs b/src/test/auxiliary/issue4516_ty_param_lib.rs index dd2ffd5002c..391e9b39610 100644 --- a/src/test/auxiliary/issue4516_ty_param_lib.rs +++ b/src/test/auxiliary/issue4516_ty_param_lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub fn to_closure(x: A) -> @fn() -> A { +pub fn to_closure(x: A) -> @fn() -> A { let result: @fn() -> A = || copy x; result } diff --git a/src/test/compile-fail/core-tls-store-pointer.rs b/src/test/compile-fail/core-tls-store-pointer.rs new file mode 100644 index 00000000000..42cf9c793d1 --- /dev/null +++ b/src/test/compile-fail/core-tls-store-pointer.rs @@ -0,0 +1,21 @@ +// Copyright 2012 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Testing that we can't store a borrowed pointer it task-local storage + +use core::task::local_data::*; + +fn key(_x: @&int) { } + +fn main() { + unsafe { + local_data_set(key, @&0); //~ ERROR does not fulfill `'static` + } +} \ No newline at end of file