Commit Graph

343 Commits

Author SHA1 Message Date
Michael Goulet 36a106891a Make rustc build with new chalk 2022-11-13 19:53:44 +00:00
Michael Goulet 6de5f6277e Bump chalk to v0.87 2022-11-13 19:29:38 +00:00
Michael Goulet 63217e08cc make dropck_outlives into a proper canonicalized type query 2022-11-09 22:58:39 +00:00
Jack Huey 00e314d5ed Add an optional Span to BrAnon and use it to print better error for HRTB error from generator interior 2022-11-07 17:39:29 -05:00
Mateusz c97fd8183a
Refactor tcx mk_const parameters. 2022-11-04 20:33:32 +00:00
Michael Goulet 2f9794b84a remove _types from ocx method names 2022-10-27 15:43:37 +00:00
Michael Goulet ce11ae5d0d Address some more nits 2022-10-27 15:43:33 +00:00
Michael Goulet d793d80cf7 (almost) Always use ObligationCtxt when dealing with canonical queries 2022-10-27 15:43:33 +00:00
lcnr face090ef1 rm `try_normalize_mir_const_after_erasing_regions` 2022-10-17 10:54:03 +02:00
Cameron Steffen 283abbf0e7 Change InferCtxtBuilder from enter to build 2022-10-07 07:10:40 -05:00
Cameron Steffen 349415d1c6 Remove TypeckResults from InferCtxt 2022-10-07 07:06:19 -05:00
Oli Scherer c7b6ebdf7c It's not about types or consts, but the lack of regions 2022-10-04 14:10:44 +00:00
Pietro Albini 3975d55d98
remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
bors f5193a9fcc Auto merge of #95474 - oli-obk:tait_ub, r=jackh726
Neither require nor imply lifetime bounds on opaque type for well formedness

The actual hidden type can live arbitrarily longer than any individual lifetime and arbitrarily shorter than all but one of the lifetimes.

fixes #86218
fixes #84305

This is a **breaking change** but it is a necessary soundness fix
2022-09-25 19:15:26 +00:00
Matthias Krüger 16de1fddee
Rollup merge of #102016 - lcnr:given-OutlivesEnvironment, r=jackh726
implied_bounds: deal with inference vars

fixes #101951

while computing implied bounds for `<<T as ConstructionFirm>::Builder as BuilderFn<'_>>::Output` normalization replaces a projection with an inference var (adding a `Projection` obligation). Until we prove that obligation, this inference var remains unknown, which caused us to miss an implied bound necessary to prove that the unnormalized projection from the trait method signature is wf.

r? types
2022-09-25 09:32:07 +02:00
Oli Scherer 37928f5986 Neither require nor imply lifetime bounds on opaque type for well formedness 2022-09-21 13:11:54 +00:00
lcnr 71f8fd5c58 improve infer var handling for implied bounds 2022-09-19 15:13:34 +02:00
lcnr 647052fc04 remove the `Subst` trait, always use `EarlyBinder` 2022-09-19 11:37:27 +02:00
bors efa717bc2d Auto merge of #101924 - jackh726:revert-static-hrtb-error, r=compiler-errors
Re-add HRTB implied static bug note

r? `@compiler-errors` since you reviewed it previously

I deleted a `normalize` call and forgot about it. Whoops.
2022-09-19 04:56:14 +00:00
Jack Huey 1eb71f0893 Add back in normalize call 2022-09-17 11:46:04 -04: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 9b45713b6c1775f0103a1ebee6ab7c6d9b781a21:

* [`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
Jack Huey e09242d5b8 Final bits 2022-09-16 17:47:53 -04:00
Jack Huey 92b759f517 Revert "Better errors for implied static bound"
This reverts commit c75817b0a7.
2022-09-16 09:47:07 -04: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
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
Jack Huey c75817b0a7 Better errors for implied static bound 2022-09-13 20:18:04 -04:00
Eric Holk cf04547b0b Address code review comments 2022-09-13 14:50:12 -07:00
Eric Holk 6c01273a15 Plumb dyn trait representation through ty::Dynamic 2022-09-12 16:55:55 -07:00
Jack Huey 1ca9eb8ec3 Remove ReEmpty 2022-09-08 20:55:55 -04: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
Jack Huey 8033c3c27d Various changes to logging of borrowck-related code 2022-08-29 10:59:21 -04:00
5225225 09ea9f0a87 Add diagnostic translation lints to crates that don't emit them 2022-08-18 19:29:02 +01:00
Matthias Krüger 01ccde5ec8
Rollup merge of #100095 - jackh726:early-binder, r=lcnr
More EarlyBinder cleanups

Each commit is independent

r? types
2022-08-04 22:25:04 +02:00
Matthias Krüger 0de7f756f0
Rollup merge of #99746 - compiler-errors:more-trait-engine, r=jackh726
Use `TraitEngine` in more places that don't specifically need `FulfillmentContext::new_in_snapshot`

Not sure if this change is worthwhile, but couldn't hurt re: chalkification

r? types
2022-08-03 22:29:27 +02:00
Jack Huey e21624dc80 Add bound_predicates_of and bound_explicit_predicates_of 2022-08-02 22:44:08 -04:00
bors 06f4950cbd Auto merge of #100032 - BoxyUwU:no_ty_in_placeholder_const, r=compiler-errors
make `PlaceholderConst` not store the type of the const

Currently the `Placeholder` variant on `ConstKind` is 28 bytes when with this PR its 8 bytes, i am not sure this is really useful at all rn since `Unevaluated` and `Value` variants are huge still but eventually it should be possible to get both down to 16 bytes 🤔. Mostly opening this to see if this change has any perf impact when done before it can make `ConstKind`/`ConstS` smaller
2022-08-02 13:10:49 +00:00
Camille GILLOT d7ea161b7e Remove DefId from AssocItemContainer. 2022-08-01 21:38:45 +02:00
Ellen 825a7cc65c make `PlaceholderConst` not store the type of the const 2022-08-01 15:42:38 +01:00
Dylan DPC 91b8b9ba4b
Rollup merge of #99714 - ouz-a:issue_57961, r=oli-obk
Fix regression introduced with #99383

Fixes #99642
2022-07-28 16:38:30 +05:30
ouz-a 8716eae3b1 add tests and comment 2022-07-27 14:43:46 +03:00
Michael Goulet 58f107ab56 Use TraitEngine in more places that don't specifically need FulfillmentCtxt::new_in_snapshot 2022-07-26 04:55:06 +00:00
ouz-a 4a0473c0f5 Bubble up obligations 2022-07-25 15:45:36 +03:00
Michael Woerister 88f6c6d8a0 Remove unused StableMap and StableSet types from rustc_data_structures 2022-07-20 13:11:39 +02:00
Alan Egerton 4f0a64736b
Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
Alan Egerton e9e5d0685b
Relax constrained generics to TypeVisitable 2022-07-05 22:25:43 +01: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
Jack Huey e16dbb5076 Make empty bounds lower to WellFormed and make WellFormed coinductive 2022-06-28 00:17:40 -04: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
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
Nicholas Nethercote 90db033955 Folding revamp.
This commit makes type folding more like the way chalk does it.

Currently, `TypeFoldable` has `fold_with` and `super_fold_with` methods.
- `fold_with` is the standard entry point, and defaults to calling
  `super_fold_with`.
- `super_fold_with` does the actual work of traversing a type.
- For a few types of interest (`Ty`, `Region`, etc.) `fold_with` instead
  calls into a `TypeFolder`, which can then call back into
  `super_fold_with`.

With the new approach, `TypeFoldable` has `fold_with` and
`TypeSuperFoldable` has `super_fold_with`.
- `fold_with` is still the standard entry point, *and* it does the
  actual work of traversing a type, for all types except types of
  interest.
- `super_fold_with` is only implemented for the types of interest.

Benefits of the new model.
- I find it easier to understand. The distinction between types of
  interest and other types is clearer, and `super_fold_with` doesn't
  exist for most types.
- With the current model is easy to get confused and implement a
  `super_fold_with` method that should be left defaulted. (Some of the
  precursor commits fixed such cases.)
- With the current model it's easy to call `super_fold_with` within
  `TypeFolder` impls where `fold_with` should be called. The new
  approach makes this mistake impossible, and this commit fixes a number
  of such cases.
- It's potentially faster, because it avoids the `fold_with` ->
  `super_fold_with` call in all cases except types of interest. A lot of
  the time the compile would inline those away, but not necessarily
  always.
2022-06-08 09:24:03 +10:00
Jack Huey 410dcc9674 Fully stabilize NLL 2022-06-03 17:16:41 -04:00
Jacob Pratt 49c82f31a8
Remove `crate` visibility usage in compiler 2022-05-20 20:04:54 -04:00
Jack Huey 0247faed29 Add bound_impl_trait_ref 2022-05-13 18:27:40 -04:00
Jack Huey c92248ab9f Add bound_type_of 2022-05-13 18:27:18 -04:00
Jack Huey 319575ae8c Introduce EarlyBinder 2022-05-10 22:47:18 -04:00
Oli Scherer 1163aa7e72 Remove opaque type obligation and just register opaque types as they are encountered.
This also registers obligations for the hidden type immediately.
2022-03-28 16:57:45 +00:00
Oli Scherer 264cd05b16 Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"
This reverts commit 6499c5e7fc, reversing
changes made to 78450d2d60.
2022-03-28 16:27:14 +00:00
InfRandomness 645620b3b3 Swap DtorckConstraint to DropckConstraint
This change was made as per suspicion that this struct was never renamed after consistent use of DropCk.

This also clarifies the meaning behind the name of this structure.
2022-03-24 20:35:35 +01:00
Michael Goulet 376d100e74 make rustc work again 2022-03-23 21:52:17 -07:00
Michael Goulet cc5885552e upgrade chalk 2022-03-23 00:01:20 -07:00
Nicholas Nethercote ca5525d564 Improve `AdtDef` interning.
This commit makes `AdtDef` use `Interned`. Much the commit is tedious
changes to introduce getter functions. The interesting changes are in
`compiler/rustc_middle/src/ty/adt.rs`.
2022-03-11 13:31:24 +11:00
Dario Nieuwenhuis b8bd9978e1 chalk/db: use correct debrujin index when replacing opaque type. 2022-02-22 00:16:56 +01:00
Dario Nieuwenhuis c6f5c7ba60 chalk/lowering: lower generator types. 2022-02-21 23:27:08 +01:00
lcnr 1245131a11 use `List<Ty<'tcx>>` for tuples 2022-02-21 07:09:11 +01:00
est31 2ef8af6619 Adopt let else in more places 2022-02-19 17:27:43 +01:00
Nicholas Nethercote a95fb8b150 Overhaul `Const`.
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as
this:
```
pub struct Const<'tcx>(&'tcx Interned<ConstS>);
```
This now matches `Ty` and `Predicate` more closely, including using
pointer-based `eq` and `hash`.

Notable changes:
- `mk_const` now takes a `ConstS`.
- `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a
  we need separate arena for it, because we can't use the `Dropless` one any
  more.
- Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes
- Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes.
- Lots of tedious sigil fiddling.
2022-02-15 16:19:59 +11:00
Nicholas Nethercote 7eb15509ce Remove unnecessary `RegionKind::` quals.
The variant names are exported, so we can use them directly (possibly
with a `ty::` qualifier). Lots of places already do this, this commit
just increases consistency.
2022-02-15 16:14:24 +11:00
Nicholas Nethercote 7024dc523a Overhaul `RegionKind` and `Region`.
Specifically, change `Region` from this:
```
pub type Region<'tcx> = &'tcx RegionKind;
```
to this:
```
pub struct Region<'tcx>(&'tcx Interned<RegionKind>);
```

This now matches `Ty` and `Predicate` more closely.

Things to note
- Regions have always been interned, but we haven't been using pointer-based
  `Eq` and `Hash`. This is now happening.
- I chose to impl `Deref` for `Region` because it makes pattern matching a lot
  nicer, and `Region` can be viewed as just a smart wrapper for `RegionKind`.
- Various methods are moved from `RegionKind` to `Region`.
- There is a lot of tedious sigil changes.
- A couple of types like `HighlightBuilder`, `RegionHighlightMode` now have a
  `'tcx` lifetime because they hold a `Ty<'tcx>`, so they can call `mk_region`.
- A couple of test outputs change slightly, I'm not sure why, but the new
  outputs are a little better.
2022-02-15 16:08:52 +11:00
Nicholas Nethercote 925ec0d3c7 Overhaul `PredicateInner` and `Predicate`.
Specifically, change `Ty` from this:
```
pub struct Predicate<'tcx> { inner: &'tcx PredicateInner<'tcx> }
```
to this:
```
pub struct Predicate<'tcx>(&'tcx Interned<PredicateS<'tcx>>)
```
where `PredicateInner` is renamed as `PredicateS`.

 This (plus a few other minor changes) makes the parallels with `Ty` and
`TyS` much clearer, and makes the uniqueness more explicit.
2022-02-15 16:03:26 +11:00
Nicholas Nethercote e9a0c429c5 Overhaul `TyS` and `Ty`.
Specifically, change `Ty` from this:
```
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```
to this
```
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
```
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
  means we can move a lot of methods away from `TyS`, leaving `TyS` as a
  barely-used type, which is appropriate given that it's not meant to
  be used directly.
- The uniqueness requirement is now explicit, via the `Interned` type.
  E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
  than via `TyS`, which wasn't obvious at all.

Much of this commit is boring churn. The interesting changes are in
these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs

Specifically:
- Most mentions of `TyS` are removed. It's very much a dumb struct now;
  `Ty` has all the smarts.
- `TyS` now has `crate` visibility instead of `pub`.
- `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
  which just works better with the new structure.
