Commit Graph

804 Commits

Author SHA1 Message Date
Dylan DPC
ecae3d74e2
Rollup merge of #99000 - JulianKnodt:allow_resolve_no_substs, r=lcnr
Move abstract const to middle

Moves AbstractConst (and all associated methods) to rustc middle for use in `rustc_infer`.
This allows for const resolution in infer to use abstract consts to walk consts and check if
they are resolvable.

This attempts to resolve the issue where `Foo<{ concrete const }, generic T>` is incorrectly marked as conflicting, and is independent from the other issue where nested abstract consts must be resolved.

r? `@lcnr`
2022-07-14 19:24:04 +05:30
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
kadmin
20fb8aba8f Fix overlapping impls 2022-07-14 09:01:17 +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
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
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
bors
6dba4ed215 Auto merge of #99056 - lcnr:higher_ranked_sub, r=oli-obk
don't use `commit_if_ok` during `higher_ranked_sub`

This snapshot doesn't really do anything useful for us, especially once we deal with placeholder outlive bounds during trait solving.

I guess that currently the idea is that `higher_ranked_sub` could cause a later `leak_check` to fail even if the combine operation isn't actually relevant. But really, using combine outside of snapshot and ignoring its result is wrong anyways, as it can constrain inference variables.

r? rust-lang/types
2022-07-09 19:57:13 +00:00
bors
052495d001 Auto merge of #98614 - oli-obk:take_unsound_opaque_types, r=wesleywiser
don't succeed `evaluate_obligation` query if new opaque types were registered

fixes #98608
fixes #98604

The root cause of all this is that in type flag computation we entirely ignore nongeneric things like struct fields and the signature of function items. So if a flag had to be set for a struct if it is set for a field, that will only happen if the field is generic, as only the generic parameters are checked.

I now believe we cannot use type flags to handle opaque types. They seem like the wrong tool for this.

