Commit graph

107 commits

Author SHA1 Message Date
bors
887999d163 Auto merge of #88439 - cynecx:unwind_asm, r=Amanieu
Unwinding support for inline assembly

r? `@Amanieu`
2021-12-04 05:59:16 +00:00
Matthias Krüger
df51bffe6b
Rollup merge of #91488 - compiler-errors:issue-91477, r=estebank
Fix ICE when `yield`ing in function returning `impl Trait`

Change an assert to a `delay_span_bug` and remove an unwrap, that should fix it.

Fixes #91477
2021-12-04 02:26:26 +01:00
Amanieu d'Antras
940b2eabad Add initial AST and MIR support for unwinding from inline assembly 2021-12-03 23:51:46 +01:00
Santiago Pastorino
85b723c4e6
Revert "Auto merge of #91354 - fee1-dead:const_env, r=spastorino"
This reverts commit 18bb8c61a9, reversing
changes made to d9baa36190.
2021-12-03 10:11:21 -03:00
Michael Goulet
7c108ababc Fix ICE when yielding in fn returning impl Trait 2021-12-02 22:36:05 -08:00
Matthias Krüger
b56e3d955a
Rollup merge of #91321 - matthewjasper:constaint-placeholders, r=jackh726
Handle placeholder regions in NLL type outlive constraints

Closes #76168
2021-12-02 22:16:09 +01:00
bors
e5038e2099 Auto merge of #91455 - matthiaskrgr:rollup-gix2hy6, r=matthiaskrgr
Rollup of 4 iffy pull requests

Successful merges:

 - #89234 (Disallow non-c-like but "fieldless" ADTs from being casted to integer if they use arbitrary enum discriminant)
 - #91045 (Issue 90702 fix: Stop treating some crate loading failures as fatal errors)
 - #91394 (Bump stage0 compiler)
 - #91411 (Enable svh tests on msvc)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-02 14:53:20 +00:00
Matthias Krüger
d96ce3ea8e
Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbini
Bump stage0 compiler

r? `@pietroalbini` (or anyone else)
2021-12-02 15:52:03 +01:00
bors
18bb8c61a9 Auto merge of #91354 - fee1-dead:const_env, r=spastorino
Cleanup: Eliminate ConstnessAnd

This is almost a behaviour-free change and purely a refactoring. "almost" because we appear to be using the wrong ParamEnv somewhere already, and this is now exposed by failing a test using the unstable `~const` feature.

We most definitely need to review all `without_const` and at some point should probably get rid of many of them by using `TraitPredicate` instead of `TraitRef`.

This is a continuation of https://github.com/rust-lang/rust/pull/90274.

r? `@oli-obk`

cc `@spastorino` `@ecstatic-morse`
2021-12-02 11:48:58 +00:00
bors
76938d64a4 Auto merge of #90446 - cjgillot:late-elided, r=jackh726
Lint elided lifetimes in path during lifetime resolution.

The lifetime elision lint is known to be brittle and can be redundant with later lifetime resolution errors. This PR aims to remove the redundancy by performing the lint after lifetime resolution.

This PR proposes to carry the information that an elision should be linted against by using a special `LifetimeName`. I am not certain this is the best solution, but it is certainly the easiest.

Fixes https://github.com/rust-lang/rust/issues/60199
Fixes https://github.com/rust-lang/rust/issues/55768
Fixes https://github.com/rust-lang/rust/issues/63110
Fixes https://github.com/rust-lang/rust/issues/71957
2021-12-01 23:22:43 +00:00
Matthias Krüger
a4f46742c2
Rollup merge of #90985 - camsteffen:diag-name-usage, r=jackh726
Use `get_diagnostic_name` more
2021-12-01 10:50:18 +01:00
Matthias Krüger
dc78cd4c61
Rollup merge of #91294 - cjgillot:process-elem, r=jackh726
Visit type in process_projection_elem.

Instead of reimplementing it for each visitor.
2021-11-30 23:43:31 +01:00
Camille GILLOT
aa2450f41b Merge Implicit and ImplicitMissing. 2021-11-30 22:56:47 +01:00
Camille GILLOT
5ea7ea8a57 Lint elided lifetimes in path during lifetime resolution. 2021-11-30 22:55:07 +01:00
Mark Rousskov
971c549ca3 re-format with new rustfmt 2021-11-30 13:08:41 -05:00
Mark Rousskov
b221c877e8 Apply cfg-bootstrap switch 2021-11-30 10:51:42 -05:00
Yuki Okushi
6e7cf2e88b
Rollup merge of #91243 - jackh726:issue-91068, r=nikomatsakis
Don't treat unnormalized function arguments as well-formed

