Skip to content

Commit fb234ae

Browse files
committed
---
yaml --- r: 103105 b: refs/heads/auto c: ece12d8 h: refs/heads/master i: 103103: adca8e7 v: v3
1 parent 7da0451 commit fb234ae

File tree

32 files changed

+336
-1041
lines changed

32 files changed

+336
-1041
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 74f3e0474b382160a6b0aec6e27fe239025519a0
16+
refs/heads/auto: ece12d8da675d8ae13954d2172347160eb7cb7f6
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/Makefile.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
#
104104
# </tips>
105105
#
106-
# <nittygritty>
106+
# <nitty-gritty>
107107
#
108108
# # The Rust Build System
109109
#
@@ -157,7 +157,7 @@
157157
#
158158
# Admittedly this is a little convoluted.
159159
#
160-
# </nittygritty>
160+
# </nitty-gritty>
161161
#
162162

163163
######################################################################

branches/auto/mk/main.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,13 @@ all: $(ALL_TARGET_RULES) $(GENERATED) docs
446446
# $(1) is the name of the doc <section> in Makefile.in
447447
# pick everything between tags | remove first line | remove last line
448448
# | remove extra (?) line | strip leading `#` from lines
449-
SHOW_DOCS = $(Q)awk '/$(1)/,/<\/$(1)>/' $(S)/Makefile.in | sed '1d' | sed '$$d' | sed 's/^\# \?//'
449+
SHOW_DOCS = $(Q)awk '/<$(1)>/,/<\/$(1)>/' $(S)/Makefile.in | sed '1d' | sed '$$d' | sed 's/^\# \?//'
450450

451451
help:
452452
$(call SHOW_DOCS,help)
453453

454-
hot-tips:
455-
$(call SHOW_DOCS,hottips)
454+
tips:
455+
$(call SHOW_DOCS,tips)
456456

457457
nitty-gritty:
458-
$(call SHOW_DOCS,nittygritty)
458+
$(call SHOW_DOCS,nitty-gritty)

branches/auto/src/compiler-rt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit f4b221571ce6f05714c1f1c6fa48f1393499989c
1+
Subproject commit d4606f1818dd8dfeaa3e509cd1cbac4482c3513e

branches/auto/src/doc/guide-tasks.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ spawn(proc() {
226226
});
227227
~~~
228228

229-
Instead we can clone the `chan`, which allows for multiple senders.
229+
Instead we can use a `SharedChan`, a type that allows a single
230+
`Chan` to be shared by multiple senders.
230231

231232
~~~
232233
# use std::task::spawn;
@@ -245,13 +246,16 @@ let result = port.recv() + port.recv() + port.recv();
245246
# fn some_expensive_computation(_i: uint) -> int { 42 }
246247
~~~
247248

248-
Cloning a `Chan` produces a new handle to the same channel, allowing multiple
249-
tasks to send data to a single port. It also upgrades the channel internally in
250-
order to allow this functionality, which means that channels that are not
251-
cloned can avoid the overhead required to handle multiple senders. But this
252-
fact has no bearing on the channel's usage: the upgrade is transparent.
249+
Here we transfer ownership of the channel into a new `SharedChan` value. Like
250+
`Chan`, `SharedChan` is a non-copyable, owned type (sometimes also referred to
251+
as an *affine* or *linear* type). Unlike with `Chan`, though, the programmer
252+
may duplicate a `SharedChan`, with the `clone()` method. A cloned
253+
`SharedChan` produces a new handle to the same channel, allowing multiple
254+
tasks to send data to a single port. Between `spawn`, `Chan` and
255+
`SharedChan`, we have enough tools to implement many useful concurrency
256+
patterns.
253257

254-
Note that the above cloning example is somewhat contrived since
258+
Note that the above `SharedChan` example is somewhat contrived since
255259
you could also simply use three `Chan` pairs, but it serves to
256260
illustrate the point. For reference, written with multiple streams, it
257261
might look like the example below.