Instead, this PR replaces the previous logic by adding a new variant of `EvaluatedToOk`: `EvaluatedToOkModuloOpaqueTypes`, which says that there were some opaque types that got hidden types bound, but that binding may not have been legal (because we don't know if the opaque type was in its defining scope or not).
2022-07-08 17:55:26 +00:00
lcnr
aea2d7e20a don't use commit_if_ok during higher_ranked_sub 2022-07-08 16:33:59 +02:00
Oli Scherer
d6b93eb793 Only register hidden types for opaque types from the current crate, nothing else would work anyway. 2022-07-08 13:59:44 +00:00
Jack Huey
2471431017 Move is_free and is_free_or_static to Region, change resolve_var to resolve_region, and remove RootEmptyRegion 2022-07-07 20:48:51 -04:00
Takayuki Maeda
83dea35384 replace guess_head_span with def_span 2022-07-06 19:09:47 +09: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
Alan Egerton
f66c06f7f2
Explicit TypeVisitable implementations 2022-07-05 22:25:35 +01:00
Alan Egerton
e4b9625b87
Add #[derive(TypeVisitable)] 2022-07-05 22:25:15 +01:00
bors
efb171e235 Auto merge of #98584 - lcnr:region-stuff-more-beans, r=oli-obk
continue nll transition by removing stuff

r? `@jackh726` for now

building on #98641
2022-07-05 14:58:31 +00:00
lcnr
9f95c605f8 region obligations, remove body_id 2022-07-04 14:35:20 +02:00
lcnr
a0d2d9f315 implied bounds byebye nested hir ids 2022-07-04 14:35:20 +02:00
lcnr
68d70fc5bd only use FnCtxt for regionck inside of bodies 2022-07-04 14:35:20 +02:00
lcnr
24799e3720 remove an unused DefId 2022-07-04 14:35:19 +02:00
lcnr
f475e880a4 InferSource::GenericArg, check for contains 2022-07-04 14:04:07 +02:00
lcnr
7952d2ed83 resolve vars in node substs 2022-07-04 13:58:29 +02:00
lcnr
eef34a648b stop suggesting things inside of macros 2022-07-04 13:58:29 +02:00
lcnr
f1836c453a update infer cost computation for types 2022-07-04 13:58:29 +02:00
lcnr
c2ed08715b remove unused function argument 2022-07-04 13:58:28 +02:00
Michael Goulet
f44ae98cee Only label place where type is needed if span is meaningful 2022-07-01 17:38:34 +00:00
Matthias Krüger
0d5636ce88
Rollup merge of #98610 - lcnr:emit_inference_failure_err-ice, r=estebank
fix `emit_inference_failure_err` ICE

fixes #98598

this fix doesn't make me too happy, but 🤷
2022-07-01 06:05:52 +02:00
Oli Scherer
84fc551664 Make evaluate_obligation not succeed unconditionally if it registered new hidden types for opaque types 2022-06-30 14:23:31 +00:00
lcnr
e043821e93 add issue number to fixme 2022-06-30 15:53:17 +02:00
Oli Scherer
ade2a96ff1 use a method instead of manually doing what its body does 2022-06-30 13:24:35 +00:00
Matthias Krüger
48170d5a1c
Rollup merge of #96727 - oli-obk:no_expect, r=lcnr
Make TAIT behave exactly like RPIT

fixes https://github.com/rust-lang/rust/issues/96552

This makes type-alias-impl-trait behave like return-position-impl-trait. Unfortunately it also causes some cases to stop compiling due to "needing type annotations" and makes panicking cause fallback for the hidden type to `()`.

All of these are addressable, but we should probably address them for RPIT and TAIT together

r? ``@lcnr``
2022-06-30 00:23:50 +02: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
Dylan DPC
fcbb2e8009
Rollup merge of #98607 - compiler-errors:tuple-wrap-suggestion, r=oli-obk
Clean up arg mismatch diagnostic, generalize tuple wrap suggestion

This is based on top of #97542, so just look at the last commit which contains the relevant changes.

1. Remove `final_arg_types` which was one of the last places we were using raw (`usize`) indices instead of typed indices in the arg mismatch suggestion code.
2. Improve the tuple wrap suggestion, now we suggest things like `call(a, b, c, d)` -> `call(a, (b, c), d)` 😺
3. Folded in fix #98645
2022-06-29 17:59:36 +05:30
Takayuki Maeda
6212e6b339 avoid many &str to String conversions with MultiSpan::push_span_label 2022-06-29 21:16:43 +09: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
Oli Scherer
c33b127d7c The only reason we had to replace opaque types in closures was due to async fn desugaring, make that explicit 2022-06-29 08:58:36 +00:00
Oli Scherer
524d2b3178 Make RPIT and TAIT work exactly the same 2022-06-29 08:58:36 +00:00
Dylan DPC
c703d11dcc
Rollup merge of #97346 - JohnTitor:remove-back-compat-hacks, r=oli-obk
Remove a back-compat hack on lazy TAIT

This PR's motivation is here: https://github.com/rust-lang/rust/issues/72614#issuecomment-1134595446
~~But removing a hack doesn't seem to reject the code on the issue, there're some more hacks?~~
r? ``@oli-obk``
2022-06-28 15:30:00 +05:30
lcnr
1d845bd412 fix emit_inference_failure_err ICE 2022-06-28 11:44:25 +02:00
Michael Goulet
75337775f7 Remove final_arg_types, improve tuple wrapping suggestion 2022-06-28 00:19:49 -07:00
lcnr
28fafc45e6 lower-generic vs. outlive 2022-06-27 16:06:46 +02:00
lcnr
70497d9d10 fold_region: remove unused parameter 2022-06-27 15:55:03 +02:00
lcnr
4dbf9ba0ab outside of borrowck, do not provide an implicit_region_bound
see comment added to the field in `VerifyBoundCx`.
2022-06-27 15:48:54 +02:00
Yuki Okushi
c24f06354a
Remove a back-compat hack on lazy TAIT 2022-06-27 20:43:44 +09: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
65187f51dc
Rollup merge of #98311 - eggyal:reverse-folder-hierarchy, r=jackh726
Reverse folder hierarchy

#91318 introduced a trait for infallible folders distinct from the fallible version.  For some reason (completely unfathomable to me now that I look at it with fresh eyes), the infallible trait was a supertrait of the fallible one: that is, all fallible folders were required to also be infallible.  Moreover the `Error` associated type was defined on the infallible trait!  It's so absurd that it has me questioning whether I was entirely sane.

This trait reverses the hierarchy, so that the fallible trait is a supertrait of the infallible one: all infallible folders are required to also be fallible (which is a trivial blanket implementation).  This of course makes much more sense!  It also enables the `Error` associated type to sit on the fallible trait, where it sensibly belongs.

There is one downside however: folders expose a `tcx` accessor method.  Since the blanket fallible implementation for infallible folders only has access to a generic `F: TypeFolder`, we need that trait to expose such an accessor to which we can delegate.  Alternatively it's possible to extract that accessor into a separate `HasTcx` trait (or similar) that would then be a supertrait of both the fallible and infallible folder traits: this would ensure that there's only one unambiguous `tcx` method, at the cost of a little additional boilerplate.  If desired, I can submit that as a separate PR.

r? ````@jackh726````
2022-06-25 15:14:11 +02:00
bors
d017d59ed0 Auto merge of #98109 - nikomatsakis:issue-98095, r=jackh726
fix universes in the NLL type tests

In the NLL code, we were not accommodating universes in the
`type_test` logic.

Fixes #98095.

r? `@compiler-errors`

This breaks some tests, however, so the purpose of this branch is more explanatory and perhaps to do a crater run.
2022-06-24 07:39:28 +00:00
Niko Matsakis
e93e10516e run x.py fmt 2022-06-23 17:00:46 -04:00
Niko Matsakis
9118fafd40 remove misleading comment
per aliemjay's suggestion
2022-06-23 17:00:28 -04:00