Skip to content

Commit c1035b3

Browse files
committed
Auto merge of #30619 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #30253, #30390, #30405, #30549, #30603, #30610 - Failed merges:
2 parents 9007d63 + 5a02d22 commit c1035b3

File tree

6 files changed

+49
-14
lines changed

6 files changed

+49
-14
lines changed

src/doc/book/macros.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,7 @@ to define a single macro that works both inside and outside our library. The
611611
function name will expand to either `::increment` or `::mylib::increment`.
612612

613613
To keep this system simple and correct, `#[macro_use] extern crate ...` may
614-
only appear at the root of your crate, not inside `mod`. This ensures that
615-
`$crate` is a single identifier.
614+
only appear at the root of your crate, not inside `mod`.
616615

617616
# The deep end
618617

src/libcore/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl<'a> Display for Arguments<'a> {
356356
/// `Debug` implementations using either `derive` or the debug builder API
357357
/// on `Formatter` support pretty printing using the alternate flag: `{:#?}`.
358358
///
359-
/// [debug_struct]: ../std/fmt/struct.Formatter.html#method.debug_struct
359+
/// [debug_struct]: ../../std/fmt/struct.Formatter.html#method.debug_struct
360360
///
361361
/// Pretty printing with `#?`:
362362
///

src/libcore/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ pub trait Iterator {
604604
/// iterators, returning a tuple where the first element comes from the
605605
/// first iterator, and the second element comes from the second iterator.
606606
///
607-
/// In other words, it zips two iterators together, into a single one. 🤐
607+
/// In other words, it zips two iterators together, into a single one.
608608
///
609609
/// When either iterator returns `None`, all further calls to `next()`
610610
/// will return `None`.

src/libcore/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ macro_rules! debug_assert {
135135
($($arg:tt)*) => (if cfg!(debug_assertions) { assert!($($arg)*); })
136136
}
137137

138-
/// Asserts that two expressions are equal to each other, testing equality in
139-
/// both directions.
138+
/// Asserts that two expressions are equal to each other.
140139
///
141-
/// On panic, this macro will print the values of the expressions.
140+
/// On panic, this macro will print the values of the expressions with their
141+
/// debug representations.
142142
///
143143
/// Unlike `assert_eq!`, `debug_assert_eq!` statements are only enabled in non
144144
/// optimized builds by default. An optimized build will omit all

src/librustc_metadata/loader.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,8 @@ impl<'a> Context<'a> {
664664
}
665665
sess.err(&format!("extern location for {} is of an unknown type: {}",
666666
self.crate_name, loc.display()));
667+
sess.help(&format!("file name should be lib*.rlib or {}*.{}",
668+
dylibname.0, dylibname.1));
667669
false
668670
});
669671

src/librustc_resolve/diagnostics.rs

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ https://doc.rust-lang.org/reference.html#use-declarations
274274
"##,
275275

276276
E0401: r##"
277-
Inner functions do not inherit type parameters from the functions they are
277+
Inner items do not inherit type parameters from the functions they are
278278
embedded in. For example, this will not compile:
279279
280280
```
@@ -286,12 +286,32 @@ fn foo<T>(x: T) {
286286
}
287287
```
288288
289-
Functions inside functions are basically just like top-level functions, except
290-
that they can only be called from the function they are in.
289+
nor will this:
290+
291+
```
292+
fn foo<T>(x: T) {
293+
type MaybeT = Option<T>;
294+
// ...
295+
}
296+
```
297+
298+
or this:
299+
300+
```
301+
fn foo<T>(x: T) {
302+
struct Foo {
303+
x: T,
304+
}
305+
// ...
306+
}
307+
```
308+
309+
Items inside functions are basically just like top-level items, except
310+
that they can only be used from the function they are in.
291311
292312
There are a couple of solutions for this.
293313
294-
You can use a closure:
314+
If the item is a function, you may use a closure:
295315
296316
```
297317
fn foo<T>(x: T) {
@@ -302,7 +322,7 @@ fn foo<T>(x: T) {
302322
}
303323
```
304324
305-
or copy over the parameters:
325+
For a generic item, you can copy over the parameters:
306326
307327
```
308328
fn foo<T>(x: T) {
@@ -313,6 +333,12 @@ fn foo<T>(x: T) {
313333
}
314334
```
315335
336+
```
337+
fn foo<T>(x: T) {
338+
type MaybeT<T> = Option<T>;
339+
}
340+
```
341+
316342
Be sure to copy over any bounds as well:
317343
318344
```
@@ -324,10 +350,18 @@ fn foo<T: Copy>(x: T) {
324350
}
325351
```
326352
353+
```
354+
fn foo<T: Copy>(x: T) {
355+
struct Foo<T: Copy> {
356+
x: T,
357+
}
358+
}
359+
```
360+
327361
This may require additional type hints in the function body.
328362
329-
In case the function is in an `impl`, defining a private helper function might
330-
be easier:
363+
In case the item is a function inside an `impl`, defining a private helper
364+
function might be easier:
331365
332366
```
333367
impl<T> Foo<T> {

0 commit comments

Comments
 (0)