Commit graph

149224 commits

Author SHA1 Message Date
Rémy Rakic
949aca6eeb don't trim paths in collector PME message 2021-05-27 22:28:04 +02:00
LeSeulArtichaut
d1f0e9f65c Test THIR unsafeck for unsafe ops in closures 2021-05-27 21:04:44 +02:00
bors
e51830b90a Auto merge of #85757 - GuillaumeGomez:rollup-k8hfhp8, r=GuillaumeGomez
Rollup of 3 pull requests

Successful merges:

 - #85722 (Fix trait methods' toggle)
 - #85730 (Mention workaround for floats in Iterator::{min, max})
 - #85738 (Rename opensbd to openbsd)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-27 18:33:43 +00:00
Guillaume Gomez
48706edc56
Rollup merge of #85738 - 370417:opensbd, r=m-ou-se
Rename opensbd to openbsd

OpenBsd was sometimes spelled "opensbd" in the standard library.
2021-05-27 20:08:24 +02:00
Guillaume Gomez
e30192ac5c
Rollup merge of #85730 - Smittyvb:iter-min-max-floats, r=m-ou-se
Mention workaround for floats in Iterator::{min, max}

`Iterator::{min, max}` can't be used with iterators of floats due to NaN issues. This suggests a workaround in the documentation of those functions.
2021-05-27 20:08:21 +02:00
Guillaume Gomez
6ac83e1808
Rollup merge of #85722 - GuillaumeGomez:trait-toggle, r=jsha
Fix trait methods' toggle

A `<details>` tag wasn't closed on trait methods, which created broken DOM. I also used this occasion to only generate the toggle in case there is documentation on the method.

r? `@jsha`
2021-05-27 20:08:17 +02:00
Camille GILLOT
8a2bea931b Remove obsolete workaround. 2021-05-27 19:37:34 +02:00
The8472
f72c60a39a Revert "Auto merge of #83770 - the8472:tra-extend, r=Mark-Simulacrum"
Due to a performance regression that didn't show up in the original perf run
this reverts commit 9111b8ae97, reversing
changes made to 9a700d2947.
2021-05-27 18:17:09 +02:00
bors
d854c3c0e9 Auto merge of #85729 - LeSeulArtichaut:thir-no-hash, r=nikomatsakis
Don't hash `thir_body`

Experiment to see if/how much this helps negate the perf impact of #85273.
r? `@ghost`
2021-05-27 15:46:48 +00:00
LeSeulArtichaut
6c4f40dee1 Make closures inherit their parent's "safety context" 2021-05-27 16:50:48 +02:00
Niko Matsakis
9385be7a0c
Update compiler/rustc_middle/src/query/mod.rs
Co-authored-by: Léo Lanteri Thauvin <leseulartichaut@gmail.com>
2021-05-27 10:31:47 -04:00
bors
ea78d1edf3 Auto merge of #85737 - scottmcm:vec-calloc-option-nonzero, r=m-ou-se
Enable Vec's calloc optimization for Option<NonZero>

Someone on discord noticed that `vec![None::<NonZeroU32>; N]` wasn't getting the optimization, so here's a PR 🙃

We can certainly do this in the standard library because we know for sure this is ok, but I think it's also a necessary consequence of documented guarantees like those in https://doc.rust-lang.org/std/option/#representation and https://doc.rust-lang.org/core/num/struct.NonZeroU32.html

It feels weird to do this without adding a test, but I wasn't sure where that would belong.  Is it worth adding codegen tests for these?
2021-05-27 13:05:57 +00:00
bjorn3
6487127a05 Remove unused tidy dep exceptions 2021-05-27 13:23:32 +02:00
Alex Veber
ef13f27bc7 Add #[track_caller] to panic_any 2021-05-27 14:19:47 +03:00
bjorn3
fa702d0d2b Merge commit '40dd3e2b7089b5e96714e064b731f6dbf17c61a9' into sync_cg_clif-2021-05-27 2021-05-27 13:08:14 +02:00
bors
8d1e3d3b74 Auto merge of #85732 - Smittyvb:trait-alias-camelcase-lint, r=varkor
Lint against non-CamelCase trait alias names

