Skip to content
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

Rollup of 25 pull requests #35321

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
e805cb6
Add io::Error doc examples
GuillaumeGomez Jul 29, 2016
aad5f6f
Add doc example for io::Stderr
GuillaumeGomez Jul 29, 2016
451683f
Add doc example for Stdin
GuillaumeGomez Jul 29, 2016
aeb3af8
Add doc example for Stdout
GuillaumeGomez Jul 29, 2016
76026d1
Fix grammar verification
dns2utf8 Jul 23, 2016
2bed205
Add io::Take doc example
GuillaumeGomez Jul 30, 2016
fda473f
Add urls in std::io types
GuillaumeGomez Jul 30, 2016
b77b9b7
Provide more explicit example of wildcard version in guessing game doc.
jongiddy Jul 31, 2016
65e3ff4
add extended information for E0529, slice pattern expects array or slice
zackmdavis Jun 17, 2016
7093d1d
add extended info for E0527, slice pattern element count expectations
zackmdavis Jun 17, 2016
e960021
extended info for E0528, expected at least this-and-such many elements
zackmdavis Jun 17, 2016
cede35e
Merge guidelines from RFC 1567 into UX Guidelines.
Havvy Jul 17, 2016
157f7c1
Add Derive not possible question to Copy
Havvy Jul 26, 2016
57e3b9e
Indicate where the `std::net::Incoming` struct is created.
frewsxcv Aug 2, 2016
f2d8db1
Link to relevant method/struct for `std::net::Shutdown` docs.
frewsxcv Aug 2, 2016
3081dd8
Add doc example for `std::ffi::NulError::nul_position`.
frewsxcv Aug 2, 2016
727d929
Add doc examples for `range::RangeArgument::{start,end}`.
frewsxcv Jul 26, 2016
1fa9b8d
Add doc example for Vec
GuillaumeGomez Aug 2, 2016
d90c166
Update the-stack-and-the-heap.md
mLuby Aug 2, 2016
3e46c9d
Add doc examples for FileType struct
GuillaumeGomez Jul 27, 2016
d603892
Add span method for hir::Generics struct
GuillaumeGomez Aug 3, 2016
9b690c9
Update E0132 to new format
GuillaumeGomez Aug 3, 2016
4fc6f5a
Add an example to `std::thread::park_timeout`
dns2utf8 Aug 3, 2016
20721a4
Add link to replacement function
dns2utf8 Aug 3, 2016
1607d5b
Add note test for E0132
GuillaumeGomez Aug 3, 2016
c89e278
Update error message for E0109
circuitfox Aug 3, 2016
33a4806
Clean up `std::raw` docs
apasel422 Aug 4, 2016
6131815
Fixes for issues #35215 and #35216
leikahing Aug 4, 2016
0e75684
Tidying up some of the line spacing / code formatting for NOTE/ERROR …
leikahing Aug 4, 2016
ded0d51
Removing trailing whitespace leftover from last re-formatting commit
leikahing Aug 4, 2016
7fc0b2f
Update E0079 to new format
Aug 4, 2016
ee8d6b0
Update error message for E0172
Aug 4, 2016
08ff7a8
Update error message E0178
Aug 4, 2016
eeda69f
Set label for unreachable pattern
saml Aug 4, 2016
034e659
Changing label to "this is an..."
saml Aug 4, 2016
7c58b26
Updated E0071 to new format.
razielgn Aug 3, 2016
5430e55
E0110 update error format
circuitfox Aug 4, 2016
4492838
Update error message E0120
Aug 4, 2016
a0bdb17
Update E0124 to the new error format
sciyoshi Aug 4, 2016
f52bf09
Rollup merge of #34319 - zackmdavis:explain_slice_pattern_errors, r=G…
steveklabnik Aug 4, 2016
30e2581
Rollup merge of #34894 - Havvy:patch-2, r=steveklabnik
steveklabnik Aug 4, 2016
9d57bd0
Rollup merge of #34994 - dns2utf8:doc_grammar, r=steveklabnik
steveklabnik Aug 4, 2016
7f559d4
Rollup merge of #35041 - frewsxcv:range-rangeargument, r=GuillaumeGomez
steveklabnik Aug 4, 2016
f301a92
Rollup merge of #35042 - Havvy:copy_error_doc, r=GuillaumeGomez
steveklabnik Aug 4, 2016
3f87e78
Rollup merge of #35076 - GuillaumeGomez:file_type_docs, r=steveklabnik
steveklabnik Aug 4, 2016
d6af812
Rollup merge of #35109 - GuillaumeGomez:io_docs, r=steveklabnik
steveklabnik Aug 4, 2016
ccf4fbf
Rollup merge of #35137 - jongiddy:explicit-wildcard, r=steveklabnik
steveklabnik Aug 4, 2016
707a291
Rollup merge of #35175 - frewsxcv:tcp, r=GuillaumeGomez
steveklabnik Aug 4, 2016
9ddde2c
Rollup merge of #35181 - GuillaumeGomez:vec_doc, r=steveklabnik
steveklabnik Aug 4, 2016
01562a1
Rollup merge of #35182 - frewsxcv:nulerror, r=steveklabnik
steveklabnik Aug 4, 2016
46f4682
Rollup merge of #35189 - mLuby:patch-1, r=steveklabnik
steveklabnik Aug 4, 2016
540451f
Rollup merge of #35239 - dns2utf8:doc_park_timeout, r=steveklabnik
steveklabnik Aug 4, 2016
1a0a919
Rollup merge of #35264 - GuillaumeGomez:E0132_update, r=jonathandturner
steveklabnik Aug 4, 2016
36a1560
Rollup merge of #35266 - circuitfox:35247-E0109-update-error-format, …
steveklabnik Aug 4, 2016
361d9b4
Rollup merge of #35281 - apasel422:repr, r=steveklabnik
steveklabnik Aug 4, 2016
e70b1ba
Rollup merge of #35285 - razielgn:updated-e0071-to-new-format, r=jona…
steveklabnik Aug 4, 2016
7188c3e
Rollup merge of #35289 - birryree:E0060_E0061_format_update, r=jonath…
steveklabnik Aug 4, 2016
fc24283
Rollup merge of #35291 - yossi-k:master, r=jonathandturner
steveklabnik Aug 4, 2016
423aa39
Rollup merge of #35294 - Roybie:35272-E0172-update-error-format, r=jo…
steveklabnik Aug 4, 2016
bf4d779
Rollup merge of #35296 - medzin:master, r=jonathandturner
steveklabnik Aug 4, 2016
ef18466
Rollup merge of #35297 - saml:e0001-label, r=jonathandturner
steveklabnik Aug 4, 2016
3d9003d
Rollup merge of #35298 - Keats:err-120, r=jonathandturner
steveklabnik Aug 4, 2016
59a2293
Rollup merge of #35299 - circuitfox:E0110-update-error-format, r=jona…
steveklabnik Aug 4, 2016
60c1910
Rollup merge of #35318 - sciyoshi:update-e0124, r=jonathandturner
steveklabnik Aug 4, 2016
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
6 changes: 5 additions & 1 deletion mk/clean.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ clean-all: clean clean-llvm

