diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f81bb0bd69dd8..be938e6f35e04 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. @@ -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/ diff --git a/src/doc/trpl/error-handling.md b/src/doc/trpl/error-handling.md index e335d59b1929d..230eb0a85ab0f 100644 --- a/src/doc/trpl/error-handling.md +++ b/src/doc/trpl/error-handling.md @@ -87,7 +87,9 @@ thread '
' 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. + ```rust,should_panic + use std::env; fn main() { @@ -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]: @@ -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: + ```rust // Searches `haystack` for the Unicode character `needle`. If one is found, the // byte offset of the character is returned. Otherwise, `None` is returned. diff --git a/src/doc/trpl/guessing-game.md b/src/doc/trpl/guessing-game.md index 4a35022b03c91..3a4328562f872 100644 --- a/src/doc/trpl/guessing-game.md +++ b/src/doc/trpl/guessing-game.md @@ -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: @@ -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 diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 53952cdc9080b..0f72dcc1281a4 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -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. @@ -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. @@ -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. diff --git a/src/libcoretest/atomic.rs b/src/libcoretest/atomic.rs index b6bb5fddf4a4b..4a71546b0afa5 100644 --- a/src/libcoretest/atomic.rs +++ b/src/libcoretest/atomic.rs @@ -10,6 +10,7 @@ use core::sync::atomic::*; use core::sync::atomic::Ordering::SeqCst; +use core::marker::{Send, Sync}; #[test] fn bool_() { @@ -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() { } + + ensure_sync_and_send::(); + ensure_sync_and_send::(); + ensure_sync_and_send::(); + ensure_sync_and_send::(); +} diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 4bbb33164d23e..78eaedfbd1b72 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -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: @@ -3258,7 +3278,6 @@ register_diagnostics! { E0090, E0103, // @GuillaumeGomez: I was unable to get this error, try your best! E0104, - E0118, // E0123, // E0127, // E0129, diff --git a/src/test/run-pass/issue-23036.rs b/src/test/run-pass/issue-23036.rs new file mode 100644 index 0000000000000..0ed4126e6cd71 --- /dev/null +++ b/src/test/run-pass/issue-23036.rs @@ -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 or the MIT license +// , 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")); +}