Commit Graph

1023 Commits

Author SHA1 Message Date
Nicholas Nethercote
f07d4efc45 Shrink hir::def::Res.
`Res::SelfTy` currently has two `Option`s. When the second one is `Some`
the first one is never consulted. So we can split it into two variants,
`Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res`
from 24 bytes to 12. This then shrinks `hir::Path` and
`hir::PathSegment`, which are the HIR types that take up the most space.
2022-09-29 08:44:52 +10:00
Ding Xiang Fei
4a2c1a12b6
fix unwind drop glue for if-then scopes 2022-09-28 18:45:11 +08:00
lcnr
1fc86a63f4 rustc_typeck to rustc_hir_analysis 2022-09-27 10:37:23 +02:00
bors
1d1f142660 Auto merge of #102257 - cjgillot:let-else-lint, r=dingxiangfei2009
Fix lint scoping for let-else.

The scoping for let-else is inconsistent with HIR nesting.  This creates cases, in `ui/let-else/let-else-allow-unused.rs` for instance, where an `allow` lint attribute does not apply to the bindings created by `let-else`.

This PR is an attempt to correct this.

As there is no lint that currently relies on this, the test for this behaviour is https://github.com/rust-lang/rust/pull/101500.

cc `@dingxiangfei2009` as you filed https://github.com/rust-lang/rust/pull/101894
2022-09-26 17:17:07 +00:00
Pietro Albini
3975d55d98
remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
Camille GILLOT
73c52bc4dc Fix scoping for let-else. 2022-09-25 11:30:49 +02:00
b-naber
a705e65605 rename Unevaluated to UnevaluatedConst 2022-09-23 14:27:34 +02:00
b-naber
9f3784df89 introduce mir::Unevaluated 2022-09-22 12:35:28 +02:00
Michael Howell
b149c48186
Rollup merge of #102021 - lcnr:tyConst-fun, r=b-naber,BoxyUwU
some post-valtree cleanup

r? project-const-generics cc ```@b-naber```
2022-09-20 10:13:01 -07:00
bors
4136b59b7d Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank
Allow patterns to constrain the hidden type of opaque types

fixes #96572

reverts a revert as original PR was a perf regression that was fixed by reverting it: https://github.com/rust-lang/rust/pull/99368#issuecomment-1186587864)

TODO:

* check if https://github.com/rust-lang/rust/issues/99685 is avoided
2022-09-20 12:09:52 +00:00
bors
2019147c56 Auto merge of #101894 - dingxiangfei2009:let-else-avoid-duplicate-storage-live, r=oli-obk
Avoid duplicating StorageLive in let-else

cc `@est31`

Fix #101867
Fix #101932

#101410 introduced directives to activate storages of bindings in let-else earlier. However, since it is using the machinery of `match` and friends for pattern matching and binding, those storages are activated for the second time. This PR adjusts this behavior and avoid the duplicated activation for let-else statements.
2022-09-19 17:27:30 +00:00
Oli Scherer
1905f8c441 Document projection condition 2022-09-19 15:33:36 +00:00
lcnr
526856768d ctfe, const_to_op only for mir constants 2022-09-19 16:17:33 +02:00
lcnr
647052fc04 remove the Subst trait, always use EarlyBinder 2022-09-19 11:37:27 +02:00
Ding Xiang Fei
48c1c1d190
avoid duplicating StorageLive in let-else 2022-09-18 12:10:53 +08:00
Dylan DPC
3ad81e0dd8
Rollup merge of #93628 - est31:stabilize_let_else, r=joshtriplett
Stabilize `let else`

