Skip to content

Commit 322d7f7

Browse files
committed
Auto merge of #48531 - kennytm:rollup, r=kennytm
Rollup of 17 pull requests - Successful merges: #47964, #47970, #48076, #48115, #48166, #48281, #48297, #48302, #48362, #48369, #48489, #48491, #48494, #48517, #48529, #48235, #48330 - Failed merges:
2 parents 026339e + 1aa1035 commit 322d7f7

File tree

41 files changed

+1143
-236
lines changed

Some content is hidden

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

41 files changed

+1143
-236
lines changed

src/bootstrap/bin/rustc.rs

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ fn main() {
6161
args.remove(n);
6262
}
6363

64+
if let Some(s) = env::var_os("RUSTC_ERROR_FORMAT") {
65+
args.push("--error-format".into());
66+
args.push(s);
67+
}
68+
6469
// Detect whether or not we're a build script depending on whether --target
6570
// is passed (a bit janky...)
6671
let target = args.windows(2)

src/bootstrap/bootstrap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def default_build_triple():
294294
raise ValueError('unknown byteorder: {}'.format(sys.byteorder))
295295
# only the n64 ABI is supported, indicate it
296296
ostype += 'abi64'
297-
elif cputype == 'sparcv9' or cputype == 'sparc64':
297+
elif cputype == 'sparc' or cputype == 'sparcv9' or cputype == 'sparc64':
298298
pass
299299
else:
300300
err = "unknown cpu type: {}".format(cputype)