branches/auto/src/libextra/json.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ the code for these traits: `#[deriving(Decodable, Encodable)]`
5959
To encode using Encodable :
6060
6161
```rust
62-
extern crate extra;
6362
extern crate serialize;
6463
use extra::json;
6564
use std::io;
@@ -99,7 +98,6 @@ A basic `ToJson` example using a TreeMap of attribute name / attribute value:
9998
10099
101100
```rust
102-
extern crate extra;
103101
extern crate collections;
104102
105103
use extra::json;
@@ -127,10 +125,9 @@ fn main() {
127125
}
128126
```
129127
130-
To decode a JSON string using `Decodable` trait :
128+
To decode a json string using `Decodable` trait :
131129
132130
```rust
133-
extern crate extra;
134131
extern crate serialize;
135132
use serialize::Decodable;
136133
@@ -157,7 +154,6 @@ Create a struct called TestStruct1 and serialize and deserialize it to and from
157154
using the serialization API, using the derived serialization code.
158155
159156
```rust
160-
extern crate extra;
161157
extern crate serialize;
162158
use extra::json;
163159
use serialize::{Encodable, Decodable};
@@ -176,7 +172,7 @@ fn main() {
176172
{data_int: 1, data_str:~"toto", data_vector:~[2,3,4,5]};
177173
let encoded_str: ~str = json::Encoder::str_encode(&to_encode_object);
178174
179-
// To deserialize use the `extra::json::from_str` and `extra::json::Decoder`
175+
// To unserialize use the `extra::json::from_str` and `extra::json::Decoder`
180176
181177
let json_object = extra::json::from_str(encoded_str);
182178
let mut decoder = json::Decoder::new(json_object.unwrap());
@@ -186,11 +182,10 @@ fn main() {
186182
187183
## Using `ToJson`
188184
189-
This example use the ToJson impl to deserialize the JSON string.
185+
This example use the ToJson impl to unserialize the json string.
190186
Example of `ToJson` trait implementation for TestStruct1.
191187
192188
```rust
193-
extern crate extra;
194189
extern crate serialize;
195190
extern crate collections;
196191
@@ -217,13 +212,13 @@ impl ToJson for TestStruct1 {
217212
}
218213
219214
fn main() {
220-
// Serialization using our impl of to_json
215+
// Seralization using our impl of to_json
221216
222217
let test2: TestStruct1 = TestStruct1 {data_int: 1, data_str:~"toto", data_vector:~[2,3,4,5]};
223218
let tjson: json::Json = test2.to_json();
224219
let json_str: ~str = tjson.to_str();
225220
226-
// Deserialize like before.
221+
// Unserialize like before.
227222
228223
let mut decoder = json::Decoder::new(json::from_str(json_str).unwrap());
229224
// create the final object

branches/auto/src/libextra/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ impl MetricMap {
11101110
11111111
// Benchmarking
11121112
1113-
/// A function that is opaque to the optimizer, to allow benchmarks to
1113+
/// A function that is opaque to the optimiser, to allow benchmarks to
11141114
/// pretend to use outputs to assist in avoiding dead-code
11151115
/// elimination.
11161116
///

branches/auto/src/libgreen/sched.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub struct Scheduler {
8686
/// A flag to tell the scheduler loop it needs to do some stealing
8787
/// in order to introduce randomness as part of a yield
8888
steal_for_yield: bool,
89-
/// Bookkeeping for the number of tasks which are currently running around
89+
/// Bookeeping for the number of tasks which are currently running around
9090
/// inside this pool of schedulers
9191
task_state: TaskState,
9292

branches/auto/src/libnative/io/file.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,7 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> {
571571
else {
572572
let fp_vec = vec::from_buf(
573573
fp_buf, wcslen(fp_buf) as uint);
574-
let fp_trimmed = str::truncate_utf16_at_nul(fp_vec);
575-
let fp_str = str::from_utf16(fp_trimmed)
576-
.expect("rust_list_dir_wfd_fp_buf returned invalid UTF-16");
574+
let fp_str = str::from_utf16(fp_vec);
577575
paths.push(Path::new(fp_str));
578576
}
579577
more_files = FindNextFileW(find_handle, wfd_ptr as HANDLE);

branches/auto/src/librustc/middle/privacy.rs

Lines changed: 38 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ pub type ExportedItems = HashSet<ast::NodeId>;
4141
/// reexporting a public struct doesn't inline the doc).
4242
pub type PublicItems = HashSet<ast::NodeId>;
4343

44-
/// Result of a checking operation - None => no errors were found. Some => an
45-
/// error and contains the span and message for reporting that error and
46-
/// optionally the same for a note about the error.
47-
type CheckResult = Option<(Span, ~str, Option<(Span, ~str)>)>;
48-
4944
////////////////////////////////////////////////////////////////////////////////
5045
/// The parent visitor, used to determine what's the parent of what (node-wise)
5146
////////////////////////////////////////////////////////////////////////////////
@@ -515,50 +510,40 @@ impl<'a> PrivacyVisitor<'a> {
515510
}
516511
}
517512

518-
fn report_error(&self, result: CheckResult) -> bool {
519-
match result {
520-
None => true,
521-
Some((span, msg, note)) => {
522-
self.tcx.sess.span_err(span, msg);
523-
match note {
524-
Some((span, msg)) => self.tcx.sess.span_note(span, msg),
525-
None => {},
526-
}
527-
false
528-
},
529-
}
530-
}
531-
532-
/// Guarantee that a particular definition is public. Returns a CheckResult
533-
/// which contains any errors found. These can be reported using `report_error`.
534-
/// If the result is `None`, no errors were found.
513+
/// Guarantee that a particular definition is public, possibly emitting an
514+
/// error message if it's not.
535515
fn ensure_public(&self, span: Span, to_check: ast::DefId,
536-
source_did: Option<ast::DefId>, msg: &str) -> CheckResult {
516+
source_did: Option<ast::DefId>, msg: &str) -> bool {
537517
match self.def_privacy(to_check) {
538-
ExternallyDenied => Some((span, format!("{} is private", msg), None)),
518+
ExternallyDenied => {
519+
self.tcx.sess.span_err(span, format!("{} is private", msg))
520+
}
539521
DisallowedBy(id) => {
540-
let (err_span, err_msg) = if id == source_did.unwrap_or(to_check).node {
541-
return Some((span, format!("{} is private", msg), None));
522+
if id == source_did.unwrap_or(to_check).node {
523+
self.tcx.sess.span_err(span, format!("{} is private", msg));
524+
return false;
542525
} else {
543-
(span, format!("{} is inaccessible", msg))
544-
};
526+
self.tcx.sess.span_err(span, format!("{} is inaccessible",
527+
msg));
528+
}
545529
match self.tcx.map.find(id) {
546530
Some(ast_map::NodeItem(item)) => {
547531
let desc = match item.node {
548532
ast::ItemMod(..) => "module",
549533
ast::ItemTrait(..) => "trait",
550-
_ => return Some((err_span, err_msg, None)),
534+
_ => return false,
551535
};
552536
let msg = format!("{} `{}` is private",
553537
desc,
554538
token::get_ident(item.ident));
555-
Some((err_span, err_msg, Some((span, msg))))
556-
},
557-
_ => Some((err_span, err_msg, None)),
539+
self.tcx.sess.span_note(span, msg);
540+
}
541+
Some(..) | None => {}
558542
}
559-
},
560-
Allowable => None,
543+
}
544+
Allowable => return true
561545
}
546+
return false;
562547
}
563548

564549
// Checks that a field is in scope.
@@ -628,99 +613,34 @@ impl<'a> PrivacyVisitor<'a> {
628613
let method_id = ty::method(self.tcx, method_id).provided_source
629614
.unwrap_or(method_id);
630615

631-
let string = token::get_ident(name);
632-
self.report_error(self.ensure_public(span,
633-
method_id,
634-
None,
635-
format!("method `{}`", string)));
616+
self.ensure_public(span,
617+
method_id,
618+
None,
619+
format!("method `{}`", token::get_ident(name)));
636620
}
637621

638622
// Checks that a path is in scope.
639623
fn check_path(&mut self, span: Span, path_id: ast::NodeId, path: &ast::Path) {
640624
debug!("privacy - path {}", self.nodestr(path_id));
641625
let def_map = self.tcx.def_map.borrow();
642-
let orig_def = def_map.get().get_copy(&path_id);
626+
let def = def_map.get().get_copy(&path_id);
643627
let ck = |tyname: &str| {
644-
let ck_public = |def: ast::DefId| {
645-
let name = token::get_ident(path.segments
646-
.last()
647-
.unwrap()
648-
.identifier);
649-
let origdid = def_id_of_def(orig_def);
650-
self.ensure_public(span,
651-
def,
652-
Some(origdid),
653-
format!("{} `{}`",
654-
tyname,
655-
name))
656-
};
657-
628+
let origdid = def_id_of_def(def);
658629
match *self.last_private_map.get(&path_id) {
659-
resolve::LastMod(resolve::AllPublic) => {},
660-
resolve::LastMod(resolve::DependsOn(def)) => {
661-
self.report_error(ck_public(def));
662-
},
663-
resolve::LastImport{value_priv: value_priv,
664-
value_used: check_value,
665-
type_priv: type_priv,
666-
type_used: check_type} => {
667-
// This dance with found_error is because we don't want to report
668-
// a privacy error twice for the same directive.
669-
let found_error = match (type_priv, check_type) {
670-
(Some(resolve::DependsOn(def)), resolve::Used) => {
671-
!self.report_error(ck_public(def))
672-
},
673-
_ => false,
674-
};
675-
if !found_error {
676-
match (value_priv, check_value) {
677-
(Some(resolve::DependsOn(def)), resolve::Used) => {
678-
self.report_error(ck_public(def));
679-
},
680-
_ => {},
681-
}
682-
}
683-
// If an import is not used in either namespace, we still want to check
684-
// that it could be legal. Therefore we check in both namespaces and only
685-
// report an error if both would be illegal. We only report one error,
686-
// even if it is illegal to import from both namespaces.
687-
match (value_priv, check_value, type_priv, check_type) {
688-
(Some(p), resolve::Unused, None, _) |
689-
(None, _, Some(p), resolve::Unused) => {
690-
let p = match p {
691-
resolve::AllPublic => None,
692-
resolve::DependsOn(def) => ck_public(def),
693-
};
694-
if p.is_some() {
695-
self.report_error(p);
696-
}
697-
},
698-
(Some(v), resolve::Unused, Some(t), resolve::Unused) => {
699-
let v = match v {
700-
resolve::AllPublic => None,
701-
resolve::DependsOn(def) => ck_public(def),
702-
};
703-
let t = match t {
704-
resolve::AllPublic => None,
705-
resolve::DependsOn(def) => ck_public(def),
706-
};
707-
match (v, t) {
708-
(Some(_), Some(t)) => {
709-
self.report_error(Some(t));
710-
},
711-
_ => {},
712-
}
713-
},
714-
_ => {},
715-
}
716-
},
630+
resolve::AllPublic => {},
631+
resolve::DependsOn(def) => {
632+
let name = token::get_ident(path.segments
633+
.last()
634+
.unwrap()
635+
.identifier);
636+
self.ensure_public(span,
637+
def,
638+
Some(origdid),
639+
format!("{} `{}`",
640+
tyname, name));
641+
}
717642
}
718643
};
719-
// FIXME(#12334) Imports can refer to definitions in both the type and
720-
// value namespaces. The privacy information is aware of this, but the
721-
// def map is not. Therefore the names we work out below will not always
722-
// be accurate and we can get slightly wonky error messages (but type
723-
// checking is always correct).
724644
let def_map = self.tcx.def_map.borrow();
725645
match def_map.get().get_copy(&path_id) {
726646
ast::DefStaticMethod(..) => ck("static method"),
@@ -748,7 +668,7 @@ impl<'a> PrivacyVisitor<'a> {
748668
// is whether the trait itself is accessible or not.
749669
method_param(method_param { trait_id: trait_id, .. }) |
750670
method_object(method_object { trait_id: trait_id, .. }) => {
751-
self.report_error(self.ensure_public(span, trait_id, None, "source trait"));
671+
self.ensure_public(span, trait_id, None, "source trait");
752672
}
753673
}
754674
}

0 commit comments

Comments
 (0)