Skip to content

Commit 571f371

Browse files
committed
Auto merge of #25403 - Manishearth:rollup, r=Manishearth
- Successful merges: #25354, #25381, #25391, #25395, #25397, #25398, #25401 - Failed merges:
2 parents dd4dad8 + 2df7ae6 commit 571f371

File tree

10 files changed

+229
-42
lines changed

10 files changed

+229
-42
lines changed

src/doc/reference.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -3529,7 +3529,9 @@ The actual implementation for each vtable entry can vary on an object-by-object
35293529
basis.
35303530

35313531
Note that for a trait object to be instantiated, the trait must be
3532-
_object-safe_. Object safety rules are defined in [RFC 255][rfc255].
3532+
_object-safe_. Object safety rules are defined in [RFC 255].
3533+
3534+
[RFC 255]: https://github.com/rust-lang/rfcs/blob/master/text/0255-object-safety.md
35333535

35343536
Given a pointer-typed expression `E` of type `&T` or `Box<T>`, where `T`
35353537
implements trait `R`, casting `E` to the corresponding pointer type `&R` or

src/doc/trpl/iterators.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ loop is just a handy way to write this `loop`/`match`/`break` construct.
4242
`for` loops aren't the only thing that uses iterators, however. Writing your
4343
own iterator involves implementing the `Iterator` trait. While doing that is
4444
outside of the scope of this guide, Rust provides a number of useful iterators
45-
to accomplish various threads. Before we talk about those, we should talk about a
45+
to accomplish various tasks. Before we talk about those, we should talk about a
4646
Rust anti-pattern. And that's using ranges like this.
4747

4848
Yes, we just talked about how ranges are cool. But ranges are also very

src/doc/trpl/the-stack-and-the-heap.md

+23-23
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ This memory is kind of like a giant array: addresses start at zero and go
8080
up to the final number. So here’s a diagram of our first stack frame:
8181

8282
| Address | Name | Value |
83-
+---------+------+-------+
83+
|---------|------|-------|
8484
| 0 | x | 42 |
8585

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

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

9090
| Address | Name | Value |
91-
+---------+------+-------+
91+
|---------|------|-------|
9292
| 2 | z | 100 |
9393
| 1 | y | 5 |
9494
| 0 | x | 42 |
@@ -107,7 +107,7 @@ value being stored.
107107
After `foo()` is over, its frame is deallocated:
108108

109109
| Address | Name | Value |
110-
+---------+------+-------+
110+
|---------|------|-------|
111111
| 0 | x | 42 |
112112

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

144144
| Address | Name | Value |
145-
+---------+------+-------+
145+
|---------|------|-------|
146146
| 0 | x | 42 |
147147

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

150150
| Address | Name | Value |
151-
+---------+------+-------+
151+
|---------|------|-------|
152152
| 3 | c | 1 |
153153
| 2 | b | 100 |
154154
| 1 | a | 5 |
@@ -157,7 +157,7 @@ Next up, `main()` calls `foo()`:
157157
And then `foo()` calls `bar()`:
158158

159159
| Address | Name | Value |
160-
+---------+------+-------+
160+
|---------|------|-------|
161161
| 4 | i | 6 |
162162
| 3 | c | 1 |
163163
| 2 | b | 100 |
@@ -170,7 +170,7 @@ After `bar()` is over, its frame is deallocated, leaving just `foo()` and
170170
`main()`:
171171

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

181181
| Address | Name | Value |
182-
+---------+------+-------+
182+
|---------|------|-------|
183183
| 0 | x | 42 |
184184

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

208208
| Address | Name | Value |
209-
+---------+------+--------+
209+
|---------|------|--------|
210210
| 1 | y | 42 |
211211
| 0 | x | ?????? |
212212

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

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

244244

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

274274
| Address | Name | Value |
275-
+---------+------+--------+
275+
|---------|------|--------|
276276
| 1 | y | 42 |
277277
| 0 | x | ?????? |
278278

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

307307
| Address | Name | Value |
308-
+---------+------+-------+
308+
|---------|------|-------|
309309
| 1 | y | 0 |
310310
| 0 | x | 5 |
311311

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

