Skip to content

Commit 486833d

Browse files
committed
Auto merge of #62923 - Centril:rollup-53i3am3, r=Centril
Rollup of 11 pull requests Successful merges: - #62261 (Take substs into account in `conservative_is_privately_uninhabited`) - #62528 (Add joining slices of slices with a slice separator, not just a single item) - #62738 (Remove uses of mem::uninitialized from std::sys::cloudabi) - #62784 (Add riscv32i-unknown-none-elf target) - #62808 (Revert "Disable stack probing for gnux32.") - #62814 (add support for hexagon-unknown-linux-musl) - #62822 (Improve some pointer-related documentation) - #62890 (Normalize use of backticks in compiler messages for libsyntax/*) - #62901 (cleanup: Remove `extern crate serialize as rustc_serialize`s) - #62905 (Normalize use of backticks in compiler messages for doc) - #62908 (normalize use of backticks for compiler messages in remaining modules) Failed merges: r? @ghost
2 parents a7f2867 + 69bc410 commit 486833d

File tree

114 files changed

+520
-329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+520
-329
lines changed

src/ci/docker/dist-various-1/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ ENV TARGETS=$TARGETS,thumbv7em-none-eabihf
112112
ENV TARGETS=$TARGETS,thumbv8m.base-none-eabi
113113
ENV TARGETS=$TARGETS,thumbv8m.main-none-eabi
114114
ENV TARGETS=$TARGETS,thumbv8m.main-none-eabihf
115+
ENV TARGETS=$TARGETS,riscv32i-unknown-none-elf
115116
ENV TARGETS=$TARGETS,riscv32imc-unknown-none-elf
116117
ENV TARGETS=$TARGETS,riscv32imac-unknown-none-elf
117118
ENV TARGETS=$TARGETS,riscv64imac-unknown-none-elf

src/doc/rustc/src/lints/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ warning: unused variable: `x`
1919
2 | let x = 5;
2020
| ^
2121
|
22-
= note: #[warn(unused_variables)] on by default
22+
= note: `#[warn(unused_variables)]` on by default
2323
= note: to avoid this warning, consider using `_x` instead
2424
```
2525

src/doc/rustc/src/lints/levels.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ warning: unused variable: `x`
5353
2 | let x = 5;
5454
| ^
5555
|
56-
= note: #[warn(unused_variables)] on by default
56+
= note: `#[warn(unused_variables)]` on by default
5757
= note: to avoid this warning, consider using `_x` instead
5858
```
5959

@@ -76,7 +76,7 @@ error: bitshift exceeds the type's number of bits
7676
2 | 100u8 << 10;
7777
| ^^^^^^^^^^^
7878
|
79-
= note: #[deny(exceeding_bitshifts)] on by default
79+
= note: `#[deny(exceeding_bitshifts)]` on by default
8080
```
8181
8282
What's the difference between an error from a lint and a regular old error?
@@ -236,7 +236,7 @@ warning: bitshift exceeds the type's number of bits
236236
2 | 100u8 << 10;
237237
| ^^^^^^^^^^^
238238
|
239-
= note: #[warn(exceeding_bitshifts)] on by default
239+
= note: `#[warn(exceeding_bitshifts)]` on by default
240240
241241
warning: this expression will panic at run-time
242242
--> lib.rs:2:5

src/doc/rustc/src/lints/listing/allowed-by-default.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub struct Foo;
165165
When set to 'deny', this will produce:
166166

167167
```text
168-
error: type does not implement `fmt::Debug`; consider adding #[derive(Debug)] or a manual implementation
168+
error: type does not implement `fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation
169169
--> src/main.rs:3:1
170170
|
171171
3 | pub struct Foo;

src/doc/rustc/src/lints/listing/deny-by-default.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`
4040
4 | fn foo<T=i32>(t: T) {}
4141
| ^
4242
|
43-
= note: #[deny(invalid_type_param_default)] on by default
43+
= note: `#[deny(invalid_type_param_default)]` on by default
4444
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4545
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
4646
```
@@ -74,7 +74,7 @@ error: private struct constructors are not usable through re-exports in outer mo
7474
5 | ::S;
7575
| ^^^
7676
|
77-
= note: #[deny(legacy_constructor_visibility)] on by default
77+
= note: `#[deny(legacy_constructor_visibility)]` on by default
7878
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
7979
= note: for more information, see issue #39207 <https://github.com/rust-lang/rust/issues/39207>
8080
```
@@ -84,9 +84,9 @@ error: private struct constructors are not usable through re-exports in outer mo
8484

8585
The legacy_directory_ownership warning is issued when
8686

87-
* There is a non-inline module with a #[path] attribute (e.g. #[path = "foo.rs"] mod bar;),
87+
* There is a non-inline module with a `#[path]` attribute (e.g. `#[path = "foo.rs"] mod bar;`),
8888
* The module's file ("foo.rs" in the above example) is not named "mod.rs", and
89-
* The module's file contains a non-inline child module without a #[path] attribute.
89+
* The module's file contains a non-inline child module without a `#[path]` attribute.
9090

