Skip to content

Rollup of 7 pull requests #25403

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 16 commits into from
May 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3529,7 +3529,9 @@ The actual implementation for each vtable entry can vary on an object-by-object
basis.

Note that for a trait object to be instantiated, the trait must be
_object-safe_. Object safety rules are defined in [RFC 255][rfc255].
_object-safe_. Object safety rules are defined in [RFC 255].

[RFC 255]: https://github.com/rust-lang/rfcs/blob/master/text/0255-object-safety.md

Given a pointer-typed expression `E` of type `&T` or `Box<T>`, where `T`
implements trait `R`, casting `E` to the corresponding pointer type `&R` or
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/iterators.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ loop is just a handy way to write this `loop`/`match`/`break` construct.
`for` loops aren't the only thing that uses iterators, however. Writing your
own iterator involves implementing the `Iterator` trait. While doing that is
outside of the scope of this guide, Rust provides a number of useful iterators
to accomplish various threads. Before we talk about those, we should talk about a
to accomplish various tasks. Before we talk about those, we should talk about a
Rust anti-pattern. And that's using ranges like this.

Yes, we just talked about how ranges are cool. But ranges are also very
Expand Down
46 changes: 23 additions & 23 deletions src/doc/trpl/the-stack-and-the-heap.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ This memory is kind of like a giant array: addresses start at zero and go
up to the final number. So here’s a diagram of our first stack frame:

| Address | Name | Value |
+---------+------+-------+
|---------|------|-------|
| 0 | x | 42 |

We’ve got `x` located at address `0`, with the value `42`.

When `foo()` is called, a new stack frame is allocated:

| Address | Name | Value |
+---------+------+-------+
|---------|------|-------|
| 2 | z | 100 |
| 1 | y | 5 |
| 0 | x | 42 |
Expand All @@ -107,7 +107,7 @@ value being stored.
After `foo()` is over, its frame is deallocated:

| Address | Name | Value |
+---------+------+-------+
|---------|------|-------|
| 0 | x | 42 |

