Skip to content

Commit 1b0dc6a

Browse files
committed
auto merge of #16092 : alexcrichton/rust/rollup, r=alexcrichton
2 parents 5ebf481 + f91a964 commit 1b0dc6a

File tree

29 files changed

+455
-91
lines changed

29 files changed

+455
-91
lines changed

src/compiletest/header.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ pub struct TestProps {
3636
pub no_prefer_dynamic: bool,
3737
// Don't run --pretty expanded when running pretty printing tests
3838
pub no_pretty_expanded: bool,
39+
// Which pretty mode are we testing with, default to 'normal'
40+
pub pretty_mode: String,
41+
// Only compare pretty output and don't try compiling
42+
pub pretty_compare_only: bool,
3943
}
4044

4145
// Load any test directives embedded in the file
@@ -51,6 +55,8 @@ pub fn load_props(testfile: &Path) -> TestProps {
5155
let mut check_stdout = false;
5256
let mut no_prefer_dynamic = false;
5357
let mut no_pretty_expanded = false;
58+
let mut pretty_mode = None;
59+
let mut pretty_compare_only = false;
5460
iter_header(testfile, |ln| {
5561
match parse_error_pattern(ln) {
5662
Some(ep) => error_patterns.push(ep),
@@ -85,6 +91,14 @@ pub fn load_props(testfile: &Path) -> TestProps {
8591
no_pretty_expanded = parse_no_pretty_expanded(ln);
8692
}
8793

94+
if pretty_mode.is_none() {
95+
pretty_mode = parse_pretty_mode(ln);
96+
}
97+
98+
if !pretty_compare_only {
99+
pretty_compare_only = parse_pretty_compare_only(ln);
100+
}
101+
88102
match parse_aux_build(ln) {
89103
Some(ab) => { aux_builds.push(ab); }
90104
None => {}
@@ -115,6 +129,8 @@ pub fn load_props(testfile: &Path) -> TestProps {
115129
check_stdout: check_stdout,
116130
no_prefer_dynamic: no_prefer_dynamic,
117131
no_pretty_expanded: no_pretty_expanded,
132+
pretty_mode: pretty_mode.unwrap_or("normal".to_string()),
133+
pretty_compare_only: pretty_compare_only
118134
}
119135
}
120136

@@ -205,6 +221,14 @@ fn parse_no_pretty_expanded(line: &str) -> bool {
205221
parse_name_directive(line, "no-pretty-expanded")
206222
}
207223

224+
fn parse_pretty_mode(line: &str) -> Option<String> {
225+
parse_name_value_directive(line, "pretty-mode")
226+
}
227+
228+
fn parse_pretty_compare_only(line: &str) -> bool {
229+
parse_name_directive(line, "pretty-compare-only")
230+
}
231+
208232
fn parse_exec_env(line: &str) -> Option<(String, String)> {
209233
parse_name_value_directive(line, "exec-env").map(|nv| {
210234
// nv is either FOO or FOO=BAR

src/compiletest/runtest.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
168168
props,
169169
testfile,
170170
srcs[round].to_string(),
171-
"normal");
171+
props.pretty_mode.as_slice());
172172

173173
if !proc_res.status.success() {
174174
fatal_proc_rec(format!("pretty-printing failed in round {}",
@@ -200,6 +200,9 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
200200

201201
compare_source(expected.as_slice(), actual.as_slice());
202202

203+
// If we're only making sure that the output matches then just stop here
204+
if props.pretty_compare_only { return; }
205+
203206
// Finally, let's make sure it actually appears to remain valid code
204207
let proc_res = typecheck_source(config, props, testfile, actual);
205208

src/doc/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ as that for which this documentation was generated.*
8484

8585
* [Reddit](http://reddit.com/r/rust)
8686
* [Stack Overflow](http://stackoverflow.com/questions/tagged/rust)
87+
* [Developer Forum](http://discuss.rust-lang.org/)
8788
* The Rust IRC channels on [irc.mozilla.org](http://irc.mozilla.org/):
8889
* [`#rust`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust) - general discussion
8990
* [`#rust-gamedev`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-gamedev) - game development

src/doc/intro.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ int add_one(void)
3636
}
3737
```
3838
39-
**Note: obviously this is very simple and non-idiomatic C++.
40-
You wouldn't write it in practice; it is for illustrative purposes.**
39+
**Note: The above C++ code is deliberately simple and non-idiomatic for the purpose
40+
of demonstration. It is not representative of production-quality C++ code.**
4141
4242
This function allocates an integer on the stack,
4343
and stores it in a variable, `i`.

src/doc/rust.md

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,6 +1950,12 @@ interpreted:
19501950
- `unsafe_no_drop_flag` - on structs, remove the flag that prevents
19511951
destructors from being run twice. Destructors might be run multiple times on
19521952
the same object with this attribute.
1953+
- `phase` - on `extern crate` statements, allows specifying which "phase" of
1954+
compilation the crate should be loaded for. Currently, there are two
1955+
choices: `link` and `plugin`. `link` is the default. `plugin` will load the
1956+
crate at compile-time and use any syntax extensions or lints that the crate
1957+
defines. They can both be specified, `#[phase(link, plugin)]` to use a crate
1958+
both at runtime and compiletime.
19531959

19541960
### Conditional compilation
19551961

@@ -2395,17 +2401,17 @@ The currently implemented features of the reference compiler are:
23952401
closure as `once` is unlikely to be supported going forward. So
23962402
they are hidden behind this feature until they are to be removed.
23972403

2398-
* `managed_boxes` - Usage of `@` pointers is gated due to many
2404+
* `asm` - The `asm!` macro provides a means for inline assembly. This is often
2405+
useful, but the exact syntax for this feature along with its semantics
2406+
are likely to change, so this macro usage must be opted into.
2407+
2408+
* `managed_boxes` - Usage of `@` is gated due to many
23992409
planned changes to this feature. In the past, this has meant
24002410
"a GC pointer", but the current implementation uses
24012411
reference counting and will likely change drastically over
24022412
time. Additionally, the `@` syntax will no longer be used to
24032413
create GC boxes.
24042414

2405-
* `asm` - The `asm!` macro provides a means for inline assembly. This is often
2406-
useful, but the exact syntax for this feature along with its semantics
2407-
are likely to change, so this macro usage must be opted into.
2408-
24092415
* `non_ascii_idents` - The compiler supports the use of non-ascii identifiers,
24102416
but the implementation is a little rough around the
24112417
edges, so this can be seen as an experimental feature for
@@ -2427,6 +2433,66 @@ The currently implemented features of the reference compiler are:
24272433
if the system linker is not used then specifying custom flags
24282434
doesn't have much meaning.
24292435

2436+
* `phase` - Usage of the `#[phase]` attribute allows loading compiler plugins
2437+
for custom lints or syntax extensions. The implementation is considered
2438+
unwholesome and in need of overhaul, and it is not clear what they
2439+
will look like moving forward.
2440+
2441+
* `plugin_registrar` - Indicates that a crate has compiler plugins that it
2442+
wants to load. As with `phase`, the implementation is
2443+
in need of a overhaul, and it is not clear that plugins
2444+
defined using this will continue to work.
2445+
2446+
* `log_syntax` - Allows use of the `log_syntax` macro attribute, which is a
2447+
nasty hack that will certainly be removed.
2448+
2449+
* `trace_macros` - Allows use of the `trace_macros` macro, which is a nasty
2450+
hack that will certainly be removed.
2451+
2452+
* `concat_idents` - Allows use of the `concat_idents` macro, which is in many
2453+
ways insufficient for concatenating identifiers, and may
2454+
be removed entirely for something more wholsome.
2455+
2456+
* `unsafe_destructor` - Allows use of the `#[unsafe_destructor]` attribute,
2457+
which is considered wildly unsafe and will be
2458+
obsoleted by language improvements.
2459+
2460+
* `intrinsics` - Allows use of the "rust-intrinsics" ABI. Compiler intrinsics
2461+
are inherently unstable and no promise about them is made.
2462+
2463+
* `lang_items` - Allows use of the `#[lang]` attribute. Like `intrinsics`,
2464+
lang items are inherently unstable and no promise about
2465+
them is made.
2466+
2467+
* `simd` - Allows use of the `#[simd]` attribute, which is overly simple and
2468+
not the SIMD interface we want to expose in the long term.
2469+
2470+
* `default_type_params` - Allows use of default type parameters. The future of
2471+
this feature is uncertain.
2472+
2473+
* `quote` - Allows use of the `quote_*!` family of macros, which are
2474+
implemented very poorly and will likely change significantly
2475+
with a proper implementation.
2476+
2477+
* `linkage` - Allows use of the `linkage` attribute, which is not portable.
2478+
2479+
* `struct_inherit` - Allows using struct inheritance, which is barely
2480+
implemented and will probably be removed. Don't use this.
2481+
2482+
* `overloaded_calls` - Allow implementing the `Fn*` family of traits on user
2483+
types, allowing overloading the call operator (`()`).
2484+
This feature may still undergo changes before being
2485+
stabilized.
2486+
2487+
* `unboxed_closure_sugar` - Allows using `|Foo| -> Bar` as a trait bound
2488+
meaning one of the `Fn` traits. Still
2489+
experimental.
2490+
2491+
* `rustc_diagnostic_macros`- A mysterious feature, used in the implementation
2492+
of rustc, not meant for mortals.
2493+
2494+
* `unboxed_closures` - A work in progress feature with many known bugs.
2495+
24302496
If a feature is promoted to a language feature, then all existing programs will
24312497
start to receive compilation warnings about #[feature] directives which enabled
24322498
the new feature (because the directive is no longer necessary). However, if

src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,14 @@
269269
<match>\\\%{common_escape}</match>
270270
</context>
271271

272+
<context id="raw-string" style-ref="string" class="string" class-disabled="no-spell-check">
273+
<start>r(#*)"</start>
274+
<end>"\%{1@start}</end>
275+
<include>
276+
<context ref="def:line-continue"/>
277+
</include>
278+
</context>
279+
272280
<context id="string" style-ref="string" class="string" class-disabled="no-spell-check">
273281
<start>"</start>
274282
<end>"</end>
@@ -287,6 +295,8 @@
287295
<end>\]</end>
288296
<include>
289297
<context ref="def:in-comment"/>
298+
<context ref="string"/>
299+
<context ref="raw-string"/>
290300
</include>
291301
</context>
292302

@@ -305,6 +315,7 @@
305315
<context ref="number"/>
306316
<context ref="scope"/>
307317
<context ref="string"/>
318+
<context ref="raw-string"/>
308319
<context ref="char"/>
309320
<context ref="lifetime"/>
310321
<context ref="attribute"/>

src/liballoc/arc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<T: Share + Send> Arc<T> {
9292
}
9393

9494
#[inline]
95-
fn inner<'a>(&'a self) -> &'a ArcInner<T> {
95+
fn inner(&self) -> &ArcInner<T> {
9696
// This unsafety is ok because while this arc is alive we're guaranteed
9797
// that the inner pointer is valid. Furthermore, we know that the
9898
// `ArcInner` structure itself is `Share` because the inner data is
@@ -142,7 +142,7 @@ impl<T: Share + Send> Clone for Arc<T> {
142142
#[experimental = "Deref is experimental."]
143143
impl<T: Send + Share> Deref<T> for Arc<T> {
144144
#[inline]
145-
fn deref<'a>(&'a self) -> &'a T {
145+
fn deref(&self) -> &T {
146146
&self.inner().data
147147
}
148148
}
@@ -155,7 +155,7 @@ impl<T: Send + Share + Clone> Arc<T> {
155155
/// data is cloned if the reference count is greater than one.
156156
#[inline]
157157
#[experimental]
158-
pub fn make_unique<'a>(&'a mut self) -> &'a mut T {
158+
pub fn make_unique(&mut self) -> &mut T {
159159
// Note that we hold a strong reference, which also counts as
160160
// a weak reference, so we only clone if there is an
161161
// additional reference of either kind.
@@ -238,7 +238,7 @@ impl<T: Share + Send> Weak<T> {
238238
}
239239

240240
#[inline]
241-
fn inner<'a>(&'a self) -> &'a ArcInner<T> {
241+
fn inner(&self) -> &ArcInner<T> {
242242
// See comments above for why this is "safe"
243243
unsafe { &*self._ptr }
244244
}

src/libcollections/dlist.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use core::fmt;
2929
use core::iter;
3030
use core::mem;
3131
use core::ptr;
32+
use std::hash::{Writer, Hash};
3233

3334
use {Collection, Mutable, Deque, MutableSeq};
3435

@@ -707,10 +708,20 @@ impl<A: fmt::Show> fmt::Show for DList<A> {
707708
}
708709
}
709710

711+
impl<S: Writer, A: Hash<S>> Hash<S> for DList<A> {
712+
fn hash(&self, state: &mut S) {
713+
self.len().hash(state);
714+
for elt in self.iter() {
715+
elt.hash(state);
716+
}
717+
}
718+
}
719+
710720
#[cfg(test)]
711721
mod tests {
712722
use std::prelude::*;
713723
use std::rand;
724+
use std::hash;
714725
use test::Bencher;
715726
use test;
716727

@@ -1075,6 +1086,24 @@ mod tests {
10751086
assert!(n != m);
10761087
}
10771088

1089+
#[test]
1090+
fn test_hash() {
1091+
let mut x = DList::new();
1092+
let mut y = DList::new();
1093+
1094+
assert!(hash::hash(&x) == hash::hash(&y));
1095+
1096+
x.push_back(1i);
1097+
x.push_back(2);
1098+
x.push_back(3);
1099+
1100+
y.push_front(3i);
1101+
y.push_front(2);
1102+
y.push_front(1);
1103+
1104+
assert!(hash::hash(&x) == hash::hash(&y));
1105+
}
1106+
10781107
#[test]
10791108
fn test_ord() {
10801109
let n: DList<int> = list_from([]);

src/libcollections/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ pub trait MutableVectorAllocating<'a, T> {
579579
*
580580
* * src - A mutable vector of `T`
581581
* * start - The index into `src` to start copying from
582-
* * end - The index into `str` to stop copying from
582+
* * end - The index into `src` to stop copying from
583583
*/
584584
fn move_from(self, src: Vec<T>, start: uint, end: uint) -> uint;
585585
}

0 commit comments

Comments
 (0)