Type aliases are linted as such, so (unstable) trait aliases should be treated the same way.
2021-05-27 10:42:01 +00:00
bjorn3
40dd3e2b70 Rustfmt 2021-05-27 12:40:08 +02:00
bjorn3
56facc424a Rustup to rustc 1.54.0-nightly (ff2c947c0 2021-05-25) 2021-05-27 12:39:40 +02:00
Scott McMurray
04d34a97d1 Enable Vec's calloc optimization for Option<NonZero> 2021-05-26 23:19:35 -07:00
Albert Ford
3cafe2a43f
Rename opensbd to openbsd 2021-05-26 23:17:13 -07:00
bors
9814e83094 Auto merge of #84124 - 12101111:libunwind, r=petrochenkov
libunwind fix and cleanup

Fix:

1. "system-llvm-libunwind" now only skip build-script for linux target
2. workaround from https://github.com/rust-lang/rust/pull/65972 is not needed, upstream fix it in 68c50708d1 ( LLVM 11 )
3. remove code for MSCV and Apple in `compile()`, as they are not used
4. fix https://github.com/rust-lang/rust/issues/69222 , compile c files and cpp files in different config
5. fix conditional compilation for musl target.
6. fix that x86_64-fortanix-unknown-sgx don't link libunwind built in build-script into rlib
2021-05-27 04:08:20 +00:00
bors
c4ec606606 Auto merge of #85734 - Dylan-DPC:rollup-q6iiees, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #84221 (E0599 suggestions and elision of generic argument if no canditate is found)
 - #84701 (stabilize member constraints)
 - #85564 ( readd capture disjoint fields gate)
 - #85583 (Get rid of PreviousDepGraph.)
 - #85649 (Update cc)
 - #85689 (Remove Iterator #[rustc_on_unimplemented]s that no longer apply.)
 - #85719 (Add inline attr to CString::into_inner so it can optimize out NonNull checks)
 - #85725 (Remove unneeded workaround)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-27 01:43:20 +00:00
Eric Huss
834ec68821 Add test to check behavior when incremental session init fails. 2021-05-26 18:17:14 -07:00
Dylan DPC
85a408a043
Rollup merge of #85725 - Smittyvb:rm-24159-workaround, r=RalfJung
Remove unneeded workaround

This removes a workaround for #24159, which has been fixed.
2021-05-27 03:02:12 +02:00
Dylan DPC
955e0f42fc
Rollup merge of #85719 - elichai:cstring-into_inner-inline, r=m-ou-se
Add inline attr to CString::into_inner so it can optimize out NonNull checks

It seems that currently if you convert any of the standard library's container to a pointer and then to a NonNull pointer, all will optimize out the NULL check except `CString`(https://godbolt.org/z/YPKW9G5xn),
because for some reason `CString::into_inner` isn't inlined even though it's a private function that should compile into a simple `mov` instruction.

Adding a simple `#[inline]` attribute solves this, code example:
```rust
use std::ffi::CString;
use std::ptr::NonNull;

pub fn cstring_nonull(mut n: CString) -> NonNull<i8> {
    NonNull::new(CString::into_raw(n)).unwrap()
}
```

assembly before:
```asm
__ZN3wat14cstring_nonull17h371c755bcad76294E:
	.cfi_startproc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	callq	__ZN3std3ffi5c_str7CString10into_inner17h28ece07b276e2878E
	testq	%rax, %rax
	je	LBB0_2
	popq	%rbp
	retq
LBB0_2:
	leaq	l___unnamed_1(%rip), %rdi
	leaq	l___unnamed_2(%rip), %rdx
	movl	$43, %esi
	callq	__ZN4core9panicking5panic17h92a83fa9085a8f73E
	.cfi_endproc

	.section	__TEXT,__const
l___unnamed_1:
	.ascii	"called `Option::unwrap()` on a `None` value"

l___unnamed_3:
	.ascii	"wat.rs"

	.section	__DATA,__const
	.p2align	3
l___unnamed_2:
	.quad	l___unnamed_3
	.asciz	"\006\000\000\000\000\000\000\000\006\000\000\000(\000\000"
```