9191
The warning can be fixed by renaming the parent module to "mod.rs" and moving
9292
it into its own directory if appropriate.
@@ -139,7 +139,7 @@ const FOO: i32 = 5;
139139
This will produce:
140140

141141
```text
142-
error: const items should never be #[no_mangle]
142+
error: const items should never be `#[no_mangle]`
143143
--> src/main.rs:3:1
144144
|
145145
3 | const FOO: i32 = 5;
@@ -187,7 +187,7 @@ error: parenthesized parameters may only be used with a trait
187187
2 | let x = 5 as usize();
188188
| ^^
189189
|
190-
= note: #[deny(parenthesized_params_in_types_and_modules)] on by default
190+
= note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default
191191
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
192192
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
193193
```

src/doc/rustc/src/lints/listing/warn-by-default.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ warning: floating-point literals cannot be used in patterns
9090
4 | 5.0 => {},
9191
| ^^^
9292
|
93-
= note: #[warn(illegal_floating_point_literal_pattern)] on by default
93+
= note: `#[warn(illegal_floating_point_literal_pattern)]` on by default
9494
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
9595
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
9696
```
@@ -109,7 +109,7 @@ extern "C" {
109109
This will produce:
110110

111111
```text
112-
warning: found struct without foreign-function-safe representation annotation in foreign module, consider adding a #[repr(C)] attribute to the type
112+
warning: found struct without foreign-function-safe representation annotation in foreign module, consider adding a `#[repr(C)]` attribute to the type
113113
--> src/main.rs:2:20
114114
|
115115
2 | static STATIC: String;
@@ -146,7 +146,7 @@ warning: cannot specify lifetime arguments explicitly if late bound lifetime par
146146
8 | S.late::<'static>(&0, &0);
147147
| ^^^^^^^
148148
|
149-
= note: #[warn(late_bound_lifetime_arguments)] on by default
149+
= note: `#[warn(late_bound_lifetime_arguments)]` on by default
150150
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
151151
= note: for more information, see issue #42868 <https://github.com/rust-lang/rust/issues/42868>
152152
```
@@ -327,7 +327,7 @@ warning: patterns aren't allowed in methods without bodies
327327
2 | fn foo(mut arg: u8);
328328
| ^^^^^^^
329329
|
330-
= note: #[warn(patterns_in_fns_without_body)] on by default
330+
= note: `#[warn(patterns_in_fns_without_body)]` on by default
331331
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
332332
= note: for more information, see issue #35203 <https://github.com/rust-lang/rust/issues/35203>
333333
```
@@ -406,7 +406,7 @@ fn foo() {}
406406
This will produce:
407407

408408
```text
409-
warning: function is marked #[no_mangle], but not exported
409+
warning: function is marked `#[no_mangle]`, but not exported
410410
--> src/main.rs:2:1
411411
|
412412
2 | fn foo() {}
@@ -433,7 +433,7 @@ static X: i32 = 4;
433433
This will produce:
434434

435435
```text
436-
warning: static is marked #[no_mangle], but not exported
436+
warning: static is marked `#[no_mangle]`, but not exported
437437
--> src/main.rs:2:1
438438
|
439439
2 | static X: i32 = 4;
@@ -496,7 +496,7 @@ warning: borrow of packed field requires unsafe function or block (error E0133)
496496
11 | let y = &x.data.0;
497497
| ^^^^^^^^^
498498
|
499-
= note: #[warn(safe_packed_borrows)] on by default
499+
= note: `#[warn(safe_packed_borrows)]` on by default
500500
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
501501
= note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
502502
```
@@ -542,7 +542,7 @@ warning: bounds on generic parameters are not enforced in type aliases
542542
2 | type SendVec<T: Send> = Vec<T>;
543543
| ^^^^
544544
|
545-
= note: #[warn(type_alias_bounds)] on by default
545+
= note: `#[warn(type_alias_bounds)]` on by default
546546
= help: the bound will not be checked when the type alias is used, and should be removed
547547
```
548548

@@ -567,7 +567,7 @@ warning: type annotations needed
567567
4 | if data.is_null() {}
568568
| ^^^^^^^
569569
|
570-
= note: #[warn(tyvar_behind_raw_pointer)] on by default
570+
= note: `#[warn(tyvar_behind_raw_pointer)]` on by default
571571
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
572572
= note: for more information, see issue #46906 <https://github.com/rust-lang/rust/issues/46906>
573573
```
@@ -787,7 +787,7 @@ warning: doc comment not used by rustdoc
787787

788788
## unused-features
789789

790-
This lint detects unused or unknown features found in crate-level #[feature] directives.
790+
This lint detects unused or unknown features found in crate-level `#[feature]` directives.
791791
To fix this, simply remove the feature flag.
792792

