Skip to content

Commit 688a74b

Browse files
committed
Auto merge of #66356 - JohnTitor:rollup-1mh7jsr, r=JohnTitor
Rollup of 13 pull requests Successful merges: - #65932 (download .tar.xz if python3 is used) - #66074 ([mir-opt] Turn on the `ConstProp` pass by default) - #66094 (Fix documentation for `Iterator::count()`.) - #66166 (rename cfg(rustdoc) into cfg(doc)) - #66227 (docs: Fix link to BufWriter::flush) - #66292 (add Result::map_or) - #66297 (Add a callback that allows compiler consumers to override queries.) - #66317 (Use a relative bindir for rustdoc to find rustc) - #66330 (Improve non-exhaustiveness handling in usefulness checking) - #66331 (Add some tests for fixed ICEs) - #66334 (Move Session fields to CrateStore) - #66335 (Move self-profile infrastructure to data structures) - #66337 (Remove dead code for encoding/decoding lint IDs) Failed merges: r? @ghost
2 parents 374ad1b + 6302a35 commit 688a74b

File tree

57 files changed

+665
-332
lines changed

Some content is hidden

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

57 files changed

+665
-332
lines changed

Cargo.lock

+2-1
Original file line numberDiff line numberDiff line change
@@ -3120,7 +3120,6 @@ dependencies = [
31203120
"graphviz",
31213121
"jobserver",
31223122
"log",
3123-
"measureme",
31243123
"num_cpus",
31253124
"parking_lot 0.9.0",
31263125
"polonius-engine",
@@ -3470,6 +3469,7 @@ dependencies = [
34703469
name = "rustc_data_structures"
34713470
version = "0.0.0"
34723471
dependencies = [
3472+
"bitflags",
34733473
"cfg-if",
34743474
"crossbeam-utils 0.6.5",
34753475
"ena",
@@ -3478,6 +3478,7 @@ dependencies = [
34783478
"jobserver",
34793479
"lazy_static 1.3.0",
34803480
"log",
3481+
"measureme",
34813482
"parking_lot 0.9.0",
34823483
"rustc-hash",
34833484
"rustc-rayon 0.3.0",

src/bootstrap/bin/rustdoc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn main() {
2525
let mut dylib_path = bootstrap::util::dylib_path();
2626
dylib_path.insert(0, PathBuf::from(libdir.clone()));
2727

28-
//FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
28+
//FIXME(misdreavus): once stdsimd uses cfg(doc) instead of cfg(dox), remove the `--cfg dox`
2929
//arguments here
3030
let mut cmd = Command::new(rustdoc);
3131
cmd.args(&args)

src/bootstrap/bootstrap.py

+29-14
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ def verify(path, sha_path, verbose):
102102
return verified
103103

104104

105-
def unpack(tarball, dst, verbose=False, match=None):
105+
def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
106106
"""Unpack the given tarball file"""
107107
print("extracting", tarball)
108-
fname = os.path.basename(tarball).replace(".tar.gz", "")
108+
fname = os.path.basename(tarball).replace(tarball_suffix, "")
109109
with contextlib.closing(tarfile.open(tarball)) as tar:
110110
for member in tar.getnames():
111111
if "/" not in member:
@@ -331,6 +331,7 @@ def __init__(self):
331331
self.use_vendored_sources = ''
332332
self.verbose = False
333333

334+
334335
def download_stage0(self):
335336
"""Fetch the build system for Rust, written in Rust
336337
@@ -344,18 +345,30 @@ def download_stage0(self):
344345
rustc_channel = self.rustc_channel
345346
cargo_channel = self.cargo_channel
346347

348+
def support_xz():
349+
try:
350+
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
351+
temp_path = temp_file.name
352+
with tarfile.open(temp_path, "w:xz") as tar:
353+
pass
354+
return True
355+
except tarfile.CompressionError:
356+
return False
357+
347358
if self.rustc().startswith(self.bin_root()) and \
348359
(not os.path.exists(self.rustc()) or
349360
self.program_out_of_date(self.rustc_stamp())):
350361
if os.path.exists(self.bin_root()):
351362
shutil.rmtree(self.bin_root())
352-
filename = "rust-std-{}-{}.tar.gz".format(
353-
rustc_channel, self.build)
363+
tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz'
364+
filename = "rust-std-{}-{}{}".format(
365+
rustc_channel, self.build, tarball_suffix)
354366
pattern = "rust-std-{}".format(self.build)
355-
self._download_stage0_helper(filename, pattern)
367+
self._download_stage0_helper(filename, pattern, tarball_suffix)
356368

357-
filename = "rustc-{}-{}.tar.gz".format(rustc_channel, self.build)
358-
self._download_stage0_helper(filename, "rustc")
369+
filename = "rustc-{}-{}{}".format(rustc_channel, self.build,
370+
tarball_suffix)
371+
self._download_stage0_helper(filename, "rustc", tarball_suffix)
359372
self.fix_executable("{}/bin/rustc".format(self.bin_root()))
360373
self.fix_executable("{}/bin/rustdoc".format(self.bin_root()))
361374
with output(self.rustc_stamp()) as rust_stamp:
@@ -365,20 +378,22 @@ def download_stage0(self):
365378
# libraries/binaries that are included in rust-std with
366379
# the system MinGW ones.
367380
if "pc-windows-gnu" in self.build:
368-
filename = "rust-mingw-{}-{}.tar.gz".format(
369-
rustc_channel, self.build)
370-
self._download_stage0_helper(filename, "rust-mingw")
381+
filename = "rust-mingw-{}-{}{}".format(
382+
rustc_channel, self.build, tarball_suffix)
383+
self._download_stage0_helper(filename, "rust-mingw", tarball_suffix)
371384

372385
if self.cargo().startswith(self.bin_root()) and \
373386
(not os.path.exists(self.cargo()) or
374387
self.program_out_of_date(self.cargo_stamp())):
375-
filename = "cargo-{}-{}.tar.gz".format(cargo_channel, self.build)
376-
self._download_stage0_helper(filename, "cargo")
388+
tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz'
389+
filename = "cargo-{}-{}{}".format(cargo_channel, self.build,
390+
tarball_suffix)
391+
self._download_stage0_helper(filename, "cargo", tarball_suffix)
377392
self.fix_executable("{}/bin/cargo".format(self.bin_root()))
378393
with output(self.cargo_stamp()) as cargo_stamp:
379394
cargo_stamp.write(self.date)
380395

381-
def _download_stage0_helper(self, filename, pattern):
396+
def _download_stage0_helper(self, filename, pattern, tarball_suffix):
382397
cache_dst = os.path.join(self.build_dir, "cache")
383398
rustc_cache = os.path.join(cache_dst, self.date)
384399
if not os.path.exists(rustc_cache):
@@ -388,7 +403,7 @@ def _download_stage0_helper(self, filename, pattern):
388403
tarball = os.path.join(rustc_cache, filename)
389404
if not os.path.exists(tarball):
390405
get("{}/{}".format(url, filename), tarball, verbose=self.verbose)
391-
unpack(tarball, self.bin_root(), match=pattern, verbose=self.verbose)
406+
unpack(tarball, tarball_suffix, self.bin_root(), match=pattern, verbose=self.verbose)
392407

393408
@staticmethod
394409
def fix_executable(fname):

src/bootstrap/builder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,8 @@ impl<'a> Builder<'a> {
12421242
cargo.arg("--frozen");
12431243
}
12441244

1245-
cargo.env("RUSTC_INSTALL_BINDIR", &self.config.bindir);
1245+
// Try to use a sysroot-relative bindir, in case it was configured absolutely.
1246+
cargo.env("RUSTC_INSTALL_BINDIR", self.config.bindir_relative());
12461247

12471248
self.ci_env.force_coloring_in_ci(&mut cargo);
12481249

src/bootstrap/config.rs

+14
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,20 @@ impl Config {
647647
config
648648
}
649649

650+
/// Try to find the relative path of `bindir`, otherwise return it in full.
651+
pub fn bindir_relative(&self) -> &Path {
652+
let bindir = &self.bindir;
653+
if bindir.is_absolute() {
654+
// Try to make it relative to the prefix.
655+
if let Some(prefix) = &self.prefix {
656+
if let Ok(stripped) = bindir.strip_prefix(prefix) {
657+
return stripped;
658+
}
659+
}
660+
}
661+
bindir
662+
}
663+
650664
/// Try to find the relative path of `libdir`.
651665
pub fn libdir_relative(&self) -> Option<&Path> {
652666
let libdir = self.libdir.as_ref()?;

src/doc/rustdoc/src/unstable-features.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,24 @@ item, it will be accompanied by a banner explaining that the item is only availa
106106
platforms.
107107

108108
For Rustdoc to document an item, it needs to see it, regardless of what platform it's currently
109-
running on. To aid this, Rustdoc sets the flag `#[cfg(rustdoc)]` when running on your crate.
109+
running on. To aid this, Rustdoc sets the flag `#[cfg(doc)]` when running on your crate.
110110
Combining this with the target platform of a given item allows it to appear when building your crate
111111
normally on that platform, as well as when building documentation anywhere.
112112

113-
For example, `#[cfg(any(windows, rustdoc))]` will preserve the item either on Windows or during the
113+
For example, `#[cfg(any(windows, doc))]` will preserve the item either on Windows or during the
114114
documentation process. Then, adding a new attribute `#[doc(cfg(windows))]` will tell Rustdoc that
115115
the item is supposed to be used on Windows. For example:
116116

117117
```rust
118118
#![feature(doc_cfg)]
119119

120120
/// Token struct that can only be used on Windows.
121-
#[cfg(any(windows, rustdoc))]
121+
#[cfg(any(windows, doc))]
122122
#[doc(cfg(windows))]
123123
pub struct WindowsToken;
124124

125125
/// Token struct that can only be used on Unix.
126-
#[cfg(any(unix, rustdoc))]
126+
#[cfg(any(unix, doc))]
127127
#[doc(cfg(unix))]
128128
pub struct UnixToken;
129129
```

src/doc/unstable-book/src/language-features/doc-cfg.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This attribute has two effects:
1313
2. The item's doc-tests will only run on the specific platform.
1414

1515
In addition to allowing the use of the `#[doc(cfg)]` attribute, this feature enables the use of a
16-
special conditional compilation flag, `#[cfg(rustdoc)]`, set whenever building documentation on your
16+
special conditional compilation flag, `#[cfg(doc)]`, set whenever building documentation on your
1717
crate.
1818

1919
This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the
@@ -22,7 +22,7 @@ standard library be documented.
2222
```rust
2323
#![feature(doc_cfg)]
2424

25-
#[cfg(any(windows, rustdoc))]
25+
#[cfg(any(windows, doc))]
2626
#[doc(cfg(windows))]
2727
/// The application's icon in the notification area (a.k.a. system tray).
2828
///

src/libcore/iter/traits/iterator.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,13 @@ pub trait Iterator {
201201

202202
/// Consumes the iterator, counting the number of iterations and returning it.
203203
///
204-
/// This method will evaluate the iterator until its [`next`] returns
205-
/// [`None`]. Once [`None`] is encountered, `count()` returns the number of
206-
/// times it called [`next`].
204+
/// This method will call [`next`] repeatedly until [`None`] is encountered,
205+
/// returning the number of times it saw [`Some`]. Note that [`next`] has to be
206+
/// called at least once even if the iterator does not have any elements.
207207
///
208208
/// [`next`]: #tymethod.next
209209
/// [`None`]: ../../std/option/enum.Option.html#variant.None
210+
/// [`Some`]: ../../std/option/enum.Option.html#variant.Some
210211
///
211212
/// # Overflow Behavior
212213
///

src/libcore/result.rs

+22
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,28 @@ impl<T, E> Result<T, E> {
514514
}
515515
}
516516

517+
/// Applies a function to the contained value (if any),
518+
/// or returns the provided default (if not).
519+
///
520+
/// # Examples
521+
///
522+
/// ```
523+
/// #![feature(result_map_or)]
524+
/// let x: Result<_, &str> = Ok("foo");
525+
/// assert_eq!(x.map_or(42, |v| v.len()), 3);
526+
///
527+
/// let x: Result<&str, _> = Err("bar");
528+
/// assert_eq!(x.map_or(42, |v| v.len()), 42);
529+
/// ```
530+
#[inline]
531+
#[unstable(feature = "result_map_or", issue = "66293")]
532+
pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U {
533+
match self {
534+
Ok(t) => f(t),
535+
Err(_) => default,
536+
}
537+
}
538+
517539
/// Maps a `Result<T, E>` to `U` by applying a function to a
518540
/// contained [`Ok`] value, or a fallback function to a
519541
/// contained [`Err`] value.

src/librustc/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ byteorder = { version = "1.3" }
4040
chalk-engine = { version = "0.9.0", default-features=false }
4141
rustc_fs_util = { path = "../librustc_fs_util" }
4242
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
43-
measureme = "0.4"

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ pub mod util {
124124
pub mod captures;
125125
pub mod common;
126126
pub mod nodemap;
127-
pub mod profiling;
128127
pub mod bug;
129128
}
130129

src/librustc/lint/context.rs

+1-26
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ use crate::util::common::time;
3535
use errors::DiagnosticBuilder;
3636
use std::slice;
3737
use rustc_data_structures::sync::{self, ParallelIterator, join, par_iter};
38-
use rustc_serialize::{Decoder, Decodable, Encoder, Encodable};
3938
use syntax::ast;
4039
use syntax::util::lev_distance::find_best_match_for_name;
4140
use syntax::visit as ast_visit;
@@ -71,7 +70,7 @@ pub struct LintStore {
7170

7271
/// Lints that are buffered up early on in the `Session` before the
7372
/// `LintLevels` is calculated
74-
#[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)]
73+
#[derive(PartialEq, Debug)]
7574
pub struct BufferedEarlyLint {
7675
pub lint_id: LintId,
7776
pub ast_id: ast::NodeId,
@@ -1574,27 +1573,3 @@ pub fn check_ast_crate<T: EarlyLintPass>(
15741573
}
15751574
}
15761575
}
1577-
1578-
impl Encodable for LintId {
1579-
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
1580-
s.emit_str(&self.lint.name.to_lowercase())
1581-
}
1582-
}
1583-
1584-
impl Decodable for LintId {
1585-
#[inline]
1586-
fn decode<D: Decoder>(d: &mut D) -> Result<LintId, D::Error> {
1587-
let s = d.read_str()?;
1588-
ty::tls::with(|tcx| {
1589-
match tcx.lint_store.find_lints(&s) {
1590-
Ok(ids) => {
1591-
if ids.len() != 0 {
1592-
panic!("invalid lint-id `{}`", s);
1593-
}
1594-
Ok(ids[0])
1595-
}
1596-
Err(_) => panic!("invalid lint-id `{}`", s),
1597-
}
1598-
})
1599-
}
1600-
}

src/librustc/middle/cstore.rs

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::path::{Path, PathBuf};
1515
use syntax::ast;
1616
use syntax::symbol::Symbol;
1717
use syntax_pos::Span;
18+
use syntax::expand::allocator::AllocatorKind;
1819
use rustc_target::spec::Target;
1920
use rustc_data_structures::sync::{self, MetadataRef};
2021
use rustc_macros::HashStable;
@@ -227,6 +228,8 @@ pub trait CrateStore {
227228
// utility functions
228229
fn encode_metadata(&self, tcx: TyCtxt<'_>) -> EncodedMetadata;
229230
fn metadata_encoding_version(&self) -> &[u8];
231+
fn injected_panic_runtime(&self) -> Option<CrateNum>;
232+
fn allocator_kind(&self) -> Option<AllocatorKind>;
230233
}
231234

232235
pub type CrateStoreDyn = dyn CrateStore + sync::Sync;

src/librustc/session/mod.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ pub use self::code_stats::{DataTypeKind, SizeKind, FieldInfo, VariantInfo};
22
use self::code_stats::CodeStats;
33

44
use crate::dep_graph::cgu_reuse_tracker::CguReuseTracker;
5-
use crate::hir::def_id::CrateNum;
65
use rustc_data_structures::fingerprint::Fingerprint;
76

87
use crate::lint;
@@ -22,18 +21,17 @@ use errors::emitter::{Emitter, EmitterWriter};
2221
use errors::emitter::HumanReadableErrorType;
2322
use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
2423
use syntax::edition::Edition;
25-
use syntax::expand::allocator::AllocatorKind;
2624
use syntax::feature_gate::{self, AttributeType};
2725
use syntax::json::JsonEmitter;
2826
use syntax::source_map;
2927
use syntax::sess::{ParseSess, ProcessCfgMod};
3028
use syntax::symbol::Symbol;
3129
use syntax_pos::{MultiSpan, Span};
32-
use crate::util::profiling::{SelfProfiler, SelfProfilerRef};
3330

3431
use rustc_target::spec::{PanicStrategy, RelroLevel, Target, TargetTriple};
3532
use rustc_data_structures::flock;
3633
use rustc_data_structures::jobserver;
34+
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
3735
use ::jobserver::Client;
3836

3937
use std;
@@ -102,12 +100,6 @@ pub struct Session {
102100
/// The maximum number of stackframes allowed in const eval.
103101
pub const_eval_stack_frame_limit: usize,
104102

105-
/// The `metadata::creader` module may inject an allocator/`panic_runtime`
106-
/// dependency if it didn't already find one, and this tracks what was
107-
/// injected.
108-
pub allocator_kind: Once<Option<AllocatorKind>>,
109-
pub injected_panic_runtime: Once<Option<CrateNum>>,
110-
111103
/// Map from imported macro spans (which consist of
112104
/// the localized span for the macro body) to the
113105
/// macro name and definition span in the source crate.
@@ -1099,7 +1091,6 @@ fn build_session_(
10991091
);
11001092
match profiler {
11011093
Ok(profiler) => {
1102-
crate::ty::query::QueryName::register_with_profiler(&profiler);
11031094
Some(Arc::new(profiler))
11041095
},
11051096
Err(e) => {
@@ -1182,8 +1173,6 @@ fn build_session_(
11821173
recursion_limit: Once::new(),
11831174
type_length_limit: Once::new(),
11841175
const_eval_stack_frame_limit: 100,
1185-
allocator_kind: Once::new(),
1186-
injected_panic_runtime: Once::new(),
11871176
imported_macro_spans: OneThread::new(RefCell::new(FxHashMap::default())),
11881177
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
11891178
cgu_reuse_tracker,

0 commit comments

Comments
 (0)