]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #73990 - jumbatm:clashing-extern-decl, r=nagisa
bors [Thu, 30 Jul 2020 14:36:41 +0000 (14:36 +0000)]
Auto merge of #73990 - jumbatm:clashing-extern-decl, r=nagisa

Fix incorrect clashing_extern_declarations warnings.

Fixes #73735, fixes #73872.

Fix clashing_extern_declarations warning for `#[repr(transparent)]` structs and safely-FFI-convertible enums, and not warning for clashes of struct members of different types, but the same size.

r? @nagisa

3 years agoAuto merge of #74930 - ecstatic-morse:const-size-align-of-val, r=oli-obk
bors [Thu, 30 Jul 2020 12:52:41 +0000 (12:52 +0000)]
Auto merge of #74930 - ecstatic-morse:const-size-align-of-val, r=oli-obk

Make `mem::size_of_val` and `mem::align_of_val` unstably const

Implements #46571 but does not stabilize it. I wanted this while working on something today.

The only reason not to immediately stabilize are concerns around [custom DSTs](https://github.com/rust-lang/rust/issues/46571#issuecomment-387669352). That proposal has made zero progress in the last two years and const eval is rich enough to support pretty much any user-defined `len` function as long as nightly features are allowed (`raw_ptr_deref`).

Currently, this raises a `const_err` lint when passed an `extern type`.

r? @oli-obk

cc @rust-lang/wg-const-eval

3 years agoFix missed same-sized member clash in ClashingExternDeclarations.
jumbatm [Tue, 7 Jul 2020 11:08:14 +0000 (21:08 +1000)]
Fix missed same-sized member clash in ClashingExternDeclarations.

3 years agoHandle structs with zst members.
jumbatm [Wed, 15 Jul 2020 07:03:53 +0000 (17:03 +1000)]
Handle structs with zst members.

3 years agoAddress code review comments.
jumbatm [Mon, 13 Jul 2020 13:06:35 +0000 (23:06 +1000)]
Address code review comments.

- Make `is_repr_nullable_ptr` freestanding again to avoid usage of
ImproperCTypesVisitor in ClashingExternDeclarations (and don't
accidentally revert the ParamEnv::reveal_all() fix from a week earlier)
- Revise match condition for 1 Adt, 1 primitive
- Generalise check for non-null type so that it would also work for
ranges which exclude any single value (all bits set, for example)
- Make is_repr_nullable_ptr return the representable type instead of
just a boolean, to avoid adding an additional, independent "source of
truth" about the FFI-compatibility of Option-like enums. Also, rename to
`repr_nullable_ptr`.

3 years agoApply suggested wording changes from code review.
jumbatm [Sat, 4 Jul 2020 02:07:43 +0000 (12:07 +1000)]
Apply suggested wording changes from code review.

Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com>
3 years agoDon't emit clashing decl lint for FFI-safe enums.
jumbatm [Fri, 3 Jul 2020 10:14:05 +0000 (20:14 +1000)]
Don't emit clashing decl lint for FFI-safe enums.

An example of an FFI-safe enum conversion is when converting
Option<NonZeroUsize> to usize. Because the Some value must be non-zero,
rustc can use 0 to represent the None variant, making this conversion is
safe. Furthermore, it can be relied on (and removing this optimisation
already would be a breaking change).

3 years agoAdd additional clashing_extern_decl cases.
jumbatm [Sun, 28 Jun 2020 21:33:15 +0000 (07:33 +1000)]
Add additional clashing_extern_decl cases.

3 years agoAuto merge of #74105 - npmccallum:naked, r=matthewjasper
bors [Thu, 30 Jul 2020 10:58:59 +0000 (10:58 +0000)]
Auto merge of #74105 - npmccallum:naked, r=matthewjasper

Suppress debuginfo on naked function arguments

A function that has no prologue cannot be reasonably expected to support
debuginfo. In fact, the existing code (before this patch) would generate
invalid instructions that caused crashes. We can solve this easily by
just not emitting the debuginfo in this case.

Fixes https://github.com/rust-lang/rust/issues/42779
cc https://github.com/rust-lang/rust/issues/32408

3 years agoAuto merge of #74876 - oli-obk:lumberjack_disable, r=RalfJung
bors [Thu, 30 Jul 2020 03:54:05 +0000 (03:54 +0000)]
Auto merge of #74876 - oli-obk:lumberjack_disable, r=RalfJung

Replace all uses of `log::log_enabled` with `Debug` printers

cc @RalfJung this touches a bunch of logging in the miri engine. There are some visual changes, mainly that in several cases we stop prepending lines with the module path and just have a newline.

3 years agoTest `{align,size}_of_val` in a const context
Dylan MacKenzie [Wed, 29 Jul 2020 21:58:06 +0000 (14:58 -0700)]
Test `{align,size}_of_val` in a const context

3 years agoAuto merge of #74923 - ehuss:update-cargo, r=Mark-Simulacrum
bors [Thu, 30 Jul 2020 02:05:48 +0000 (02:05 +0000)]
Auto merge of #74923 - ehuss:update-cargo, r=Mark-Simulacrum

Update cargo

14 commits in aa6872140ab0fa10f641ab0b981d5330d419e927..974eb438da8ced6e3becda2bbf63d9b643eacdeb
2020-07-23 13:46:27 +0000 to 2020-07-29 16:15:05 +0000
- Fix O0 build scripts by default without `[profile.release]` (rust-lang/cargo#8560)
- Emphasize git dependency version locking behavior. (rust-lang/cargo#8561)
- Update lock file encodings on changes (rust-lang/cargo#8554)
- Fix sporadic lto test failures. (rust-lang/cargo#8559)
- build-std: Fix libraries paths following upstream (rust-lang/cargo#8558)
- Flag git http errors as maybe spurious (rust-lang/cargo#8553)
- Display builtin aliases with `cargo --list` (rust-lang/cargo#8542)
- Check manifest for requiring nonexistent features (rust-lang/cargo#7950)
- Clarify test name filter usage (rust-lang/cargo#8552)
- Revert Cargo Book changes for default edition (rust-lang/cargo#8551)
- Prepare for not defaulting to master branch for git deps (rust-lang/cargo#8522)
- Include `+` for crates.io feature requirements in the Cargo Book section on features (rust-lang/cargo#8547)
- Update termcolor and fwdansi versions (rust-lang/cargo#8540)
- Cargo book nitpick in Manifest section (rust-lang/cargo#8543)

3 years agoAuto merge of #74929 - Manishearth:rollup-z2vflrp, r=Manishearth
bors [Thu, 30 Jul 2020 00:17:51 +0000 (00:17 +0000)]
Auto merge of #74929 - Manishearth:rollup-z2vflrp, r=Manishearth

Rollup of 10 pull requests

Successful merges:

 - #74742 (Remove links to rejected errata 4406 for RFC 4291)
 - #74819 (Point towards `format_spec`; it is in other direction)
 - #74852 (Explain why inlining default ToString impl)
 - #74869 (Make closures and generators a must use types)
 - #74873 (symbol mangling: use ty::print::Print for consts)
 - #74902 (Remove deprecated unstable `{Box,Rc,Arc}::into_raw_non_null` functions)
 - #74904 (Fix some typos in src/librustdoc/clean/auto_trait.rs)
 - #74910 (fence docs: fix example Mutex)
 - #74912 (Fix broken link in unstable book `plugin`)
 - #74927 (Change the target data layout to specify more values)

Failed merges:

r? @ghost

3 years agoMake `{align,size}_of_val` `const`
Dylan MacKenzie [Wed, 29 Jul 2020 21:56:58 +0000 (14:56 -0700)]
Make `{align,size}_of_val` `const`

3 years agoRollup merge of #74927 - Lokathor:Lokathor-patch-1, r=jonas-schievink
Manish Goregaokar [Wed, 29 Jul 2020 23:38:34 +0000 (16:38 -0700)]
Rollup merge of #74927 - Lokathor:Lokathor-patch-1, r=jonas-schievink

Change the target data layout to specify more values

This does not actually alter the previously specified important parts, but apparently `rustc` cares about more layout components than `cargo-xbuild` ever did. This extends the data layout to be a fully specified layout, as given in the error from issue #74767

* Closes https://github.com/rust-lang/rust/issues/74767

3 years agoRollup merge of #74912 - giraffate:fix_broken_link_in_unstable_plugin_book, r=jonas...
Manish Goregaokar [Wed, 29 Jul 2020 23:38:33 +0000 (16:38 -0700)]
Rollup merge of #74912 - giraffate:fix_broken_link_in_unstable_plugin_book, r=jonas-schievink

Fix broken link in unstable book `plugin`

There is broken link in https://doc.rust-lang.org/unstable-book/language-features/plugin.html#lint-plugins.

3 years agoRollup merge of #74910 - RalfJung:fence, r=Mark-Simulacrum
Manish Goregaokar [Wed, 29 Jul 2020 23:38:31 +0000 (16:38 -0700)]
Rollup merge of #74910 - RalfJung:fence, r=Mark-Simulacrum

fence docs: fix example Mutex

Fixes https://github.com/rust-lang/rust/issues/74808

Cc @pca006132

3 years agoRollup merge of #74904 - joshtriplett:typo-fix, r=jonas-schievink
Manish Goregaokar [Wed, 29 Jul 2020 23:38:29 +0000 (16:38 -0700)]
Rollup merge of #74904 - joshtriplett:typo-fix, r=jonas-schievink

Fix some typos in src/librustdoc/clean/auto_trait.rs

3 years agoRollup merge of #74902 - rust-lang:into_raw_non_null, r=dtolnay
Manish Goregaokar [Wed, 29 Jul 2020 23:38:28 +0000 (16:38 -0700)]
Rollup merge of #74902 - rust-lang:into_raw_non_null, r=dtolnay

Remove deprecated unstable `{Box,Rc,Arc}::into_raw_non_null` functions

FCP: https://github.com/rust-lang/rust/issues/47336#issuecomment-619369613

3 years agoRollup merge of #74873 - lcnr:const-print, r=eddyb
Manish Goregaokar [Wed, 29 Jul 2020 23:38:26 +0000 (16:38 -0700)]
Rollup merge of #74873 - lcnr:const-print, r=eddyb

symbol mangling: use ty::print::Print for consts

r? @eddyb

3 years agoRollup merge of #74869 - tmiasko:must-use-closures, r=ecstatic-morse
Manish Goregaokar [Wed, 29 Jul 2020 23:38:24 +0000 (16:38 -0700)]
Rollup merge of #74869 - tmiasko:must-use-closures, r=ecstatic-morse

Make closures and generators a must use types

Warn about unused expressions with closure or generator type. This follows
existing precedence of must use annotations present on `FnOnce`, `FnMut`, `Fn`
traits, which already indirectly apply to closures in some cases, e.g.,:

```rust
fn f() -> impl FnOnce() {
    || {}
}

fn main() {
    // an existing warning: unused implementer of `std::ops::FnOnce` that must be used:
    f();

    // a new warning: unused closure that must be used:
    || {};
}
```

Closes #74691.

3 years agoRollup merge of #74852 - lzutao:inline-rm-tostring, r=nnethercote
Manish Goregaokar [Wed, 29 Jul 2020 23:38:22 +0000 (16:38 -0700)]
Rollup merge of #74852 - lzutao:inline-rm-tostring, r=nnethercote

Explain why inlining default ToString impl

Trying to remove inline attribute from default ToString impl causes regression.
Perf result at <https://github.com/rust-lang/rust/pull/74852#issuecomment-664812994>.

3 years agoRollup merge of #74819 - tmiasko:format-spec, r=joshtriplett
Manish Goregaokar [Wed, 29 Jul 2020 23:38:20 +0000 (16:38 -0700)]
Rollup merge of #74819 - tmiasko:format-spec, r=joshtriplett

Point towards `format_spec`; it is in other direction

3 years agoRollup merge of #74742 - poliorcetics:ip-addr-remove-rejected-errata, r=nikomatsakis
Manish Goregaokar [Wed, 29 Jul 2020 23:38:19 +0000 (16:38 -0700)]
Rollup merge of #74742 - poliorcetics:ip-addr-remove-rejected-errata, r=nikomatsakis

Remove links to rejected errata 4406 for RFC 4291

Fixes #74198.

For now I simply removed the links, the docs seems clear enough to me but I'm no expert in the domain so don't hesitate to correct me if more is needed.

cc @ghanan94.

@rustbot modify labels: T-doc, T-libs

3 years agoChange the target data layout to specify more values
Lokathor [Wed, 29 Jul 2020 22:26:09 +0000 (16:26 -0600)]
Change the target data layout to specify more values

This does not actually alter the previously specified important parts, but apparently `rustc` cares about more layout components than `cargo-xbuild` ever did. This extends the data layout to be fully specified layout, as given in the error from issue #74767

3 years agoAuto merge of #73767 - P1n3appl3:rustdoc-formats, r=tmandry
bors [Wed, 29 Jul 2020 22:24:46 +0000 (22:24 +0000)]
Auto merge of #73767 - P1n3appl3:rustdoc-formats, r=tmandry

Refactor librustdoc html backend

This PR moves several types out of the librustdoc::html module so that they can be used by a future json backend. These changes are a re-implementation of [some work done 6 months ago](https://github.com/rust-lang/rust/compare/master...GuillaumeGomez:multiple-output-formats) by @GuillaumeGomez. I'm currently working on said json backend and will put up an RFC soon with the proposed implementation.

There are a couple of changes that are more substantial than relocating structs to a different module:
1. The `Cache` is no longer part of the `html::render::Context` type and therefor it needs to be explicitly passed to any functions that access it.
2. The driving function `html::render::run` has been rewritten to use the `FormatRenderer` trait which should allow different backends to re-use the driving code.

r? @GuillaumeGomez

cc @tmandry @betamos

3 years agoPass by value
Joseph Ryan [Wed, 29 Jul 2020 21:48:22 +0000 (16:48 -0500)]
Pass by value

3 years agoRefactor DocFS to fix error handling bugs
Joseph Ryan [Wed, 29 Jul 2020 21:15:31 +0000 (16:15 -0500)]
Refactor DocFS to fix error handling bugs

3 years agoAuto merge of #74733 - richkadel:llvm-coverage-map-gen-5, r=tmandry
bors [Wed, 29 Jul 2020 20:35:52 +0000 (20:35 +0000)]
Auto merge of #74733 - richkadel:llvm-coverage-map-gen-5, r=tmandry

Fixed coverage map issues; better aligned with LLVM APIs

Found some problems with the coverage map encoding when testing with more than one counter per function.

While debugging, I realized some better ways to structure the Rust implementation of the coverage mapping generator. I refactored somewhat, resulting in less code overall, expanded coverage of LLVM Coverage Map capabilities, and much closer alignment with LLVM data structures, APIs, and naming.

This should be easier to follow and easier to maintain.

r? @tmandry

Rust compiler MCP rust-lang/compiler-team#278
Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation

3 years agoUpdate cargo
Eric Huss [Wed, 29 Jul 2020 18:02:05 +0000 (11:02 -0700)]
Update cargo

3 years agoAuto merge of #74837 - xldenis:mir-dump-crate-file, r=oli-obk
bors [Wed, 29 Jul 2020 17:50:30 +0000 (17:50 +0000)]
Auto merge of #74837 - xldenis:mir-dump-crate-file, r=oli-obk

Fix #70767

This PR changes the format of MIR dump filenames to include the crate name rather than `rustc` at the start.

As a result, we can now place mir-opt tests in the same directory as the source files, like with UI tests. I had to make sure that `compiletest` added a bit_width suffix to the expected files when appropriate but otherwise the change is only moving the files to the correct location and ensuring that the `EMIT_MIR` lines are correct.

Fixes #70767
cc @oli-obk

3 years agoAuto merge of #72488 - KodrAus:stabilize/const_type_id, r=nikomatsakis
bors [Wed, 29 Jul 2020 15:58:32 +0000 (15:58 +0000)]
Auto merge of #72488 - KodrAus:stabilize/const_type_id, r=nikomatsakis

Stabilize const_type_id feature

The tracking issue for `const_type_id` points to the ill-fated #41875. So I'm re-energizing `TypeId` shenanigans by opening this one up to see if there's anything blocking us from stabilizing the constification of type ids.

Will wait for CI before pinging teams/groups.

-----

This PR stabilizes the `const_type_id` feature, which allows `TypeId::of` (and the underlying unstable intrinsic) to be called in constant contexts.

There are some [sanity tests](https://github.com/rust-lang/rust/blob/master/src/test/ui/consts/const-typeid-of-rpass.rs) that demonstrate its usage, but I’ve included some more below.

As a simple example, you could create a constant item that contains some type ids:

```rust
use std::any::TypeId;

const TYPE_IDS: [TypeId; 2] = [
    TypeId::of::<u32>(),
    TypeId::of::<i32>(),
];

assert_eq!(TypeId::of::<u32>(), TYPE_IDS[0]);
```

Type ids can also now appear in associated constants. You could create a trait that associates each type with its constant type id:

```rust
trait Any where Self: 'static {
    const TYPE_ID: TypeId = TypeId::of::<Self>();
}

impl<T: 'static> Any for T { }

assert_eq!(TypeId::of::<usize>(), usize::TYPE_ID);
```

`TypeId::of` is generic, which we saw above in the way the generic `Self` argument was used. This has some implications for const evaluation. It means we can make trait impls evaluate differently depending on information that wasn't directly passed through the trait system. This violates the _parametricity_ property, which requires all instances of a generic function to behave the same way with respect to its generic parameters. That's not unique to `TypeId::of`, other generic const functions based on compiler intrinsics like `mem::align_of` can also violate parametricity. In practice Rust doesn't really have type parametricity anyway since it monomorphizes generics into concrete functions, so violating it using type ids isn’t new.

As an example of how impls can behave differently, you could combine constant type ids with the `const_if_match` feature to dispatch calls based on the type id of the generic `Self`, rather than based on information about `Self` that was threaded through trait bounds. It's like a rough-and-ready form of specialization:

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

trait Specialized where Self: 'static {
    // An associated constant that determines the function to call
    // at compile-time based on `TypeId::of::<Self>`.
    const CALL: fn(&Self) = {
        const USIZE: TypeId = TypeId::of::<usize>();

        match TypeId::of::<Self>() {
            // Use a closure for `usize` that transmutes the generic `Self` to
            // a concrete `usize` and dispatches to `Self::usize`.
            USIZE => |x| Self::usize(unsafe { &*(x as *const Self as *const usize) }),
            // For other types, dispatch to the generic `Self::default`.
            _ => Self::default,
        }
    };

    fn call(&self) {
        // Call the function we determined at compile-time
        (Self::CALL)(self)
    }

    fn default(x: &Self);
    fn usize(x: &usize);
}

// Implement our `Specialized` trait for any `Debug` type.
impl<T: fmt::Debug + 'static> Specialized for T {
    fn default(x: &Self) {
        println!("default: {:?}", x);
    }

    fn usize(x: &usize) {
        println!("usize: {:?}", x);
    }
}

// Will print "usize: 42"
Specialized::call(&42usize);

// Will print "default: ()"
Specialized::call(&());
```

Type ids have some edges that this stabilization exposes to more contexts. It's possible for type ids to collide (but this is a bug). Since they can change between compiler versions, it's never valid to cast a type id to its underlying value.

3 years agoMove mir-opt tests to toplevel
Xavier Denis [Tue, 28 Jul 2020 13:22:21 +0000 (15:22 +0200)]
Move mir-opt tests to toplevel

3 years agoMoved structs/enums with repr(C) to LLVM types into ffi.rs crates
Rich Kadel [Wed, 29 Jul 2020 06:09:16 +0000 (23:09 -0700)]
Moved structs/enums with repr(C) to LLVM types into ffi.rs crates

Some were in librustc_codegen_llvm, but others are not tied to LLVM, so
I put them in a new crate: librustc_codegen_ssa/coverageinfo/ffi.rs

3 years agoFix broken link in unstable book `plugin`
Takayuki Nakata [Wed, 29 Jul 2020 14:21:56 +0000 (23:21 +0900)]
Fix broken link in unstable book `plugin`

3 years agoAuto merge of #72049 - mati865:mingw-lld, r=petrochenkov
bors [Wed, 29 Jul 2020 13:58:19 +0000 (13:58 +0000)]
Auto merge of #72049 - mati865:mingw-lld, r=petrochenkov

MinGW: enable dllexport/dllimport

Fixes (only when using LLD) https://github.com/rust-lang/rust/issues/50176
Fixes https://github.com/rust-lang/rust/issues/72319

This makes `windows-gnu` on pair with `windows-msvc` when it comes to symbol exporting.
For MinGW it means both good things like correctly working dllimport/dllexport, ability to link with LLD and bad things like https://github.com/rust-lang/rust/issues/27438.

Not sure but maybe this should land behind unstable compiler option (`-Z`) or environment variable?

3 years agofence docs: fix example Mutex
Ralf Jung [Wed, 29 Jul 2020 13:44:19 +0000 (15:44 +0200)]
fence docs: fix example Mutex

3 years agoAdd test for #50176
Mateusz Mikuła [Fri, 3 Jul 2020 19:00:14 +0000 (21:00 +0200)]
Add test for #50176

3 years agoMinGW: emit dllexport/dllimport by rustc
Mateusz Mikuła [Thu, 7 May 2020 09:52:21 +0000 (11:52 +0200)]
MinGW: emit dllexport/dllimport by rustc

This fixes various cases where LD could not guess dllexport correctly and greatly improves compatibility with LLD which is not going to support linker scripts anytime soon

3 years agoadd crate name to mir dumps
Xavier Denis [Mon, 27 Jul 2020 19:22:43 +0000 (21:22 +0200)]
add crate name to mir dumps

3 years agoAuto merge of #74900 - tmiasko:doc-open, r=Mark-Simulacrum
bors [Wed, 29 Jul 2020 11:19:36 +0000 (11:19 +0000)]
Auto merge of #74900 - tmiasko:doc-open, r=Mark-Simulacrum

Fix opening docs for std crates with ./x.py doc --open library/*

The directories for core, alloc, std, proc_macro, and test crates now
correspond directly to the crate name, and stripping the "lib" prefix is
no longer necessary.

3 years agoFix opening docs for std crates with ./x.py doc --open library/*
Tomasz Miąsko [Wed, 29 Jul 2020 00:00:00 +0000 (00:00 +0000)]
Fix opening docs for std crates with ./x.py doc --open library/*

The directories for core, alloc, std, proc_macro, and test crates now
correspond directly to the crate name and stripping the "lib" prefix is
no longer necessary.

3 years agoFix some typos in src/librustdoc/clean/auto_trait.rs
Josh Triplett [Wed, 29 Jul 2020 10:25:38 +0000 (03:25 -0700)]
Fix some typos in src/librustdoc/clean/auto_trait.rs

3 years agoAddress review comments
Oliver Scherer [Wed, 29 Jul 2020 09:37:33 +0000 (11:37 +0200)]
Address review comments

3 years agoRemove deprecated unstable `{Box,Rc,Arc}::into_raw_non_null` functions
Simon Sapin [Wed, 29 Jul 2020 08:57:16 +0000 (10:57 +0200)]
Remove deprecated unstable `{Box,Rc,Arc}::into_raw_non_null` functions

FCP: https://github.com/rust-lang/rust/issues/47336#issuecomment-619369613

3 years agoAuto merge of #74896 - imbolc:patch-1, r=kennytm
bors [Wed, 29 Jul 2020 08:52:01 +0000 (08:52 +0000)]
Auto merge of #74896 - imbolc:patch-1, r=kennytm

Update `fs::remove_file` docs

Mention that absence of file causes an error

3 years agoLink to syntax section when referencing it
Tomasz Miąsko [Mon, 27 Jul 2020 00:00:00 +0000 (00:00 +0000)]
Link to syntax section when referencing it

3 years agoExplain why inline default ToString impl
Lzu Tao [Wed, 29 Jul 2020 07:38:06 +0000 (07:38 +0000)]
Explain why inline default ToString impl

3 years agoUpdate `fs::remove_file` docs
Imbolc [Wed, 29 Jul 2020 05:18:01 +0000 (08:18 +0300)]
Update `fs::remove_file` docs

Mention that absence of file causes an error

3 years agoAuto merge of #74887 - Mark-Simulacrum:cache-non-exhaustive, r=petrochenkov
bors [Wed, 29 Jul 2020 04:59:37 +0000 (04:59 +0000)]
Auto merge of #74887 - Mark-Simulacrum:cache-non-exhaustive, r=petrochenkov

Cache non-exhaustive separately from attributes

This prevents cross-crate attribute loading from metadata just for non_exhaustive checking; cross-crate attribute loading implies disk reading and is relatively slow.

3 years agoAuto merge of #74894 - JohnTitor:rollup-4ine62a, r=JohnTitor
bors [Wed, 29 Jul 2020 01:38:00 +0000 (01:38 +0000)]
Auto merge of #74894 - JohnTitor:rollup-4ine62a, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #74266 (Clean up E0720 explanation)
 - #74671 (add const generics array coercion test)
 - #74707 (Add str::[r]split_once)
 - #74814 (Fix RefUnwindSafe & UnwinsSafe impls for lazy::SyncLazy)
 - #74859 (Update outdated readme)
 - #74864 (ayu theme: Change doccomment color to `#a1ac88`)
 - #74872 (Enable to ping RISC-V group via triagebot)
 - #74891 (handle ConstEquate in rustdoc)

Failed merges:

r? @ghost

3 years agoFunctionCoverage: improve type checking with newtype_index types
Rich Kadel [Wed, 29 Jul 2020 00:45:58 +0000 (17:45 -0700)]
FunctionCoverage: improve type checking with newtype_index types

3 years agoRollup merge of #74891 - lcnr:auto-trait-finder, r=varkor
Yuki Okushi [Wed, 29 Jul 2020 00:24:25 +0000 (09:24 +0900)]
Rollup merge of #74891 - lcnr:auto-trait-finder, r=varkor

handle ConstEquate in rustdoc

fixes #74882

r? @varkor cc @eddyb

3 years agoRollup merge of #74872 - JohnTitor:ping-risc-v, r=Mark-Simulacrum
Yuki Okushi [Wed, 29 Jul 2020 00:24:24 +0000 (09:24 +0900)]
Rollup merge of #74872 - JohnTitor:ping-risc-v, r=Mark-Simulacrum

Enable to ping RISC-V group via triagebot

We have the RISC-V group (https://github.com/rust-lang/team/blob/master/teams/risc-v.toml) but don't enable to ping on this repository (https://github.com/rust-lang/rust/pull/74813#issuecomment-664841177).
We don't have the instructions on the rustc-dev-guide yet but I'll create it soonish.

3 years agoRollup merge of #74864 - lzutao:ayu-doccolor, r=GuillaumeGomez
Yuki Okushi [Wed, 29 Jul 2020 00:24:22 +0000 (09:24 +0900)]
Rollup merge of #74864 - lzutao:ayu-doccolor, r=GuillaumeGomez

ayu theme: Change doccomment color to `#a1ac88`

Before:
![image](https://user-images.githubusercontent.com/15225902/88621499-d1cbff80-d0ca-11ea-99c3-5e2632709274.png)

After:
![image](https://user-images.githubusercontent.com/15225902/88621471-bf51c600-d0ca-11ea-9455-9c297f50f15f.png)

Close #74788

3 years agoRollup merge of #74859 - mark-i-m:patch-1, r=JohnTitor
Yuki Okushi [Wed, 29 Jul 2020 00:24:20 +0000 (09:24 +0900)]
Rollup merge of #74859 - mark-i-m:patch-1, r=JohnTitor

Update outdated readme

3 years agoRollup merge of #74814 - matklad:unwind-safe, r=KodrAus
Yuki Okushi [Wed, 29 Jul 2020 00:24:19 +0000 (09:24 +0900)]
Rollup merge of #74814 - matklad:unwind-safe, r=KodrAus

Fix RefUnwindSafe & UnwinsSafe impls for lazy::SyncLazy

I *think* we should implement those unconditionally with respect to `F`.

The user code can't observe the closure in any way, and we poison lazy if the closure itself panics.

But I've never fully wrapped my head around `UnwindSafe` traits, so :man_shrugging:

3 years agoRollup merge of #74707 - matklad:split_once, r=dtolnay
Yuki Okushi [Wed, 29 Jul 2020 00:24:17 +0000 (09:24 +0900)]
Rollup merge of #74707 - matklad:split_once, r=dtolnay

Add str::[r]split_once

This is useful for quick&dirty parsing of key: value config pairs. Used a bunch in Cargo and rust-analyzer:

* https://github.com/rust-lang/cargo/search?q=splitn%282&unscoped_q=splitn%282
* https://github.com/rust-analyzer/rust-analyzer/search?q=split_delim&unscoped_q=split_delim

In theory, once const-generics are done, this functionality could be achieved without a dedicated method with

```rust
match s.splitn(delimier, 2).collect_array::<2>() {
  Some([prefix, suffix]) => todo!(),
  None => todo!(),
}
```

Even in that world, having a dedicated method seems clearer on the intention.

I am not sure about naming -- this is something I've just came up with yesterday, I don't know off the top of my head analogs in other languages.

If T-libs thinks this is a reasonable API to have, I'll open a tracking issue and add more thorough tests.

3 years agoRollup merge of #74671 - rust-lang:const-generics-coerce-unsized, r=nikomatsakis
Yuki Okushi [Wed, 29 Jul 2020 00:24:15 +0000 (09:24 +0900)]
Rollup merge of #74671 - rust-lang:const-generics-coerce-unsized, r=nikomatsakis

add const generics array coercion test

3 years agoRollup merge of #74266 - GuillaumeGomez:cleanup-e0720, r=Dylan-DPC
Yuki Okushi [Wed, 29 Jul 2020 00:24:13 +0000 (09:24 +0900)]
Rollup merge of #74266 - GuillaumeGomez:cleanup-e0720, r=Dylan-DPC

Clean up E0720 explanation

r? @Dylan-DPC

3 years agoAuto merge of #74791 - tmiasko:raw-waker-inline, r=LukasKalbertodt
bors [Tue, 28 Jul 2020 23:45:05 +0000 (23:45 +0000)]
Auto merge of #74791 - tmiasko:raw-waker-inline, r=LukasKalbertodt

Add #[inline] to RawWaker::new

`RawWaker::new` is used when creating a new waker or cloning an existing one,
for example as in code below. The `RawWakerVTable::new` can be const evaluated,
but `RawWaker::new` itself cannot since waker pointer is not known at compile
time. Add `#[inline]` to avoid overhead of a function call.

```rust
unsafe fn clone_waker<W: Wake + Send + Sync + 'static>(waker: *const ()) -> RawWaker {
    unsafe { Arc::incr_strong_count(waker as *const W) };
    RawWaker::new(
        waker as *const (),
        &RawWakerVTable::new(clone_waker::<W>, wake::<W>, wake_by_ref::<W>, drop_waker::<W>),
    )
}
```

3 years agoRefactor MIR coverage instrumentation
Rich Kadel [Mon, 27 Jul 2020 23:25:08 +0000 (16:25 -0700)]
Refactor MIR coverage instrumentation

Lays a better foundation for injecting more counters in each function.

3 years agohandle ConstEquate in rustdoc
Bastian Kauschke [Tue, 28 Jul 2020 22:00:55 +0000 (00:00 +0200)]
handle ConstEquate in rustdoc

3 years agoAuto merge of #74861 - mark-i-m:mv-std-followup, r=Mark-Simulacrum
bors [Tue, 28 Jul 2020 21:48:22 +0000 (21:48 +0000)]
Auto merge of #74861 - mark-i-m:mv-std-followup, r=Mark-Simulacrum

Re-enable linkcheck after moving std

3 years agoCache non-exhaustive separately from attributes
Mark Rousskov [Tue, 28 Jul 2020 17:31:48 +0000 (13:31 -0400)]
Cache non-exhaustive separately from attributes

3 years agoAuto merge of #74471 - da-x:string-type-diagnostic-item, r=petrochenkov
bors [Tue, 28 Jul 2020 20:00:37 +0000 (20:00 +0000)]
Auto merge of #74471 - da-x:string-type-diagnostic-item, r=petrochenkov

librustc_typeck: use diag item instead of string compare

3 years agoCollect library features from library/
Mark Rousskov [Tue, 28 Jul 2020 13:52:39 +0000 (09:52 -0400)]
Collect library features from library/

3 years agoreenable tests after moving std
mark [Tue, 28 Jul 2020 04:02:34 +0000 (23:02 -0500)]
reenable tests after moving std

3 years agoAuto merge of #74482 - alexcrichton:update-stdarch, r=hanna-kruppe
bors [Tue, 28 Jul 2020 17:39:39 +0000 (17:39 +0000)]
Auto merge of #74482 - alexcrichton:update-stdarch, r=hanna-kruppe

Update stdarch submodule

This commit updates the src/stdarch submodule primarily to include
rust-lang/stdarch#874 which updated and revamped WebAssembly SIMD
intrinsics and renamed WebAssembly atomics intrinsics. This is all
unstable surface area of the standard library so the changes should be
ok here. The SIMD updates also enable SIMD intrinsics to be used by any
program any any time, yay!

cc #74372, a tracking issue I've opened for the stabilization of SIMD
intrinsics

3 years agoReplace write-to-vec hack by introducing a display renderer for allocations
Oliver Scherer [Tue, 28 Jul 2020 17:16:09 +0000 (19:16 +0200)]
Replace write-to-vec hack by introducing a display renderer for allocations

3 years agoAdd note to clearly mark the RFC as rejected
Alexis Bourget [Sun, 26 Jul 2020 20:00:29 +0000 (22:00 +0200)]
Add note to clearly mark the RFC as rejected

3 years agoRemove links to rejected errata 4406 for RFC 4291
Alexis Bourget [Sat, 25 Jul 2020 12:55:51 +0000 (14:55 +0200)]
Remove links to rejected errata 4406 for RFC 4291

3 years agoUpdate stdarch submodule
Alex Crichton [Sat, 18 Jul 2020 15:43:09 +0000 (08:43 -0700)]
Update stdarch submodule

This commit updates the src/stdarch submodule primarily to include
rust-lang/stdarch#874 which updated and revamped WebAssembly SIMD
intrinsics and renamed WebAssembly atomics intrinsics. This is all
unstable surface area of the standard library so the changes should be
ok here. The SIMD updates also enable SIMD intrinsics to be used by any
program any any time, yay!

cc #74372, a tracking issue I've opened for the stabilization of SIMD
intrinsics

3 years agoReplace all uses of `log::log_enabled` with `Debug` printers
Oliver Scherer [Tue, 28 Jul 2020 14:15:40 +0000 (16:15 +0200)]
Replace all uses of `log::log_enabled` with `Debug` printers

3 years agoAuto merge of #73964 - jyn514:sane-defaults, r=Mark-Simulacrum
bors [Tue, 28 Jul 2020 13:56:32 +0000 (13:56 +0000)]
Auto merge of #73964 - jyn514:sane-defaults, r=Mark-Simulacrum

Improve defaults in x.py

- Make the default stage dependent on the subcommand
- Don't build stage1 rustc artifacts with x.py build --stage 1. If this is what you want, use x.py build --stage 2 instead, which gives you a working libstd.
- Change default debuginfo when debug = true from 2 to 1

I tried to fix CI to use `--stage 2` everywhere it currently has no stage, but I might have missed a spot.
This does not update much of the documentation - most of it is in https://github.com/rust-lang/rustc-dev-guide/ or https://github.com/rust-lang/rust-forge and will need a separate PR.

See individual commits for a detailed rationale of each change.
See also the MCP: https://github.com/rust-lang/compiler-team/issues/326

r? @Mark-Simulacrum , but anyone is free to give an opinion.

3 years agoUse --stage 2 in checktools
Joshua Nelson [Tue, 28 Jul 2020 13:36:56 +0000 (09:36 -0400)]
Use --stage 2 in checktools

- Remove useless --stage 2 argument to checktools.sh
- Fix help text for expand-yaml-anchors (it had a typo)

3 years agoFix bad rebase
Joshua Nelson [Tue, 28 Jul 2020 12:34:59 +0000 (08:34 -0400)]
Fix bad rebase

3 years agosymbol mangling: use ty::print::Print for consts
Bastian Kauschke [Tue, 28 Jul 2020 12:34:18 +0000 (14:34 +0200)]
symbol mangling: use ty::print::Print for consts

3 years agoEnable to ping RISC-V group via triagebot
Yuki Okushi [Tue, 28 Jul 2020 12:01:13 +0000 (21:01 +0900)]
Enable to ping RISC-V group via triagebot

3 years agoAuto merge of #74796 - infinity0:master, r=nikomatsakis
bors [Tue, 28 Jul 2020 09:02:32 +0000 (09:02 +0000)]
Auto merge of #74796 - infinity0:master, r=nikomatsakis

config.toml.example: Update remap-debuginfo doc to be more general & accurate

This makes it more obvious that the work-around to #74786 is actually correct, and a custom `--remap-path-prefix` isn't needed.

In fact the previous comment `/rustc/$hash/$crate` was wrong, it is not `$crate` but whatever path exists in the rustc source tree, so either `src/$crate` or `vendor/$crate`. I've fixed that as well to avoid future confusion.

3 years agoAdd str::[r]split_once
Aleksey Kladov [Fri, 24 Jul 2020 07:39:09 +0000 (09:39 +0200)]
Add str::[r]split_once

This is useful for quick&dirty parsing of key: value config pairs

3 years agoFix RefUnwindSafe & UnwinsSafe impls for lazy::SyncLazy
Aleksey Kladov [Mon, 27 Jul 2020 09:22:36 +0000 (11:22 +0200)]
Fix RefUnwindSafe & UnwinsSafe impls for lazy::SyncLazy

The logic here is the same as for Send&Sync impls.

3 years agoAuto merge of #74855 - jyn514:separate-lints, r=Manishearth
bors [Tue, 28 Jul 2020 05:49:59 +0000 (05:49 +0000)]
Auto merge of #74855 - jyn514:separate-lints, r=Manishearth

Separate `missing_doc_code_examples` from intra-doc links

These two lints have no relation other than both being nightly-only.
This allows stabilizing intra-doc links without stabilizing `missing_doc_code_examples`.

Fixes one of the issues spotted by @ollie27 in https://github.com/rust-lang/rust/pull/74430#issuecomment-664693080.

r? @Manishearth

3 years agoayu theme: Change doccomment color to `#a1ac88`
Lzu Tao [Tue, 28 Jul 2020 05:12:12 +0000 (05:12 +0000)]
ayu theme: Change doccomment color to `#a1ac88`

Co-authored-by: Cldfire <cldfire@3grid.net>
3 years agoupdate stderr for polymorphic ui test
Ashley Mannix [Tue, 28 Jul 2020 04:37:31 +0000 (14:37 +1000)]
update stderr for polymorphic ui test

3 years agoAdd #[inline] to RawWaker::new
Tomasz Miąsko [Sun, 26 Jul 2020 00:00:00 +0000 (00:00 +0000)]
Add #[inline] to RawWaker::new

3 years agoAuto merge of #74841 - infinity0:fix-exec, r=Mark-Simulacrum
bors [Tue, 28 Jul 2020 03:42:22 +0000 (03:42 +0000)]
Auto merge of #74841 - infinity0:fix-exec, r=Mark-Simulacrum

rustbuild: use Display for exit status instead of Debug, see #74832 for justification

3 years agoremove unstable const_type_id feature
Ashley Mannix [Tue, 28 Jul 2020 03:33:08 +0000 (13:33 +1000)]
remove unstable const_type_id feature

3 years agobump const type id stabilization to 1.46.0
Ashley Mannix [Tue, 30 Jun 2020 00:21:22 +0000 (10:21 +1000)]
bump const type id stabilization to 1.46.0

3 years agostabilize const_type_id feature
Ashley Mannix [Sat, 23 May 2020 05:17:19 +0000 (15:17 +1000)]
stabilize const_type_id feature

3 years agoprivate_items_doc_tests -> doc_test_lints
Joshua Nelson [Tue, 28 Jul 2020 03:05:01 +0000 (23:05 -0400)]
private_items_doc_tests -> doc_test_lints

3 years agoUse exhaustive match for assert
Joshua Nelson [Tue, 28 Jul 2020 01:53:10 +0000 (21:53 -0400)]
Use exhaustive match for assert

3 years agoAdd assert that tests happen with stage 2 in CI
Joshua Nelson [Mon, 27 Jul 2020 19:53:01 +0000 (15:53 -0400)]
Add assert that tests happen with stage 2 in CI

- Use stage 2 for makefile
- Move assert to builder
- Don't add an assert for --help
- Allow --stage 0 if passed explicitly
- Don't assert defaults during tests

Otherwise it's impossible to test the defaults!

3 years agoUse --stage 2 explicitly in CI
Joshua Nelson [Tue, 14 Jul 2020 02:28:26 +0000 (22:28 -0400)]
Use --stage 2 explicitly in CI

- expand yaml anchors
- don't use --stage 2 for dist; that's already the default

3 years agoAdd tests for the new behavior
Joshua Nelson [Tue, 14 Jul 2020 00:25:21 +0000 (20:25 -0400)]
Add tests for the new behavior

- Only set stage 2 in dist tests
- Add test for `x.py doc` without args
- Add test for `x.py build` without args
- Add test for `x.py build --stage 0`

3 years agoMove tests into a submodule
Joshua Nelson [Tue, 14 Jul 2020 00:20:42 +0000 (20:20 -0400)]
Move tests into a submodule

3 years agoFix most bootstrap tests
Joshua Nelson [Mon, 13 Jul 2020 23:55:33 +0000 (19:55 -0400)]
Fix most bootstrap tests

Uses --stage 2 for all the existing tests

3 years agoChange debuginfo to default to 1 if `debug = true` is set
Joshua Nelson [Thu, 2 Jul 2020 12:59:50 +0000 (08:59 -0400)]
Change debuginfo to default to 1 if `debug = true` is set

From [a conversation in discord](https://discordapp.com/channels/442252698964721669/443151243398086667/719200989269327882):

> Linking seems to consume all available RAM, leading to the OS to swap memory to disk and slowing down everything in the process
Compiling itself doesn't seem to take up as much RAM, and I'm only looking to check whether a minimal testcase can be compiled by rustc, where the runtime performance isn't much of an issue

> do you have debug = true or debuginfo-level = 2 in config.toml?
> if so I think that results in over 2GB of debuginfo nowadays and is likely the culprit
> which might mean we're giving out bad advice :(

Anecdotally, this sped up my stage 1 build from 15 to 10 minutes.

This still adds line numbers, it only removes variable and type information.

- Improve wording for debuginfo description

Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com>
3 years agoDon't build rustc without std
Joshua Nelson [Thu, 2 Jul 2020 12:40:34 +0000 (08:40 -0400)]
Don't build rustc without std

- Set rustc to build only when explicitly asked for

This allows building the stage2 rustc artifacts, which nothing depends
on.

Previously the behavior was as follows (where stageN <-> stage(N-1) artifacts, except for stage0 libstd):

- `x.py build --stage 0`:
  - stage0 libstd
  - stage1 rustc (but without putting rustc in stage0/)

This leaves you without any rustc at all except for the beta compiler
(https://github.com/rust-lang/rust/issues/73519). This is never what you want.

- `x.py build --stage 1`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage1 rustdoc
  - stage2 rustc

This leaves you with a broken stage2 rustc which doesn't even have
libcore and is effectively useless. Additionally, it compiles rustc
twice, which is not normally what you want.

- `x.py build --stage 2`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage2 rustc
  - stage2 rustdoc and tools

This builds all tools in release mode. This is the correct usage for CI,
but takes far to long for development.

Now the behavior is as follows:

- `x.py build --stage 0`:
  - stage0 libstd

This is suitable for contributors only working on the standard library,
as it means rustc never has to be compiled.

- `x.py build --stage 1`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage1 rustdoc

This is suitable for contributors working on the compiler. It ensures
that you have a working rustc and libstd without having to pass
`src/libstd` in addition.

- `x.py build --stage 2`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage2 rustc
  - stage2 libstd
  - stage2 rustdoc

This is suitable for debugging errors which only appear with the stage2
compiler.

- `x.py build --stage 2 src/libstd src/rustc`
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage2 rustc
  - stage2 libstd
  - stage2 rustdoc, tools, etc.
  - stage2 rustc artifacts ('stage3')

This is suitable for CI, which wants all tools in release mode.
However, most of the use cases for this should use `x.py dist` instead,
which builds all the tools without each having to be named individually.

3 years agoMake the default stage dependent on the subcommand
Joshua Nelson [Thu, 2 Jul 2020 12:08:09 +0000 (08:08 -0400)]
Make the default stage dependent on the subcommand

 ### x.py build/test: stage 1

I've seen very few people who actually use full stage 2 builds on purpose. These compile rustc and libstd twice and don't give you much more information than a stage 1 build (except in rare cases like https://github.com/rust-lang/rust/pull/68692#discussion_r376392145). For new contributors, this makes the build process even more daunting than it already is. As long as CI is changed to use `--stage 2` I see no downside here.

 ### x.py bench/dist/install: stage 2

These commands have to do with a finished, optimized version of rustc. It seems very rare to want to use these with a stage 1 build.

 ### x.py doc: stage 0

Normally when you document things you're just fixing a typo. In this case there is no need to build the whole rust compiler, since the documentation will usually be the same when generated with the beta compiler or with stage 1.

Note that for this release cycle only there will be a significant different between stage0 and stage1 docs: https://github.com/rust-lang/rust/pull/73101. However most of the time this will not be the case.