Partial revert of #88312

r? ``@pnkfelix``
cc ``@nikomatsakis``
2021-11-30 17:29:06 +09:00
Oli Scherer
a9a79f657c
Completely remove ConstnessAnd 2021-11-29 21:19:49 +08:00
Camille GILLOT
29b30a9bd2 Visit type in process_projection_elem. 2021-11-27 17:39:27 +01:00
Matthew Jasper
2a83c11d4d Handle placeholder regions in NLL type outlive constraints 2021-11-26 22:06:08 +00:00
jackh726
eeaa215f85 Don't treat unnormalized function arguments as well-formed 2021-11-25 21:16:27 -05:00
Michael Goulet
718a3b1f2d Fix issue 91206 2021-11-25 16:34:30 +00:00
bors
8a48b376d5 Auto merge of #90491 - Mark-Simulacrum:push-pred-faster, r=matthewjasper
Optimize live point computation

This refactors the live-point computation to lower per-MIR-instruction costs by operating on a largely per-block level. This doesn't fundamentally change the number of operations necessary, but it greatly improves the practical performance by aggregating bit manipulation into ranges rather than single-bit; this scales much better with larger blocks.

On the benchmark provided in #90445, with 100,000 array elements, walltime for a check build is improved from 143 seconds to 15.

I consider the tiny losses here acceptable given the many small wins on real world benchmarks and large wins on stress tests. The new code scales much better, but on some subset of inputs the slightly higher constant overheads decrease performance somewhat. Overall though, this is expected to be a big win for pathological cases (as illustrated by the test case motivating this work) and largely not material for non-pathological cases. I consider the new code somewhat easier to follow, too.
2021-11-24 15:51:46 +00:00
Cameron Steffen
9c83f8c4d1 Simplify for loop desugar 2021-11-21 08:15:21 -06:00
Cameron Steffen
dec40530f7 Use get_diagnostic_name more 2021-11-16 17:14:18 -06:00
Yuki Okushi
21bff4a4c1
Rollup merge of #90801 - b-naber:missing_normalization_equate_inputs_output, r=jackh726
Normalize both arguments of `equate_normalized_input_or_output`

Fixes https://github.com/rust-lang/rust/issues/90638
Fixes https://github.com/rust-lang/rust/issues/90612

Temporary fix for a more complex underlying problem stemming from an inability to normalize closure substs during typecheck.

r? ````@jackh726````
2021-11-16 15:59:39 +09:00
Josh Triplett
8c9bfaa5f3 Stabilize format_args_capture
Works as expected, and there are widespread reports of success with it,
as well as interest in it.
2021-11-15 10:14:29 +01:00
b-naber
26ca71fdb2 normalize argument b in equate_normalized_inputs_output 2021-11-11 23:54:15 +01:00
Matthias Krüger
fd74c93403
Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakis
Type inference for inline consts

Fixes #78132
Fixes #78174
Fixes #81857
Fixes #89964

Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure.

Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts.

The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure.

With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME.

Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck).
cc `````@spastorino````` `````@lcnr`````
r? `````@nikomatsakis`````