Assembly after:
```asm
__ZN3wat14cstring_nonull17h9645eb9341fb25d7E:
	.cfi_startproc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	movq	%rdi, %rax
	popq	%rbp
	retq
	.cfi_endproc
```

(Related discussion on zulip: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/NonNull.20From.3CBox.3CT.3E.3E)
2021-05-27 03:02:11 +02:00
Dylan DPC
de1d7dbd0f
Rollup merge of #85689 - m-ou-se:array-intoiter-3, r=estebank
Remove Iterator #[rustc_on_unimplemented]s that no longer apply.

Now that `IntoIterator` is implemented for arrays, all the `rustc_on_unimplemented` for arrays of ranges (e.g. `for _ in [1..3] {}`) no longer apply, since they are now valid Rust.

Separated these from #85670, because we should discuss a potential new (clippy?) lint for these.

Until Rust 1.52, `for _ in [1..3] {}` produced:

```
error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator
 --> src/main.rs:2:14
  |
2 |     for _ in [1..3] {}
  |              ^^^^^^ if you meant to iterate between two values, remove the square brackets
  |
  = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]`
  = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end`
  = note: required by `std::iter::IntoIterator::into_iter`
```

But in Rust 1.53 and later, it compiles fine. It iterates over the array by value, for one iteration with the element `1..3`.

This is probably a mistake, which is no longer caught. Should we have a lint for it? Should Clippy have a lint for it?

cc ```@estebank``` ```@flip1995```

cc https://github.com/rust-lang/rust/issues/84513
2021-05-27 03:02:10 +02:00
Dylan DPC
0c53acc6f8
Rollup merge of #85649 - ChrisDenton:update-cc, r=matthewjasper
Update cc

Recent commits have improved `cc`'s finding of MSVC tools on Windows. In particular it should help to address these issues: #83043 and #43468
2021-05-27 03:02:09 +02:00
Dylan DPC
e7c9469786
Rollup merge of #85583 - cjgillot:no-previous-dg, r=petrochenkov
Get rid of PreviousDepGraph.

Its only role is to access the `SerializedDepGraph`.
2021-05-27 03:02:09 +02:00
Dylan DPC
9d4a6449db
Rollup merge of #85564 - pnkfelix:issue-85435-readd-capture-disjoint-fields-gate, r=nikomatsakis
readd capture disjoint fields gate

This readds a feature gate guard that was added in PR #83521. (Basically, there were unintended consequences to the code exposed by removing the feature gate guard.)

The root bug still remains to be resolved, as discussed in issue #85561. This is just a band-aid suitable for a beta backport.

Cc issue #85435

Note that the latter issue is unfixed until we backport this (or another fix) to 1.53 beta
2021-05-27 03:02:08 +02:00
Dylan DPC
3530a7895a
Rollup merge of #84701 - nikomatsakis:stabilize-member-constraints-61997, r=jackh726
stabilize member constraints

Stabilizes the use of "member constraints" in solving `impl Trait` bindings. This is a step towards stabilizing a "MVP" of "named impl Trait".

# Member constraint stabilization report

