Skip to content

Rolling up PRs in the queue #16092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jul 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ pub struct TestProps {
pub no_prefer_dynamic: bool,
// Don't run --pretty expanded when running pretty printing tests
pub no_pretty_expanded: bool,
// Which pretty mode are we testing with, default to 'normal'
pub pretty_mode: String,
// Only compare pretty output and don't try compiling
pub pretty_compare_only: bool,
}

// Load any test directives embedded in the file
Expand All @@ -51,6 +55,8 @@ pub fn load_props(testfile: &Path) -> TestProps {
let mut check_stdout = false;
let mut no_prefer_dynamic = false;
let mut no_pretty_expanded = false;
let mut pretty_mode = None;
let mut pretty_compare_only = false;
iter_header(testfile, |ln| {
match parse_error_pattern(ln) {
Some(ep) => error_patterns.push(ep),
Expand Down Expand Up @@ -85,6 +91,14 @@ pub fn load_props(testfile: &Path) -> TestProps {
no_pretty_expanded = parse_no_pretty_expanded(ln);
}

if pretty_mode.is_none() {
pretty_mode = parse_pretty_mode(ln);
}

if !pretty_compare_only {
pretty_compare_only = parse_pretty_compare_only(ln);
}

match parse_aux_build(ln) {
Some(ab) => { aux_builds.push(ab); }
None => {}
Expand Down Expand Up @@ -115,6 +129,8 @@ pub fn load_props(testfile: &Path) -> TestProps {
check_stdout: check_stdout,
no_prefer_dynamic: no_prefer_dynamic,
no_pretty_expanded: no_pretty_expanded,
pretty_mode: pretty_mode.unwrap_or("normal".to_string()),
pretty_compare_only: pretty_compare_only
}
}

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

fn parse_pretty_mode(line: &str) -> Option<String> {
parse_name_value_directive(line, "pretty-mode")
}

fn parse_pretty_compare_only(line: &str) -> bool {
parse_name_directive(line, "pretty-compare-only")
}

fn parse_exec_env(line: &str) -> Option<(String, String)> {
parse_name_value_directive(line, "exec-env").map(|nv| {
// nv is either FOO or FOO=BAR
Expand Down
5 changes: 4 additions & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
props,
testfile,
srcs[round].to_string(),
"normal");
props.pretty_mode.as_slice());

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

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

// If we're only making sure that the output matches then just stop here
if props.pretty_compare_only { return; }

// Finally, let's make sure it actually appears to remain valid code
let proc_res = typecheck_source(config, props, testfile, actual);

Expand Down
1 change: 1 addition & 0 deletions src/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ as that for which this documentation was generated.*

* [Reddit](http://reddit.com/r/rust)
* [Stack Overflow](http://stackoverflow.com/questions/tagged/rust)
* [Developer Forum](http://discuss.rust-lang.org/)
* The Rust IRC channels on [irc.mozilla.org](http://irc.mozilla.org/):
* [`#rust`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust) - general discussion
* [`#rust-gamedev`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-gamedev) - game development
Expand Down
4 changes: 2 additions & 2 deletions src/doc/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ int add_one(void)
}
```

**Note: obviously this is very simple and non-idiomatic C++.
You wouldn't write it in practice; it is for illustrative purposes.**
**Note: The above C++ code is deliberately simple and non-idiomatic for the purpose
of demonstration. It is not representative of production-quality C++ code.**

This function allocates an integer on the stack,
and stores it in a variable, `i`.
Expand Down
76 changes: 71 additions & 5 deletions src/doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,12 @@ interpreted:
- `unsafe_no_drop_flag` - on structs, remove the flag that prevents
destructors from being run twice. Destructors might be run multiple times on
the same object with this attribute.
- `phase` - on `extern crate` statements, allows specifying which "phase" of
compilation the crate should be loaded for. Currently, there are two
choices: `link` and `plugin`. `link` is the default. `plugin` will load the
crate at compile-time and use any syntax extensions or lints that the crate
defines. They can both be specified, `#[phase(link, plugin)]` to use a crate
both at runtime and compiletime.

### Conditional compilation

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

* `managed_boxes` - Usage of `@` pointers is gated due to many
* `asm` - The `asm!` macro provides a means for inline assembly. This is often
useful, but the exact syntax for this feature along with its semantics
are likely to change, so this macro usage must be opted into.

* `managed_boxes` - Usage of `@` is gated due to many
planned changes to this feature. In the past, this has meant
"a GC pointer", but the current implementation uses
reference counting and will likely change drastically over
time. Additionally, the `@` syntax will no longer be used to
create GC boxes.

* `asm` - The `asm!` macro provides a means for inline assembly. This is often
useful, but the exact syntax for this feature along with its semantics
are likely to change, so this macro usage must be opted into.

* `non_ascii_idents` - The compiler supports the use of non-ascii identifiers,
but the implementation is a little rough around the
edges, so this can be seen as an experimental feature for
Expand All @@ -2427,6 +2433,66 @@ The currently implemented features of the reference compiler are:
if the system linker is not used then specifying custom flags
doesn't have much meaning.

* `phase` - Usage of the `#[phase]` attribute allows loading compiler plugins
for custom lints or syntax extensions. The implementation is considered
unwholesome and in need of overhaul, and it is not clear what they
will look like moving forward.

* `plugin_registrar` - Indicates that a crate has compiler plugins that it
wants to load. As with `phase`, the implementation is
in need of a overhaul, and it is not clear that plugins
defined using this will continue to work.

* `log_syntax` - Allows use of the `log_syntax` macro attribute, which is a
nasty hack that will certainly be removed.

* `trace_macros` - Allows use of the `trace_macros` macro, which is a nasty
hack that will certainly be removed.

* `concat_idents` - Allows use of the `concat_idents` macro, which is in many
ways insufficient for concatenating identifiers, and may
be removed entirely for something more wholsome.

* `unsafe_destructor` - Allows use of the `#[unsafe_destructor]` attribute,
which is considered wildly unsafe and will be
obsoleted by language improvements.

* `intrinsics` - Allows use of the "rust-intrinsics" ABI. Compiler intrinsics
are inherently unstable and no promise about them is made.

* `lang_items` - Allows use of the `#[lang]` attribute. Like `intrinsics`,
lang items are inherently unstable and no promise about
them is made.

* `simd` - Allows use of the `#[simd]` attribute, which is overly simple and
not the SIMD interface we want to expose in the long term.

* `default_type_params` - Allows use of default type parameters. The future of
this feature is uncertain.

* `quote` - Allows use of the `quote_*!` family of macros, which are
implemented very poorly and will likely change significantly
with a proper implementation.

* `linkage` - Allows use of the `linkage` attribute, which is not portable.

* `struct_inherit` - Allows using struct inheritance, which is barely
implemented and will probably be removed. Don't use this.

* `overloaded_calls` - Allow implementing the `Fn*` family of traits on user
types, allowing overloading the call operator (`()`).
This feature may still undergo changes before being
stabilized.

* `unboxed_closure_sugar` - Allows using `|Foo| -> Bar` as a trait bound
meaning one of the `Fn` traits. Still
experimental.

* `rustc_diagnostic_macros`- A mysterious feature, used in the implementation
of rustc, not meant for mortals.

* `unboxed_closures` - A work in progress feature with many known bugs.

If a feature is promoted to a language feature, then all existing programs will
start to receive compilation warnings about #[feature] directives which enabled
the new feature (because the directive is no longer necessary). However, if
Expand Down
11 changes: 11 additions & 0 deletions src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@
<match>\\\%{common_escape}</match>
</context>

<context id="raw-string" style-ref="string" class="string" class-disabled="no-spell-check">
<start>r(#*)"</start>
<end>"\%{1@start}</end>
<include>
<context ref="def:line-continue"/>
</include>
</context>

<context id="string" style-ref="string" class="string" class-disabled="no-spell-check">
<start>"</start>
<end>"</end>
Expand All @@ -287,6 +295,8 @@
<end>\]</end>
<include>
<context ref="def:in-comment"/>
<context ref="string"/>
<context ref="raw-string"/>
</include>
</context>

Expand All @@ -305,6 +315,7 @@
<context ref="number"/>
<context ref="scope"/>
<context ref="string"/>
<context ref="raw-string"/>
<context ref="char"/>
<context ref="lifetime"/>
<context ref="attribute"/>
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<T: Share + Send> Arc<T> {
}

#[inline]
fn inner<'a>(&'a self) -> &'a ArcInner<T> {
fn inner(&self) -> &ArcInner<T> {
// This unsafety is ok because while this arc is alive we're guaranteed
// that the inner pointer is valid. Furthermore, we know that the
// `ArcInner` structure itself is `Share` because the inner data is
Expand Down Expand Up @@ -142,7 +142,7 @@ impl<T: Share + Send> Clone for Arc<T> {
#[experimental = "Deref is experimental."]
impl<T: Send + Share> Deref<T> for Arc<T> {
#[inline]
fn deref<'a>(&'a self) -> &'a T {
fn deref(&self) -> &T {
&self.inner().data
}
}
Expand All @@ -155,7 +155,7 @@ impl<T: Send + Share + Clone> Arc<T> {
/// data is cloned if the reference count is greater than one.
#[inline]
#[experimental]
pub fn make_unique<'a>(&'a mut self) -> &'a mut T {
pub fn make_unique(&mut self) -> &mut T {
// Note that we hold a strong reference, which also counts as
// a weak reference, so we only clone if there is an
// additional reference of either kind.
Expand Down Expand Up @@ -238,7 +238,7 @@ impl<T: Share + Send> Weak<T> {
}

#[inline]
fn inner<'a>(&'a self) -> &'a ArcInner<T> {
fn inner(&self) -> &ArcInner<T> {
// See comments above for why this is "safe"
unsafe { &*self._ptr }
}
Expand Down
29 changes: 29 additions & 0 deletions src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use core::fmt;
use core::iter;
use core::mem;
use core::ptr;
use std::hash::{Writer, Hash};

use {Collection, Mutable, Deque, MutableSeq};

Expand Down Expand Up @@ -707,10 +708,20 @@ impl<A: fmt::Show> fmt::Show for DList<A> {
}
}

impl<S: Writer, A: Hash<S>> Hash<S> for DList<A> {
fn hash(&self, state: &mut S) {
self.len().hash(state);
for elt in self.iter() {
elt.hash(state);
}
}
}

#[cfg(test)]
mod tests {
use std::prelude::*;
use std::rand;
use std::hash;
use test::Bencher;
use test;

Expand Down Expand Up @@ -1075,6 +1086,24 @@ mod tests {
assert!(n != m);
}

#[test]
fn test_hash() {
let mut x = DList::new();
let mut y = DList::new();

assert!(hash::hash(&x) == hash::hash(&y));

x.push_back(1i);
x.push_back(2);
x.push_back(3);

y.push_front(3i);
y.push_front(2);
y.push_front(1);

assert!(hash::hash(&x) == hash::hash(&y));
}

#[test]
fn test_ord() {
let n: DList<int> = list_from([]);
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ pub trait MutableVectorAllocating<'a, T> {
*
* * src - A mutable vector of `T`
* * start - The index into `src` to start copying from
* * end - The index into `str` to stop copying from
* * end - The index into `src` to stop copying from
*/
fn move_from(self, src: Vec<T>, start: uint, end: uint) -> uint;
}
Expand Down
Loading