317317
| Address | Name | Value |
318-
+---------+------+-------+
318+
|---------|------|-------|
319319
| 3 | z | 42 |
320320
| 2 | i | 0 |
321321
| 1 | y | 0 |
@@ -367,7 +367,7 @@ fn main() {
367367
First, we call `main()`:
368368

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

382382
| Address | Name | Value |
383-
+-----------------+------+----------------+
383+
|-----------------|------|----------------|
384384
| 2<sup>30</sup> | | 20 |
385385
| ... | ... | ... |
386386
| 5 | z | 4 |
@@ -397,7 +397,7 @@ since `j` points at `h`.
397397
Next, `foo()` calls `baz()`, passing `z`:
398398

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

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

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

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

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

495495
| Address | Name | Value |
496-
+-----------------+------+----------------+
496+
|-----------------|------|----------------|
497497
| 2<sup>30</sup> | | 20 |
498498
| ... | ... | ... |
499499
| 5 | z | 4 |
@@ -506,7 +506,7 @@ what it points to: (2<sup>30</sup>) - 1.
506506
And after that, `foo()` returns:
507507

508508
| Address | Name | Value |
509-
+-----------------+------+----------------+
509+
|-----------------|------|----------------|
510510
| 2<sup>30</sup> | | 20 |
511511
| ... | ... | ... |
512512
| 2 | j | 0 |

src/librustc_resolve/diagnostics.rs

+84-6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,88 @@ about what constitutes an Item declaration and what does not:
4949
http://doc.rust-lang.org/reference.html#statements
5050
"##,
5151

52+
E0251: r##"
53+
Two items of the same name cannot be imported without rebinding one of the
54+
items under a new local name.
55+
56+
An example of this error:
57+
58+
```
59+
use foo::baz;
60+
use bar::*; // error, do `use foo::baz as quux` instead on the previous line
61+
62+
fn main() {}
63+
64+
mod foo {
65+
pub struct baz;
66+
}
67+
68+
mod bar {
69+
pub mod baz {}
70+
}
71+
```
72+
"##,
73+
74+
E0252: r##"
75+
Two items of the same name cannot be imported without rebinding one of the
76+
items under a new local name.
77+
78+
An example of this error:
79+
80+
```
81+
use foo::baz;
82+
use bar::baz; // error, do `use bar::baz as quux` instead
83+
84+
fn main() {}
85+
86+
mod foo {
87+
pub struct baz;
88+
}
89+
90+
mod bar {
91+
pub mod baz {}
92+
}
93+
```
94+
"##,
95+
96+
E0255: r##"
97+
You can't import a value whose name is the same as another value defined in the
98+
module.
99+
100+
An example of this error:
101+
102+
```
103+
use bar::foo; // error, do `use bar::foo as baz` instead
104+
105+
fn foo() {}
106+
107+
mod bar {
108+
pub fn foo() {}
109+
}
110+
111+
fn main() {}
112+
```
113+
"##,
114+
115+
E0256: r##"
116+
You can't import a type or module when the name of the item being imported is
117+
the same as another type or submodule defined in the module.
118+
119+
An example of this error:
120+
121+
```
122+
use foo::Bar; // error
123+
124+
type Bar = u32;
125+
126+
mod foo {
127+
pub mod Bar { }
128+
}
129+
130+
fn main() {}
131+
```
132+
"##,
133+
52134
E0259: r##"
53135
The name chosen for an external crate conflicts with another external crate that
54136
has been imported into the current module.
@@ -122,14 +204,10 @@ http://doc.rust-lang.org/reference.html#types
122204
register_diagnostics! {
123205
E0157,
124206
E0153,
125-
E0251, // a named type or value has already been imported in this module
126-
E0252, // a named type or value has already been imported in this module
127207
E0253, // not directly importable
128208
E0254, // import conflicts with imported crate in this module
129-
E0255, // import conflicts with value in this module
130-
E0256, // import conflicts with type in this module
131-
E0257, // inherent implementations are only allowed on types defined in the current module
132-
E0258, // import conflicts with existing submodule
209+
E0257,
210+
E0258,
133211
E0364, // item is private
134212
E0365 // item is private
135213
}

src/librustc_typeck/check/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -3082,8 +3082,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
30823082
let mut checked = false;
30833083
opt_place.as_ref().map(|place| match place.node {
30843084
ast::ExprPath(None, ref path) => {
3085-
// FIXME(pcwalton): For now we hardcode the two permissible
3086-
// places: the exchange heap and the managed heap.
3085+
// FIXME(pcwalton): For now we hardcode the only permissible
3086+
// place: the exchange heap.
30873087
let definition = lookup_full_def(tcx, path.span, place.id);
30883088
let def_id = definition.def_id();
30893089
let referent_ty = fcx.expr_ty(&**subexpr);
@@ -3097,7 +3097,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
30973097

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

0 commit comments

Comments
 (0)