| Info | |
| --- | --- |
| Tracking issue | [rust-lang/rust#61997](https://github.com/rust-lang/rust/issues/61997) |
| Implementation history | [rust-lang/rust#61775] |
| rustc-dev-guide coverage | [link](https://rustc-dev-guide.rust-lang.org/borrow_check/region_inference/member_constraints.html) |
| Complications | [rust-lang/rust#61773] |

[rust-lang/rust#61775]: https://github.com/rust-lang/rust/pull/61775
[rust-lang/rust#61773]: https://github.com/rust-lang/rust/issues/61773

## Background

Member constraints are an extension to our region solver that was introduced to make async fn region solving tractable. There are used in situations like the following:

```rust
fn foo<'a, 'b>(...) -> impl Trait<'a, 'b> { .. }
```

The problem here is that every region R in the hidden type must be equal to *either* `'a` *or* `'b` (or `'static`). This cannot be expressed simply via 'outlives constriants' like `R: 'a`. Therefore, we introduce a 'member constraint' `R member of ['a, 'b]`.

These constraints were introduced in [rust-lang/rust#61775]. At the time, we kept them feature gated and used them only for `impl Trait` return types that are derived from `async fn`. The intention, however, was always to support them in other contexts once we had time to gain more experience with them.

**In the time since their introduction, we have encountered no surprises or bugs due to these member constraints.** They are tested extensively as part of every async function that involves multiple unrelated lifetimes in its arguments.

## Tests

The behavior of member constraints is covered by the following tests:

* [`src/test/ui/async-await/multiple-lifetimes`](20e032e650/src/test/ui/async-await/multiple-lifetimes) -- tests using the async await, which are mostly already stabilized
* [`src/test/ui/impl-trait/multiple-lifetimes.rs`](20e032e650/src/test/ui/impl-trait/multiple-lifetimes.rs)
* [`src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.rs`](20e032e650/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.rs)
* [`src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-fg.rs`](20e032e650/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-fg.rs)
* [`src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs`](20e032e650/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs)

These tests cover a number of scenarios:

* `-> implTrait<'a, 'b>` with unrelated lifetimes `'a` and `'b`, as described above
* `async fn` that returns an `impl Trait` like the previous case, which desugars to a kind of "nested" impl trait like `impl Future<Output = impl Trait<'a, 'b>>`

## Potential concerns

There is a potential interaction with `impl Trait` on local variables, described in [rust-lang/rust#61773]. The challenge is that if you have a program like:

```rust=
trait Foo<'_> { }
impl Foo<'_> for &u32 { }

fn bar() {
  let x: impl Foo<'_> = &44; // let's call the region variable for `'_` `'1`
}
```

then we would wind up with `'0 member of ['1, 'static]`, where `'0` is the region variable in the hidden type (`&'0 u32`) and `'1` is the region variable in the bounds `Foo<'1>`. This is tricky because both `'0` and `'1` are being inferred -- so making them equal may have other repercussions.

That said, `impl Trait` in bindings are not stable, and the implementation is pretty far from stabilization. Moreover, the difficulty highlighted here is not due to the presence of member constraints -- it's inherent to the design of the language. In other words, stabilizing member constraints does not actually cause us to accept anything that would make this problem any harder.

So I don't see this as a blocker to stabilization of member constraints; it is potentially a blocker to stablization of `impl trait` in let bindings.
2021-05-27 03:02:07 +02:00
Dylan DPC
f2810d5fa0
Rollup merge of #84221 - ABouttefeux:generic-arg-elision, r=estebank
E0599 suggestions and elision of generic argument if no canditate is found

fixes #81576
changes: In error E0599 (method not found) generic argument are eluded if the method was not found anywhere. If the method was found in another inherent implementation suggest that it was found elsewhere.

Example
```rust

struct Wrapper<T>(T);

struct Wrapper2<T> {
    x: T,
}

impl Wrapper2<i8> {
    fn method(&self) {}
}

fn main() {
    let wrapper = Wrapper(i32);
    wrapper.method();
    let wrapper2 = Wrapper2{x: i32};
    wrapper2.method();
}
```

```
Error[E0599]: no method named `method` found for struct `Wrapper<_>` in the current scope
....
error[E0599]: no method named `method` found for struct `Wrapper2<i32>` in the current scope
...
   = note: The method was found for Wrapper2<i8>.

```
I am not very happy with the ```no method named `test` found for struct `Vec<_, _>` in the current scope```. I think it might be better to show only one generic argument `Vec<_>` if there is a default one. But I haven't yet found a way to do that,
2021-05-27 03:02:03 +02:00
Smittyvb
b00f6fc8a1
don't use unneeded closure
Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
2021-05-26 20:38:50 -04:00
Smittyvb
7146a05a43
don't use unneeded closure
Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
2021-05-26 20:38:43 -04:00
Smitty
edef5bc31b Lint against non-camelCase trait alias names
Type aliases are linted as such, so (unstable) trait aliases should be
treated the same way.
2021-05-26 19:55:27 -04:00
bors
86ac0b4147 Auto merge of #85652 - ehuss:linkchecker-perf, r=Mark-Simulacrum
Optimize linkchecker and add report.

This makes three changes to the linkchecker:

* Adds a report displayed after it finishes.
* Improves the performance by caching all filesystem access. The linkchecker can take over a minute to run on some systems, and this should make it about 2-3 times faster.
* Added a few tests.
2021-05-26 23:13:15 +00:00
Jacob Pratt
741b9a4fa7
Bless test output 2021-05-26 18:07:10 -04:00
Jacob Pratt
35ce36812a
Unify feature flags as step_trait
While stdlib implementations of the unchecked methods require unchecked
math, there is no reason to gate it behind this for external users. The
reasoning for a separate `step_trait_ext` feature is unclear, and as
such has been merged as well.
2021-05-26 18:07:10 -04:00
Jacob Pratt
bc2f0fb5a9
Specialize implementations
Implementations in stdlib are now optimized as they were before.
2021-05-26 18:07:09 -04:00
Smitty
e7a3ada210 Mention float workaround in Iterator::{min,max} 2021-05-26 17:15:54 -04:00
LeSeulArtichaut
fdc15ef823 Don't hash thir_body 2021-05-26 22:34:42 +02:00
bors
9111b8ae97 Auto merge of #83770 - the8472:tra-extend, r=Mark-Simulacrum
Add `TrustedRandomAccess` specialization for `Vec::extend()`

This should do roughly the same as the `TrustedLen` specialization but result in less IR by using `__iterator_get_unchecked`
instead of `Iterator::for_each`

Conflicting specializations are manually prioritized by grouping them under yet another helper trait.
2021-05-26 19:22:31 +00:00
Paul Trojahn
119bff1247 Fix typo 2021-05-26 19:19:47 +02:00
Smitty
ff8a387490 Remove unneeded workaround
This removes a workaround for #24159, which has been fixed.
2021-05-26 13:16:26 -04:00
bors
9a700d2947 Auto merge of #85721 - Xanewok:update-rls, r=Xanewok
Update RLS

Closes #85453

r? `@ghost`
2021-05-26 16:35:45 +00:00
Niko Matsakis
b3054d2c21 bless compare-mode=nll output 2021-05-26 12:05:34 -04:00
bors
f6a28aa403 Auto merge of #85720 - Dylan-DPC:rollup-in5917x, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #85478 (Disallow shadowing const parameters)
 - #85625 (Prevent double drop in `Vec::dedup_by` if a destructor panics)
 - #85627 (Fix a few details in THIR unsafeck)
 - #85633 (Post-monomorphization errors traces MVP)
 - #85670 (Remove arrays/IntoIterator message from Iterator trait.)
 - #85678 (fix `matches!` and `assert_matches!` on edition 2021)
 - #85679 (Remove num_as_ne_bytes feature)
 - #85712 (Fix typo in core::array::IntoIter comment)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-26 13:51:30 +00:00
Guillaume Gomez
3bed0be9fc Update trait toggle test 2021-05-26 14:36:58 +02:00
Guillaume Gomez
f9499ea9f5 * Fix bug where some <details> tags were not closed.
* Don't generate a <details> if there is no documentation
2021-05-26 14:35:39 +02:00
Igor Matuszewski
b36c45d6df Update RLS 2021-05-26 14:02:26 +02:00
bjorn3
e20fe219e6 Sync from rust 1969c2e312 2021-05-26 14:01:50 +02:00