🎉  **Stabilizes the `let else` feature, added by [RFC 3137](https://github.com/rust-lang/rfcs/pull/3137).** 🎉

Reference PR: https://github.com/rust-lang/reference/pull/1156

closes #87335 (`let else` tracking issue)

FCP: https://github.com/rust-lang/rust/pull/93628#issuecomment-1029383585

----------

## Stabilization report

### Summary

The feature allows refutable patterns in `let` statements if the expression is
followed by a diverging `else`:

```Rust
fn get_count_item(s: &str) -> (u64, &str) {
    let mut it = s.split(' ');
    let (Some(count_str), Some(item)) = (it.next(), it.next()) else {
        panic!("Can't segment count item pair: '{s}'");
    };
    let Ok(count) = u64::from_str(count_str) else {
        panic!("Can't parse integer: '{count_str}'");
    };
    (count, item)
}
assert_eq!(get_count_item("3 chairs"), (3, "chairs"));
```

### Differences from the RFC / Desugaring

Outside of desugaring I'm not aware of any differences between the implementation and the RFC. The chosen desugaring has been changed from the RFC's [original](https://rust-lang.github.io/rfcs/3137-let-else.html#reference-level-explanations). You can read a detailed discussion of the implementation history of it in `@cormacrelf` 's [summary](https://github.com/rust-lang/rust/pull/93628#issuecomment-1041143670) in this thread, as well as the [followup](https://github.com/rust-lang/rust/pull/93628#issuecomment-1046598419). Since that followup, further changes have happened to the desugaring, in #98574, #99518, #99954. The later changes were mostly about the drop order: On match, temporaries drop in the same order as they would for a `let` declaration. On mismatch, temporaries drop before the `else` block.

### Test cases

In chronological order as they were merged.

Added by df9a2e0687 (#87688):

* [`ui/pattern/usefulness/top-level-alternation.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/pattern/usefulness/top-level-alternation.rs) to ensure the unreachable pattern lint visits patterns inside `let else`.

Added by 5b95df4bdc (#87688):

* [`ui/let-else/let-else-bool-binop-init.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-bool-binop-init.rs) to ensure that no lazy boolean expressions (using `&&` or `||`) are allowed in the expression, as the RFC mandates.
* [`ui/let-else/let-else-brace-before-else.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-brace-before-else.rs) to ensure that no `}` directly preceding the `else` is allowed in the expression, as the RFC mandates.
* [`ui/let-else/let-else-check.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-check.rs) to ensure that `#[allow(...)]` attributes added to the entire `let` statement apply for the `else` block.
* [`ui/let-else/let-else-irrefutable.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-irrefutable.rs) to ensure that the `irrefutable_let_patterns` lint fires.
* [`ui/let-else/let-else-missing-semicolon.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-missing-semicolon.rs) to ensure the presence of semicolons at the end of the `let` statement.
* [`ui/let-else/let-else-non-diverging.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-non-diverging.rs) to ensure the `else` block diverges.
* [`ui/let-else/let-else-run-pass.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-run-pass.rs) to ensure the feature works in some simple test case settings.
* [`ui/let-else/let-else-scope.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-scope.rs) to ensure the bindings created by the outer `let` expression are not available in the `else` block of it.

Added by bf7c32a447 (#89965):

* [`ui/let-else/issue-89960.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/issue-89960.rs) as a regression test for the ICE-on-error bug #89960 . Later in 102b9125e1 this got removed in favour of more comprehensive tests.

Added by 856541963c (#89974):

* [`ui/let-else/let-else-if.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-if.rs) to test for the improved error message that points out that `let else if` is not possible.

Added by 9b45713b6c:

* [`ui/let-else/let-else-allow-unused.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-allow-unused.rs) as a regression test for #89807, to ensure that `#[allow(...)]` attributes added to the entire `let` statement apply for bindings created by the `let else` pattern.

Added by 61bcd8d307 (#89841):

* [`ui/let-else/let-else-non-copy.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-non-copy.rs) to ensure that a copy is performed out of non-copy wrapper types. This mirrors `if let` behaviour. The test case bases on rustc internal changes originally meant for #89933 but then removed from the PR due to the error prior to the improvements of #89841.
* [`ui/let-else/let-else-source-expr-nomove-pass.rs `](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-source-expr-nomove-pass.rs) to ensure that while there is a move of the binding in the successful case, the `else` case can still access the non-matching value. This mirrors `if let` behaviour.

Added by 102b9125e1 (#89841):

* [`ui/let-else/let-else-ref-bindings.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-ref-bindings.rs) and [`ui/let-else/let-else-ref-bindings-pass.rs `](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-ref-bindings-pass.rs) to check `ref` and `ref mut` keywords in the pattern work correctly and error when needed.

Added by 2715c5f984 (#89841):

* Match ergonomic tests adapted from the `rfc2005` test suite.

Added by fec8a507a2 (#89841):

* [`ui/let-else/let-else-deref-coercion-annotated.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-deref-coercion-annotated.rs) and [`ui/let-else/let-else-deref-coercion.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-deref-coercion.rs) to check deref coercions.

#### Added since this stabilization report was originally written (2022-02-09)

Added by 76ea566677 (#94211):

* [`ui/let-else/let-else-destructuring.rs`](https://github.com/rust-lang/rust/blob/1.63.0/src/test/ui/let-else/let-else-destructuring.rs) to give a nice error message if an user tries to do an assignment with a (possibly refutable) pattern and an `else` block, like asked for in #93995.

Added by e7730dcb7e (#94208):

* [`ui/let-else/let-else-allow-in-expr.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-allow-in-expr.rs) to test whether `#[allow(unused_variables)]` works in the expr, as well as its non presence, as well as putting it on the entire `let else` *affects* the expr, too. This was adding a missing test as pointed out by the stabilization report.
* Expansion of `ui/let-else/let-else-allow-unused.rs` and `ui/let-else/let-else-check.rs` to ensure that non-presence of `#[allow(unused)]` does issue the unused lint. This was adding a missing test case as pointed out by the stabilization report.

Added by 5bd71063b3 (#94208):

* [`ui/let-else/let-else-slicing-error.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-slicing-error.rs), a regression test for #92069, which got fixed without addition of a regression test. This resolves a missing test as pointed out by the stabilization report.

Added by 5374688e1d (#98574):

* [`src/test/ui/async-await/async-await-let-else.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/async-await/async-await-let-else.rs) to test the interaction of async/await with `let else`

Added by 6c529ded86 (#98574):

* [`src/test/ui/let-else/let-else-temporary-lifetime.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-temporary-lifetime.rs) as a (partial) regression test for #98672

Added by 9b56640106 (#99518):

* [`src/test/ui/let-else/let-else-temp-borrowck.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-temporary-lifetime.rs) as a regression test for #93951
* Extension of `src/test/ui/let-else/let-else-temporary-lifetime.rs` to include a partial regression test for #98672 (especially regarding `else` drop order)

Added by baf9a7cb57 (#99518):

* Extension of `src/test/ui/let-else/let-else-temporary-lifetime.rs` to include a partial regression test for #93951, similar to `let-else-temp-borrowck.rs`

Added by 60be2de8b7 (#99518):

* Extension of `src/test/ui/let-else/let-else-temporary-lifetime.rs` to include a program that can now be compiled thanks to borrow checker implications of #99518

Added by 47a7a91c96 (#100132):

* [`src/test/ui/let-else/issue-100103.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/issue-100103.rs), as a regression test for #100103, to ensure that there is no ICE when doing `Err(...)?` inside else blocks.

Added by e3c5bd617d (#100443):

* [`src/test/ui/let-else/let-else-then-diverge.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-then-diverge.rs), to verify that there is no unreachable code error with the current desugaring.

Added by 981852677c (#100443):

* [`src/test/ui/let-else/issue-94176.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/issue-94176.rs), to make sure that a correct span is emitted for a missing trailing expression error. Regression test for #94176.

Added by e182d12a84 (#100434):

* [src/test/ui/unpretty/pretty-let-else.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/unpretty/pretty-let-else.rs), as a regression test to ensure pretty printing works for `let else` (this bug surfaced in many different ways)

Added by e26285603c (#99954):

* [`src/test/ui/let-else/let-else-temporary-lifetime.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-temporary-lifetime.rs) extended to contain & borrows as well, as this was identified as an earlier issue with the desugaring: https://github.com/rust-lang/rust/issues/98672#issuecomment-1200196921

Added by 2d8460ef43 (#99291):

* [`src/test/ui/let-else/let-else-drop-order.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-drop-order.rs) a matrix based test for various drop order behaviour of `let else`. Especially, it verifies equality of `let` and `let else` drop orders, [resolving](https://github.com/rust-lang/rust/pull/93628#issuecomment-1238498468) a [stabilization blocker](https://github.com/rust-lang/rust/pull/93628#issuecomment-1055738523).

Added by 1b87ce0d40 (#101410):

* Edit to `src/test/ui/let-else/let-else-temporary-lifetime.rs` to add the `-Zvalidate-mir` flag, as a regression test for #99228

Added by af591ebe4d (#101410):

* [`src/test/ui/let-else/issue-99975.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/issue-99975.rs) as a regression test for the ICE #99975.

Added by this PR:

* `ui/let-else/let-else.rs`, a simple run-pass check, similar to `ui/let-else/let-else-run-pass.rs`.

### Things not currently tested

* ~~The `#[allow(...)]` tests check whether allow works, but they don't check whether the non-presence of allow causes a lint to fire.~~ → *test added by e7730dcb7eb29a10ee73f269f4dc6e9d606db0da*
* ~~There is no `#[allow(...)]` test for the expression, as there are tests for the pattern and the else block.~~ → *test added by e7730dcb7eb29a10ee73f269f4dc6e9d606db0da*
* ~~`let-else-brace-before-else.rs` forbids the `let ... = {} else {}` pattern and there is a rustfix to obtain `let ... = ({}) else {}`. I'm not sure whether the `.fixed` files are checked by the tooling that they compile. But if there is no such check, it would be neat to make sure that `let ... = ({}) else {}` compiles.~~ → *test added by e7730dcb7eb29a10ee73f269f4dc6e9d606db0da*
* ~~#92069 got closed as fixed, but no regression test was added. Not sure it's worth to add one.~~ → *test added by 5bd71063b3810d977aa376d1e6dd7cec359330cc*
* ~~consistency between `let else` and `if let` regarding lifetimes and drop order: https://github.com/rust-lang/rust/pull/93628#issuecomment-1055738523~~ → *test added by 2d8460ef43d902f34ba2133fe38f66ee8d2fdafc*

Edit: they are all tested now.

### Possible future work / Refutable destructuring assignments

[RFC 2909](https://rust-lang.github.io/rfcs/2909-destructuring-assignment.html) specifies destructuring assignment, allowing statements like `FooBar { a, b, c } = foo();`.
As it was stabilized, destructuring assignment only allows *irrefutable* patterns, which before the advent of `let else` were the only patterns that `let` supported.
So the combination of `let else` and destructuring assignments gives reason to think about extensions of the destructuring assignments feature that allow refutable patterns, discussed in #93995.

A naive mapping of `let else` to destructuring assignments in the form of `Some(v) = foo() else { ... };` might not be the ideal way. `let else` needs a diverging `else` clause as it introduces new bindings, while assignments have a default behaviour to fall back to if the pattern does not match, in the form of not performing the assignment. Thus, there is no good case to require divergence, or even an `else` clause at all, beyond the need for having *some* introducer syntax so that it is clear to readers that the assignment is not a given (enums and structs look similar). There are better candidates for introducer syntax however than an empty `else {}` clause, like `maybe` which could be added as a keyword on an edition boundary:

```Rust
let mut v = 0;
maybe Some(v) = foo(&v);
maybe Some(v) = foo(&v) else { bar() };
```

Further design discussion is left to an RFC, or the linked issue.
2022-09-17 15:31:06 +05:30
bors
c524c7dd25 Auto merge of #98588 - b-naber:valtrees-cleanup, r=lcnr
Use only ty::Unevaluated<'tcx, ()> in type system

r? `@lcnr`
2022-09-17 03:04:22 +00:00
Oli Scherer
dab1074b91 Only generate OpaqueCast for opaque types 2022-09-16 11:37:50 +00:00
Oli Scherer
40e2de8c41 Revert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""
This reverts commit 4a742a691e.
2022-09-16 11:36:39 +00:00
Oli Scherer
5d664f7a8f Merge two arguments into one 2022-09-16 11:36:09 +00:00
est31
173eb6f407 Only enable the let_else feature on bootstrap
On later stages, the feature is already stable.

Result of running:

rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-15 21:06:45 +02:00
est31
5633e863bd Remove feature gate from let else suggestion
The let else suggestion added by 0d92752b8a
does not need a feature gate any more.
2022-09-15 21:06:45 +02:00
Ding Xiang Fei
4a5d2a561c
add diagram to explain the MIR structure 2022-09-15 10:08:14 +08:00
Ding Xiang Fei
c7d1c9b66f
add explanatory note 2022-09-15 10:08:13 +08:00
Ding Xiang Fei
34f0c4502f
supplement for the missing or incomplete comments 2022-09-15 10:08:11 +08:00
Ding Xiang Fei
1b87ce0d40
reorder nesting scopes and declare bindings without drop schedule 2022-09-15 10:07:54 +08:00
bors
6153d3cbe6 Auto merge of #101212 - eholk:dyn-star, r=compiler-errors
Initial implementation of dyn*

This PR adds extremely basic and incomplete support for [dyn*](https://smallcultfollowing.com/babysteps//blog/2022/03/29/dyn-can-we-make-dyn-sized/). The goal is to get something in tree behind a flag to make collaboration easier, and also to make sure the implementation so far is not unreasonable. This PR does quite a few things:

* Introduce `dyn_star` feature flag
* Adds parsing for `dyn* Trait` types
* Defines `dyn* Trait` as a sized type
* Adds support for explicit casts, like `42usize as dyn* Debug`
  * Including const evaluation of such casts
* Adds codegen for drop glue so things are cleaned up properly when a `dyn* Trait` object goes out of scope
* Adds codegen for method calls, at least for methods that take `&self`

Quite a bit is still missing, but this gives us a starting point. Note that this is never intended to become stable surface syntax for Rust, but rather `dyn*` is planned to be used as an implementation detail for async functions in dyn traits.

Joint work with `@nikomatsakis` and `@compiler-errors.`

r? `@bjorn3`
2022-09-14 18:10:51 +00:00
b-naber
6af8fb7936 address review again 2022-09-14 17:30:25 +02:00
Camille GILLOT
f3a37ed574 Shrink some visibilities. 2022-09-13 19:18:24 +02:00
Camille GILLOT
af128b0144 Also compute implicit params in THIR. 2022-09-13 19:18:24 +02:00
Camille GILLOT
445841cda3 Compute explicit MIR params on THIR. 2022-09-13 19:18:23 +02:00
Camille GILLOT
f76594a0bc Simplify MIR building entry. 2022-09-13 19:18:23 +02:00
Camille GILLOT
1f370d9437 Use tcx.hir() utils for spans in MIR building.
This corrects the `span_with_body` in the case of closures, which was
incorrectly shortened to the `def_span`.
2022-09-13 19:18:23 +02:00
Camille GILLOT
ffe20d61d6 Only keep one version of ImplicitSelfKind. 2022-09-13 19:18:23 +02:00
b-naber
a4bbb8db5c use ty::Unevaluated<'tcx, ()> in type system 2022-09-13 17:40:59 +02:00
Eric Holk
c5441acf67 Call destructors when dyn* object goes out of scope 2022-09-12 16:55:57 -07:00
Eric Holk
549c105bb3 dyn* through more typechecking and MIR 2022-09-12 16:55:56 -07:00
bors
2e44c17c12 Auto merge of #100968 - cjgillot:mir-upvar-vec, r=wesleywiser
Only compute captures once when building MIR.
2022-09-10 12:07:29 +00:00
Camille Gillot
bcbd183ca3
Remove unused temp.
Co-authored-by: Wesley Wiser <wwiser@gmail.com>
2022-09-10 12:10:04 +02:00
bors
24d6992020 Auto merge of #101467 - nnethercote:shrink-hir-Ty-Pat, r=spastorino
Shrink `hir::Ty` and `hir::Pat`

r? `@ghost`
2022-09-08 13:11:57 +00:00
Dylan DPC
0d61a507f5
Rollup merge of #101399 - cjgillot:borrowck-binding-span, r=estebank
Shrink span for bindings with subpatterns.

Bindings with nested patterns (`binding @ pat` syntax) currently point to the full pattern.  This PR proposes to shrink the span to stop before the ````@`.```  This makes the diagnostics for move/mutability conflicts clearer, as they not point to the `binding` only, instead of the full pat.

r? ```@estebank```
2022-09-08 11:55:06 +05:30
Nicholas Nethercote
e67f39f8bc Introduce DotDotPos.
This shrinks `hir::Pat` from 88 to 72 bytes.
2022-09-08 15:25:50 +10:00
Camille GILLOT
5d94d42485 Shrink span for bindings with subpatterns. 2022-09-06 20:57:44 +02:00
Guillaume Gomez
d13aefdc65
Rollup merge of #101357 - compiler-errors:variant-sugg-tweak, r=oli-obk
Include enum path in variant suggestion

(except for `Result` and `Option`, which we should have via the prelude)

Fixes #101356
2022-09-06 17:00:25 +02:00
Takayuki Maeda
fea1c5f5c8 refactor: remove unnecessary variables 2022-09-05 22:31:02 +09:00
Takayuki Maeda
87c6da363f separate the receiver from arguments in HIR 2022-09-05 22:25:49 +09:00
Michael Goulet
be53bd8380 Include enum path in variant suggestion 2022-09-03 08:11:17 +00:00
Nicholas Nethercote
43a0268f3a Use boxed slices in PatKind.
To shrink it a little more.
2022-09-02 07:26:22 +10:00
Nicholas Nethercote
a40124e01c Box CanonicalUserTypeAnnotation::CanonicalUserType.
This shrinks `Ascription`, which shrinks `PatKind::AscribeUserType`,
which shrinks `Pat`.
2022-09-02 07:26:22 +10:00
Nicholas Nethercote
2c4c8eb1a3 Box PatKind::Range.
Because it's the biggest variant. Also, make `PatRange` non-`Copy`,
because it's 104 bytes, which is pretty big.
2022-09-02 07:26:22 +10:00
Nicholas Nethercote
bd1e6836a0 Avoid some clones.
`Builder::expr_into_pattern` has a single call site. Currently the
`pattern` argument at the call site is always cloned.

This commit changes things so that we instead do a clone within
`expr_into_pattern`, but only if the pattern has the
`PatKind::AscribeUserType` kind, and we only clone the annotation within
the pattern instead of the entire pattern.
2022-09-02 07:26:22 +10:00
Nicholas Nethercote
053874eecc Clean up THIR patterns.
`thir::Pat::kind` is a `Box<PatKind>`, which doesn't follow the usual
pattern in AST/HIR/THIR which is that the "kind" enum for a node is
stored inline within the parent struct.

This commit makes the `PatKind` directly inline within the `Pat`. This
requires using `Box<Pat>` in all the types that hold a `Pat.

Ideally, `Pat` would be stored in `Thir` like `Expr` and `Stmt` and
referred to with a `PatId` rather than `Box<Pat>`. But this is hard to
do because lots of `Pat`s get created after the destruction of the `Cx`
that does normal THIR building. But this does get us a step closer to
`PatId`, because all the `Box<Pat>` occurrences would be replaced with
`PatId` if `PatId` ever happened.

At 128 bytes, `Pat` is large. Subsequent commits will shrink it.
2022-09-02 07:26:17 +10:00
Oli Scherer
1fc9ef1edd tracing::instrument cleanup 2022-09-01 14:54:27 +00:00
Oli Scherer
ee3c835018 Always import all tracing macros for the entire crate instead of piecemeal by module 2022-09-01 14:54:27 +00:00
Oli Scherer
d3b22c7267 Directly use the instrument macro instead of its full path 2022-09-01 14:53:46 +00:00
Dezhi Wu
b1430fb7ca Fix a bunch of typo
This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos
2022-08-31 18:24:55 +08:00
Nilstrieb
d1ef8180f9 Revert let_chains stabilization
This reverts commit 3266460749.

This is the revert against master, the beta revert was already done in #100538.
2022-08-29 19:34:11 +02:00
Matthias Krüger
d182081de1
Rollup merge of #99027 - tmiasko:basic-blocks, r=oli-obk
Replace `Body::basic_blocks()` with field access

Since the refactoring in #98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.

Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
2022-08-29 06:34:43 +02:00
Tomasz Miąsko
b48870b451 Replace Body::basic_blocks() with field access 2022-08-26 14:27:08 +02:00
bors
8a13871b69 Auto merge of #100944 - nnethercote:shrink-thir-Expr, r=cjgillot
Shrink `thir::Expr`

r? `@cjgillot`
2022-08-26 10:00:27 +00:00
Yuki Okushi
b3f178350a
Rollup merge of #99954 - dingxiangfei2009:break-out-let-else-higher-up, r=oli-obk
let-else: break out to one scope higher for let-else

```@est31``` This PR follows up with #99518 which is to break out to the last remainder scope. It breaks to the out-most `region_scope` of the block if the first statement is a `let-else`.
2022-08-25 08:50:55 +09:00
Nicholas Nethercote
e3755c1d54 Rename thir::Adt as thir::AdtExpr.
This matches the naming scheme used elsewhere, e.g. in the AST, and
avoids name clashes with the `ExprKind::Closure` variant.
2022-08-24 15:06:50 +10:00
Nicholas Nethercote
e57ac764b8 Box thir::ExprKind::InlineAsm.
This shrinks `thir::Expr`.
2022-08-24 15:06:50 +10:00
Nicholas Nethercote
b3245a8dff Box thir::ExprKind::Closure.
This shrinks `thir::Expr`.
2022-08-24 15:06:50 +10:00
Nicholas Nethercote
2df805fc7a Store blocks in Thir.
Like expressions, statements, and match arms. This shrinks `thir::Stmt`
and is a precursor to further shrinking `thir::Expr`.
2022-08-24 15:06:44 +10:00
Nicholas Nethercote
e7c25c3a97 Box user_ty fields in thir::ExprKind.
This shrinks several large variants of `ExprKind`.
2022-08-24 14:16:09 +10:00
Camille GILLOT
389c6041a4 Only compute captures once when building MIR. 2022-08-23 22:24:43 +02:00
Nicholas Nethercote
6087dc2054 Remove the symbol from ast::LitKind::Err.
Because it's never used meaningfully.
2022-08-23 16:56:24 +10:00
bors
a785176741 Auto merge of #100881 - Dylan-DPC:rollup-q9rr658, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #98200 (Expand potential inner `Or` pattern for THIR)
 - #99770 (Make some const prop mir-opt tests `unit-test`s)
 - #99957 (Rework Ipv6Addr::is_global to check for global reachability rather than global scope - rebase)
 - #100331 (Guarantee `try_reserve` preserves the contents on error)
 - #100336 (Fix two const_trait_impl issues)
 - #100713 (Convert diagnostics in parser/expr to SessionDiagnostic)
 - #100820 (Use pointer `is_aligned*` methods)
 - #100872 (Add guarantee that Vec::default() does not alloc)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-22 17:46:57 +00:00
Dylan DPC
56ba13ac7f
Rollup merge of #98200 - ouz-a:issue-98177, r=oli-obk
Expand potential inner `Or` pattern for THIR

Code assumed there wouldn't be a deeper `Or` pattern inside expanded `PatStack` this fixes it by looking for the `Or` pattern inside expanded `PatStack`.

A more ideal solution would be recursively doing this but I haven't found a good way to do that.
_fixes #97898_
2022-08-22 20:34:08 +05:30
Nilstrieb
135c24102c Fix span for consts in mir builder 2022-08-22 14:06:55 +02:00
Dylan DPC
2fe2975391
Rollup merge of #100081 - RalfJung:unused-unsafe-in-unsafe-fn, r=jackh726
never consider unsafe blocks unused if they would be required with deny(unsafe_op_in_unsafe_fn)

Judging from https://github.com/rust-lang/rust/issues/71668#issuecomment-1200317370 the consensus nowadays seems to be that we should never consider an unsafe block unused if it was required with `deny(unsafe_op_in_unsafe_fn)`, no matter whether that lint is actually enabled or not. So let's adjust rustc accordingly.

The first commit does the change, the 2nd does some cleanup.
2022-08-19 12:26:40 +05:30
Mark Rousskov
154a09dd91 Adjust cfgs 2022-08-12 16:28:15 -04:00
Dylan DPC
561ea0a746
Rollup merge of #99110 - audunhalland:match_has_guard_from_candidate, r=pnkfelix
Determine match_has_guard from candidates instead of looking up thir table again

Currently looking through mir build of matches because of interest in deref patterns. Finding some micro-optimizable things.
2022-08-11 22:46:57 +05:30
Matthias Krüger
b11b8d6939
Rollup merge of #100240 - cjgillot:noice-structural-match, r=davidtwco
Fail gracefully when const pattern is not structural match.

Fixes https://github.com/rust-lang/rust/issues/82909
2022-08-10 00:00:30 +02:00
Takayuki Maeda
56ec5bec1e suggest adding an appropriate missing pattern excluding comments 2022-08-09 14:27:26 +09:00
Camille GILLOT
aa031f9fbf Fail gracefully when const pattern is not structural match. 2022-08-07 19:12:33 +02:00
Matthias Krüger
eabf1a2e8e
Rollup merge of #100132 - compiler-errors:issue-100103, r=tmiasko
Use (actually) dummy place for let-else divergence

Fixes #100103
2022-08-06 16:15:56 +02:00
Matthias Krüger
6b938c8491
Rollup merge of #100093 - wcampbell0x2a:unused-parens-for-match-arms, r=petrochenkov
Enable unused_parens for match arms

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

Currently I can't get the `stderr` to work with `./x.py test`, but this should fix the issue. Help would be appreciated!
2022-08-04 22:25:02 +02:00
wcampbell
8dd44f1af4 Enable unused_parens for match arms 2022-08-04 07:16:39 -04:00
bors
2f2243c9b6 Auto merge of #99843 - oli-obk:is_useful_perf, r=compiler-errors
Some `is_useful` cleanups

#98582 was reverted because it was a perf regression.

https://github.com/rust-lang/rust/pull/99806 reintroduces the changes, but this PR picks individual ones that have no regressions.
2022-08-04 07:35:33 +00:00
Michael Goulet
47a7a91c96 Use (actually) dummy place for let-else divergence 2022-08-04 05:08:09 +00:00
Ralf Jung
86e2ca3088
add link to discussion 2022-08-02 18:57:22 -04:00
Ralf Jung
ee3fc9dff8 never consider unsafe blocks unused if they would be required with unsafe_op_in_unsafe_fn 2022-08-02 17:09:41 -04:00
Camille GILLOT
957548183d Remove trait_of_item query. 2022-08-01 21:39:26 +02:00
Camille GILLOT
d7ea161b7e Remove DefId from AssocItemContainer. 2022-08-01 21:38:45 +02:00
Matthias Krüger
8db3d7cfb6
Rollup merge of #99911 - cjgillot:no-guess, r=davidtwco
Remove some uses of `guess_head_span`

That function cuts a span at the first occurrence of `{`.  Using `def_span` is almost always more precise.
2022-08-01 16:49:31 +02:00
Ding Xiang Fei
8467a7b33e
provide a clearer explanation of scope breaking 2022-07-31 20:37:30 +08:00
Dylan DPC
403c1b3802
Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillot
Use LocalDefId for closures more
2022-07-31 17:36:40 +05:30
Cameron Steffen
cf2433a74f Use LocalDefId for closures more 2022-07-30 15:59:17 -05:00
Ding Xiang Fei
02443552c5
break out to one scope higher for let-else 2022-07-31 00:02:47 +08:00
Dylan DPC
c668820365
Rollup merge of #99311 - kckeiks:clean-up-body-owner-methods, r=cjgillot
change maybe_body_owned_by to take local def id

Issue https://github.com/rust-lang/rust/issues/96341
r? `@cjgillot`
2022-07-30 20:39:46 +05:30
Yuki Okushi
955091be8f
Rollup merge of #99518 - dingxiangfei2009:let-else-additional-tests, r=oli-obk
Let-else: break out scopes when a let-else pattern fails to match

This PR will commit to a new behavior so that values from initializer expressions are dropped earlier when a let-else pattern fails to match.

Fix #98672.
Close #93951.
cc `@camsteffen` `@est31`
2022-07-30 07:39:49 +09:00
Miguel Guarniz
0c609a4c1f Change enclosing_body_owner to return LocalDefId
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:26:10 -04:00
Miguel Guarniz
16513d689e Rename local_did to def_id
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:26:10 -04:00
Miguel Guarniz
25bdc8965e Change maybe_body_owned_by to take local def id
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:25:58 -04:00
Camille GILLOT
a09b7ebfd3 Use DefKind instead of FnKind for recursion lint. 2022-07-29 18:10:43 +02:00
Camille GILLOT
6733bc3066 Remove guess_head_span. 2022-07-28 23:14:04 +02:00
Oli Scherer
803d374f9b Pass PatCtxt instead of passing MatchCtxt + Ty separately 2022-07-28 08:49:39 +00:00
Oli Scherer
544de44a6b Don't pass (the rather large) PatCtxt by value 2022-07-28 08:44:49 +00:00
Oli Scherer
970ff3d45d Move constructor into the branch that actually uses it 2022-07-28 08:33:36 +00:00
Guillaume Gomez
9e7b7d5e1c
Rollup merge of #99651 - compiler-errors:fn-and-raw-ptr-in-const-generics, r=oli-obk
Deeply deny fn and raw ptrs in const generics

I think this is right -- just because we wrap a fn ptr in a wrapper type does not mean we should allow it in a const parameter.

We now reject both of these in the same way:

```
#![feature(adt_const_params)]

#[derive(Eq, PartialEq)]
struct Wrapper();

fn foo<const W: Wrapper>() {}

fn foo2<const F: fn()>() {}
```

This does regress one test (`src/test/ui/consts/refs_check_const_eq-issue-88384.stderr`), but I'm not sure it should've passed in the first place.

cc: ``@b-naber`` who introduced that test^
fixes #99641
2022-07-27 17:55:04 +02:00
Takayuki Maeda
051e98b7bf avoid &str/Symbol to String conversions 2022-07-25 22:40:00 +09:00
Michael Goulet
10b69ab0d2 Remove non-descriptive boolean from search_for_structural_match_violation 2022-07-25 03:39:23 +00:00
Michael Goulet
c1f54c30bb Get rid of redundant NonStructuralMatchTyKind 2022-07-25 03:39:22 +00:00
Michael Goulet
1152e70363 Deeply deny fn and raw ptrs in const generics 2022-07-25 03:39:22 +00:00
Ding Xiang Fei
9b56640106
break out scopes when let-else fails to match 2022-07-21 00:35:43 +08:00
Oli Scherer
4a742a691e Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank"
This reverts commit 6f8fb911ad, reversing
changes made to 7210e46dc6.
2022-07-20 07:55:58 +00:00
Michael Goulet
6d2bd541e0 use body's param-env when checking if type needs drop 2022-07-17 10:56:12 -07:00
Caio
3266460749 Stabilize let_chains 2022-07-16 20:17:58 -03:00
Oli Scherer
57e9f7a556 Infer wildcard type from other patterns at every pattern level 2022-07-15 15:56:17 +00:00
Oli Scherer
92e470a1de Move constructor into the branch that actually uses it 2022-07-15 15:56:17 +00:00
Oli Scherer
ea68ce7fac Revert a hack that only ever worked on level deep 2022-07-15 15:56:17 +00:00
Oli Scherer
728c7e8bda Allow destructuring opaque types, since the patterns constrain the opaque types 2022-07-15 15:56:17 +00:00
Oli Scherer
12457f814c Some tracing helpers 2022-07-15 15:56:16 +00:00
Oli Scherer
0c6918fe21 Reuse a helper method instead of manually rolling it 2022-07-15 15:56:16 +00:00
Oli Scherer
7a8a048b58 Remove early return that would likely have caused miscompilations if it ever happened 2022-07-15 15:56:16 +00:00
Oli Scherer
eeb10335ce Pass one argument instead of fetching two fields of it at every call site 2022-07-15 15:56:16 +00:00
Oli Scherer
a034446fae Add some tracing instrumentation 2022-07-15 15:56:16 +00:00
Oli Scherer
84a444a1f4 Introduce opaque type to hidden type projection 2022-07-15 15:49:22 +00:00
bors
f1a8854f9b Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #97720 (Always create elided lifetime parameters for functions)
 - #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`)
 - #98705 (Implement `for<>` lifetime binder for closures)
 - #99126 (remove allow(rustc::potential_query_instability) in rustc_span)
 - #99139 (Give a better error when `x dist` fails for an optional tool)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-14 11:00:30 +00:00
Dylan DPC
e5a86d7358
Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
Implement `for<>` lifetime binder for closures

This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following:

```rust
let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
//       ^^^^^^^^^^^--- new!
```

cc ``@Aaron1011`` ``@cjgillot``
2022-07-14 14:14:21 +05:30
bors
0ed9c64c3e Auto merge of #98975 - jyn514:unstable_opts, r=wesleywiser
Rename `debugging_opts` to `unstable_opts`

This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.

cc https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Codegen.20options.20.2F.20debugging.20options

r? `@Amanieu` cc `@nikic` `@joshtriplett`
2022-07-14 08:14:31 +00:00
Joshua Nelson
3c9765cff1 Rename debugging_opts to unstable_opts
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
2022-07-13 17:47:06 -05:00
Ralf Jung
e4593ef0f2 assigning to a union field can never drop now 2022-07-13 18:27:28 -04:00
Maybe Waffle
df4fee9841 Add an indirection for closures in hir::ExprKind
This helps bring `hir::Expr` size down, `Closure` was the biggest
variant, especially after `for<>` additions.
2022-07-12 21:00:13 +04:00
Ding Xiang Fei
5374688e1d
add tests for async await 2022-07-11 23:20:39 +02:00
Ding Xiang Fei
1cd30e7b32
move else block into the Local struct 2022-07-11 23:20:37 +02:00
Ding Xiang Fei
6c529ded86
lower let-else in MIR instead 2022-07-11 23:20:36 +02:00
Dylan DPC
9fc297a2ae
Rollup merge of #99140 - TaKO8Ki:implement-is-accessible-span, r=fee1-dead
Implement `SourceMap::is_span_accessible`

This patch adds `SourceMap::is_span_accessible` and replaces `span_to_snippet(span).is_ok()` and `span_to_snippet(span).is_err()` with it. This removes a `&str` to `String` conversion.
2022-07-11 15:19:32 +05:30
Takayuki Maeda
018155c3a2 rename a method 2022-07-11 16:51:19 +09:00
Takayuki Maeda
12d11e9a35 implement is_accessible_span 2022-07-11 11:36:15 +09:00
Michael Goulet
a1634642e0 Deny floats even when adt_const_params is enabled 2022-07-11 00:04:00 +00:00
Audun Halland
2036aea18e Determine match_has_guard from candidates instead of looking up thir table again 2022-07-10 11:27:36 +02:00
Ralf Jung
4e7aaf1f44 tweak names and output and bless 2022-07-09 07:43:56 -04:00
Ralf Jung
ac265cdc19 review feedback 2022-07-09 07:27:29 -04:00
Ralf Jung
a422b42159 don't allow ZST in ScalarInt
There are several indications that we should not ZST as a ScalarInt:
- We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it.
  `ValTree::zst()` used the former, but the latter could possibly arise as well.
- Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`.
- LLVM codegen already had to special-case ZST ScalarInt.

So instead add new ZST variants to those types that did not have other variants
which could be used for this purpose.
2022-07-09 07:27:29 -04:00
Tomasz Miąsko
c9dd1d9983 Make MIR basic blocks field public
This makes it possible to mutably borrow different fields of the MIR
body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`.

To preserve validity of control flow graph caches in the presence of
modifications, a new struct `BasicBlocks` wraps together basic blocks
and control flow graph caches.

The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`.
On the other hand a mutable access requires explicit `as_mut()` call.
2022-07-07 08:11:49 +02:00
Alan Egerton
4f0a64736b
Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
bors
54f79babae Auto merge of #98925 - Dylan-DPC:rollup-9185c9y, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #97712 (ptr::copy and ptr::swap are doing untyped copies)
 - #98624 (lints: mostly translatable diagnostics)
 - #98776 (rustdoc: improve click behavior of the source code mobile full-screen "sidebar")
 - #98856 (Remove FIXME from rustdoc intra-doc test)
 - #98913 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-05 12:17:26 +00:00
Dylan DPC
291df97fae
Rollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-errors
lints: mostly translatable diagnostics

As lints are created slightly differently than other diagnostics, intended to try make them translatable first and then look into the applicability of diagnostic structs but ended up just making most of the diagnostics in the crate translatable (which will still be useful if I do make a lot of them structs later anyway).

r? ``@compiler-errors``
2022-07-05 16:04:32 +05:30
bors
53792b9c5c Auto merge of #96862 - oli-obk:enum_cast_mir, r=RalfJung
Change enum->int casts to not go through MIR casts.

follow-up to https://github.com/rust-lang/rust/pull/96814

this simplifies all backends and even gives LLVM more information about the return value of `Rvalue::Discriminant`, enabling optimizations in more cases.
2022-07-05 09:36:29 +00:00
Oli Scherer
82c73af4a6 Prefer trace level instrumentation for the new noisy instrument attributes 2022-07-05 09:27:06 +00:00
Dylan DPC
d287726aa0
Rollup merge of #98639 - camsteffen:no-node-binding, r=compiler-errors
Factor out `hir::Node::Binding`
2022-07-02 12:23:38 +05:30
Cameron Steffen
ec82bc1996 Factor out hir::Node::Binding 2022-07-01 10:04:19 -05:00
bors
5b9775fe17 Auto merge of #98402 - cjgillot:undead, r=michaelwoerister
Rewrite dead-code pass to avoid fetching HIR.

This allows to get a more uniform handling of spans, and to simplify the grouping of diagnostics for variants and fields.
2022-07-01 14:43:15 +00:00
David Wood
7d2eba6311 middle: translation in LintDiagnosticBuilder
Accept `DiagnosticMessage` in `LintDiagnosticBuilder::build` so that
lints can be built with translatable diagnostic messages.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:58:41 +01:00
Oli Scherer
7839cb963f Change enum->int casts to not go through MIR casts.
Instead we generate a discriminant rvalue and cast the result of that.
2022-06-30 07:47:07 +00:00
Matthias Krüger
d34c4ca9be
Rollup merge of #98668 - TaKO8Ki:avoid-many-&str-to-string-conversions, r=Dylan-DPC
Avoid some `&str` to `String` conversions with `MultiSpan::push_span_label`

This patch removes some`&str` to `String` conversions with `MultiSpan::push_span_label`.
2022-06-29 20:35:07 +02:00
Takayuki Maeda
6212e6b339 avoid many &str to String conversions with MultiSpan::push_span_label 2022-06-29 21:16:43 +09:00
Oli Scherer
0e674b3ec5 Some tracing cleanups 2022-06-29 09:56:30 +00:00
bors
66c83ffca1 Auto merge of #98558 - nnethercote:smallvec-1.8.1, r=lqd
Update `smallvec` to 1.8.1.

This pulls in https://github.com/servo/rust-smallvec/pull/282, which
gives some small wins for rustc.

r? `@lqd`
2022-06-29 09:11:29 +00:00
Michael Goulet
8fd73560b3 Do not use a suggestion to change a binding's name to a type 2022-06-28 22:34:13 +00:00
Nicholas Nethercote
7c40661ddb Update smallvec to 1.8.1.
This pulls in https://github.com/servo/rust-smallvec/pull/282, which
gives some small wins for rustc.
2022-06-27 08:48:55 +10:00
Matthias Krüger
ea07b969ea
Rollup merge of #98429 - b-naber:use-correct-substs-discriminant-cast, r=lcnr
Use correct substs in enum discriminant cast

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

r? ```@lcnr```
2022-06-25 15:14:13 +02:00
b-naber
bf48b622a5 fmt 2022-06-24 16:43:38 +02:00
b-naber
f39c0d6b0a address review 2022-06-24 13:43:56 +02:00
b-naber
38814fc039 small refactor 2022-06-24 13:19:23 +02:00
ouz-a
661d488bfd use true recursion 2022-06-24 14:16:48 +03:00
b-naber
2e3221a927 use correct substs in enum discriminant hack 2022-06-24 11:11:40 +02:00
Camille GILLOT
2d82234331 Remove dead code. 2022-06-23 22:16:50 +02:00
Matthias Krüger
3e5800b8d3
Rollup merge of #98267 - compiler-errors:suggest-wildcard-arm, r=oli-obk
Don't omit comma when suggesting wildcard arm after macro expr

* Also adds `Span::eq_ctxt` to consolidate the various usages of `span.ctxt() == other.ctxt()`
* Also fixes an unhygenic usage of spans which caused the suggestion to render weirdly when we had one arm match in a macro
* Also always suggests a comma (i.e. even after a block) if we're rendering a wildcard arm in a single-line match (looks prettier 🌹)

Fixes #94866
2022-06-20 20:13:10 +02:00
bors
9a0b774966 Auto merge of #97931 - xldenis:fix-if-let-source-scopes, r=nagisa
Fix `SourceScope` for `if let` bindings.

Fixes #97799.

I'm not sure how to test this properly, is there any way to observe the difference in behavior apart from `ui` tests? I'm worried that they would be overlooked in the case of a regression.
2022-06-20 03:08:52 +00:00
Michael Goulet
3d16c22864 Be more hygenic with spans 2022-06-19 16:47:21 -07:00
Michael Goulet
52c9906c4b Use Span::eq_ctxt method instead of .ctxt() == .ctxt() 2022-06-19 16:46:59 -07:00
Michael Goulet
2c3bb42ebd Only omit trailing comma if block doesn't come from macro expansion 2022-06-19 16:46:37 -07:00
ouz-a
90abfe9ce2 expand inner or pattern 2022-06-17 21:38:26 +03:00
Nicholas Nethercote
bdbf9b297b compare_const_vals: add a special case for certain ranges.
This commit removes the `a == b` early return, which isn't useful in
practice, and replaces it with one that helps matches with many ranges,
including char ranges.
2022-06-16 11:25:34 +10:00
Nicholas Nethercote
73c52b724a compare_const_vals: Use infallible evaluation.
Because these evaluations can never fail.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote
246a5e08bf Remove ty arg from compare_const_vals.
It's now only used in no-longer-interesting assertion.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote
3ab6ef1938 Remove from_bool closure.
The code is clearer and simpler without it. Note that the `a == b` early
return at the top of the function means the `a == b` test at the end of
the function could never succeed.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote
fab85ddbeb Inline and remove fallback closure. 2022-06-16 10:52:58 +10:00
Nicholas Nethercote
b67635fdfd Remove one use of compare_const_vals.
A direct comparison has the same effect. This also avoids the need for a
type test within `compare_const_vals`.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote
9b4b34a0a6 Assert type equality of a and b in compare_const_vals.
Because they're always equal.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote
d5a13e2ca0 Remove dead code from compare_const_vals.
It's never executed when running the entire test suite. I think it's
because of the early return at the top of the function if `a.ty() != ty`
succeeds.
2022-06-16 10:52:56 +10:00
Nicholas Nethercote
be6c364142 simplify_match_pair: avoid the second comparison if possible.
Also, the `try_to_bits` always succeeds, so use `unwrap`.
2022-06-16 10:52:19 +10:00
Nicholas Nethercote
c4cd04480b sort_candidates: avoid the second comparison if possible.
This is a performance win for `unicode-normalization`.

The commit also removes the closure, which isn't necessary. And
reformulates the comparison into a form I find easier to read.
2022-06-16 10:52:19 +10:00
Nicholas Nethercote
7e4ec35d0c const_range_contains: avoid the second comparison if possible.
This is a performance win for `unicode-normalization`.

Also, I find the new formulation easier to read.
2022-06-16 10:52:19 +10:00
Yuki Okushi
87e373e82f
Rollup merge of #98110 - cjgillot:closure-brace, r=Aaron1011
Make `ExprKind::Closure` a struct variant.

Simple refactor since we both need it to introduce additional fields in `ExprKind::Closure`.

r? ``@Aaron1011``
2022-06-15 19:37:14 +09:00
Xavier Denis
a5e27a1134 Only create scopes for if let 2022-06-14 18:45:33 -07:00
b-naber
060acc97db rebase 2022-06-14 16:12:28 +02:00
b-naber
773d8b2e15 address review 2022-06-14 16:11:27 +02:00
b-naber
dbef6e4507 address review 2022-06-14 16:08:18 +02:00
b-naber
5c95a3db2a fix clippy test failures 2022-06-14 16:08:11 +02:00
b-naber
705d818bd5 implement valtrees as the type-system representation for constant values 2022-06-14 16:07:11 +02:00
Nicholas Nethercote
93e4b6ef06 Rename the ConstS::val field as kind.
And likewise for the `Const::val` method.

Because its type is called `ConstKind`. Also `val` is a confusing name
because `ConstKind` is an enum with seven variants, one of which is
called `Value`. Also, this gives consistency with `TyS` and `PredicateS`
which have `kind` fields.

The commit also renames a few `Const` variables from `val` to `c`, to
avoid confusion with the `ConstKind::Value` variant.
2022-06-14 13:06:44 +10:00
Camille GILLOT
3039cfeb6a Make ExprKind::Closure a struct variant. 2022-06-12 00:16:27 +02:00
Xavier Denis
e39c92e7aa Actually fix 2022-06-10 13:06:26 -07:00
Xavier Denis
cc75f0e5da Revert "More minimal changes"
This reverts commit fe0dedcb06947317d41a8570b7fff7f8690dcbff.
2022-06-10 13:01:56 -07:00
Xavier Denis
53deccf069 More minimal changes 2022-06-10 13:01:56 -07:00
Xavier Denis
b48f3d86fc Fix SourceScope for if let bindings. 2022-06-10 13:01:56 -07:00
Ding Xiang Fei
6cad569a95
thir: wrap hir id of vars into local var id 2022-06-09 17:00:38 +08:00
Dylan DPC
fd76e0eee0
Rollup merge of #97325 - tmiasko:capture-enum-field, r=arora-aman
Fix precise field capture of univariant enums

When constructing a MIR from a THIR field expression, introduce an
additional downcast projection before accessing a field of an enum.

When rebasing a place builder on top of a captured place, account for
the fact that a single HIR enum field projection corresponds to two MIR
projection elements: a downcast element and a field element.

Fixes #95271.
Fixes #96299.
Fixes #96512.
Fixes #97378.

r? ``@nikomatsakis`` ``@arora-aman``
2022-06-07 17:25:43 +02:00
Maybe Waffle
afaa9854fa Replace &Vec<_>s with &[_]s 2022-06-03 20:42:42 +04:00
Ralf Jung
fafccdced3 add cast kind of from_exposed_addr (int-to-ptr casts) 2022-06-02 10:46:13 -04:00
Ralf Jung
4dc5d457d8 rename PointerAddress → PointerExposeAddress 2022-06-01 14:08:17 -04:00
Tomasz Miąsko
dff602fc18 Add a pointer to address cast kind
A pointer to address cast are often special-cased.
Introduce a dedicated cast kind to make them easy distinguishable.
2022-05-31 00:00:00 +00:00
bors
4f39fb1f34 Auto merge of #97383 - dingxiangfei2009:restore-region-scope-tree-query, r=dingxiangfei2009
Try to cache region_scope_tree as a query

This PR will attempt to restore `region_scope_tree` as a query so that caching works again. It seems that `region_scope_tree` could be re-computed for nested items after all, which could explain the performance regression introduced by #95563.

cc `@Mark-Simulacrum` `@pnkfelix` I will try to trigger a perf run here.
2022-05-28 14:30:25 +00:00
Matthias Krüger
5fc8a8e227 clippy::complexity fixes
clone_on_copy
useless_format
bind_instead_of_map
filter_map_identity
useless_conversion
map_flatten
unnecessary_unwrap
2022-05-26 13:14:24 +02:00
Dylan DPC
8a3ad4942c
Rollup merge of #97351 - b-naber:adt-const-params-structural-match-violation, r=michaelwoerister
Output correct type responsible for structural match violation

Previously we included the outermost type that caused a structural match violation in the error message and stated that that type must be annotated with `#[derive(Eq, PartialEq)]` even if it already had that annotation. This PR outputs the correct type in the error message.

Fixes https://github.com/rust-lang/rust/issues/97278
2022-05-25 17:37:21 +02:00
Dylan DPC
11faf2e12a
Rollup merge of #95953 - JakobDegen:repeat-leak, r=oli-obk
Modify MIR building to drop repeat expressions with length zero

Closes #74836 .

Previously, when a user wrote `[foo; 0]` we used to simply leak `foo`. The goal is to fix that. This PR changes MIR building to make `[foo; 0]` equivalent to `{ drop(foo); [] }` in all cases. Of course, this is a breaking change (see below). A crater run did not indicate any regressions though, and given that the previous behavior was almost definitely not what any user wanted, it seems unlikely that anyone was relying on this.

Note that const generics are in general unaffected by this. Inserting the extra `drop` is only meaningful/necessary when `foo` is of a non-`Copy` type, and array repeat expressions with const generic repetition count must always be `Copy`.

Besides the obvious change to behavior associated with the additional drop, there are three categories of examples where this also changes observable behavior. In all of these cases, the new behavior is consistent with what you would get by replacing `[foo; 0]` with `{ drop(foo); [] }`. As such, none of these give the user new powers to express more things.

**No longer allowed in const (breaking)**:

```rust
const _: [String; 0] = [String::new(); 0];
```

This compiles on stable today. Because we now introduce the drop of `String`, this no longer compiles as `String` may not be dropped in a const context.

**Reduced dataflow (non-breaking)**:

```rust
let mut x: i32 = 0;
let r = &x;
let a = [r; 0];
x = 5;
let _b = a;
```

Borrowck rejects this code on stable because it believes there is dataflow between `a` and `r`, and so the lifetime of `r` has to extend to the last statement. This change removes the dataflow and the above code is allowed to compile.

**More const promotion (non-breaking)**:

```rust
let _v: &'static [String; 0] = &[String::new(); 0];
```

This does not compile today because `String` having drop glue keeps it from being const promoted (despite that drop glue never being executed). After this change, this is allowed to compile.

### Alternatives

A previous attempt at this tried to reduce breakage by various tricks. This is still a possibility, but given that crater showed no regressions it seems unclear why we would want to introduce this complexity.

Disallowing `[foo; 0]` completely is also an option, but obviously this is more of a breaking change. I do not know how often this is actually used though.

r? `@oli-obk`
2022-05-25 10:48:27 +02:00
Ding Xiang Fei
4c6074fbb0
try to cache region_scope_tree as a query 2022-05-25 13:52:32 +08:00
Jakob Degen
0f65bcd920 Modify MIR building to drop foo in [foo; 0] 2022-05-24 15:53:37 -04:00
b-naber
e2e425e8d2 give correct error message on structural match violation 2022-05-24 13:01:34 +02:00
Jakob Degen
09b0936db2 Refactor call terminator to always hold a destination place 2022-05-23 17:49:04 -04:00
Tomasz Miąsko
0e7eca77e1 Fix precise field capture of univariant enums
When constructing a MIR from a THIR field expression, introduce an
additional downcast projection before accessing a field of an enum.

When rebasing a place builder on top of a captured place, account for
the fact that a single HIR enum field projection corresponds to two MIR
projection elements: a downcast element and a field element.
2022-05-23 19:07:06 +02:00
Jack Huey
683a9c8391 Do leak check after function ptr coercion 2022-05-22 11:18:36 -04:00
Ding Xiang Fei
6044fbe462
factor out the rvalue lifetime rule
remove region_scope_tree from RegionCtxt

Apply suggestions from code review

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-05-22 16:46:50 +08:00
bors
e52e7115c7 Auto merge of #96515 - lcnr:user-types-in-pat, r=nikomatsakis
correctly deal with user type ascriptions in pat

supersedes #93856

`thir::PatKind::AscribeUserType` previously resulted in `CanonicalUserTypeAnnotations` where the inferred type already had a subtyping relation according to `variance` to the `user_ty`.

The bug can pretty much be summarized as follows:

- during mir building
  - `user_ty -> inferred_ty`: considers variance
  - `StatementKind::AscribeUserType`: `inferred_ty` is the type of the place, so no variance needed
- during mir borrowck
  - `user_ty -> inferred_ty`: does not consider variance
  - `StatementKind::AscribeUserType`: applies variance

This mostly worked fine. The lifetimes in `inferred_ty` were only bound by its relation to `user_ty` and to the `place` of `StatementKind::AscribeUserType`, so it doesn't matter where exactly the subtyping happens.

It does however matter when having higher ranked subtying. At this point the place where the subtyping happens is forced, causing this mismatch between building and borrowck to result in unintended errors.

cc #96514 which is pretty much the same issue

r? `@nikomatsakis`
2022-05-21 23:34:30 +00:00
lcnr
39a03779f8 correctly deal with user type ascriptions in pat 2022-05-21 08:13:17 +02:00
Jacob Pratt
49c82f31a8
Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
bors
cd282d7f75 Auto merge of #97019 - b-naber:transition-to-valtrees-pt1, r=oli-obk
Transition to valtrees pt1

Compartmentalising https://github.com/rust-lang/rust/pull/96591 as much as possible.

r? `@oli-obk`
2022-05-18 20:12:07 +00:00
bors
07ae142d77 Auto merge of #96863 - SparrowLii:let, r=michaelwoerister
use `hir::Let` in `hir::Guard::IfLet`

This PR fixes the FIXME about using `hir::Let` in `hir::Guard::IfLet`
2022-05-18 17:48:46 +00:00
b-naber
96b36d6eb2 use GlobalId in eval_to_valtree query and introduce query for valtree_to_const_val 2022-05-16 15:58:15 +02:00
bors
2a8a0fc423 Auto merge of #96883 - jackh726:early-binder-2, r=oli-obk
Add EarlyBinder

Chalk has no concept of `Param` (e0ade19d13/chalk-ir/src/lib.rs (L579)) or `ReEarlyBound` (e0ade19d13/chalk-ir/src/lib.rs (L1308)). Everything  is just "bound" - the equivalent of rustc's late-bound. It's not completely clear yet whether to move everything to the same time of binder in rustc or add `Param` and `ReEarlyBound` in Chalk.

Either way, tracking when we have or haven't already substituted out these in rustc can be helpful.

As a first step, I'm just adding a `EarlyBinder` newtype that is required to call `subst`. I also add a couple "transparent" `bound_*` wrappers around a couple query that are often immediately substituted.

r? `@nikomatsakis`
2022-05-14 23:53:11 +00:00
Jack Huey
c92248ab9f Add bound_type_of 2022-05-13 18:27:18 -04:00
bors
481db40311 Auto merge of #95562 - lcnr:attr-no-encode, r=davidtwco
don't encode only locally used attrs

Part of https://github.com/rust-lang/compiler-team/issues/505.

We now filter builtin attributes before encoding them in the crate metadata in case they should only be used in the local crate. To prevent accidental misuse `get_attrs` now requires the caller to state which attribute they are interested in. For places where that isn't trivially possible, I've added a method `fn get_attrs_unchecked` which I intend to remove in a followup PR.

After this pull request landed, we can then slowly move all attributes to only be used in the local crate while being certain that we don't accidentally try to access them from extern crates.

cc https://github.com/rust-lang/rust/pull/94963#issuecomment-1082924289
2022-05-12 12:48:30 +00:00
Aaron Hill
6b747aa397
Remove PartialOrd/Ord impl for PlaceRef
This is a new attempt at #93315. It removes one usage
of the `Ord` impl for `DefId`, which should make it easier
to eventually remove that impl.
2022-05-11 16:22:23 -04:00
bors
b862b438db Auto merge of #96888 - Aaron1011:fake-borrow-no-sort, r=petrochenkov
Use `FxIndexSet` to avoid sorting fake borrows

This fixes #96449, but I haven't yet been able to
make the reproducer work using `#[cfg]` attributes,
so we can't use the 'revision' infra to write a test

The previous implementation relied on sorting by `PlaceRef`.
This requires sorting by a `DefId`, which uses untracked state
(see #93315)
2022-05-11 04:09:45 +00:00
Jack Huey
319575ae8c Introduce EarlyBinder 2022-05-10 22:47:18 -04:00
lcnr
6c8265dc56 only_local: always check for misuse 2022-05-10 12:07:35 +02:00
Aaron Hill
aa0cc9c1e2
Use FxIndexSet to avoid sorting fake borrows
This fixes #96449, but I haven't yet been able to
make the reproducer work using `#[cfg]` attributes,
so we can't use the 'revision' infra to write a test

The previous implementation relied on sorting by `PlaceRef`.
This requires sorting by a `DefId`, which uses untracked state
(see #93315)
2022-05-09 22:29:46 -04:00
lcnr
32b13ac928 review 2022-05-09 18:40:18 +02:00
lcnr
d371ebe117 only compute codegen_fn_attrs where needed 2022-05-09 18:40:18 +02:00
SparrowLii
5251a80c0a use hir::Let in hir::Guard 2022-05-09 20:35:58 +08:00
bors
574830f573 Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors
Begin fixing all the broken doctests in `compiler/`

Begins to fix #95994.
All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are.
There are also a few that I marked `ignore` that could maybe be made to work but seem less important.
Each `ignore` has a rough "reason" for ignoring after it parentheses, with

- `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax"
- `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy.
- `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR.
- `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup.

Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful.

I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-07 06:30:29 +00:00
lcnr
a87fa6314f mirror_expr cleanup 2022-05-06 19:00:37 +02:00
Yuki Okushi
da57b3a832
Rollup merge of #96628 - joshtriplett:stabilize-then-some, r=m-ou-se
Stabilize `bool::then_some`

FCP completed in https://github.com/rust-lang/rust/issues/80967
2022-05-05 10:20:35 +09:00
Josh Triplett
0fc5c524f5 Stabilize bool::then_some 2022-05-04 13:22:08 +02:00
Oli Scherer
db02e61038 Generate an intermediate temporary for Drop constants.
To limit the fallout from this, don't do this for the last (or only) operand in an rvalue.
2022-05-04 09:09:52 +00:00
Elliot Roberts
7907385999 fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
Vadim Petrochenkov
5b5964f569 rustc: Panic by default in DefIdTree::parent
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.

Same applies to `local_parent`/`opt_local_parent`.
2022-05-02 01:56:50 +03:00
Emil Gardström
2e47271cb8
only show a simple description in E0133 span label 2022-04-24 18:33:07 +02:00
Emil Gardström
8b8f6653cf
add DefId to unsafety violations and display function path in E0133
this enables consumers to access the function definition that was reported to be unsafe
2022-04-24 18:33:06 +02:00
Dylan DPC
38e3f523c0
Rollup merge of #93313 - tmiasko:uninhabited, r=tmandry
Check if call return type is visibly uninhabited when building MIR

The main motivation behind the change is to expose information about diverging
calls to the generator transform and match the precision of drop range tracking
which already understands that call expressions with visibly uninhabited types
diverges.

This change should also accept strictly more programs than before. That is
programs that were previously rejected due to errors raised by control-flow
sensitive checks in a code that is no longer considered reachable.

Fixes #93161.
2022-04-20 18:26:01 +02:00
Dylan DPC
91847c43cc
Rollup merge of #96023 - matthiaskrgr:clippyper1304, r=lcnr
couple of clippy::perf fixes
2022-04-16 14:25:56 +02:00
bors
080d5452e1 Auto merge of #94468 - Amanieu:global_asm_sym, r=nagisa
Implement sym operands for global_asm!

Tracking issue: #93333

This PR is pretty much a complete rewrite of `sym` operand support for inline assembly so that the same implementation can be shared by `asm!` and `global_asm!`. The main changes are:
- At the AST level, `sym` is represented as a special `InlineAsmSym` AST node containing a path instead of an `Expr`.
- At the HIR level, `sym` is split into `SymStatic` and `SymFn` depending on whether the path resolves to a static during AST lowering (defaults to `SynFn` if `get_early_res` fails).
  - `SymFn` is just an `AnonConst`. It runs through typeck and we just collect the resulting type at the end. An error is emitted if the type is not a `FnDef`.
  - `SymStatic` directly holds a path and the `DefId` of the `static` that it is pointing to.
- The representation at the MIR level is mostly unchanged. There is a minor change to THIR where `SymFn` is a constant instead of an expression.
- At the codegen level we need to apply the target's symbol mangling to the result of `tcx.symbol_name()` depending on the target. This is done by calling the LLVM name mangler, which handles all of the details.
  - On Mach-O, all symbols have a leading underscore.
  - On x86 Windows, different mangling is used for cdecl, stdcall, fastcall and vectorcall.
  - No mangling is needed on other platforms.

r? `@nagisa`
cc `@eddyb`
2022-04-16 04:46:01 +00:00
Dylan DPC
ba9c3a13ee
Rollup merge of #96026 - matthiaskrgr:clippy_compl_1304, r=Dylan-DPC
couple of clippy::complexity fixes
2022-04-15 20:50:47 +02:00
ouz-a
c20bb1d59f Update issue-92893.stderr 2022-04-14 23:42:15 +03:00
Amanieu d'Antras
dc345d8bff Reimplement lowering of sym operands for asm! so that it also works with global_asm! 2022-04-14 15:32:03 +01:00
Matthias Krüger
7c2d57e0fa couple of clippy::complexity fixes 2022-04-13 22:51:34 +02:00
Matthias Krüger
bbd7ce6904 couple of clippy::perf fixes 2022-04-13 22:18:28 +02:00
bors
e3c43e64ec Auto merge of #94255 - b-naber:use-mir-constant-in-thir, r=oli-obk
Use mir constant in thir instead of ty::Const

This is blocked on https://github.com/rust-lang/rust/pull/94059 (does include its changes, the first two commits in this PR correspond to those changes) and https://github.com/rust-lang/rust/pull/93800 being reinstated (which had to be reverted). Mainly opening since `@lcnr` offered to give some feedback and maybe also for a perf-run (if necessary).

This currently contains a lot of duplication since some of the logic of `ty::Const` had to be copied to `mir::ConstantKind`, but with the introduction of valtrees a lot of that functionality will disappear from `ty::Const`.

Only the last commit contains changes that need to be reviewed here. Did leave some `FIXME` comments regarding future implementation decisions and some things that might be incorrectly implemented.

r? `@oli-obk`
2022-04-13 07:50:56 +00:00
b-naber
3be987e076 dont make lit_to_mir_constant a query 2022-04-08 11:56:21 +02:00
Ralf Jung
38004b72bc interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internal 2022-04-07 16:24:48 -04:00
b-naber
c3491378e3 get rid of visit_constant in thir visitor 2022-04-06 10:43:58 +02:00
David Wood
c45f29595d span: move MultiSpan
`MultiSpan` contains labels, which are more complicated with the
introduction of diagnostic translation and will use types from
`rustc_errors` - however, `rustc_errors` depends on `rustc_span` so
`rustc_span` cannot use types like `DiagnosticMessage` without
dependency cycles. Introduce a new `rustc_error_messages` crate that can
contain `DiagnosticMessage` and `MultiSpan`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:00 +01:00
b-naber
14e3d038c0 rebase and remove dead code 2022-04-02 12:47:06 +02:00
b-naber
9b28d3b494 try to evaluate in from_opt_const_arg_anon_const 2022-04-02 12:21:02 +02:00
b-naber
0078e54185 rebase and use ty::Const in patterns again 2022-04-02 12:21:00 +02:00