clean-llvm: $(CLEAN_LLVM_RULES)

clean: clean-misc $(CLEAN_STAGE_RULES)
clean: clean-misc clean-grammar $(CLEAN_STAGE_RULES)

clean-misc:
@$(call E, cleaning)
Expand All @@ -47,6 +47,10 @@ clean-misc:
$(Q)rm -Rf dist/*
$(Q)rm -Rf doc

clean-grammar:
@$(call E, cleaning grammar verification)
$(Q)cd src/grammar && rm -Rf verify *.class *.java *.tokens
$(Q)rm -Rf grammar
define CLEAN_GENERIC

clean-generic-$(2)-$(1):
Expand Down
2 changes: 1 addition & 1 deletion mk/grammar.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $(BG):

$(BG)RustLexer.class: $(BG) $(SG)RustLexer.g4
$(Q)$(CFG_ANTLR4) -o $(BG) $(SG)RustLexer.g4
$(Q)$(CFG_JAVAC) -d $(BG) $(BG)RustLexer.java
$(Q)$(CFG_JAVAC) -d $(BG) -classpath /usr/share/java/antlr-complete.jar $(BG)RustLexer.java

check-build-lexer-verifier: $(BG)verify

Expand Down
3 changes: 2 additions & 1 deletion mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ cleantestlibs:

.PHONY: tidy
tidy: $(HBIN0_H_$(CFG_BUILD))/tidy$(X_$(CFG_BUILD)) \
$(SNAPSHOT_RUSTC_POST_CLEANUP)
$(SNAPSHOT_RUSTC_POST_CLEANUP) \
check-build-lexer-verifier
$(TARGET_RPATH_VAR0_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $< $(S)src

$(HBIN0_H_$(CFG_BUILD))/tidy$(X_$(CFG_BUILD)): \
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book/guessing-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ numbers. A bare number like above is actually shorthand for `^0.3.0`,
meaning "anything compatible with 0.3.0".
If we wanted to use only `0.3.0` exactly, we could say `rand="=0.3.0"`
(note the two equal signs).
And if we wanted to use the latest version we could use `*`.
And if we wanted to use the latest version we could use `rand="*"`.
We could also use a range of versions.
[Cargo’s documentation][cargodoc] contains more details.

Expand Down
2 changes: 2 additions & 0 deletions src/doc/book/the-stack-and-the-heap.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ The stack is very fast, and is where memory is allocated in Rust by default.
But the allocation is local to a function call, and is limited in size. The
heap, on the other hand, is slower, and is explicitly allocated by your
program. But it’s effectively unlimited in size, and is globally accessible.
Note this meaning of heap, which allocates arbitrary-sized blocks of memory in arbitrary
order, is quite different from the heap data structure.

# The Stack

Expand Down
120 changes: 120 additions & 0 deletions src/doc/rustc-ux-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ Error explanations are long form descriptions of error messages provided with
the compiler. They are accessible via the `--explain` flag. Each explanation
comes with an example of how to trigger it and advice on how to fix it.

Long error codes explanations are a very important part of Rust. Having an
explanation of what failed helps to understand the error and is appreciated by
Rust developers of all skill levels.

* All of them are accessible [online](http://doc.rust-lang.org/error-index.html),
which are auto-generated from rustc source code in different places:
[librustc](https://github.com/rust-lang/rust/blob/master/src/librustc/diagnostics.rs),
Expand All @@ -74,6 +78,122 @@ code with backticks.
* When talking about the compiler, call it `the compiler`, not `Rust` or
`rustc`.

Note: The following sections are mostly a repaste of [RFC 1567](https://github.com/rust-lang/rfcs/blob/master/text/1567-long-error-codes-explanation-normalization.md).

### Template

Long error descriptions should match the following template. The next few
sections of this document describe what each section is about.

E000: r##"
[Error description]

Example of erroneous code:

```compile_fail
[Minimal example]
```

[Error explanation]

```
[How to fix the problem]
```

[Optional Additional information]

"##,

### Error description

Provide a more detailed error message. For example:

```ignore
extern crate a;
extern crate b as a;
```

We get the `E0259` error code which says "an extern crate named `a` has already been imported in this module" and the error explanation says: "The name chosen for an external crate conflicts with another external crate that has been imported into the current module.".

### Minimal example

Provide an erroneous code example which directly follows `Error description`. The erroneous example will be helpful for the `How to fix the problem`. Making it as simple as possible is really important in order to help readers to understand what the error is about. A comment should be added with the error on the same line where the errors occur. Example:

```ignore
type X = u32<i32>; // error: type parameters are not allowed on this type
```

If the error comments is too long to fit 80 columns, split it up like this, so the next line start at the same column of the previous line:

```ignore
type X = u32<'static>; // error: lifetime parameters are not allowed on
// this type
```

And if the sample code is too long to write an effective comment, place your comment on the line before the sample code:

```ignore
// error: lifetime parameters are not allowed on this type
fn super_long_function_name_and_thats_problematic() {}
```

Of course, it the comment is too long, the split rules still applies.

### Error explanation

Provide a full explanation about "__why__ you get the error" and some leads on __how__ to fix it. If needed, use additional code snippets to improve your explanations.

### How to fix the problem

This part will show how to fix the error that we saw previously in the `Minimal example`, with comments explaining how it was fixed.

### Additional information

Some details which might be useful for the users, let's take back `E0109` example. At the end, the supplementary explanation is the following: "Note that type parameters for enum-variant constructors go after the variant, not after the enum (`Option::None::<u32>`, not `Option::<u32>::None`).". It provides more information, not directly linked to the error, but it might help user to avoid doing another error.

### Full Example

E0409: r##"
An "or" pattern was used where the variable bindings are not consistently bound
across patterns.

Example of erroneous code:

```compile_fail,E0409
let x = (0, 2);
match x {
(0, ref y) | (y, 0) ={ /* use y */} // error: variable `y` is bound with
// different mode in pattern #2
// than in pattern #1
_ =()
}
```

Here, `y` is bound by-value in one case and by-reference in the other.

To fix this error, just use the same mode in both cases.
Generally using `ref` or `ref mut` where not already used will fix this:

```rust
let x = (0, 2);
match x {
(0, ref y) | (ref y, 0) ={ /* use y */}
_ =()
}
```

Alternatively, split the pattern:

```rust
let x = (0, 2);
match x {
(y, 0) ={ /* use y */ }
(0, ref y) ={ /* use y */}
_ =()
}
```
"##,

## Compiler Flags

* Flags should be orthogonal to each other. For example, if we'd have a
Expand Down
4 changes: 2 additions & 2 deletions src/grammar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Uses [antlr4](http://www.antlr.org/) and a custom Rust tool to compare
ASTs/token streams generated. You can use the `check-lexer` make target to
run all of the available tests.

To use manually:
To use manually, assuming antlr4 ist installed at `/usr/share/java/antlr-complete.jar`:

```
antlr4 RustLexer.g4
javac *.java
javac -classpath /usr/share/java/antlr-complete.jar *.java
rustc -O verify.rs
for file in ../*/**.rs; do
echo $file;
Expand Down
6 changes: 3 additions & 3 deletions src/grammar/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ skipped=0
check() {
grep --silent "// ignore-lexer-test" "$1";

# if it's *not* found...
# if it is *not* found...
if [ $? -eq 1 ]; then
cd $2 # This `cd` is so java will pick up RustLexer.class. I couldn't
cd $2 # This `cd` is so java will pick up RustLexer.class. I could not
# figure out how to wrangle the CLASSPATH, just adding build/grammar
# didn't seem to have any effect.
# did not seem to have any effect.
if $3 RustLexer tokens -tokens < $1 | $4 $1 $5; then
echo "pass: $1"
passed=`expr $passed + 1`
Expand Down
6 changes: 4 additions & 2 deletions src/grammar/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#![feature(plugin, rustc_private)]

extern crate syntax;
extern crate syntax_pos;
extern crate rustc;

#[macro_use]
Expand Down Expand Up @@ -290,9 +291,10 @@ fn main() {

let options = config::basic_options();
let session = session::build_session(options, &DepGraph::new(false), None,
syntax::diagnostics::registry::Registry::new(&[]),
syntax::errors::registry::Registry::new(&[]),
Rc::new(DummyCrateStore));
let filemap = session.parse_sess.codemap().new_filemap(String::from("<n/a>"), code);
let filemap = session.parse_sess.codemap()
.new_filemap("<n/a>".to_string(), None, code);
let mut lexer = lexer::StringReader::new(session.diagnostic(), filemap);
let cm = session.codemap();

Expand Down
32 changes: 32 additions & 0 deletions src/libcollections/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,45 @@ pub trait RangeArgument<T> {
/// Start index (inclusive)
///
/// Return start value if present, else `None`.
///
/// # Examples
///
/// ```
/// #![feature(collections)]
/// #![feature(collections_range)]
///
/// extern crate collections;
///
/// # fn main() {
/// use collections::range::RangeArgument;
///
/// assert_eq!((..10).start(), None);
/// assert_eq!((3..10).start(), Some(&3));
/// # }
/// ```
fn start(&self) -> Option<&T> {
None
}

/// End index (exclusive)
///
/// Return end value if present, else `None`.
///
/// # Examples
///
/// ```
/// #![feature(collections)]
/// #![feature(collections_range)]
///
/// extern crate collections;
///
/// # fn main() {
/// use collections::range::RangeArgument;
///
/// assert_eq!((3..).end(), None);
/// assert_eq!((3..10).end(), Some(&10));
/// # }
/// ```
fn end(&self) -> Option<&T> {
None
}
Expand Down
19 changes: 19 additions & 0 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,25 @@ impl<T> Vec<T> {
/// Note that this will drop any excess capacity. Calling this and
/// converting back to a vector with `into_vec()` is equivalent to calling
/// `shrink_to_fit()`.
///
/// # Examples
///
/// ```
/// let v = vec![1, 2, 3];
///
/// let slice = v.into_boxed_slice();
/// ```
///
/// Any excess capacity is removed:
///
/// ```
/// let mut vec = Vec::with_capacity(10);
/// vec.extend([1, 2, 3].iter().cloned());
///
/// assert_eq!(vec.capacity(), 10);
/// let slice = vec.into_boxed_slice();
/// assert_eq!(slice.into_vec().capacity(), 3);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn into_boxed_slice(mut self) -> Box<[T]> {
unsafe {
Expand Down
6 changes: 6 additions & 0 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ pub trait Unsize<T: ?Sized> {
/// Generalizing the latter case, any type implementing `Drop` can't be `Copy`, because it's
/// managing some resource besides its own `size_of::<T>()` bytes.
///
/// ## What if I derive `Copy` on a type that can't?
///
/// If you try to derive `Copy` on a struct or enum, you will get a compile-time error.
/// Specifically, with structs you'll get [E0204](https://doc.rust-lang.org/error-index.html#E0204)
/// and with enums you'll get [E0205](https://doc.rust-lang.org/error-index.html#E0205).
///
/// ## When should my type be `Copy`?
///
/// Generally speaking, if your type _can_ implement `Copy`, it should. There's one important thing
Expand Down
16 changes: 8 additions & 8 deletions src/libcore/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
/// only designed to be used by unsafe code that needs to manipulate
/// the low-level details.
///
/// There is no `Repr` implementation for `TraitObject` because there
/// is no way to refer to all trait objects generically, so the only
/// There is no way to refer to all trait objects generically, so the only
/// way to create values of this type is with functions like
/// `std::mem::transmute`. Similarly, the only way to create a true
/// [`std::mem::transmute`][transmute]. Similarly, the only way to create a true
/// trait object from a `TraitObject` value is with `transmute`.
///
/// [transmute]: ../mem/fn.transmute.html
///
/// Synthesizing a trait object with mismatched types—one where the
/// vtable does not correspond to the type of the value to which the
/// data pointer points—is highly likely to lead to undefined
Expand All @@ -50,13 +51,13 @@
/// ```
/// #![feature(raw)]
///
/// use std::mem;
/// use std::raw;
/// use std::{mem, raw};
///
/// // an example trait
/// trait Foo {
/// fn bar(&self) -> i32;
/// }
///
/// impl Foo for i32 {
/// fn bar(&self) -> i32 {
/// *self + 1
Expand All @@ -74,19 +75,18 @@
/// // the data pointer is the address of `value`
/// assert_eq!(raw_object.data as *const i32, &value as *const _);
///
///
/// let other_value: i32 = 456;
///
/// // construct a new object, pointing to a different `i32`, being
/// // careful to use the `i32` vtable from `object`
/// let synthesized: &Foo = unsafe {
/// mem::transmute(raw::TraitObject {
/// data: &other_value as *const _ as *mut (),
/// vtable: raw_object.vtable
/// vtable: raw_object.vtable,
/// })
/// };
///
/// // it should work just like we constructed a trait object out of
/// // it should work just as if we had constructed a trait object out of
/// // `other_value` directly
/// assert_eq!(synthesized.bar(), 457);
/// ```
Expand Down
Loading