Skip to content

Commit b120c7e

Browse files
committed
---
yaml --- r: 67023 b: refs/heads/master c: 3bcc196 h: refs/heads/master i: 67021: 6716d26 67019: 1a8c987 67015: 37978a2 67007: e888bd1 v: v3
1 parent 6b6a7e3 commit b120c7e

23 files changed

+657
-390
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 002bfd796648547839d0f3740308995b4a926f50
2+
refs/heads/master: 3bcc196f8297af16ffcfeae98f20ed0496344e84
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/configure

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -750,18 +750,18 @@ then
750750
cd ${CFG_SRC_DIR}
751751

752752
msg "git: submodule sync"
753-
"${CFG_GIT}" submodule --quiet sync
753+
"${CFG_GIT}" submodule sync
754754

755755
msg "git: submodule update"
756-
"${CFG_GIT}" submodule --quiet update --init
756+
"${CFG_GIT}" submodule update --init
757757
need_ok "git failed"
758758

759759
msg "git: submodule foreach sync"
760-
"${CFG_GIT}" submodule --quiet foreach --recursive 'if test -e .gitmodules; then git submodule sync; fi'
760+
"${CFG_GIT}" submodule foreach --recursive 'if test -e .gitmodules; then git submodule sync; fi'
761761
need_ok "git failed"
762762

763763
msg "git: submodule foreach update"
764-
"${CFG_GIT}" submodule --quiet update --init --recursive
764+
"${CFG_GIT}" submodule update --init --recursive
765765
need_ok "git failed"
766766

767767
# NB: this is just for the sake of getting the submodule SHA1 values
@@ -770,9 +770,9 @@ then
770770
"${CFG_GIT}" submodule status --recursive
771771

772772
msg "git: submodule clobber"
773-
"${CFG_GIT}" submodule --quiet foreach --recursive git clean -dxf
773+
"${CFG_GIT}" submodule foreach --recursive git clean -dxf
774774
need_ok "git failed"
775-
"${CFG_GIT}" submodule --quiet foreach --recursive git checkout .
775+
"${CFG_GIT}" submodule foreach --recursive git checkout .
776776
need_ok "git failed"
777777

778778
cd ${CFG_BUILD_DIR}

trunk/doc/rust.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,41 @@ static bits_n_strings: BitsNStrings<'static> = BitsNStrings {
11221122
};
11231123
~~~~
11241124

1125+
#### Mutable statics
1126+
1127+
If a static item is declared with the ```mut``` keyword, then it is allowed to
1128+
be modified by the program. One of Rust's goals is to make concurrency bugs hard
1129+
to run into, and this is obviously a very large source of race conditions or
1130+
other bugs. For this reason, an ```unsafe``` block is required when either
1131+
reading or writing a mutable static variable. Care should be taken to ensure
1132+
that modifications to a mutable static are safe with respect to other tasks
1133+
running in the same process.
1134+
1135+
Mutable statics are still very useful, however. They can be used with C
1136+
libraries and can also be bound from C libraries (in an ```extern``` block).
1137+
1138+
~~~
1139+
# fn atomic_add(_: &mut uint, _: uint) -> uint { 2 }
1140+
1141+
static mut LEVELS: uint = 0;
1142+
1143+
// This violates the idea of no shared state, and this doesn't internally
1144+
// protect against races, so this function is `unsafe`
1145+
unsafe fn bump_levels_unsafe1() -> uint {
1146+
let ret = LEVELS;
1147+
LEVELS += 1;
1148+
return ret;
1149+
}
1150+
1151+
// Assuming that we have an atomic_add function which returns the old value,
1152+
// this function is "safe" but the meaning of the return value may not be what
1153+
// callers expect, so it's still marked as `unsafe`
1154+
unsafe fn bump_levels_unsafe2() -> uint {
1155+
return atomic_add(&mut LEVELS, 1);
1156+
}
1157+
1158+
~~~
1159+
11251160
### Traits
11261161

11271162
A _trait_ describes a set of method types.

