Skip to content

Rollup of 7 pull requests #28423

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

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ac6a9eb
Added --explain for E0118.
Sep 5, 2015
2575687
Added commet too
Sep 5, 2015
872f349
E0118, not EO118!
Sep 5, 2015
1f4fe5f
Removed comment. Apparently that shouldnt be there.
Sep 5, 2015
a85bc05
De-registered the duplicate E0118
Sep 5, 2015
5fa6095
I think I found the bug! I was missing a comma.
Sep 6, 2015
1eb7262
This time, I found the error'
Sep 6, 2015
a8a8dfb
Line longer that 80 chars.
Sep 6, 2015
5c5cca5
Small syntax and formatting changes
id4ho Sep 6, 2015
eb53461
Fixed incorrect error explanation
Sep 9, 2015
e570e86
Add a comment that the `Atomic*` are all implicitly `Send`
tbu- Sep 9, 2015
51354e9
Add a compile-time test for the `Send`- and `Sync`-ness of `Atomic*`
tbu- Sep 9, 2015
35209dc
Fix typo
Sep 14, 2015
4543dad
Cheat sheet
Sep 14, 2015
4e25329
Add test for #23036
apasel422 Sep 15, 2015
320880e
Fix option link and anchor links.
Sep 15, 2015
b69a511
Added anchors for the code snippets.
Sep 15, 2015
c1e9f47
Rollup merge of #28263 - christopherdumas:add_help_E0118, r=nikomatsakis
steveklabnik Sep 15, 2015
c9fefb8
Rollup merge of #28276 - jackwilsonv:patch-5, r=Manishearth
steveklabnik Sep 15, 2015
81fc328
Rollup merge of #28314 - tbu-:pr_atomics_are_send, r=brson
steveklabnik Sep 15, 2015
da978ee
Rollup merge of #28401 - christopherdumas:beginners_manuel, r=Gankro
steveklabnik Sep 15, 2015
b164131
Rollup merge of #28417 - apasel422:issue-23036, r=arielb1
steveklabnik Sep 15, 2015
fe8a95e
Rollup merge of #28420 - christopherdumas:intergrate_error_burnstushi…
steveklabnik Sep 15, 2015
d895106
Rollup merge of #28422 - christopherdumas:label_code, r=steveklabnik
steveklabnik Sep 15, 2015
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
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ are:
* Although out of date, [Tom Lee's great blog article][tlgba] is very helpful
* [rustaceans.org][ro] is helpful, but mostly dedicated to IRC
* The [Rust Compiler Testing Docs][rctd]
* For @bors, [this cheetsheat][cheetsheat] is helpful (Remember to replace `@homu` with `@bors` in the commands that you use.)
* For @bors, [this cheat sheet][cheatsheet] is helpful (Remember to replace `@homu` with `@bors` in the commands that you use.)
* **Google**!
* Don't be afraid to ask! The Rust community is friendly and helpful.

Expand All @@ -235,4 +235,4 @@ are:
[tlgba]: http://tomlee.co/2014/04/03/a-more-detailed-tour-of-the-rust-compiler/
[ro]: http://www.rustaceans.org/
[rctd]: ./COMPILER_TESTS.md
[cheetsheat]: http://buildbot.rust-lang.org/homu/
[cheatsheet]: http://buildbot.rust-lang.org/homu/
5 changes: 4 additions & 1 deletion src/doc/trpl/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ thread '<main>' panicked at 'Invalid number: 11', src/bin/panic-simple.rs:5
Here's another example that is slightly less contrived. A program that accepts
an integer as an argument, doubles it and prints it.

<a name="code-unwrap-double"/>
```rust,should_panic

use std::env;

fn main() {
Expand Down Expand Up @@ -120,7 +122,7 @@ It would be better if we just showed the code for unwrapping because it is so
simple, but to do that, we will first need to explore the `Option` and `Result`
types. Both of these types have a method called `unwrap` defined on them.

## The `Option` type
### The `Option` type

The `Option` type is [defined in the standard library][5]:

Expand All @@ -137,6 +139,7 @@ system is an important concept because it will cause the compiler to force the
programmer to handle that absence. Let's take a look at an example that tries
to find a character in a string:

<a name="code-option-ex-string-find"/>
```rust
// Searches `haystack` for the Unicode character `needle`. If one is found, the
// byte offset of the character is returned. Otherwise, `None` is returned.
Expand Down
6 changes: 3 additions & 3 deletions src/doc/trpl/guessing-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ With this definition, anything of type `Foo` can be either a
`Foo::Bar` or a `Foo::Baz`. We use the `::` to indicate the
namespace for a particular `enum` variant.

The [`Ordering`][ordering] enum has three possible variants: `Less`, `Equal`,
The [`Ordering`][ordering] `enum` has three possible variants: `Less`, `Equal`,
and `Greater`. The `match` statement takes a value of a type, and lets you
create an ‘arm’ for each possible value. Since we have three types of
`Ordering`, we have three arms:
Expand Down Expand Up @@ -918,9 +918,9 @@ let guess: u32 = match guess.trim().parse() {

This is how you generally move from ‘crash on error’ to ‘actually handle the
error’, by switching from `ok().expect()` to a `match` statement. The `Result`
returned by `parse()` is an enum just like `Ordering`, but in this case, each
returned by `parse()` is an `enum` just like `Ordering`, but in this case, each
variant has some data associated with it: `Ok` is a success, and `Err` is a
failure. Each contains more information: the successful parsed integer, or an
failure. Each contains more information: the successfully parsed integer, or an
error type. In this case, we `match` on `Ok(num)`, which sets the inner value
of the `Ok` to the name `num`, and then we just return it on the right-hand
side. In the `Err` case, we don’t care what kind of error it is, so we just
Expand Down
3 changes: 3 additions & 0 deletions src/libcore/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ impl Default for AtomicBool {
}
}

// Send is implicitly implemented for AtomicBool.
unsafe impl Sync for AtomicBool {}

/// A signed integer type which can be safely shared between threads.
Expand All @@ -106,6 +107,7 @@ impl Default for AtomicIsize {
}
}

