Commit Graph

1154 Commits

Author SHA1 Message Date
Matthias Krüger
6111a7345b
Rollup merge of #105443 - compiler-errors:move-more, r=oli-obk
Move some queries and methods

Each commit's title should be self-explanatory. Motivated to break up some large, general files and move queries into leaf crates.
2022-12-09 07:25:46 +01:00
Matthias Krüger
086bdbbd73
Rollup merge of #104922 - estebank:fur-elize, r=oli-obk
Detect long types in E0308 and write them to disk

On type error with long types, print an abridged type and write the full type to disk.

Print the widest possible short type while still fitting in the terminal.
2022-12-08 12:57:28 +01:00
Michael Goulet
3b9daac6a2 Move some suggestions from error_reporting to error_reporting::suggest 2022-12-08 05:58:30 +00:00
Michael Goulet
da929fa63c Make get_impl_future_output_ty work with AFIT 2022-12-05 17:34:42 +00:00
Yuki Okushi
7d4af8852c
Rollup merge of #105188 - compiler-errors:verbose-ty-err, r=TaKO8Ki
Don't elide type information when printing E0308 with `-Zverbose`

When we pass `-Zverbose`, we kinda expect for all `_` to be replaced with more descriptive information, for example --

```
   = note: expected fn pointer `fn(_, u32)`
                 found fn item `fn(_, i32) {foo}`
```

Where `_` is the "identical" part of the fn signatures, now gets rendered as:

```
   = note: expected fn pointer `fn(i32, u32)`
                 found fn item `fn(i32, i32) {foo}`
```
2022-12-03 12:51:30 +09:00
Michael Goulet
5c642d7d1c Don't elide information when printing E0308 with Zverbose 2022-12-02 21:01:59 +00:00
Matthias Krüger
8e0d83a70c
Rollup merge of #105185 - compiler-errors:normalize_fn_sig-in-err-ctxt, r=lcnr
Move `normalize_fn_sig` to `TypeErrCtxt`

r? `@lcnr`
2022-12-02 21:22:50 +01:00
Michael Goulet
ffca711760 Move normalize_fn_sig to TypeErrCtxt 2022-12-02 19:29:14 +00:00
Michael Goulet
e45daa9856 Drive-by: remove unused type alias 2022-12-01 19:00:09 +00:00
bors
90711a86e5 Auto merge of #99814 - aliemjay:patch-2, r=jackh726
fix universe map in ifcx.instantiate_canonical_*

Previously, `infcx.instantiate_canonical_*` maps the root universe in `canonical` into `ty::UniverseIndex::Root`, I think because it assumes it works with a fresh `infcx` but this is not true for the use cases in mir typeck. Now the root universe is mapped into `infcx.universe()`.

I catched this accidentally while reviewing the code. I'm not sure if this is the right fix or if it is really a bug!
2022-11-30 14:03:36 +00:00
bors
e0098a5cc3 Auto merge of #105012 - WaffleLapkin:into, r=oli-obk
Make `tcx.mk_const` more permissive wrt `kind` argument (`impl Into`)

r? `@oli-obk` you've asked for this >:)
2022-11-29 13:28:44 +00:00
Esteban Küber
360c0a7a3e Tweak shortening logic to be less trigger happy 2022-11-28 14:08:19 -08:00
Esteban Küber
7674edeeba Detect long types in E0308 and write them to disk
On type error with long types, print an abridged type and write the full
type to disk.

Print the widest possible short type while still fitting in the
terminal.
2022-11-28 14:08:18 -08:00
Maybe Waffle
f4d00fe785 Remove Const::from_value
...it's just `mk_const` but without the sparcles
2022-11-28 17:28:30 +00:00
Maybe Waffle
26b87bf8ff Simplify calls to tcx.mk_const
`mk_const(ty::ConstKind::X(...), ty)` can now be simplified to
`mk_cosnt(...,                   ty)`.