`````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-09 19:00:40 +01:00
Deadbeef
f1126f1272
Make select_* methods return Vec for TraitEngine 2021-11-08 23:35:23 +08:00
Matthias Krüger
5c454551da more clippy fixes 2021-11-07 16:59:05 +01:00
Gary Guo
c4103d438f Rename functions reflect that inline const is also "typeck_child" 2021-11-07 04:00:34 +00:00
Gary Guo
ff055e2135 Ensure closure requirements are proven for inline const 2021-11-07 04:00:34 +00:00
Gary Guo
468192a9c5 Implement type inference for inline consts
In most cases it is handled in the same way as closures.
2021-11-07 04:00:32 +00:00
Matthias Krüger
0a5640b55f use matches!() macro in more places 2021-11-06 16:13:14 +01:00
Mark Rousskov
03afb61b53 Optimize live point computation
This is just replicating the previous algorithm, but taking advantage of the
bitset structures to optimize into tighter and better optimized loops.
Particularly advantageous on enormous MIR blocks, which are relatively rare in
practice.
2021-11-03 11:24:59 -04:00
bors
88a5a984fe Auto merge of #90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnr
Revert "Add rustc lint, warning when iterating over hashmaps"

Fixes perf regressions introduced in https://github.com/rust-lang/rust/pull/90235 by temporarily reverting the relevant PR.
2021-10-29 04:55:51 +00:00
bors
df76418f1e Auto merge of #90387 - matthiaskrgr:rollup-b2x8v0x, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #90082 (Fix minor typos)
 - #90336 (Remove extra lines in examples for `Duration::try_from_secs_*`)
 - #90376 (Various cleanups around opaque types)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-28 22:44:45 +00:00
bors
c390d69a61 Auto merge of #90281 - xldenis:public-borrow-set, r=nikomatsakis
Add BorrowSet to public api

This PR adds `BorrowSet` to the public api so that verification tools can obtain the activation and reservation points of two phase borrows without having to redo calculations themselves (and thus potentially differently from rustc).

Turns out we already can obtain `MoveData` thanks to the public `HasMoveData` trait, so constructing a `BorrowSet` should not provide much of an issue. However, I can't speak to the soundness of this approach, is it safe to take an under-approximation of `MoveData`?

r? `@nikomatsakis`
2021-10-28 19:34:01 +00:00
Mark Rousskov
3215eeb99f
Revert "Add rustc lint, warning when iterating over hashmaps" 2021-10-28 11:01:42 -04:00
Oli Scherer
bc552fc417 Move instantiate_opaque_types to rustc_infer.
It does not depend on anything from rustc_trait_selection anymore.
2021-10-28 14:12:24 +00:00
Xavier Denis
9894a9a716 Add BorrowSet to public api 2021-10-25 22:16:07 +02:00
bors
235d9853d8 Auto merge of #90042 - pietroalbini:1.56-master, r=Mark-Simulacrum
Bump bootstrap compiler to 1.57

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

r? `@Mark-Simulacrum`
2021-10-25 11:31:47 +00:00
Matthias Krüger
87822b27ee
Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
2021-10-24 15:48:42 +02:00
Pietro Albini
b63ab8005a update cfg(bootstrap) 2021-10-23 21:55:57 -04:00
bors
aa5740c715 Auto merge of #90104 - spastorino:coherence-for-negative-trait, r=nikomatsakis
Implement coherence checks for negative trait impls

The main purpose of this PR is to be able to [move Error trait to core](https://github.com/rust-lang/project-error-handling/issues/3).

This feature is necessary to handle the following from impl on box.

```rust
impl From<&str> for Box<dyn Error> { ... }
```

Without having negative traits affect coherence moving the error trait into `core` and moving that `From` impl to `alloc` will cause the from impl to no longer compiler because of a potential future incompatibility. The compiler indicates that `&str` _could_ introduce an `Error` impl in the future, and thus prevents the `From` impl in `alloc` that would cause overlap with `From<E: Error> for Box<dyn Error>`. Adding `impl !Error for &str {}` with the negative trait coherence feature will disable this error by encoding a stability guarantee that `&str` will never implement `Error`, making the `From` impl compile.

We would have this in `alloc`:

```rust
impl From<&str> for Box<dyn Error> {} // A
impl<E> From<E> for Box<dyn Error> where E: Error {} // B
```

and this in `core`:

```rust
trait Error {}
impl !Error for &str {}
```

r? `@nikomatsakis`

This PR was built on top of `@yaahc` PR #85764.

Language team proposal: to https://github.com/rust-lang/lang-team/issues/96
2021-10-23 12:51:15 +00:00
Yuki Okushi
91fb223f59
Rollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwco
Don't mark for loop iter expression as desugared

We typically don't mark spans of lowered things as desugared. This helps Clippy rightly discern when code is (not) from expansion. This was discovered by ``@flip1995`` at https://github.com/rust-lang/rust-clippy/pull/7789#issuecomment-939289501.
2021-10-22 19:42:45 +09:00
Santiago Pastorino
6975afd141
Add polarity to TraitPredicate 2021-10-20 12:10:41 -03:00
bors
1af55d19c7 Auto merge of #89933 - est31:let_else, r=michaelwoerister
Adopt let_else across the compiler

This performs a substitution of code following the pattern:

```
let <id> = if let <pat> = ... { identity } else { ... : ! };
```

To simplify it to:

```
let <pat> = ... { identity } else { ... : ! };
```

By adopting the `let_else` feature (cc #87335).

The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet.

Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.
2021-10-19 14:41:39 +00:00
bors
ec724ac075 Auto merge of #89229 - oli-obk:i_love_inferctxt, r=jackh726
Remove redundant member-constraint check

impl trait will, for each lifetime in the hidden type, register a "member constraint" that says the lifetime must be equal or outlive one of the lifetimes of the impl trait. These member constraints will be solved by borrowck

But, as you can see in the big red block of removed code, there was an ad-hoc check for member constraints happening at the site where they get registered. This check had some minor effects on diagnostics, but will fall down on its feet with my big type alias impl trait refactor. So we removed it and I pulled the removal out into a (hopefully) reviewable PR that works on master directly.
2021-10-18 23:02:53 +00:00