// Send is implicitly implemented for AtomicIsize.
unsafe impl Sync for AtomicIsize {}

/// An unsigned integer type which can be safely shared between threads.
Expand All @@ -120,6 +122,7 @@ impl Default for AtomicUsize {
}
}

// Send is implicitly implemented for AtomicUsize.
unsafe impl Sync for AtomicUsize {}

/// A raw pointer type which can be safely shared between threads.
Expand Down
11 changes: 11 additions & 0 deletions src/libcoretest/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use core::sync::atomic::*;
use core::sync::atomic::Ordering::SeqCst;
use core::marker::{Send, Sync};

#[test]
fn bool_() {
Expand Down Expand Up @@ -82,3 +83,13 @@ fn static_init() {
assert!(S_INT.load(SeqCst) == 0);
assert!(S_UINT.load(SeqCst) == 0);
}

#[test]
fn static_sync_and_send() {
fn ensure_sync_and_send<T:Sync+Send>() { }

ensure_sync_and_send::<AtomicBool>();
ensure_sync_and_send::<AtomicUsize>();
ensure_sync_and_send::<AtomicIsize>();
ensure_sync_and_send::<AtomicPtr>();
}
21 changes: 20 additions & 1 deletion src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,26 @@ For information on the design of the orphan rules, see [RFC 1023].
[RFC 1023]: https://github.com/rust-lang/rfcs/pull/1023
"##,

E0118: r##"
Rust can't find a base type for an implementation you are providing, or the type
cannot have an implementation. For example, only a named type or a trait can
have an implementation:

```
type NineString = [char, ..9] // This isn't a named type (struct, enum or trait)
impl NineString {
// Some code here
}
```

In the other, simpler case, Rust just can't find the type you are providing an
impelementation for:

```
impl SomeTypeThatDoesntExist { }
```
"##,

E0119: r##"
There are conflicting trait implementations for the same type.
Example of erroneous code:
Expand Down Expand Up @@ -3258,7 +3278,6 @@ register_diagnostics! {
E0090,
E0103, // @GuillaumeGomez: I was unable to get this error, try your best!
E0104,
E0118,
// E0123,
// E0127,
// E0129,
Expand Down
18 changes: 18 additions & 0 deletions src/test/run-pass/issue-23036.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2015 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::collections::HashMap;
use std::path::Path;

fn main() {
let mut map = HashMap::new();
map.insert(Path::new("a"), 0);
map.get(Path::new("a"));
}