trunk/src/librustc/metadata/common.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ pub static tag_mod_child: uint = 0x7e;
179179
pub static tag_misc_info: uint = 0x7f;
180180
pub static tag_misc_info_crate_items: uint = 0x80;
181181

182-
pub static tag_item_method_provided_source: uint = 0x81;
183-
184182
pub struct LinkMeta {
185183
name: @str,
186184
vers: @str,

trunk/src/librustc/metadata/csearch.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use metadata::common::*;
1515
use metadata::cstore;
1616
use metadata::decoder;
1717
use metadata;
18-
use middle::ty;
18+
use middle::{ty, resolve};
1919

2020
use std::vec;
2121
use reader = extra::ebml::reader;
@@ -97,10 +97,10 @@ pub fn get_enum_variants(tcx: ty::ctxt, def: ast::def_id)
9797
}
9898

9999
/// Returns information about the given implementation.
100-
pub fn get_impl(tcx: ty::ctxt, impl_def_id: ast::def_id)
101-
-> ty::Impl {
102-
let cdata = cstore::get_crate_data(tcx.cstore, impl_def_id.crate);
103-
decoder::get_impl(tcx.cstore.intr, cdata, impl_def_id.node, tcx)
100+
pub fn get_impl(cstore: @mut cstore::CStore, impl_def_id: ast::def_id)
101+
-> resolve::Impl {
102+
let cdata = cstore::get_crate_data(cstore, impl_def_id.crate);
103+
decoder::get_impl(cstore.intr, cdata, impl_def_id.node)
104104
}
105105

106106
pub fn get_method(tcx: ty::ctxt, def: ast::def_id) -> ty::Method {

trunk/src/librustc/metadata/decoder.rs

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use metadata::decoder;
2020
use metadata::tydecode::{parse_ty_data, parse_def_id,
2121
parse_type_param_def_data,
2222
parse_bare_fn_ty_data, parse_trait_ref_data};
23-
use middle::ty;
23+
use middle::{ty, resolve};
2424

2525
use std::hash::HashUtil;
2626
use std::int;
@@ -174,6 +174,14 @@ fn item_parent_item(d: ebml::Doc) -> Option<ast::def_id> {
174174
None
175175
}
176176

177+
fn translated_parent_item_opt(cnum: ast::crate_num, d: ebml::Doc) ->
178+
Option<ast::def_id> {
179+
let trait_did_opt = item_parent_item(d);
180+
do trait_did_opt.map |trait_did| {
181+
ast::def_id { crate: cnum, node: trait_did.node }
182+
}
183+
}
184+
177185
fn item_reqd_and_translated_parent_item(cnum: ast::crate_num,
178186
d: ebml::Doc) -> ast::def_id {
179187
let trait_did = item_parent_item(d).expect("item without parent");
@@ -185,12 +193,6 @@ fn item_def_id(d: ebml::Doc, cdata: cmd) -> ast::def_id {
185193
return translate_def_id(cdata, reader::with_doc_data(tagdoc, parse_def_id));
186194
}
187195

188-
fn get_provided_source(d: ebml::Doc, cdata: cmd) -> Option<ast::def_id> {
189-
do reader::maybe_get_doc(d, tag_item_method_provided_source).map |doc| {
190-
translate_def_id(cdata, reader::with_doc_data(*doc, parse_def_id))
191-
}
192-
}
193-
194196
fn each_reexport(d: ebml::Doc, f: &fn(ebml::Doc) -> bool) -> bool {
195197
for reader::tagged_docs(d, tag_items_data_item_reexport) |reexport_doc| {
196198
if !f(reexport_doc) {
@@ -321,19 +323,13 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
321323
UnsafeFn => dl_def(ast::def_fn(did, ast::unsafe_fn)),
322324
Fn => dl_def(ast::def_fn(did, ast::impure_fn)),
323325
ForeignFn => dl_def(ast::def_fn(did, ast::extern_fn)),
324-
StaticMethod | UnsafeStaticMethod => {
325-
let purity = if fam == UnsafeStaticMethod { ast::unsafe_fn } else
326-
{ ast::impure_fn };
327-
// def_static_method carries an optional field of its enclosing
328-
// *trait*, but not an inclosing Impl (if this is an inherent
329-
// static method). So we need to detect whether this is in
330-
// a trait or not, which we do through the mildly hacky
331-
// way of checking whether there is a trait_method_sort.
332-
let trait_did_opt = if reader::maybe_get_doc(
333-
item, tag_item_trait_method_sort).is_some() {
334-
Some(item_reqd_and_translated_parent_item(cnum, item))
335-
} else { None };
336-
dl_def(ast::def_static_method(did, trait_did_opt, purity))
326+
UnsafeStaticMethod => {
327+
let trait_did_opt = translated_parent_item_opt(cnum, item);
328+
dl_def(ast::def_static_method(did, trait_did_opt, ast::unsafe_fn))
329+
}
330+
StaticMethod => {
331+
let trait_did_opt = translated_parent_item_opt(cnum, item);
332+
dl_def(ast::def_static_method(did, trait_did_opt, ast::impure_fn))
337333
}
338334
Type | ForeignType => dl_def(ast::def_ty(did)),
339335
Mod => dl_def(ast::def_mod(did)),
@@ -799,29 +795,34 @@ fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ {
799795
}
800796

801797
fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc,
802-
tcx: ty::ctxt) -> ~[@ty::Method] {
798+
base_tps: uint) -> ~[@resolve::MethodInfo] {
803799
let mut rslt = ~[];
804800
for reader::tagged_docs(item, tag_item_impl_method) |doc| {
805801
let m_did = reader::with_doc_data(doc, parse_def_id);
806-
rslt.push(@get_method(intr, cdata, m_did.node, tcx));
802+
let mth_item = lookup_item(m_did.node, cdata.data);
803+
let explicit_self = get_explicit_self(mth_item);
804+
rslt.push(@resolve::MethodInfo {
805+
did: translate_def_id(cdata, m_did),
806+
n_tps: item_ty_param_count(mth_item) - base_tps,
807+
ident: item_name(intr, mth_item),
808+
explicit_self: explicit_self});
807809
}
808-
809810
rslt
810811
}
811812

812813
/// Returns information about the given implementation.
813-
pub fn get_impl(intr: @ident_interner, cdata: cmd, impl_id: ast::node_id,
814-
tcx: ty::ctxt)
815-
-> ty::Impl {
814+
pub fn get_impl(intr: @ident_interner, cdata: cmd, impl_id: ast::node_id)
815+
-> resolve::Impl {
816816
let data = cdata.data;
817817
let impl_item = lookup_item(impl_id, data);
818-
ty::Impl {
818+
let base_tps = item_ty_param_count(impl_item);
819+
resolve::Impl {
819820
did: ast::def_id {
820821
crate: cdata.cnum,
821822
node: impl_id,
822823
},
823824
ident: item_name(intr, impl_item),
824-
methods: item_impl_methods(intr, cdata, impl_item, tcx),
825+
methods: item_impl_methods(intr, cdata, impl_item, base_tps),
825826
}
826827
}
827828

@@ -841,16 +842,13 @@ pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
841842
{
842843
let method_doc = lookup_item(id, cdata.data);
843844
let def_id = item_def_id(method_doc, cdata);
844-
let container_id = item_reqd_and_translated_parent_item(cdata.cnum,
845-
method_doc);
846845
let name = item_name(intr, method_doc);
847846
let type_param_defs = item_ty_param_defs(method_doc, tcx, cdata,
848847
tag_item_method_tps);
849848
let transformed_self_ty = doc_transformed_self_ty(method_doc, tcx, cdata);
850849
let fty = doc_method_fty(method_doc, tcx, cdata);
851850
let vis = item_visibility(method_doc);
852851
let explicit_self = get_explicit_self(method_doc);
853-
let provided_source = get_provided_source(method_doc, cdata);
854852

855853
ty::Method::new(
856854
name,
@@ -862,9 +860,7 @@ pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
862860
fty,
863861
explicit_self,
864862
vis,
865-
def_id,
866-
container_id,
867-
provided_source
863+
def_id
868864
)
869865
}
870866

0 commit comments

Comments
 (0)