Skip to content

Commit 346aec9

Browse files
committed
Auto merge of rust-lang#74235 - Manishearth:rollup-bgs3q14, r=Manishearth
Rollup of 19 pull requests Successful merges: - rust-lang#71322 (Accept tuple.0.0 as tuple indexing (take 2)) - rust-lang#72303 (Add core::future::{poll_fn, PollFn}) - rust-lang#73862 (Stabilize casts and coercions to `&[T]` in const fn) - rust-lang#73887 (stabilize const mem::forget) - rust-lang#73989 (adjust ub-enum test to be endianess-independent) - rust-lang#74045 (Explain effects of debugging options from config.toml) - rust-lang#74076 (Add `read_exact_at` and `write_all_at` to WASI's `FileExt`) - rust-lang#74099 (Add VecDeque::range* methods) - rust-lang#74100 (Use str::strip* in bootstrap) - rust-lang#74103 (Only add CFGuard on `windows-msvc` targets) - rust-lang#74109 (Only allow `repr(i128/u128)` on enum) - rust-lang#74122 (Start-up clean-up) - rust-lang#74125 (Correctly mark the ending span of a match arm) - rust-lang#74127 (Avoid "whitelist") - rust-lang#74129 (:arrow_up: rust-analyzer) - rust-lang#74135 (Update books) - rust-lang#74145 (Update rust-installer to latest version) - rust-lang#74161 (Fix disabled dockerfiles) - rust-lang#74162 (take self by value in ToPredicate) Failed merges: r? @ghost
2 parents daecab3 + 79fc386 commit 346aec9

File tree

130 files changed

+1599
-596
lines changed

Some content is hidden

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

130 files changed

+1599
-596
lines changed