src/bootstrap/builder.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,11 @@ impl<'a> Builder<'a> {
444444

445445
fn run(self, builder: &Builder) -> Interned<PathBuf> {
446446
let compiler = self.compiler;
447-
let lib = if compiler.stage >= 1 && builder.build.config.libdir.is_some() {
448-
builder.build.config.libdir.clone().unwrap()
447+
let config = &builder.build.config;
448+
let lib = if compiler.stage >= 1 && config.libdir_relative().is_some() {
449+
builder.build.config.libdir_relative().unwrap()
449450
} else {
450-
PathBuf::from("lib")
451+
Path::new("lib")
451452
};
452453
let sysroot = builder.sysroot(self.compiler).join(lib)
453454
.join("rustlib").join(self.target).join("lib");
@@ -598,6 +599,9 @@ impl<'a> Builder<'a> {
598599
if let Some(target_linker) = self.build.linker(target) {
599600
cargo.env("RUSTC_TARGET_LINKER", target_linker);
600601
}
602+
if let Some(ref error_format) = self.config.rustc_error_format {
603+
cargo.env("RUSTC_ERROR_FORMAT", error_format);
604+
}
601605
if cmd != "build" && cmd != "check" {
602606
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.build.build)));
603607
}

src/bootstrap/compile.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,7 @@ fn rustc_cargo_env(build: &Build, cargo: &mut Command) {
516516
.env("CFG_VERSION", build.rust_version())
517517
.env("CFG_PREFIX", build.config.prefix.clone().unwrap_or_default());
518518

519-
let libdir_relative =
520-
build.config.libdir.clone().unwrap_or(PathBuf::from("lib"));
519+
let libdir_relative = build.config.libdir_relative().unwrap_or(Path::new("lib"));
521520
cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
522521

523522
// If we're not building a compiler with debugging information then remove

src/bootstrap/config.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::collections::{HashMap, HashSet};
1717
use std::env;
1818
use std::fs::File;
1919
use std::io::prelude::*;
20-
use std::path::PathBuf;
20+
use std::path::{Path, PathBuf};
2121
use std::process;
2222
use std::cmp;
2323

@@ -57,6 +57,7 @@ pub struct Config {
5757
pub profiler: bool,
5858
pub ignore_git: bool,
5959
pub exclude: Vec<PathBuf>,
60+
pub rustc_error_format: Option<String>,
6061

6162
pub run_host_only: bool,
6263

@@ -330,6 +331,7 @@ impl Config {
330331
config.test_miri = false;
331332
config.rust_codegen_backends = vec![INTERNER.intern_str("llvm")];
332333

334+
config.rustc_error_format = flags.rustc_error_format;
333335
config.on_fail = flags.on_fail;
334336
config.stage = flags.stage;
335337
config.src = flags.src;
@@ -564,6 +566,17 @@ impl Config {
564566
config
565567
}
566568

569+
/// Try to find the relative path of `libdir`.
570+
pub fn libdir_relative(&self) -> Option<&Path> {
571+
let libdir = self.libdir.as_ref()?;
572+
if libdir.is_relative() {
573+
Some(libdir)
574+
} else {
575+
// Try to make it relative to the prefix.
576+
libdir.strip_prefix(self.prefix.as_ref()?).ok()
577+
}
578+
}
579+
567580
pub fn verbose(&self) -> bool {
568581
self.verbose > 0
569582
}

src/bootstrap/flags.rs

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub struct Flags {
4343
pub cmd: Subcommand,
4444
pub incremental: bool,
4545
pub exclude: Vec<PathBuf>,
46+
pub rustc_error_format: Option<String>,
4647
}
4748

4849
pub enum Subcommand {
@@ -118,6 +119,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
118119
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
119120
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
120121
opts.optflag("h", "help", "print this help message");
122+
opts.optflag("", "error-format", "rustc error format");
121123

122124
// fn usage()
123125
let usage = |exit_code: i32, opts: &Options, subcommand_help: &str, extra_help: &str| -> ! {
@@ -370,6 +372,7 @@ Arguments:
370372
verbose: matches.opt_count("verbose"),
371373
stage,
372374
on_fail: matches.opt_str("on-fail"),
375+
rustc_error_format: matches.opt_str("error-format"),
373376
keep_stage: matches.opt_str("keep-stage").map(|j| j.parse().unwrap()),
374377
build: matches.opt_str("build").map(|s| INTERNER.intern_string(s)),
375378
host: split(matches.opt_strs("host"))

src/bootstrap/native.rs

+3
Original file line numberDiff line numberDiff line change
@@ -480,16 +480,19 @@ impl Step for Openssl {
480480
"mips64el-unknown-linux-gnuabi64" => "linux64-mips64",
481481
"mipsel-unknown-linux-gnu" => "linux-mips32",
482482
"powerpc-unknown-linux-gnu" => "linux-ppc",
483+
"powerpc-unknown-netbsd" => "BSD-generic32",
483484
"powerpc64-unknown-linux-gnu" => "linux-ppc64",
484485
"powerpc64le-unknown-linux-gnu" => "linux-ppc64le",
485486
"s390x-unknown-linux-gnu" => "linux64-s390x",
487+
"sparc-unknown-linux-gnu" => "linux-sparcv9",
486488
"sparc64-unknown-linux-gnu" => "linux64-sparcv9",
487489
"sparc64-unknown-netbsd" => "BSD-sparc64",
488490
"x86_64-apple-darwin" => "darwin64-x86_64-cc",
489491
"x86_64-linux-android" => "linux-x86_64",
490492
"x86_64-unknown-freebsd" => "BSD-x86_64",
491493
"x86_64-unknown-dragonfly" => "BSD-x86_64",
492494
"x86_64-unknown-linux-gnu" => "linux-x86_64",
495+
"x86_64-unknown-linux-gnux32" => "linux-x32",
493496
"x86_64-unknown-linux-musl" => "linux-x86_64",
494497
"x86_64-unknown-netbsd" => "BSD-x86_64",
495498
_ => panic!("don't know how to configure OpenSSL for {}", target),

src/doc/unstable-book/src/library-features/entry-and-modify.md

-77
This file was deleted.

src/liballoc/btree/map.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,6 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
21142114
/// # Examples
21152115
///
21162116
/// ```
2117-
/// #![feature(entry_and_modify)]
21182117
/// use std::collections::BTreeMap;
21192118
///
21202119
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
@@ -2129,7 +2128,7 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
21292128
/// .or_insert(42);
21302129
/// assert_eq!(map["poneyland"], 43);
21312130
/// ```
2132-
#[unstable(feature = "entry_and_modify", issue = "44733")]
2131+
#[stable(feature = "entry_and_modify", since = "1.26.0")]
21332132
pub fn and_modify<F>(self, mut f: F) -> Self
21342133
where F: FnMut(&mut V)
21352134
{

src/libcore/iter/iterator.rs

+79-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use cmp::Ordering;
1212
use ops::Try;
1313

1414
use super::{AlwaysOk, LoopState};
15-
use super::{Chain, Cycle, Cloned, Enumerate, Filter, FilterMap, FlatMap, Fuse};
15+
use super::{Chain, Cycle, Cloned, Enumerate, Filter, FilterMap, Fuse};
16+
use super::{Flatten, FlatMap, flatten_compat};
1617
use super::{Inspect, Map, Peekable, Scan, Skip, SkipWhile, StepBy, Take, TakeWhile, Rev};
1718
use super::{Zip, Sum, Product};
1819
use super::{ChainState, FromIterator, ZipImpl};
@@ -997,11 +998,15 @@ pub trait Iterator {
997998
/// an extra layer of indirection. `flat_map()` will remove this extra layer
998999
/// on its own.
9991000
///
1001+
/// You can think of [`flat_map(f)`][flat_map] as the semantic equivalent
1002+
/// of [`map`]ping, and then [`flatten`]ing as in `map(f).flatten()`.
1003+
///
10001004
/// Another way of thinking about `flat_map()`: [`map`]'s closure returns
10011005
/// one item for each element, and `flat_map()`'s closure returns an
10021006
/// iterator for each element.
10031007
///
10041008
/// [`map`]: #method.map
1009+
/// [`flatten`]: #method.flatten
10051010
///
10061011
/// # Examples
10071012
///
@@ -1021,7 +1026,79 @@ pub trait Iterator {
10211026
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
10221027
where Self: Sized, U: IntoIterator, F: FnMut(Self::Item) -> U,
10231028
{
1024-
FlatMap{iter: self, f: f, frontiter: None, backiter: None }
1029+
FlatMap { inner: flatten_compat(self.map(f)) }
1030+
}
1031+
1032+
/// Creates an iterator that flattens nested structure.
1033+
///
1034+
/// This is useful when you have an iterator of iterators or an iterator of
1035+
/// things that can be turned into iterators and you want to remove one
1036+
/// level of indirection.
1037+
///
1038+
/// # Examples
1039+
///
1040+
/// Basic usage:
1041+
///
1042+
/// ```
1043+
/// #![feature(iterator_flatten)]
1044+
///
1045+
/// let data = vec![vec![1, 2, 3, 4], vec![5, 6]];
1046+
/// let flattened = data.into_iter().flatten().collect::<Vec<u8>>();
1047+
/// assert_eq!(flattened, &[1, 2, 3, 4, 5, 6]);
1048+
/// ```
1049+
///
1050+
/// Mapping and then flattening:
1051+
///
1052+
/// ```
1053+
/// #![feature(iterator_flatten)]
1054+
///
1055+
/// let words = ["alpha", "beta", "gamma"];
1056+
///
1057+
/// // chars() returns an iterator
1058+
/// let merged: String = words.iter()
1059+
/// .map(|s| s.chars())
1060+
/// .flatten()
1061+
/// .collect();
1062+
/// assert_eq!(merged, "alphabetagamma");
1063+
/// ```
1064+
///
1065+
/// You can also rewrite this in terms of [`flat_map()`] which is preferable
1066+
/// in this case since that conveys intent clearer:
1067+
///
1068+
/// ```
1069+
/// let words = ["alpha", "beta", "gamma"];
1070+
///
1071+
/// // chars() returns an iterator
1072+
/// let merged: String = words.iter()
1073+
/// .flat_map(|s| s.chars())
1074+
/// .collect();
1075+
/// assert_eq!(merged, "alphabetagamma");
1076+
/// ```
1077+
///
1078+
/// Flattening once only removes one level of nesting:
1079+
///
1080+
/// ```
1081+
/// #![feature(iterator_flatten)]
1082+
///
1083+
/// let d3 = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
1084+
///
1085+
/// let d2 = d3.iter().flatten().collect::<Vec<_>>();
1086+
/// assert_eq!(d2, [&[1, 2], &[3, 4], &[5, 6], &[7, 8]]);
1087+
///
1088+
/// let d1 = d3.iter().flatten().flatten().collect::<Vec<_>>();
1089+
/// assert_eq!(d1, [&1, &2, &3, &4, &5, &6, &7, &8]);
1090+
/// ```
1091+
///
1092+
/// Here we see that `flatten()` does not perform a "deep" flatten.
1093+
/// Instead, only one level of nesting is removed. That is, if you
1094+
/// `flatten()` a three-dimensional array the result will be
1095+
/// two-dimensional and not one-dimensional. To get a one-dimensional
1096+
/// structure, you have to `flatten()` again.
1097+
#[inline]
1098+
#[unstable(feature = "iterator_flatten", issue = "48213")]
1099+
fn flatten(self) -> Flatten<Self>
1100+
where Self: Sized, Self::Item: IntoIterator {
1101+
Flatten { inner: flatten_compat(self) }
10251102
}
10261103

10271104
/// Creates an iterator which ends after the first [`None`].

0 commit comments

Comments
 (0)