- The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
  of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
  (pointer-based, for the `Equal` case) and partly on `TyS`
  (contents-based, for the other cases).
- There are many tedious sigil adjustments, i.e. adding or removing `*`
  or `&`. They seem to be unavoidable.
2022-02-15 16:03:24 +11:00
Matthew Jasper 1e6d38230f Reverse parameter to placeholder substitution in chalk results 2022-02-11 21:38:17 +00:00
Matthew Jasper d4fa173ed3 Fix more chalk lowering issues
- Implement lowering for subtype goals
- Use correct lang item for Generator trait
- Use `lower_into` for lowering `ty::Variance`
2022-02-11 21:38:17 +00:00
Matthew Jasper cb3cff3761 Stop using a placeholder for empty regions in Chalk 2022-02-11 21:38:16 +00:00
Oli Scherer d54195db22 Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"
This reverts commit e7cc3bddbe, reversing
changes made to 734368a200.
2022-02-11 07:18:06 +00:00
Camille GILLOT 8edd32c940 Avoid clone. 2022-02-09 20:11:33 +01:00
Camille GILLOT 6c2ee885e6 Ensure that queries only return Copy types. 2022-02-09 20:07:38 +01:00
Oli Scherer 0f6e06b7c0 Lazily resolve type-alias-impl-trait defining uses
by using an opaque type obligation to bubble up comparisons between opaque types and other types

Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2022-02-02 15:40:11 +00:00
kadmin bd03d8167f Remove generalization over projection
Instead, just use a term everywhere.
2022-01-28 00:25:36 +00:00
pierwill 8d27c28e39 ⬆ chalk to 0.76.0 2022-01-19 13:44:43 -06:00
bors 7bc7be860f Auto merge of #87648 - JulianKnodt:const_eq_constrain, r=oli-obk
allow eq constraints on associated constants