Cargo.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1366,8 +1366,8 @@ checksum = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d"
13661366
name = "installer"
13671367
version = "0.0.0"
13681368
dependencies = [
1369+
"anyhow",
13691370
"clap",
1370-
"failure",
13711371
"flate2",
13721372
"lazy_static",
13731373
"num_cpus",

config.toml.example

+6-2
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@
318318
#codegen-units-std = 1
319319

320320
# Whether or not debug assertions are enabled for the compiler and standard
321-
# library.
321+
# library. Debug assertions control the maximum log level used by rustc. When
322+
# enabled calls to `trace!` and `debug!` macros are preserved in the compiled
323+
# binary, otherwise they are omitted.
322324
#
323325
# Defaults to rust.debug value
324326
#debug-assertions = false
@@ -331,7 +333,9 @@
331333

332334
# Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`.
333335
# `0` - no debug info
334-
# `1` - line tables only
336+
# `1` - line tables only - sufficient to generate backtraces that include line
337+
# information and inlined functions, set breakpoints at source code
338+
# locations, and step through execution in a debugger.
335339
# `2` - full debug info with variable and type information
336340
# Can be overridden for specific subsets of Rust code (rustc, std or tools).
337341
# Debuginfo for tests run with compiletest is not controlled by this option

src/bootstrap/compile.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -963,10 +963,11 @@ pub fn run_cargo(
963963
.collect::<Vec<_>>();
964964
for (prefix, extension, expected_len) in toplevel {
965965
let candidates = contents.iter().filter(|&&(_, ref filename, ref meta)| {
966-
filename.starts_with(&prefix[..])
967-
&& filename[prefix.len()..].starts_with('-')
968-
&& filename.ends_with(&extension[..])
969-
&& meta.len() == expected_len
966+
meta.len() == expected_len
967+
&& filename
968+
.strip_prefix(&prefix[..])
969+
.map(|s| s.starts_with('-') && s.ends_with(&extension[..]))
970+
.unwrap_or(false)
970971
});
971972
let max = candidates
972973
.max_by_key(|&&(_, _, ref metadata)| FileTime::from_last_modification_time(metadata));

src/bootstrap/doc.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,6 @@ impl Step for Std {
439439
builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "rustdoc");
440440
compile::std_cargo(builder, target, compiler.stage, &mut cargo);
441441

442-
// Keep a whitelist so we do not build internal stdlib crates, these will be
443-
// build by the rustc step later if enabled.
444442
cargo.arg("-p").arg(package);
445443
// Create all crate output directories first to make sure rustdoc uses
446444
// relative links.
@@ -460,6 +458,10 @@ impl Step for Std {
460458

461459
builder.run(&mut cargo.into());
462460
};
461+
// Only build the following crates. While we could just iterate over the
462+
// folder structure, that would also build internal crates that we do
463+
// not want to show in documentation. These crates will later be visited
464+
// by the rustc step, so internal documentation will show them.
463465
let krates = ["alloc", "core", "std", "proc_macro", "test"];
464466
for krate in &krates {
465467
run_cargo_rustdoc_for(krate);

src/bootstrap/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,9 @@ impl Build {
436436
output(Command::new(&build.initial_rustc).arg("--version").arg("--verbose"));
437437
let local_release = local_version_verbose
438438
.lines()
439-
.filter(|x| x.starts_with("release:"))
439+
.filter_map(|x| x.strip_prefix("release:"))
440440
.next()
441441
.unwrap()
442-
.trim_start_matches("release:")
443442
.trim();
444443
let my_version = channel::CFG_RELEASE_NUM;
445444
if local_release.split('.').take(2).eq(my_version.split('.').take(2)) {
@@ -1089,10 +1088,10 @@ impl Build {
10891088
let toml_file_name = self.src.join(&format!("src/tools/{}/Cargo.toml", package));
10901089
let toml = t!(fs::read_to_string(&toml_file_name));
10911090
for line in toml.lines() {
1092-
let prefix = "version = \"";
1093-
let suffix = "\"";
1094-
if line.starts_with(prefix) && line.ends_with(suffix) {
1095-
return line[prefix.len()..line.len() - suffix.len()].to_string();
1091+
if let Some(stripped) =
1092+
line.strip_prefix("version = \"").and_then(|s| s.strip_suffix("\""))
1093+
{
1094+
return stripped.to_owned();
10961095
}
10971096
}
10981097

src/ci/docker/host-x86_64/disabled/riscv64gc-linux/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ RUN curl https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.16.tar.xz | tar
4040
cp linux.config linux-5.6.16/.config && \
4141
cd /build/linux-5.6.16 && \
4242
make olddefconfig && \
43-
make -j$(nproc) vmlinux
44-
RUN cp linux-5.6.16/vmlinux /tmp
45-
RUN rm -rf linux-5.6.16
43+
make -j$(nproc) vmlinux && \
44+
cp vmlinux /tmp && \
45+
rm -rf linux-5.6.16
4646

4747
# Compile an instance of busybox as this provides a lightweight system and init
4848
# binary which we will boot into. Only trick here is configuring busybox to

src/ci/docker/run.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then
119119
exit 1
120120
fi
121121
# Transform changes the context of disabled Dockerfiles to match the enabled ones
122-
tar --transform 's#^./disabled/#./#' -C $docker_dir -c . | docker \
122+
tar --transform 's#disabled/#./#' -C $script_dir -c . | docker \
123123
build \
124124
--rm \
125125
-t rust-ci \
126-
-f "$image/Dockerfile" \
126+
-f "host-$(uname -m)/$image/Dockerfile" \
127127
-
128128
else
129129
echo Invalid image: $image

src/doc/rust-by-example

src/etc/test-float-parse/runtests.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ def main():
195195
global MAILBOX
196196
tests = [os.path.splitext(f)[0] for f in glob('*.rs')
197197
if not f.startswith('_')]
198-
whitelist = sys.argv[1:]
199-
if whitelist:
200-
tests = [test for test in tests if test in whitelist]
198+
listed = sys.argv[1:]
199+
if listed:
200+
tests = [test for test in tests if test in listed]
201201
if not tests:
202202
print("Error: No tests to run")
203203
sys.exit(1)
@@ -210,8 +210,6 @@ def main():
210210
mailman.daemon = True
211211
mailman.start()
212212
for test in tests:
213-
if whitelist and test not in whitelist:
214-
continue
215213
run(test)
216214
MAILBOX.put(None)
217215
mailman.join()

src/liballoc/collections/vec_deque.rs

+103-13
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,108 @@ impl<T> VecDeque<T> {
10841084
self.tail == self.head
10851085
}
10861086

1087+
fn range_start_end<R>(&self, range: R) -> (usize, usize)
1088+
where
1089+
R: RangeBounds<usize>,
1090+
{
1091+
let len = self.len();
1092+
let start = match range.start_bound() {
1093+
Included(&n) => n,
1094+
Excluded(&n) => n + 1,
1095+
Unbounded => 0,
1096+
};
1097+
let end = match range.end_bound() {
1098+
Included(&n) => n + 1,
1099+
Excluded(&n) => n,
1100+
Unbounded => len,
1101+
};
1102+
assert!(start <= end, "lower bound was too large");
1103+
assert!(end <= len, "upper bound was too large");
1104+
(start, end)
1105+
}
1106+
1107+
/// Creates an iterator that covers the specified range in the `VecDeque`.
1108+
///
1109+
/// # Panics
1110+
///
1111+
/// Panics if the starting point is greater than the end point or if
1112+
/// the end point is greater than the length of the vector.
1113+
///
1114+
/// # Examples
1115+
///
1116+
/// ```
1117+
/// #![feature(deque_range)]
1118+
///
1119+
/// use std::collections::VecDeque;
1120+
///
1121+
/// let v: VecDeque<_> = vec![1, 2, 3].into_iter().collect();
1122+
/// let range = v.range(2..).copied().collect::<VecDeque<_>>();
1123+
/// assert_eq!(range, [3]);
1124+
///
1125+
/// // A full range covers all contents
1126+
/// let all = v.range(..);
1127+
/// assert_eq!(all.len(), 3);
1128+
/// ```
1129+
#[inline]
1130+
#[unstable(feature = "deque_range", issue = "74217")]
1131+
pub fn range<R>(&self, range: R) -> Iter<'_, T>
1132+
where
1133+
R: RangeBounds<usize>,
1134+
{
1135+
let (start, end) = self.range_start_end(range);
1136+
let tail = self.wrap_add(self.tail, start);
1137+
let head = self.wrap_add(self.tail, end);
1138+
Iter {
1139+
tail,
1140+
head,
1141+
// The shared reference we have in &self is maintained in the '_ of Iter.
1142+
ring: unsafe { self.buffer_as_slice() },
1143+
}
1144+
}
1145+
1146+
/// Creates an iterator that covers the specified mutable range in the `VecDeque`.
1147+
///
1148+
/// # Panics
1149+
///
1150+
/// Panics if the starting point is greater than the end point or if
1151+
/// the end point is greater than the length of the vector.
1152+
///
1153+
/// # Examples
1154+
///
1155+
/// ```
1156+
/// #![feature(deque_range)]
1157+
///
1158+
/// use std::collections::VecDeque;
1159+
///
1160+
/// let mut v: VecDeque<_> = vec![1, 2, 3].into_iter().collect();
1161+
/// for v in v.range_mut(2..) {
1162+
/// *v *= 2;
1163+
/// }
1164+
/// assert_eq!(v, vec![1, 2, 6]);
1165+
///
1166+
/// // A full range covers all contents
1167+
/// for v in v.range_mut(..) {
1168+
/// *v *= 2;
1169+
/// }
1170+
/// assert_eq!(v, vec![2, 4, 12]);
1171+
/// ```
1172+
#[inline]
1173+
#[unstable(feature = "deque_range", issue = "74217")]
1174+
pub fn range_mut<R>(&mut self, range: R) -> IterMut<'_, T>
1175+
where
1176+
R: RangeBounds<usize>,
1177+
{
1178+
let (start, end) = self.range_start_end(range);
1179+
let tail = self.wrap_add(self.tail, start);
1180+
let head = self.wrap_add(self.tail, end);
1181+
IterMut {
1182+
tail,
1183+
head,
1184+
// The shared reference we have in &mut self is maintained in the '_ of IterMut.
1185+
ring: unsafe { self.buffer_as_mut_slice() },
1186+
}
1187+
}
1188+
10871189
/// Creates a draining iterator that removes the specified range in the
10881190
/// `VecDeque` and yields the removed items.
10891191
///
@@ -1129,19 +1231,7 @@ impl<T> VecDeque<T> {
11291231
// When finished, the remaining data will be copied back to cover the hole,
11301232
// and the head/tail values will be restored correctly.
11311233
//
1132-
let len = self.len();
1133-
let start = match range.start_bound() {
1134-
Included(&n) => n,
1135-
Excluded(&n) => n + 1,
1136-
Unbounded => 0,
1137-
};
1138-
let end = match range.end_bound() {
1139-
Included(&n) => n + 1,
1140-
Excluded(&n) => n,
1141-
Unbounded => len,
1142-
};
1143-
assert!(start <= end, "drain lower bound was too large");
1144-
assert!(end <= len, "drain upper bound was too large");
1234+
let (start, end) = self.range_start_end(range);
11451235

11461236
// The deque's elements are parted into three segments:
11471237
// * self.tail -> drain_tail

src/liballoc/collections/vec_deque/tests.rs

+59
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,65 @@ fn test_remove() {
246246
}
247247
}
248248

249+
#[test]
250+
fn test_range() {
251+
let mut tester: VecDeque<usize> = VecDeque::with_capacity(7);
252+
253+
let cap = tester.capacity();
254+
for len in 0..=cap {
255+
for tail in 0..=cap {
256+
for start in 0..=len {
257+
for end in start..=len {
258+
tester.tail = tail;
259+
tester.head = tail;
260+
for i in 0..len {
261+
tester.push_back(i);
262+
}
263+
264+
// Check that we iterate over the correct values
265+
let range: VecDeque<_> = tester.range(start..end).copied().collect();
266+
let expected: VecDeque<_> = (start..end).collect();
267+
assert_eq!(range, expected);
268+
}
269+
}
270+
}
271+
}
272+
}
273+
274+
#[test]
275+
fn test_range_mut() {
276+
let mut tester: VecDeque<usize> = VecDeque::with_capacity(7);
277+
278+
let cap = tester.capacity();
279+
for len in 0..=cap {
280+
for tail in 0..=cap {
281+
for start in 0..=len {
282+
for end in start..=len {
283+
tester.tail = tail;
284+
tester.head = tail;
285+
for i in 0..len {
286+
tester.push_back(i);
287+
}
288+
289+
let head_was = tester.head;
290+
let tail_was = tester.tail;
291+
292+
// Check that we iterate over the correct values
293+
let range: VecDeque<_> = tester.range_mut(start..end).map(|v| *v).collect();
294+
let expected: VecDeque<_> = (start..end).collect();
295+
assert_eq!(range, expected);
296+
297+
// We shouldn't have changed the capacity or made the
298+
// head or tail out of bounds
299+
assert_eq!(tester.capacity(), cap);
300+
assert_eq!(tester.tail, tail_was);
301+
assert_eq!(tester.head, head_was);
302+
}
303+
}
304+
}
305+
}
306+
}
307+
249308
#[test]
250309
fn test_drain() {
251310
let mut tester: VecDeque<usize> = VecDeque::with_capacity(7);

src/liballoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
#![feature(const_in_array_repeat_expressions)]
9090
#![cfg_attr(bootstrap, feature(const_if_match))]
9191
#![feature(cow_is_borrowed)]
92+
#![feature(deque_range)]
9293
#![feature(dispatch_from_dyn)]
9394
#![feature(core_intrinsics)]
9495
#![feature(container_error_extra)]

src/libcore/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl<'a, 'f: 'a> DerefMut for VaList<'a, 'f> {
280280
// within a private module. Once RFC 2145 has been implemented look into
281281
// improving this.
282282
mod sealed_trait {
283-
/// Trait which whitelists the allowed types to be used with [VaList::arg]
283+
/// Trait which permits the allowed types to be used with [VaList::arg].
284284
///
285285
/// [VaList::arg]: ../struct.VaList.html#method.arg
286286
#[unstable(

src/libcore/future/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::{
1212
mod future;
1313
mod into_future;
1414
mod pending;
15+
mod poll_fn;
1516
mod ready;
1617

1718
#[stable(feature = "futures_api", since = "1.36.0")]
@@ -25,6 +26,9 @@ pub use pending::{pending, Pending};
2526
#[unstable(feature = "future_readiness_fns", issue = "70921")]
2627
pub use ready::{ready, Ready};
2728

29+
#[unstable(feature = "future_poll_fn", issue = "72302")]
30+
pub use poll_fn::{poll_fn, PollFn};
31+
2832
/// This type is needed because:
2933
///
3034
/// a) Generators cannot implement `for<'a, 'b> Generator<&'a mut Context<'b>>`, so we need to pass

0 commit comments

Comments
 (0)