Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 14 pull requests #66366

Merged
merged 47 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7550b61
Fix documentation for `Iterator::count()`.
ArturKovacs Nov 4, 2019
6ce3e1d
Fixed trailing whitespace.
ArturKovacs Nov 4, 2019
23be25c
Improve wording in the documentation of `Iterator::count()`.
ArturKovacs Nov 4, 2019
0282c27
rename cfg(rustdoc) into cfg(doc)
GuillaumeGomez Nov 6, 2019
b7c0e46
Add long error explanation for E0623
GuillaumeGomez Nov 7, 2019
ffc1c5a
Update ui tests
GuillaumeGomez Nov 7, 2019
413ab57
docs: Fix link to BufWriter::flush
bryanburgers Nov 8, 2019
1b8b2ee
add raw ptr variant of UnsafeCell::get
RalfJung Nov 9, 2019
8d56bcc
download .tar.xz if python3 is used
Oct 29, 2019
0019371
bootstrap: don't call support_xz in hot-path
Nov 11, 2019
f9f5a88
Add a callback that allows compiler consumers to override queries.
vakaras Nov 11, 2019
e1cf38a
Move injected_panic_runtime to CrateStore
Mark-Simulacrum Nov 11, 2019
2c6d609
Move allocator_kind to CrateStore
Mark-Simulacrum Nov 11, 2019
1aee3e4
Use a relative bindir for rustdoc to find rustc
cuviper Nov 11, 2019
e8f3a9f
add Result::map_or
tesuji Nov 11, 2019
eb99c73
Match constructor first in Constructor methods
Nadrieril Nov 12, 2019
357d53c
Introduce Constructor::NonExhaustive
Nadrieril Nov 12, 2019
e398d89
Move NonExhaustive checks to the relevant match branches
Nadrieril Nov 12, 2019
ec45882
Add test for issue-30904
JohnTitor Nov 12, 2019
bae9832
Add test for issue-40231
JohnTitor Nov 12, 2019
412f000
Add test for issue-52432
JohnTitor Nov 12, 2019
74d45af
Add test for issue-63279
JohnTitor Nov 12, 2019
bfa5e5f
Fallback to the unmodified path in bindir_relative
cuviper Nov 12, 2019
f696b21
Move self-profile infrastructure to data structures
Mark-Simulacrum Nov 11, 2019
8c29b74
Remove dead code for encoding/decoding lint IDs
Mark-Simulacrum Nov 12, 2019
2fd5454
Register queries with self profiler in rustc_interface
Mark-Simulacrum Nov 12, 2019
6a3a055
Update error_codes.rs
Dylan-DPC Nov 13, 2019
1de094a
Update error_codes.rs
Dylan-DPC Nov 13, 2019
fd868d4
tidy up!
Dylan-DPC Nov 13, 2019
aba385a
Trailing full stop
RalfJung Nov 13, 2019
19ebe2f
clarify why we can do the ptr cast
RalfJung Nov 13, 2019
5b5ae01
expand docs
RalfJung Nov 13, 2019
861698a
make things ugly
RalfJung Nov 13, 2019
4ac230a
Rollup merge of #65932 - guanqun:download-xz, r=alexcrichton
JohnTitor Nov 13, 2019
e365d5a
Rollup merge of #66094 - ArturKovacs:fix-count-doc, r=Dylan-DPC
JohnTitor Nov 13, 2019
6eea500
Rollup merge of #66166 - GuillaumeGomez:rename-rustdoc-to-doc, r=Quie…
JohnTitor Nov 13, 2019
be3fcf4
Rollup merge of #66186 - GuillaumeGomez:long-err-explanation-E0623, r…
JohnTitor Nov 13, 2019
fac0982
Rollup merge of #66227 - bryanburgers:bufwriter-docs-fix-flush-link, …
JohnTitor Nov 13, 2019
689cc04
Rollup merge of #66248 - RalfJung:unsafe_cell_raw_get, r=SimonSapin
JohnTitor Nov 13, 2019
961d51d
Rollup merge of #66292 - lzutao:result-map_or, r=SimonSapin
JohnTitor Nov 13, 2019
c75a48a
Rollup merge of #66297 - vakaras:edit-queries, r=oli-obk
JohnTitor Nov 13, 2019
1cbd34f
Rollup merge of #66317 - cuviper:bindir_relative, r=Mark-Simulacrum
JohnTitor Nov 13, 2019
60ba5c7
Rollup merge of #66330 - Nadrieril:nonexhaustive-constructor, r=varkor
JohnTitor Nov 13, 2019
5683fe5
Rollup merge of #66331 - JohnTitor:add-tests, r=Centril
JohnTitor Nov 13, 2019
f735cd2
Rollup merge of #66334 - Mark-Simulacrum:sess-cstore, r=petrochenkov
JohnTitor Nov 13, 2019
fab583b
Rollup merge of #66335 - Mark-Simulacrum:self-profile-to-data, r=mich…
JohnTitor Nov 13, 2019
d52dafd
Rollup merge of #66337 - Mark-Simulacrum:no-decode-lint-id, r=Dylan-DPC
JohnTitor Nov 13, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3120,7 +3120,6 @@ dependencies = [
"graphviz",
"jobserver",
"log",
"measureme",
"num_cpus",
"parking_lot 0.9.0",
"polonius-engine",
Expand Down Expand Up @@ -3470,6 +3469,7 @@ dependencies = [
name = "rustc_data_structures"
version = "0.0.0"
dependencies = [
"bitflags",
"cfg-if",
"crossbeam-utils 0.6.5",
"ena",
Expand All @@ -3478,6 +3478,7 @@ dependencies = [
"jobserver",
"lazy_static 1.3.0",
"log",
"measureme",
"parking_lot 0.9.0",
"rustc-hash",
"rustc-rayon 0.3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() {
let mut dylib_path = bootstrap::util::dylib_path();
dylib_path.insert(0, PathBuf::from(libdir.clone()));

//FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
//FIXME(misdreavus): once stdsimd uses cfg(doc) instead of cfg(dox), remove the `--cfg dox`
//arguments here
let mut cmd = Command::new(rustdoc);
cmd.args(&args)
Expand Down
43 changes: 29 additions & 14 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ def verify(path, sha_path, verbose):
return verified


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


def download_stage0(self):
"""Fetch the build system for Rust, written in Rust

Expand All @@ -344,18 +345,30 @@ def download_stage0(self):
rustc_channel = self.rustc_channel
cargo_channel = self.cargo_channel

def support_xz():
try:
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
temp_path = temp_file.name
with tarfile.open(temp_path, "w:xz") as tar:
pass
return True
except tarfile.CompressionError:
return False

if self.rustc().startswith(self.bin_root()) and \
(not os.path.exists(self.rustc()) or
self.program_out_of_date(self.rustc_stamp())):
if os.path.exists(self.bin_root()):
shutil.rmtree(self.bin_root())
filename = "rust-std-{}-{}.tar.gz".format(
rustc_channel, self.build)
tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz'
filename = "rust-std-{}-{}{}".format(
rustc_channel, self.build, tarball_suffix)
pattern = "rust-std-{}".format(self.build)
self._download_stage0_helper(filename, pattern)
self._download_stage0_helper(filename, pattern, tarball_suffix)

filename = "rustc-{}-{}.tar.gz".format(rustc_channel, self.build)
self._download_stage0_helper(filename, "rustc")
filename = "rustc-{}-{}{}".format(rustc_channel, self.build,
tarball_suffix)
self._download_stage0_helper(filename, "rustc", tarball_suffix)
self.fix_executable("{}/bin/rustc".format(self.bin_root()))
self.fix_executable("{}/bin/rustdoc".format(self.bin_root()))
with output(self.rustc_stamp()) as rust_stamp:
Expand All @@ -365,20 +378,22 @@ def download_stage0(self):
# libraries/binaries that are included in rust-std with
# the system MinGW ones.
if "pc-windows-gnu" in self.build:
filename = "rust-mingw-{}-{}.tar.gz".format(
rustc_channel, self.build)
self._download_stage0_helper(filename, "rust-mingw")
filename = "rust-mingw-{}-{}{}".format(
rustc_channel, self.build, tarball_suffix)
self._download_stage0_helper(filename, "rust-mingw", tarball_suffix)

if self.cargo().startswith(self.bin_root()) and \
(not os.path.exists(self.cargo()) or
self.program_out_of_date(self.cargo_stamp())):
filename = "cargo-{}-{}.tar.gz".format(cargo_channel, self.build)
self._download_stage0_helper(filename, "cargo")
tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz'
filename = "cargo-{}-{}{}".format(cargo_channel, self.build,
tarball_suffix)
self._download_stage0_helper(filename, "cargo", tarball_suffix)
self.fix_executable("{}/bin/cargo".format(self.bin_root()))
with output(self.cargo_stamp()) as cargo_stamp:
cargo_stamp.write(self.date)

def _download_stage0_helper(self, filename, pattern):
def _download_stage0_helper(self, filename, pattern, tarball_suffix):
cache_dst = os.path.join(self.build_dir, "cache")
rustc_cache = os.path.join(cache_dst, self.date)
if not os.path.exists(rustc_cache):
Expand All @@ -388,7 +403,7 @@ def _download_stage0_helper(self, filename, pattern):
tarball = os.path.join(rustc_cache, filename)
if not os.path.exists(tarball):
get("{}/{}".format(url, filename), tarball, verbose=self.verbose)
unpack(tarball, self.bin_root(), match=pattern, verbose=self.verbose)
unpack(tarball, tarball_suffix, self.bin_root(), match=pattern, verbose=self.verbose)

@staticmethod
def fix_executable(fname):
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,8 @@ impl<'a> Builder<'a> {
cargo.arg("--frozen");
}

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

self.ci_env.force_coloring_in_ci(&mut cargo);

Expand Down
14 changes: 14 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,20 @@ impl Config {
config
}

/// Try to find the relative path of `bindir`, otherwise return it in full.
pub fn bindir_relative(&self) -> &Path {
let bindir = &self.bindir;
if bindir.is_absolute() {
// Try to make it relative to the prefix.
if let Some(prefix) = &self.prefix {
if let Ok(stripped) = bindir.strip_prefix(prefix) {
return stripped;
}
}
}
bindir
}

/// Try to find the relative path of `libdir`.
pub fn libdir_relative(&self) -> Option<&Path> {
let libdir = self.libdir.as_ref()?;
Expand Down
8 changes: 4 additions & 4 deletions src/doc/rustdoc/src/unstable-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,24 @@ item, it will be accompanied by a banner explaining that the item is only availa
platforms.

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

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

```rust
#![feature(doc_cfg)]

/// Token struct that can only be used on Windows.
#[cfg(any(windows, rustdoc))]
#[cfg(any(windows, doc))]
#[doc(cfg(windows))]
pub struct WindowsToken;

/// Token struct that can only be used on Unix.
#[cfg(any(unix, rustdoc))]
#[cfg(any(unix, doc))]
#[doc(cfg(unix))]
pub struct UnixToken;
```
Expand Down
4 changes: 2 additions & 2 deletions src/doc/unstable-book/src/language-features/doc-cfg.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This attribute has two effects:
2. The item's doc-tests will only run on the specific platform.

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

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

#[cfg(any(windows, rustdoc))]
#[cfg(any(windows, doc))]
#[doc(cfg(windows))]
/// The application's icon in the notification area (a.k.a. system tray).
///
Expand Down
39 changes: 38 additions & 1 deletion src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1545,9 +1545,46 @@ impl<T: ?Sized> UnsafeCell<T> {
#[stable(feature = "rust1", since = "1.0.0")]
pub const fn get(&self) -> *mut T {
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of
// #[repr(transparent)]
// #[repr(transparent)]. This exploits libstd's special status, there is
// no guarantee for user code that this will work in future versions of the compiler!
self as *const UnsafeCell<T> as *const T as *mut T
}

/// Gets a mutable pointer to the wrapped value.
/// The difference to [`get`] is that this function accepts a raw pointer,
/// which is useful to avoid the creation of temporary references.
///
/// The result can be cast to a pointer of any kind.
/// Ensure that the access is unique (no active references, mutable or not)
/// when casting to `&mut T`, and ensure that there are no mutations
/// or mutable aliases going on when casting to `&T`.
///
/// [`get`]: #method.get
///
/// # Examples
///
/// Gradual initialization of an `UnsafeCell` requires `raw_get`, as
/// calling `get` would require creating a reference to uninitialized data:
///
/// ```
/// #![feature(unsafe_cell_raw_get)]
/// use std::cell::UnsafeCell;
/// use std::mem::MaybeUninit;
///
/// let m = MaybeUninit::<UnsafeCell<i32>>::uninit();
/// unsafe { UnsafeCell::raw_get(m.as_ptr()).write(5); }
/// let uc = unsafe { m.assume_init() };
///
/// assert_eq!(uc.into_inner(), 5);
/// ```
#[inline]
#[unstable(feature = "unsafe_cell_raw_get", issue = "66358")]
pub const fn raw_get(this: *const Self) -> *mut T {
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of
// #[repr(transparent)]. This exploits libstd's special status, there is
// no guarantee for user code that this will work in future versions of the compiler!
this as *const T as *mut T
}
}

#[stable(feature = "unsafe_cell_default", since = "1.10.0")]
Expand Down
7 changes: 4 additions & 3 deletions src/libcore/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,13 @@ pub trait Iterator {

/// Consumes the iterator, counting the number of iterations and returning it.
///
/// This method will evaluate the iterator until its [`next`] returns
/// [`None`]. Once [`None`] is encountered, `count()` returns the number of
/// times it called [`next`].
/// This method will call [`next`] repeatedly until [`None`] is encountered,
/// returning the number of times it saw [`Some`]. Note that [`next`] has to be
/// called at least once even if the iterator does not have any elements.
///
/// [`next`]: #tymethod.next
/// [`None`]: ../../std/option/enum.Option.html#variant.None
/// [`Some`]: ../../std/option/enum.Option.html#variant.Some
///
/// # Overflow Behavior
///
Expand Down
22 changes: 22 additions & 0 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,28 @@ impl<T, E> Result<T, E> {
}
}

/// Applies a function to the contained value (if any),
/// or returns the provided default (if not).
///
/// # Examples
///
/// ```
/// #![feature(result_map_or)]
/// let x: Result<_, &str> = Ok("foo");
/// assert_eq!(x.map_or(42, |v| v.len()), 3);
///
/// let x: Result<&str, _> = Err("bar");
/// assert_eq!(x.map_or(42, |v| v.len()), 42);
/// ```
#[inline]
#[unstable(feature = "result_map_or", issue = "66293")]
pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U {
match self {
Ok(t) => f(t),
Err(_) => default,
}
}

/// Maps a `Result<T, E>` to `U` by applying a function to a
/// contained [`Ok`] value, or a fallback function to a
/// contained [`Err`] value.
Expand Down
1 change: 0 additions & 1 deletion src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ byteorder = { version = "1.3" }
chalk-engine = { version = "0.9.0", default-features=false }
rustc_fs_util = { path = "../librustc_fs_util" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
measureme = "0.4"
46 changes: 45 additions & 1 deletion src/librustc/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,51 @@ fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
```
"##,

E0623: r##"
A lifetime didn't match what was expected.

Erroneous code example:

```compile_fail,E0623
struct Foo<'a> {
x: &'a isize,
}

fn bar<'short, 'long>(c: Foo<'short>, l: &'long isize) {
let _: Foo<'long> = c; // error!
}
```

In this example, we tried to set a value with an incompatible lifetime to
another one (`'long` is unrelated to `'short`). We can solve this issue in
two different ways:

Either we make `'short` live at least as long as `'long`:

```
struct Foo<'a> {
x: &'a isize,
}

// we set 'short to live at least as long as 'long
fn bar<'short: 'long, 'long>(c: Foo<'short>, l: &'long isize) {
let _: Foo<'long> = c; // ok!
}
```

Or we use only one lifetime:

```
struct Foo<'a> {
x: &'a isize,
}

fn bar<'short>(c: Foo<'short>, l: &'short isize) {
let _: Foo<'short> = c; // ok!
}
```
"##,

E0635: r##"
The `#![feature]` attribute specified an unknown feature.

Expand Down Expand Up @@ -2329,7 +2374,6 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
E0488, // lifetime of variable does not enclose its declaration
E0489, // type/lifetime parameter not in scope here
E0490, // a value of type `..` is borrowed for too long
E0623, // lifetime mismatch where both parameters are anonymous regions
E0628, // generators cannot have explicit parameters
E0631, // type mismatch in closure arguments
E0637, // "'_" is not a valid lifetime bound
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ pub mod util {
pub mod captures;
pub mod common;
pub mod nodemap;
pub mod profiling;
pub mod bug;
}

Expand Down
Loading