And then, after `main()`, even this last value goes away. Easy!
Expand Down Expand Up @@ -142,13 +142,13 @@ fn main() {
Okay, first, we call `main()`:

| Address | Name | Value |
+---------+------+-------+
|---------|------|-------|
| 0 | x | 42 |

Next up, `main()` calls `foo()`:

| Address | Name | Value |
+---------+------+-------+
|---------|------|-------|
| 3 | c | 1 |
| 2 | b | 100 |
| 1 | a | 5 |
Expand All @@ -157,7 +157,7 @@ Next up, `main()` calls `foo()`:
And then `foo()` calls `bar()`:

| Address | Name | Value |
+---------+------+-------+
|---------|------|-------|
| 4 | i | 6 |
| 3 | c | 1 |
| 2 | b | 100 |
Expand All @@ -170,7 +170,7 @@ After `bar()` is over, its frame is deallocated, leaving just `foo()` and
`main()`:

| Address | Name | Value |
+---------+------+-------+
|---------|------|-------|
| 3 | c | 1 |
| 2 | b | 100 |
| 1 | a | 5 |
Expand All @@ -179,7 +179,7 @@ After `bar()` is over, its frame is deallocated, leaving just `foo()` and
And then `foo()` ends, leaving just `main()`

| Address | Name | Value |
+---------+------+-------+
|---------|------|-------|
| 0 | x | 42 |

And then we’re done. Getting the hang of it? It’s like piling up dishes: you
Expand All @@ -206,7 +206,7 @@ fn main() {
Here’s what happens in memory when `main()` is called:

| Address | Name | Value |
+---------+------+--------+
|---------|------|--------|
| 1 | y | 42 |
| 0 | x | ?????? |

Expand All @@ -218,7 +218,7 @@ it allocates some memory for the heap, and puts `5` there. The memory now looks
like this:

| Address | Name | Value |
+-----------------+------+----------------+
|-----------------|------|----------------|
| 2<sup>30</sup> | | 5 |
| ... | ... | ... |
| 1 | y | 42 |
Expand All @@ -243,7 +243,7 @@ layout of a program which has been running for a while now:


| Address | Name | Value |
+----------------------+------+----------------------+
|----------------------|------|----------------------|
| 2<sup>30</sup> | | 5 |
| (2<sup>30</sup>) - 1 | | |
| (2<sup>30</sup>) - 2 | | |
Expand Down Expand Up @@ -272,7 +272,7 @@ when it was created. Great! So when `x` goes away, it first frees the memory
allocated on the heap:

| Address | Name | Value |
+---------+------+--------+
|---------|------|--------|
| 1 | y | 42 |
| 0 | x | ?????? |

Expand Down Expand Up @@ -305,7 +305,7 @@ fn main() {
When we enter `main()`, memory looks like this:

| Address | Name | Value |
+---------+------+-------+
|---------|------|-------|
| 1 | y | 0 |
| 0 | x | 5 |

Expand All @@ -315,7 +315,7 @@ memory location that `x` lives at, which in this case is `0`.
What about when we call `foo()`, passing `y` as an argument?

| Address | Name | Value |
+---------+------+-------+
|---------|------|-------|
| 3 | z | 42 |
| 2 | i | 0 |
| 1 | y | 0 |
Expand Down Expand Up @@ -367,7 +367,7 @@ fn main() {
First, we call `main()`:

| Address | Name | Value |
+-----------------+------+----------------+
|-----------------|------|----------------|
| 2<sup>30</sup> | | 20 |
| ... | ... | ... |
| 2 | j | 0 |
Expand All @@ -380,7 +380,7 @@ value pointing there.
Next, at the end of `main()`, `foo()` gets called:

| Address | Name | Value |
+-----------------+------+----------------+
|-----------------|------|----------------|
| 2<sup>30</sup> | | 20 |
| ... | ... | ... |
| 5 | z | 4 |
Expand All @@ -397,7 +397,7 @@ since `j` points at `h`.
Next, `foo()` calls `baz()`, passing `z`:

| Address | Name | Value |
+-----------------+------+----------------+
|-----------------|------|----------------|
| 2<sup>30</sup> | | 20 |
| ... | ... | ... |
| 7 | g | 100 |
Expand All @@ -413,7 +413,7 @@ We’ve allocated memory for `f` and `g`. `baz()` is very short, so when it’s
over, we get rid of its stack frame:

| Address | Name | Value |
+-----------------+------+----------------+
|-----------------|------|----------------|
| 2<sup>30</sup> | | 20 |
| ... | ... | ... |
| 5 | z | 4 |
Expand All @@ -426,7 +426,7 @@ over, we get rid of its stack frame:
Next, `foo()` calls `bar()` with `x` and `z`:

| Address | Name | Value |
+----------------------+------+----------------------+
|----------------------|------|----------------------|
| 2<sup>30</sup> | | 20 |
| (2<sup>30</sup>) - 1 | | 5 |
| ... | ... | ... |
Expand All @@ -449,7 +449,7 @@ case, we set up the variables as usual.
At the end of `bar()`, it calls `baz()`:

| Address | Name | Value |
+----------------------+------+----------------------+
|----------------------|------|----------------------|
| 2<sup>30</sup> | | 20 |
| (2<sup>30</sup>) - 1 | | 5 |
| ... | ... | ... |
Expand All @@ -473,7 +473,7 @@ far.
After `baz()` is over, we get rid of `f` and `g`:

| Address | Name | Value |
+----------------------+------+----------------------+
|----------------------|------|----------------------|
| 2<sup>30</sup> | | 20 |
| (2<sup>30</sup>) - 1 | | 5 |
| ... | ... | ... |
Expand All @@ -493,7 +493,7 @@ Next, we return from `bar()`. `d` in this case is a `Box<T>`, so it also frees
what it points to: (2<sup>30</sup>) - 1.

| Address | Name | Value |
+-----------------+------+----------------+
|-----------------|------|----------------|
| 2<sup>30</sup> | | 20 |
| ... | ... | ... |
| 5 | z | 4 |
Expand All @@ -506,7 +506,7 @@ what it points to: (2<sup>30</sup>) - 1.
And after that, `foo()` returns:

| Address | Name | Value |
+-----------------+------+----------------+
|-----------------|------|----------------|
| 2<sup>30</sup> | | 20 |
| ... | ... | ... |
| 2 | j | 0 |
Expand Down
90 changes: 84 additions & 6 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,88 @@ about what constitutes an Item declaration and what does not:
http://doc.rust-lang.org/reference.html#statements
"##,

E0251: r##"
Two items of the same name cannot be imported without rebinding one of the
items under a new local name.

An example of this error:

```
use foo::baz;
use bar::*; // error, do `use foo::baz as quux` instead on the previous line

fn main() {}

mod foo {
pub struct baz;
}

mod bar {
pub mod baz {}
}
```
"##,

E0252: r##"
Two items of the same name cannot be imported without rebinding one of the
items under a new local name.

An example of this error:

```
use foo::baz;
use bar::baz; // error, do `use bar::baz as quux` instead

fn main() {}

mod foo {
pub struct baz;
}

mod bar {
pub mod baz {}
}
```
"##,

E0255: r##"
You can't import a value whose name is the same as another value defined in the
module.

An example of this error:

```
use bar::foo; // error, do `use bar::foo as baz` instead

fn foo() {}

mod bar {
pub fn foo() {}
}

fn main() {}
```
"##,

E0256: r##"
You can't import a type or module when the name of the item being imported is
the same as another type or submodule defined in the module.

An example of this error:

```
use foo::Bar; // error

type Bar = u32;

mod foo {
pub mod Bar { }
}

fn main() {}
```
"##,

E0259: r##"
The name chosen for an external crate conflicts with another external crate that
has been imported into the current module.
Expand Down Expand Up @@ -122,14 +204,10 @@ http://doc.rust-lang.org/reference.html#types
register_diagnostics! {
E0157,
E0153,
E0251, // a named type or value has already been imported in this module
E0252, // a named type or value has already been imported in this module
E0253, // not directly importable
E0254, // import conflicts with imported crate in this module
E0255, // import conflicts with value in this module
E0256, // import conflicts with type in this module
E0257, // inherent implementations are only allowed on types defined in the current module
E0258, // import conflicts with existing submodule
E0257,
E0258,
E0364, // item is private
E0365 // item is private
}
9 changes: 5 additions & 4 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3082,8 +3082,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
let mut checked = false;
opt_place.as_ref().map(|place| match place.node {
ast::ExprPath(None, ref path) => {
// FIXME(pcwalton): For now we hardcode the two permissible
// places: the exchange heap and the managed heap.
// FIXME(pcwalton): For now we hardcode the only permissible
// place: the exchange heap.
let definition = lookup_full_def(tcx, path.span, place.id);
let def_id = definition.def_id();
let referent_ty = fcx.expr_ty(&**subexpr);
Expand All @@ -3097,7 +3097,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,

if !checked {
span_err!(tcx.sess, expr.span, E0066,
"only the managed heap and exchange heap are currently supported");
"only the exchange heap is currently supported");
fcx.write_ty(id, tcx.types.err);
}
}
Expand Down Expand Up @@ -3317,7 +3317,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
if let Err(_) = fcx.mk_eqty(false, infer::Misc(expr.span),
result_type, ty::mk_nil(fcx.tcx())) {
span_err!(tcx.sess, expr.span, E0069,
"`return;` in function returning non-nil");
"`return;` in a function whose return type is \
not `()`");
},
Some(ref e) => {
check_expr_coercable_to_type(fcx, &**e, result_type);
Expand Down
Loading