Commit Graph

124265 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Imbolc
c4e44d7373
Update fs::remove_file docs
Mention that absence of file causes an error
2020-07-29 08:18:01 +03:00
bors
10c375700c 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.
2020-07-29 04:59:37 +00:00
bors
517385b31b 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
2020-07-29 01:38:00 +00:00
Rich Kadel
b58afc088f FunctionCoverage: improve type checking with newtype_index types 2020-07-28 17:45:58 -07:00
Yuki Okushi
2b4ae49f2e
Rollup merge of #74891 - lcnr:auto-trait-finder, r=varkor
handle ConstEquate in rustdoc

fixes #74882

r? @varkor cc @eddyb
2020-07-29 09:24:25 +09:00
Yuki Okushi
18bb8355df
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.
2020-07-29 09:24:24 +09:00
Yuki Okushi
1de0211d8e
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
2020-07-29 09:24:22 +09:00
Yuki Okushi
451ed88b8b
Rollup merge of #74859 - mark-i-m:patch-1, r=JohnTitor
Update outdated readme
2020-07-29 09:24:20 +09:00
Yuki Okushi
bd91877636
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 🤷‍♂️
2020-07-29 09:24:19 +09:00
Yuki Okushi
6968b75bd0
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.
2020-07-29 09:24:17 +09:00
Yuki Okushi
157975c6c4
Rollup merge of #74671 - rust-lang:const-generics-coerce-unsized, r=nikomatsakis
add const generics array coercion test
2020-07-29 09:24:15 +09:00
Yuki Okushi
1ed74eeef9
Rollup merge of #74266 - GuillaumeGomez:cleanup-e0720, r=Dylan-DPC
Clean up E0720 explanation

r? @Dylan-DPC
2020-07-29 09:24:13 +09:00
bors
4cca9505ea 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>),
    )
}
```
2020-07-28 23:45:05 +00:00
Rich Kadel
20f55c193d Refactor MIR coverage instrumentation
Lays a better foundation for injecting more counters in each function.
2020-07-28 15:08:19 -07:00
Bastian Kauschke
2a16bb085e handle ConstEquate in rustdoc 2020-07-29 00:00:55 +02:00
bors
a7eff79135 Auto merge of #74861 - mark-i-m:mv-std-followup, r=Mark-Simulacrum
Re-enable linkcheck after moving std
2020-07-28 21:48:22 +00:00
Mark Rousskov
13ad2322ca Cache non-exhaustive separately from attributes 2020-07-28 16:26:38 -04:00
bors
2caf854f7a Auto merge of #74471 - da-x:string-type-diagnostic-item, r=petrochenkov
librustc_typeck: use diag item instead of string compare
2020-07-28 20:00:37 +00:00
Mark Rousskov
6726ca2b28 Collect library features from library/ 2020-07-28 13:03:59 -05:00
mark
856f68fa14 reenable tests after moving std 2020-07-28 13:03:59 -05:00
bors
98efae8760 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
2020-07-28 17:39:39 +00:00
Alexis Bourget
90d00527d1 Add note to clearly mark the RFC as rejected 2020-07-28 18:53:35 +02:00
Alexis Bourget
dcce6cb511 Remove links to rejected errata 4406 for RFC 4291 2020-07-28 18:53:35 +02:00
Alex Crichton
83b493018a 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
2020-07-28 09:41:09 -07:00
bors
7b3a781937 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.
2020-07-28 13:56:32 +00:00
Joshua Nelson
da40cf81e6 Use --stage 2 in checktools
- Remove useless --stage 2 argument to checktools.sh
- Fix help text for expand-yaml-anchors (it had a typo)
2020-07-28 09:36:56 -04:00
Joshua Nelson
c4c6453b7b Fix bad rebase 2020-07-28 08:34:59 -04:00
Yuki Okushi
b85dae00dc
Enable to ping RISC-V group via triagebot 2020-07-28 21:01:13 +09:00
bors
2c28244cf0 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.
2020-07-28 09:02:32 +00:00
Aleksey Kladov
6e9dc7d9ff Add str::[r]split_once
This is useful for quick&dirty parsing of key: value config pairs
2020-07-28 09:58:20 +02:00
Aleksey Kladov
ed1439cea4 Fix RefUnwindSafe & UnwinsSafe impls for lazy::SyncLazy
The logic here is the same as for Send&Sync impls.
2020-07-28 09:51:08 +02:00
bors
1f5d69dacc 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
2020-07-28 05:49:59 +00:00
Lzu Tao
5faef5e00c ayu theme: Change doccomment color to #a1ac88
Co-authored-by: Cldfire <cldfire@3grid.net>
2020-07-28 05:12:12 +00:00
Ashley Mannix
9d4818c6f9 update stderr for polymorphic ui test 2020-07-28 14:37:31 +10:00
Tomasz Miąsko
0a51a9fb00 Add #[inline] to RawWaker::new 2020-07-28 06:14:52 +02:00