I searched with the following regex: \mk_const\([\n\s]*(ty::)?ConstKind\
I've left `ty::ConstKind::{Bound, Error}` as-is, they seem clearer this
way.
2022-11-28 17:27:20 +00:00
Maybe Waffle
7087d9b2a0 Remove tcx.mk_const_var
... `tcx.mk_const` can now be used instead
2022-11-28 17:27:20 +00:00
Matthias Krüger
60d136000e
Rollup merge of #104936 - cjgillot:self-rpit-orig-too, r=oli-obk
Ignore bivariant parameters in test_type_match.

https://github.com/rust-lang/rust/pull/103491 made opaque types bivariant with respect of some of their lifetime parameters.  Because of this bivariance, some lifetime variables were not unified to anything during borrowck, and were considered as unequal by borrowck type test.

This PR makes type test ignore the bivariant parameters in test_type_match.

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

r? `@oli-obk`
2022-11-28 17:25:47 +01:00
Dylan DPC
8a84dd8fcc
Rollup merge of #104890 - lcnr:small-cleanup, r=fee1-dead
small method code cleanup
2022-11-28 15:42:11 +05:30
Dylan DPC
f90484df8a
Rollup merge of #104732 - WaffleLapkin:from_def_idn't, r=compiler-errors
Refactor `ty::ClosureKind` related stuff

I've tried to fix all duplication and weirdness, but if I missed something do tell :p

r? `@compiler-errors`
2022-11-28 15:42:10 +05:30
Matthias Krüger
86304f5149
Rollup merge of #104976 - WaffleLapkin:move_comments, r=cjgillot
Prefer doc comments over `//`-comments in compiler

Doc comments are generally nicer: they show up in the documentation, they are shown in IDEs when you hover other mentions of items, etc. Thus it makes sense to use them instead of `//`-comments.
2022-11-27 22:14:08 +01:00
bors
454784afba Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errors
Separate lifetime ident from lifetime resolution in HIR

Drive-by: change how suggested generic args are computed.
Fixes https://github.com/rust-lang/rust/issues/103815

I recommend reviewing commit-by-commit.
2022-11-27 14:30:19 +00:00
Maybe Waffle
1d42936b18 Prefer doc comments over //-comments in compiler 2022-11-27 11:19:04 +00:00
Maybe Waffle
5ba0056346 Use TyCtxt::is_fn_trait is a couple more places 2022-11-27 07:20:28 +00:00
Maybe Waffle
881862ecb7 Rename fn_trait_kind_from_{from_lang=>def_id} to better convey meaning 2022-11-27 07:14:49 +00:00
Guillaume Gomez
4019c8aaf7
Rollup merge of #104921 - compiler-errors:no-binder-on-fut-ty, r=cjgillot
Remove unnecessary binder from `get_impl_future_output_ty`

We never construct an `async fn` with a higher-ranked `impl Future` bound anyways, and basically all the call-sites already skip the binder.
2022-11-26 17:47:24 +01:00
Guillaume Gomez
e6c83d9e42
Rollup merge of #104788 - compiler-errors:unresolved-ct-in-gen, r=fee1-dead
Do not record unresolved const vars in generator interior

Don't record types in the generator interior when we see unresolved const variables.

We already do this for associated types -- this is important to avoid unresolved inference variables in the generator results during writeback, since the writeback results get stable hashed in incremental mode.

Fixes #104787
2022-11-26 17:47:23 +01:00
Guillaume Gomez
a2e485c25c
Rollup merge of #104786 - WaffleLapkin:amp-mut-help, r=compiler-errors
Use the power of adding helper function to simplify code w/ `Mutability`

r? `@compiler-errors`
2022-11-26 17:47:23 +01:00
Camille GILLOT
89afda7811 Ignore bivariant parameters in test_type_match. 2022-11-26 09:50:01 +00:00
Michael Goulet
6210812494 Do not record unresolved const vars in generator interior 2022-11-26 05:38:43 +00:00
Michael Goulet
1472b38039 Remove unnecessary binder from get_impl_future_output_ty 2022-11-26 05:22:52 +00:00
bors
aff003becd Auto merge of #99798 - JulianKnodt:ac1, r=BoxyUwU
Add `ConstKind::Expr`

Starting to implement `ty::ConstKind::Abstract`, most of the match cases are stubbed out, some I was unsure what to add, others I didn't want to add until a more complete implementation was ready.

r? `@lcnr`
2022-11-25 22:56:59 +00:00
lcnr
a215b7b4df remove TypeError::ObjectUnsafeCoercion 2022-11-25 16:39:23 +01:00
Boxy
2ac5d91d63 Make expand_abstract_consts infallible 2022-11-25 09:28:44 +00:00
kadmin
5bb1a9febc Add expand_abstract_const
Adds the ability to directly expand a const to an expr without having to deal with intermediate
steps.
2022-11-25 09:28:43 +00:00
kadmin
f9750c1554 Add empty ConstKind::Abstract
Initial pass at expr/abstract const/s

Address comments

Switch to using a list instead of &[ty::Const], rm `AbstractConst`

Remove try_unify_abstract_consts

Update comments

Add edits

Recurse more

More edits

Prevent equating associated consts

Move failing test to ui

Changes this test from incremental to ui, and mark it as failing and a known bug.
Does not cause the compiler to ICE, so should be ok.
2022-11-25 09:28:43 +00:00
Santiago Pastorino
974e2837bb
Introduce PredicateKind::Clause 2022-11-25 00:04:54 -03:00
Santiago Pastorino
1930c77de1
Remove normalize_projection_type 2022-11-24 09:02:55 -03:00
Maybe Waffle
8195e12dd9 Add Mutability::ref_prefix_str, order Mutability, simplify code 2022-11-23 19:36:27 +00:00
Camille GILLOT
fb7d25e978 Separate lifetime ident from resolution in HIR. 2022-11-23 19:33:06 +00:00
Manish Goregaokar
53eab246db
Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnr
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases

r? ````@lcnr````

fixes #99840
2022-11-22 22:54:38 -05:00
bors
b7463e8bdb Auto merge of #103578 - petrochenkov:nofict, r=nagisa
Unreserve braced enum variants in value namespace

With this PR braced enum variants (`enum E { V { /*...*/ } }`) no longer take a slot in value namespace, so the special case mentioned in the note in https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md#braced-structs is removed.

Report - https://github.com/rust-lang/rust/pull/103578#issuecomment-1292594900.
2022-11-22 10:17:09 +00:00
Oli Scherer
7658e0fccf Stop passing the self-type as a separate argument. 2022-11-21 20:39:46 +00:00
Oli Scherer
ec8d01fdcc Allow iterators instead of requiring slices that will get turned into iterators 2022-11-21 20:33:55 +00:00
Oli Scherer
6f77c97b38 Assert that various types have the right amount of generic args and fix the sites that used the wrong amount 2022-11-21 20:31:59 +00:00
Vadim Petrochenkov
7a5376d23c Unreserve braced enum variants in value namespace 2022-11-21 22:40:06 +03:00
Oli Scherer
c16a90f5e3 Test generalization during coherence 2022-11-21 16:47:29 +00:00
Oli Scherer
11adf03790 Add some more assertions for type relations not used during coherence 2022-11-21 16:38:49 +00:00
Oli Scherer
7301cd7844 Type generalization should not look at opaque type in coherence 2022-11-21 16:38:23 +00:00
Oli Scherer
11ae334f07 Remove a function that doesn't actually do anything 2022-11-21 16:37:57 +00:00
Oli Scherer
f42e490d6f Register obligations from type relation 2022-11-21 16:37:53 +00:00