Commit Graph

124312 Commits

Author SHA1 Message Date
bors
438c59f010 Auto merge of #74908 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/74580
Cc @rust-lang/miri r? @ghost
2020-07-30 18:29:08 +00:00
Ralf Jung
1a2208afc5 update Miri 2020-07-30 19:05:21 +02:00
bors
6b09c37ddc 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
2020-07-30 14:36:41 +00:00
bors
21867225a7 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
2020-07-30 12:52:41 +00:00
jumbatm
0bd292dea1 Fix missed same-sized member clash in ClashingExternDeclarations. 2020-07-30 21:59:02 +10:00
jumbatm
30a6f57308 Handle structs with zst members. 2020-07-30 21:59:02 +10:00
jumbatm
060666d0a4 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`.
2020-07-30 21:59:02 +10:00
jumbatm
5e52edca52 Apply suggested wording changes from code review.
Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com>
2020-07-30 21:59:02 +10:00
jumbatm
3eaead7d51 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).
2020-07-30 21:59:01 +10:00
jumbatm
4da72f5387 Add additional clashing_extern_decl cases. 2020-07-30 21:59:01 +10:00
bors
1ce0cf070e 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
2020-07-30 10:58:59 +00:00
bors
1799d31847 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.
2020-07-30 03:54:05 +00:00
Dylan MacKenzie
88fd4943a6 Test {align,size}_of_val in a const context 2020-07-29 19:41:35 -07:00
bors
6e50a225fd 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)
2020-07-30 02:05:48 +00:00
bors
fb0b1237b1 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
2020-07-30 00:17:51 +00:00
Dylan MacKenzie
9caf0b5222 Make {align,size}_of_val const 2020-07-29 16:50:15 -07:00
Manish Goregaokar
f4f77d756d
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
2020-07-29 16:38:34 -07:00
Manish Goregaokar
cae4d4d1d0
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.
2020-07-29 16:38:33 -07:00
Manish Goregaokar
2050128302
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
2020-07-29 16:38:31 -07:00
Manish Goregaokar
1d53340e04
Rollup merge of #74904 - joshtriplett:typo-fix, r=jonas-schievink
Fix some typos in src/librustdoc/clean/auto_trait.rs
2020-07-29 16:38:29 -07:00
Manish Goregaokar
0f9b7bd80f
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
2020-07-29 16:38:28 -07:00
Manish Goregaokar
e6b0376e7b
Rollup merge of #74873 - lcnr:const-print, r=eddyb
symbol mangling: use ty::print::Print for consts

r? @eddyb
2020-07-29 16:38:26 -07:00
Manish Goregaokar
4230f96bbe
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.
2020-07-29 16:38:24 -07:00
Manish Goregaokar
c07998e0e7
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>.
2020-07-29 16:38:22 -07:00
Manish Goregaokar
35226766c9
Rollup merge of #74819 - tmiasko:format-spec, r=joshtriplett
Point towards `format_spec`; it is in other direction
2020-07-29 16:38:20 -07:00
Manish Goregaokar
acad0a0517
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
2020-07-29 16:38:19 -07:00
Lokathor
e9509273e6
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
2020-07-29 16:26:09 -06:00
bors
6b269e4432 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
2020-07-29 22:24:46 +00:00
Joseph Ryan
29df0508f3
Pass by value 2020-07-29 16:48:22 -05:00
Joseph Ryan
7621a5b635
Refactor DocFS to fix error handling bugs 2020-07-29 16:15:31 -05:00
bors
db0492ace4 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
2020-07-29 20:35:52 +00:00
Eric Huss
89d7906acd Update cargo 2020-07-29 11:02:05 -07:00
bors
8611e526b7 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
2020-07-29 17:50:30 +00:00
bors
6fd4c3f20f 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.
2020-07-29 15:58:32 +00:00
Xavier Denis
f07607f47a Move mir-opt tests to toplevel 2020-07-29 17:36:03 +02:00
Rich Kadel
5b2e2b25e4 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
2020-07-29 08:22:17 -07:00
Takayuki Nakata
ab166cfffa Fix broken link in unstable book plugin 2020-07-29 23:21:56 +09:00
bors
584e83dd5a 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?
2020-07-29 13:58:19 +00:00
Ralf Jung
897149a883 fence docs: fix example Mutex 2020-07-29 15:45:42 +02:00
Mateusz Mikuła
87abd656da Add test for #50176 2020-07-29 14:19:58 +02:00
Mateusz Mikuła
db9a84a1af 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
2020-07-29 14:19:57 +02:00
Xavier Denis
86be22ebcd add crate name to mir dumps 2020-07-29 13:41:11 +02:00
bors
06e7b93f6a 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.
2020-07-29 11:19:36 +00:00
Tomasz Miąsko
6b4c739f92 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.
2020-07-29 12:46:04 +02:00
Josh Triplett
82766cb78a Fix some typos in src/librustdoc/clean/auto_trait.rs 2020-07-29 03:25:38 -07:00
Oliver Scherer
b81d164f61 Address review comments 2020-07-29 11:37:33 +02:00
Simon Sapin
1fb67363bf Remove deprecated unstable {Box,Rc,Arc}::into_raw_non_null functions
FCP: https://github.com/rust-lang/rust/issues/47336#issuecomment-619369613
2020-07-29 11:00:31 +02:00
bors
0dd362ec17 Auto merge of #74896 - imbolc:patch-1, r=kennytm
Update `fs::remove_file` docs

Mention that absence of file causes an error
2020-07-29 08:52:01 +00:00
Tomasz Miąsko
1b4a6a5183 Link to syntax section when referencing it 2020-07-29 10:43:40 +02:00
Lzu Tao
27e1b0632c Explain why inline default ToString impl 2020-07-29 07:38:06 +00:00