793793
## unused-imports
@@ -839,7 +839,7 @@ warning: unused macro definition
839839

840840
## unused-must-use
841841

842-
This lint detects unused result of a type flagged as #[must_use]. Some
842+
This lint detects unused result of a type flagged as `#[must_use]`. Some
843843
example code that triggers this lint:
844844

845845
```rust

src/liballoc/slice.rs

+83-21
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,10 @@ impl<T> [T] {
494494
/// assert_eq!([[1, 2], [3, 4]].concat(), [1, 2, 3, 4]);
495495
/// ```
496496
#[stable(feature = "rust1", since = "1.0.0")]
497-
pub fn concat<Separator: ?Sized>(&self) -> T::Output
498-
where T: SliceConcat<Separator>
497+
pub fn concat<Item: ?Sized>(&self) -> <Self as Concat<Item>>::Output
498+
where Self: Concat<Item>
499499
{
500-
SliceConcat::concat(self)
500+
Concat::concat(self)
501501
}
502502

503503
/// Flattens a slice of `T` into a single value `Self::Output`, placing a
@@ -508,12 +508,13 @@ impl<T> [T] {
508508
/// ```
509509
/// assert_eq!(["hello", "world"].join(" "), "hello world");
510510
/// assert_eq!([[1, 2], [3, 4]].join(&0), [1, 2, 0, 3, 4]);
511+
/// assert_eq!([[1, 2], [3, 4]].join(&[0, 0][..]), [1, 2, 0, 0, 3, 4]);
511512
/// ```
512513
#[stable(feature = "rename_connect_to_join", since = "1.3.0")]
513-
pub fn join<Separator: ?Sized>(&self, sep: &Separator) -> T::Output
514-
where T: SliceConcat<Separator>
514+
pub fn join<Separator>(&self, sep: Separator) -> <Self as Join<Separator>>::Output
515+
where Self: Join<Separator>
515516
{
516-
SliceConcat::join(self, sep)
517+
Join::join(self, sep)
517518
}
518519

519520
/// Flattens a slice of `T` into a single value `Self::Output`, placing a
@@ -528,10 +529,10 @@ impl<T> [T] {
528529
/// ```
529530
#[stable(feature = "rust1", since = "1.0.0")]
530531
#[rustc_deprecated(since = "1.3.0", reason = "renamed to join")]
531-
pub fn connect<Separator: ?Sized>(&self, sep: &Separator) -> T::Output
532-
where T: SliceConcat<Separator>
532+
pub fn connect<Separator>(&self, sep: Separator) -> <Self as Join<Separator>>::Output
533+
where Self: Join<Separator>
533534
{
534-
SliceConcat::join(self, sep)
535+
Join::join(self, sep)
535536
}
536537

537538
}
@@ -578,45 +579,83 @@ impl [u8] {
578579
// Extension traits for slices over specific kinds of data
579580
////////////////////////////////////////////////////////////////////////////////
580581

581-
/// Helper trait for [`[T]::concat`](../../std/primitive.slice.html#method.concat)
582-
/// and [`[T]::join`](../../std/primitive.slice.html#method.join)
582+
/// Helper trait for [`[T]::concat`](../../std/primitive.slice.html#method.concat).
583+
///
584+
/// Note: the `Item` type parameter is not used in this trait,
585+
/// but it allows impls to be more generic.
586+
/// Without it, we get this error:
587+
///
588+
/// ```error
589+
/// error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predica
590+
/// --> src/liballoc/slice.rs:608:6
591+
/// |
592+
/// 608 | impl<T: Clone, V: Borrow<[T]>> Concat for [V] {
593+
/// | ^ unconstrained type parameter
594+
/// ```
595+
///
596+
/// This is because there could exist `V` types with multiple `Borrow<[_]>` impls,
597+
/// such that multiple `T` types would apply:
598+
///
599+
/// ```
600+
/// # #[allow(dead_code)]
601+
/// pub struct Foo(Vec<u32>, Vec<String>);
602+
///
603+
/// impl std::borrow::Borrow<[u32]> for Foo {
604+
/// fn borrow(&self) -> &[u32] { &self.0 }
605+
/// }
606+
///
607+
/// impl std::borrow::Borrow<[String]> for Foo {
608+
/// fn borrow(&self) -> &[String] { &self.1 }
609+
/// }
610+
/// ```
583611
#[unstable(feature = "slice_concat_trait", issue = "27747")]
584-
pub trait SliceConcat<Separator: ?Sized>: Sized {
612+
pub trait Concat<Item: ?Sized> {
585613
#[unstable(feature = "slice_concat_trait", issue = "27747")]
586614
/// The resulting type after concatenation
587615
type Output;
588616

589617
/// Implementation of [`[T]::concat`](../../std/primitive.slice.html#method.concat)
590618
#[unstable(feature = "slice_concat_trait", issue = "27747")]
591-
fn concat(slice: &[Self]) -> Self::Output;
619+
fn concat(slice: &Self) -> Self::Output;
620+
}
621+
622+
/// Helper trait for [`[T]::join`](../../std/primitive.slice.html#method.join)
623+
#[unstable(feature = "slice_concat_trait", issue = "27747")]
624+
pub trait Join<Separator> {
625+
#[unstable(feature = "slice_concat_trait", issue = "27747")]
626+
/// The resulting type after concatenation
627+
type Output;
592628

593629
/// Implementation of [`[T]::join`](../../std/primitive.slice.html#method.join)
594630
#[unstable(feature = "slice_concat_trait", issue = "27747")]
595-
fn join(slice: &[Self], sep: &Separator) -> Self::Output;
631+
fn join(slice: &Self, sep: Separator) -> Self::Output;
596632
}
597633

598-
#[unstable(feature = "slice_concat_ext",
599-
reason = "trait should not have to exist",
600-
issue = "27747")]
601-
impl<T: Clone, V: Borrow<[T]>> SliceConcat<T> for V {
634+
#[unstable(feature = "slice_concat_ext", issue = "27747")]
635+
impl<T: Clone, V: Borrow<[T]>> Concat<T> for [V] {
602636
type Output = Vec<T>;
603637

604-
fn concat(slice: &[Self]) -> Vec<T> {
638+
fn concat(slice: &Self) -> Vec<T> {
605639
let size = slice.iter().map(|slice| slice.borrow().len()).sum();
606640
let mut result = Vec::with_capacity(size);
607641
for v in slice {
608642
result.extend_from_slice(v.borrow())
609643
}
610644
result
611645
}
646+
}
647+
648+
#[unstable(feature = "slice_concat_ext", issue = "27747")]
649+
impl<T: Clone, V: Borrow<[T]>> Join<&T> for [V] {
650+
type Output = Vec<T>;
612651

613-
fn join(slice: &[Self], sep: &T) -> Vec<T> {
652+
fn join(slice: &Self, sep: &T) -> Vec<T> {
614653
let mut iter = slice.iter();
615654
let first = match iter.next() {
616655
Some(first) => first,
617656
None => return vec![],
618657
};
619-
let size = slice.iter().map(|slice| slice.borrow().len()).sum::<usize>() + slice.len() - 1;
658+
let size = slice.iter().map(|v| v.borrow().len()).sum::<usize>() + slice.len() - 1;
620659
let mut result = Vec::with_capacity(size);
621660
result.extend_from_slice(first.borrow());
622661

@@ -628,6 +667,29 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcat<T> for V {
628667
}
629668
}
630669

670+
#[unstable(feature = "slice_concat_ext", issue = "27747")]
671+
impl<T: Clone, V: Borrow<[T]>> Join<&[T]> for [V] {
672+
type Output = Vec<T>;
673+
674+
fn join(slice: &Self, sep: &[T]) -> Vec<T> {
675+
let mut iter = slice.iter();
676+
let first = match iter.next() {
677+
Some(first) => first,
678+
None => return vec![],
679+
};
680+
let size = slice.iter().map(|v| v.borrow().len()).sum::<usize>() +
681+
sep.len() * (slice.len() - 1);
682+
let mut result = Vec::with_capacity(size);
683+
result.extend_from_slice(first.borrow());
684+
685+
for v in iter {
686+
result.extend_from_slice(sep);
687+
result.extend_from_slice(v.borrow())
688+
}
689+
result
690+
}
691+
}
692+
631693
////////////////////////////////////////////////////////////////////////////////
632694
// Standard trait implementations for slices
633695
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)