Updates #70256

(cc `@varkor,` `@Centril)`
2022-01-18 09:58:39 +00:00
Matthias Krüger cb5ecff8b2
Rollup merge of #92640 - compiler-errors:array-deref-on-newtype, r=lcnr
Fix ICEs related to `Deref<Target=[T; N]>` on newtypes

1. Stash a const infer's type into the canonical var during canonicalization, so we can recreate the fresh const infer with that same type.
    For example, given `[T; _]` we know `_` is a `usize`. If we go from infer => canonical => infer, we shouldn't forget that variable is a usize.
Fixes #92626
Fixes #83704

2. Don't stash the autoderef'd slice type that we get from method lookup, but instead recreate it during method confirmation. We need to do this because the type we receive back after picking the method references a type variable that does not exist after probing is done.
Fixes #92637

... A better solution for the second issue would be to actually _properly_ implement `Deref` for `[T; N]` instead of fixing this autoderef hack to stop leaking inference variables. But I actually looked into this, and there are many complications with const impls.
2022-01-18 04:41:58 +01:00
kadmin 1c1ce2fbda Add term to ExistentialProjection
Also prevent ICE when adding a const in associated const equality.
2022-01-17 20:01:22 +00:00
kadmin e7529d6a38 Update term for use in more places
Replace use of `ty()` on term and use it in more places. This will allow more flexibility in the
future, but slightly worried it allows items which are consts which only accept types.
2022-01-17 19:59:40 +00:00
kadmin 67f56671d0 Use Term in ProjectionPredicate
ProjectionPredicate should be able to handle both associated types and consts so this adds the
first step of that. It mainly just pipes types all the way down, not entirely sure how to handle
consts, but hopefully that'll come with time.
2022-01-17 17:44:56 +00:00
Ellen 71bbb603f4 initial revert 2022-01-15 01:16:55 +00:00
Michael Goulet 012910dab2 Canonicalize const variables correctly 2022-01-12 08:27:41 -08:00
Matthew Jasper d7595853a2 Add `trait_item_def_id` to `AssocItem`
This allows avoiding some lookups by name
2022-01-07 12:28:12 -08:00
bors e670844012 Auto merge of #91929 - anuvratsingh:remove_in_band_lifetimes_compiler_rustc_traits, r=jackh726
Removed `in_band_lifetimes` from `rustc_traits`

Issue: [#91867](https://github.com/rust-lang/rust/issues/91867)
2021-12-31 05:08:24 +00:00
Anuvrat 58a888fcc1
Removed `in_band_lifetimes` from `rustc_traits` 2021-12-30 13:59:19 -05:00
bors c1d301bb29 Auto merge of #92167 - pierwill:chalk-update, r=jackh726
Update chalk to 0.75.0

- Compute flags in `intern_ty`
- Remove `tracing-serde` from `PERMITTED_DEPENDENCIES`
- Bump `tracing-tree` to 0.2.0
- Bump `tracing-subscriber` to 0.3.3
2021-12-23 08:59:55 +00:00
pierwill ea25b779eb Update chalk to 0.75.0
- Compute flags in `intern_ty`
- Remove tracing-serde from PERMITTED_DEPENDENCIES
- Disable `tracing-full` feature in `chalk-solve`
- Bump tracing-tree to 0.2.0
2021-12-22 10:07:44 -06:00
b-naber 399ab40dbd get rid of normalize_generic_arg... queries 2021-12-13 23:05:25 +01:00
b-naber 8250eef685 normalize_generic_arg_after in terms of try version 2021-12-13 23:04:09 +01:00
Alan Egerton bfc434b6d0
Reduce boilerplate around infallible folders 2021-12-02 16:14:16 +00:00
b-naber ff448cfcee implement version of normalize_erasing_regions that doesn't assume value is normalizable 2021-12-01 12:12:38 +01:00
LeSeulArtichaut 30bf20a692
Unwrap the results of type folders
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26 07:38:25 +00:00
LeSeulArtichaut 6dc3dae46f
Adapt `TypeFolder` implementors to return a `Result`
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26 07:25:16 +00:00
Deadbeef f1126f1272
Make select_* methods return Vec for TraitEngine 2021-11-08 23:35:23 +08:00
jackh726 2b5b456e23 Move some outlives bounds things from rustc_trait_selection to rustc_typeck 2021-10-15 12:14:19 -04:00
jackh726 a7c132de55 Move push_outlives_components to rustc_infer 2021-10-15 12:13:35 -04:00
Matthias Krüger e6f77a1787 clippy::complexity fixes 2021-10-08 20:07:44 +02:00
Aaron Hill 93ab12eeab
Improve cause information for NLL higher-ranked errors
This PR has several interconnected pieces:

1. In some of the NLL region error code, we now pass
   around an `ObligationCause`, instead of just a plain `Span`.
   This gets forwarded into `fulfill_cx.register_predicate_obligation`
   during error reporting.
2. The general InferCtxt error reporting code is extended to
   handle `ObligationCauseCode::BindingObligation`
3. A new enum variant `ConstraintCategory::Predicate` is added.
   We try to avoid using this as the 'best blame constraint' - instead,
   we use it to enhance the `ObligationCause` of the `BlameConstraint`
   that we do end up choosing.

As a result, several NLL error messages now contain the same
"the lifetime requirement is introduced here" message as non-NLL
errors.

Having an `ObligationCause` available will likely prove useful
for future improvements to NLL error messages.
2021-09-27 10:23:45 -05:00
Jubilee ee2e97c416
Rollup merge of #89001 - jackh726:binder-cleanup, r=nikomatsakis
Be explicit about using Binder::dummy

This is somewhat of a late followup to the binder refactor PR. It removes `ToPredicate` and `ToPolyTraitImpls` that hide the use of `Binder::dummy`. While this does make code a bit more verbose, it allows us be more careful about where we create binders.

Another alternative here might be to add a new trait `ToBinder` or something with a `dummy()` fn. Which could still allow grepping but allows doing something like `trait_ref.dummy()` (but I also wonder if longer-term, it would be better to be even more explicit with a `bind_with_vars(ty::List::empty())` *but* that's not clear yet.

r? ``@nikomatsakis``
2021-09-24 11:40:11 -07:00
Mark Rousskov c746be2219 Migrate to 2021 2021-09-20 22:21:42 -04:00
jackh726 be76bdf905 Remove ToPredicate impls that use Binder::dummy 2021-09-15 20:54:50 -04:00
bors d5cd3205fd Auto merge of #88371 - Manishearth:rollup-pkkjsme, r=Manishearth
Rollup of 11 pull requests

Successful merges:

 - #87832 (Fix debugger stepping behavior with `match` expressions)
 - #88123 (Make spans for tuple patterns in E0023 more precise)
 - #88215 (Reland #83738: "rustdoc: Don't load all extern crates unconditionally")
 - #88216 (Don't stabilize creation of TryReserveError instances)
 - #88270 (Handle type ascription type ops in NLL HRTB diagnostics)
 - #88289 (Fixes for LLVM change 0f45c16f2caa7c035e5c3edd40af9e0d51ad6ba7)
 - #88320 (type_implements_trait consider obligation failure on overflow)
 - #88332 (Add argument types tait tests)
 - #88340 (Add `c_size_t` and `c_ssize_t` to `std::os::raw`.)
 - #88346 (Revert "Add type of a let tait test impl trait straight in let")
 - #88348 (Add field types tait tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-27 01:07:17 +00:00
Manish Goregaokar 1e94fe1a45
Rollup merge of #88270 - lqd:hrtb-type-ascription, r=nikomatsakis
Handle type ascription type ops in NLL HRTB diagnostics

Currently, there are still a few cases of the "higher-ranked subtype error" of yore, 4 of which are related to type ascription.

This PR is a follow-up to #86700, adding support for type ascription type ops, and makes 3 of these tests output the same diagnostics in NLL mode as the migrate mode (and 1 is now much closer, especially if you ignore that it already outputs an additional error in NLL mode -- which could be a duplicate caused by a lack of normalization like [these comments point out](9583fd1bdd/compiler/rustc_traits/src/type_op.rs (L122-L157)), or an imprecision in some parts of normalization as [described here](https://github.com/rust-lang/rust/pull/86700#discussion_r689086688)).

Since we discussed these recently:
- [here](https://github.com/rust-lang/rust/pull/86700#discussion_r689158868), cc ````@matthewjasper,````
- and [here](https://github.com/rust-lang/rust/issues/57374#issuecomment-901500856), cc ````@Aaron1011.````

It should only leave [this TAIT test](9583fd1bdd/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs) as still emitting [the terse error](9583fd1bdd/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.nll.stderr).

r? ````@estebank```` (so that they shake their fist at NLL's general direction less often) or ````@nikomatsakis```` or matthew or aaron, the more the merrier.
2021-08-26 12:38:09 -07:00
lcnr bfaf13af4e make unevaluated const substs optional 2021-08-26 11:00:30 +02:00
lcnr f4b606fd17 require a `tcx` for `TypeVisitor` 2021-08-26 10:54:01 +02:00
Rémy Rakic 820e2680ec handle ascription type op in NLL HRTB diagnostics
Refactors the `type_op_ascribe_user_type` query into a version which
accepts a span, and uses it in the nicer NLL HRTB bound region errors.
2021-08-23 23:31:01 +02:00
Frank Steffahn bf88b113ea Fix typos “a”→“an” 2021-08-22 15:35:11 +02:00
Niko Matsakis 947c0de028 introduce a Coerce predicate 2021-08-19 17:28:24 -04:00
bors 3d0774d0dc Auto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakis
Matthew's work on improving NLL's "higher-ranked subtype error"s

This PR rebases `@matthewjasper's` [branch](https://github.com/matthewjasper/rust/tree/nll-hrtb-errors) which has great work to fix the obscure higher-ranked subtype errors that are tracked in #57374.

These are a blocker to turning full NLLs on, and doing some internal cleanups to remove some of the old region code.

The goal is so `@nikomatsakis` can take a look at this early, and I'll then do my best to help do the changes and followup work to land this work, and move closer to turning off the migration mode.

I've only updated the branch and made it compile, removed a warning or two.

r? `@nikomatsakis`

(Here's the [zulip topic to discuss this](https://rust-lang.zulipchat.com/#narrow/stream/122657-t-compiler.2Fwg-nll/topic/.2357374.3A.20improving.20higher-ranked.20subtype.20errors.20via.20.2386700) that Niko wanted)
2021-08-18 15:54:59 +00:00
Rémy Rakic 2cf4b87393 De-dupe NLL HRTB diagnostics' use of `type_op_prove_predicate` 2021-08-15 14:49:36 +02:00
Deadbeef f25d2bd53b
Assign FIXMEs to me and remove obsolete ones
Also fixed capitalization of documentation
2021-08-14 16:48:01 +00:00
Deadbeef a00f2bcf5c
Try to fix problem 2021-08-13 09:28:50 +00:00
Deadbeef 32390a0df6
move Constness into TraitPredicate 2021-08-13 09:26:33 +00:00
bors b53a93db2d Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum
rfc3052 followup: Remove authors field from Cargo manifests

Since RFC 3052 soft deprecated the authors field, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information for contributors, we may as well
remove it from crates in this repo.
2021-08-02 05:49:17 +00:00
Jade 3cf820e17d rfc3052: Remove authors field from Cargo manifests
Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.
2021-07-29 14:56:05 -07:00
Matthias Krüger aa74c75d84 clippy:: append_instead_of_extend 2021-07-25 12:26:02 +02:00
Aaron Hill a765333738
Add initial implementation of HIR-based WF checking for diagnostics
During well-formed checking, we walk through all types 'nested' in
generic arguments. For example, WF-checking `Option<MyStruct<u8>>`
will cause us to check `MyStruct<u8>` and `u8`. However, this is done
on a `rustc_middle::ty::Ty`, which has no span information. As a result,
any errors that occur will have a very general span (e.g. the
definintion of an associated item).

This becomes a problem when macros are involved. In general, an
associated type like `type MyType = Option<MyStruct<u8>>;` may
have completely different spans for each nested type in the HIR. Using
the span of the entire associated item might end up pointing to a macro
invocation, even though a user-provided span is available in one of the
nested types.

This PR adds a framework for HIR-based well formed checking. This check
is only run during error reporting, and is used to obtain a more precise
span for an existing error. This is accomplished by individually
checking each 'nested' type in the HIR for the type, allowing us to
find the most-specific type (and span) that produces a given error.

The majority of the changes are to the error-reporting code. However,
some of the general trait code is modified to pass through more
information.

Since this has no soundness implications, I've implemented a minimal
version to begin with, which can be extended over time. In particular,
this only works for HIR items with a corresponding `DefId` (e.g. it will
not work for WF-checking performed within function bodies).
2021-07-16 16:29:02 -05:00
Aaron Hill 7e5a88a56c
Combine individual limit queries into single `limits` query 2021-07-04 13:02:51 -05:00
Aaron Hill ff15b5e2c7
Query-ify global limit attribute handling 2021-07-04 12:33:14 -05:00
Smitty bdfcb88e8b Use HTTPS links where possible 2021-06-23 16:26:46 -04:00
Scott McMurray 65a0a8b386 Stabilize ops::ControlFlow (just the type) 2021-05-23 13:20:05 -07:00
bors 0978a9eb99 Auto merge of #83207 - oli-obk:valtree2, r=lcnr
normalize mir::Constant differently from ty::Const in preparation for valtrees

Valtrees are unable to represent many kind of constant values (this is on purpose). For constants that are used at runtime, we do not need a valtree representation and can thus use a different form of evaluation. In order to make this explicit and less fragile, I added a `fold_constant` method to `TypeFolder` and implemented it for normalization. Normalization can now, when it wants to eagerly evaluate a constant, normalize `mir::Constant` directly into a `mir::ConstantKind::Val` instead of relying on the `ty::Const` evaluation.

In the future we can get rid of the `ty::Const` in there entirely and add our own `Unevaluated` variant to `mir::ConstantKind`. This would allow us to remove the `promoted` field from `ty::ConstKind::Unevaluated`, as promoteds can never occur in the type system.

cc `@rust-lang/wg-const-eval`

r? `@lcnr`
2021-04-02 10:28:12 +00:00
Jack Huey 6d5efa9f04 Add var to BoundRegion. Add query to get bound vars for applicable items. 2021-03-31 10:16:37 -04:00
Jack Huey 62a49c3bb8 Add tcx lifetime to Binder 2021-03-31 10:13:57 -04:00
Oli Scherer dbacfbc368 Add a new normalization query just for mir constants 2021-03-31 10:40:42 +00:00
kadmin e4e5db4e42 Add has_default to GenericParamDefKind::Const
This currently creates a field which is always false on GenericParamDefKind for future use when
consts are permitted to have defaults

Update const_generics:default locations

Previously just ignored them, now actually do something about them.

Fix using type check instead of value

Add parsing

This adds all the necessary changes to lower const-generics defaults from parsing.

Change P<Expr> to AnonConst

This matches the arguments passed to instantiations of const generics, and makes it specific to
just anonymous constants.

Attempt to fix lowering bugs
2021-03-23 17:16:20 +00:00
Vadim Petrochenkov dac96d45af Fix use of bare trait objects everywhere 2021-03-18 02:18:58 +03:00
Ryan Levick a6d926d80d Fix tests 2021-03-03 11:22:44 +01:00
Dylan DPC 66211f6657
Rollup merge of #82066 - matthewjasper:trait-ref-fix, r=jackh726
Ensure valid TraitRefs are created for GATs

This fixes `ProjectionTy::trait_ref` to use the correct substs. Places that need all of the substs have been updated to not use `trait_ref`.

r? ````@jackh726````
2021-02-18 16:57:34 +01:00
Dylan DPC c8dacf95ae
Rollup merge of #82029 - tmiasko:debug, r=matthewjasper
Use debug log level for developer oriented logs

The information logged here is of limited general interest, while at the
same times makes it impractical to simply enable logging and share the
resulting logs due to the amount of the output produced.

Reduce log level from info to debug for developer oriented information.

For example, when building cargo, this reduces the amount of logs
generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB.

Continuation of changes from 81350.
2021-02-14 16:54:52 +01:00
klensy 93c8ebe022 bumped smallvec deps 2021-02-14 18:03:11 +03:00
Matthew Jasper dfee89f755 Make ProjectionTy::trait_ref truncate substs again
Also make sure that type arguments of associated types are printed in
some error messages.
2021-02-13 19:30:07 +00:00
Tomasz Miąsko 361dcd5ca7 Use debug log level for developer oriented logs
The information logged here is of limited general interest, while at the
same times makes it impractical to simply enable logging and share the
resulting logs due to the amount of the output produced.

Reduce log level from info to debug for developer oriented information.

For example, when building cargo, this reduces the amount of logs
generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB.

Continuation of changes from 81350.
2021-02-13 00:00:00 +00:00
Jack Huey a0622d60e0 Update Chalk 2021-02-02 12:37:22 -05:00
Jack Huey 4b64bc1fc9 Upgrade Chalk 2021-02-01 10:37:45 -05:00
LeSeulArtichaut 50e1ae15e9 Use ty::{IntTy,UintTy,FloatTy} in rustc 2021-01-18 21:09:30 +01:00
Jack Huey 3dea68de1d Review changes 2021-01-16 18:56:37 -05:00
Jack Huey 66c179946b Use no_bound_vars 2021-01-16 18:50:34 -05:00
Jack Huey 476bd53058 Cleanup 2021-01-16 18:50:34 -05:00
Jack Huey e76476afe4 Cleanup 2021-01-16 18:40:47 -05:00
Jack Huey 4cd6f85a07 Remove PredicateKind 2021-01-16 18:40:47 -05:00
Jack Huey 4cb3d6f983 Intermediate formatting and such 2021-01-16 18:40:47 -05:00
Jack Huey 8278314a8b Remove PredicateKind::Atom 2021-01-16 18:40:47 -05:00
0xflotus cb177852c1
fix: small typo error in chalk/mod.rs 2020-12-27 03:22:23 +01:00
Jack Huey 328fcee4af Make BoundRegion have a kind of BoungRegionKind 2020-12-18 15:27:28 -05:00
Jack Huey ed80815bf2 Move binder for dyn to each list item 2020-12-11 15:02:46 -05:00
Joshua Nelson 6354e85e8f Don't run `resolve_vars_if_possible` in `normalize_erasing_regions`
NOTE: `needs_infer()` needs to come after ignoring generic parameters
2020-11-18 12:25:36 -05:00
bors e0ef0fc392 Auto merge of #78779 - LeSeulArtichaut:ty-visitor-return, r=oli-obk
Introduce `TypeVisitor::BreakTy`

Implements MCP rust-lang/compiler-team#383.
r? `@ghost`
cc `@lcnr` `@oli-obk`

~~Blocked on FCP in rust-lang/compiler-team#383.~~
2020-11-17 12:24:34 +00:00
Bastian Kauschke 2bf93bd852 compiler: fold by value 2020-11-16 22:34:57 +01:00
LeSeulArtichaut e0f3119103 Introduce `TypeVisitor::BreakTy` 2020-11-14 20:25:27 +01:00
Dylan DPC 0aed74aa43
Rollup merge of #78502 - matthewjasper:chalkup, r=nikomatsakis
Update Chalk to 0.36.0

This PR updates Chalk and fixes a number of bugs in the chalk integration code.

cc `@rust-lang/wg-traits`
r? `@nikomatsakis`
2020-11-09 19:06:46 +01:00
bors 0d033dee3e Auto merge of #78182 - LeSeulArtichaut:ty-visitor-contolflow, r=lcnr,oli-obk
TypeVisitor: use `std::ops::ControlFlow` instead of `bool`

Implements MCP rust-lang/compiler-team#374.

Blocked on FCP in rust-lang/compiler-team#374.
r? `@lcnr` cc `@jonas-schievink`
2020-10-30 22:53:55 +00:00
Matthew Jasper 4d60a80713 Address review comment and update chalk to 0.36.0 2020-10-30 19:39:33 +00:00
Matthew Jasper acb6a06123 Fix various Chalk lowering bugs
- Add more well-known traits
- Use the correct binders when lowering trait objects
- Use correct substs when lowering trait objects
- Use the correct binders for opaque_ty_data
- Lower negative impls with the correct polarity
- Supply associated type values
- Use `predicates_defined_on` for where clauses
2020-10-30 19:39:33 +00:00
Matthew Jasper 299a65ff71 Update chalk 0.32.0 -> 0.35.0 2020-10-30 19:39:30 +00:00
Joshua Nelson bfecb18771 Fix some more clippy warnings 2020-10-30 10:12:56 -04:00
LeSeulArtichaut 9433eb83fe Remove implicit `Continue` type 2020-10-30 12:27:47 +01:00
LeSeulArtichaut 61f8182cec TypeVisitor: use `ControlFlow` in rustc_{mir,privacy,traits,typeck} 2020-10-30 12:27:44 +01:00
Jack Huey 11d62aa284 Review comments 2020-10-16 12:58:50 -04:00
Jack Huey dd5c9bf139 Use map_bound(_ref) instead of Binder::bind when possible 2020-10-16 12:58:50 -04:00
Roxane a64ad51ff7 Address comments 2020-10-14 00:17:42 -04:00
Roxane dc183702da Replace tuple of infer vars for upvar_tys with single infer var
This commit allows us to decide the number of captures required after
completing capture ananysis, which is required as part of implementing
RFC-2229.

Co-authored-by: Aman Arora <me@aman-arora.com>
Co-authored-by: Jenny Wills <wills.jenniferg@gmail.com>
2020-10-11 03:32:35 -04:00
Bram van den Heuvel e185278534 Update chalk to 0.32.0 2020-10-08 13:17:01 +02:00
Jack Huey 23491084bc Update to chalk 0.31. Implement some unimplemented. Ignore some tests in compare mode chalk don't finish. 2020-10-06 14:14:25 -04:00
Matthew Jasper c9eeb60b63 Deduplicate some code 2020-10-06 11:19:33 +01:00
Matthew Jasper 022c148fcd Fix tests from rebase 2020-10-06 11:19:33 +01:00
Matthew Jasper 27534b3932 Fix rebase 2020-10-06 11:19:33 +01:00
Matthew Jasper d08ab945de Fix rebase 2020-10-06 11:19:32 +01:00
Matthew Jasper bc08b791bc Fix bugs in evaluating WellFormed predicates
- List the nestsed obligations in an order that works with the
  single pass used by evaluation
- Propagate recursion depth correctly
2020-10-06 11:19:31 +01:00
Matthew Jasper f958e6c246 Separate bounds and predicates for associated/opaque types 2020-10-06 11:19:29 +01:00
Bram van den Heuvel ef7377eb05 Update chalk to 0.29.0 2020-09-27 15:54:07 +02:00
Bram van den Heuvel 51c781f613 Upgrade chalk to 0.28.0 2020-09-24 20:54:33 +02:00
Bram van den Heuvel 5f67571e34 Update chalk to 0.27.0 2020-09-24 19:10:01 +02:00
Bram van den Heuvel 61b2a6f5e5 Update chalk to 0.26.0 2020-09-24 19:10:01 +02:00
Bram van den Heuvel ed784023e5 Update chalk to 0.25.0 2020-09-24 19:10:01 +02:00
Bram van den Heuvel cb660c6ab5 Update chalk to 0.24.0 2020-09-24 19:10:01 +02:00
Bram van den Heuvel 52eeff6fbe Update chalk to 0.23.0 2020-09-24 19:10:00 +02:00
Bram van den Heuvel b832a97a51 Update chalk to 0.22.0 2020-09-24 19:10:00 +02:00
est31 ebdea01143 Remove redundant #![feature(...)] 's from compiler/ 2020-09-17 07:58:45 +02:00
Ralf Jung 0bcc96dd3d
Rollup merge of #76641 - nox:pointee-random-stuff, r=eddyb
Some cleanup changes and commenting

r? @nikomatsakis
Cc @eddyb
2020-09-16 08:25:00 +02:00
Anthony Ramine caf6c92d19 Clean up some language trait items comparisons 2020-09-12 18:35:57 +02:00
Bram van den Heuvel 7dad29d686 Remove def_id field from ParamEnv 2020-09-09 10:14:31 +02:00
Jack Huey 0aa215305a kind -> kind() 2020-09-04 19:17:57 -04:00
Jack Huey f690569465 Review comments 2020-09-04 19:12:54 -04:00
Jack Huey 76c728901e More chalk work 2020-09-04 19:12:54 -04:00
Jack Huey d66452c3e5 Upgrade chalk to 0.21 2020-09-04 19:12:54 -04:00
LeSeulArtichaut 3e14b684dd Change ty.kind to a method 2020-09-04 17:47:51 +02:00
mark 9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00