Commit Graph

1893 Commits

Author SHA1 Message Date
Esteban Küber
b9da55afb5 Introduce Span::is_visible 2022-12-09 14:35:55 -08:00
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
Michael Goulet
25a6daccab Move codegen_select_candidate to a rustc_traits 2022-12-08 05:16:57 +00:00
Michael Goulet
b36035c20f Move vtable methods into its own module 2022-12-08 05:16:57 +00:00
Michael Goulet
48270044b0 Move has_structural_eq_impls provider to rustc_ty_utils 2022-12-08 05:16:48 +00:00
Matthias Krüger
b23419b03d
Rollup merge of #105400 - BoxyUwU:braced_param_evaluatability, r=oli-obk
normalize before handling simple checks for evaluatability of `ty::Const`

`{{{{{{{ N }}}}}}}` is desugared into a `ConstKind::Unevaluated` for an anonymous `const` item so when calling `is_const_evaluatable` on it we skip the `ConstKind::Param(_) => Ok(())` arm which is incorrect.
2022-12-07 15:39:08 +01:00
Boxy
9f438bef0b normalize before matching on ConstKind 2022-12-06 22:53:13 +00:00
Boxy
0070fae2dc typo :( 2022-12-06 16:40:57 +00:00
Matthias Krüger
a9ffe7c738
Rollup merge of #105342 - compiler-errors:note_cause_code-takes-predicate, r=fee1-dead
Make `note_obligation_cause_code`  take a `impl ToPredicate` for predicate

The only usecase that wasn't `impl ToPredicate` was noting overflow errors while revealing opaque types, which passed in an `Obligation<'tcx, Ty<'tcx>>`... Since this only happens in a `RevealAll` environment, which is after typeck (and probably primarily within `normalize_erasing_regions`) we're unlikely to display anything useful while noting this code, evidenced by the lack of UI test changes.
2022-12-06 13:27:45 +01:00
Matthias Krüger
07fd8089a4
Rollup merge of #105340 - estebank:ice-ice-baby, r=compiler-errors
Avoid ICE by accounting for missing type

Fix #105330
2022-12-06 13:27:45 +01:00
Matthias Krüger
762d2545f4
Rollup merge of #105339 - BoxyUwU:wf_ct_kind_expr, r=TaKO8Ki
support `ConstKind::Expr` in `is_const_evaluatable` and `WfPredicates::compute`

Fixes #105205

Currently we haven't implemented a way to evaluate `ConstKind::Expr(Expr::Binop(Add, 1, 2))` so I just left that with a `FIXME` and a `delay_span_bug` since I have no idea how to do that and it would make this a much larger (and more complicated) PR :P
2022-12-06 13:27:44 +01:00
Esteban Küber
eff76455fd Avoid ICE by accounting for missing type
Fix #105330
2022-12-05 20:30:17 -08:00
Yuki Okushi
1310d9bd2b
Rollup merge of #105338 - estebank:other-impls, r=compiler-errors
Tweak "the following other types implement trait"

When *any* of the suggested impls is an exact match, *only* show the exact matches. This is particularly relevant for integer types.

r? `@compiler-errors`
2022-12-06 12:48:54 +09:00
Yuki Okushi
e09c71e4c1
Rollup merge of #105324 - compiler-errors:gat-where-clause-binding-obl, r=jackh726
Point at GAT `where` clause when an obligation is unsatisfied

Slightly helps with #105306
2022-12-06 12:48:54 +09:00
Michael Goulet
d2a80c1571 Avoid noting cause code (which is usually misc, b/c codegen) for opaque type reveal overflow 2022-12-06 00:19:55 +00:00
Michael Goulet
e940f845be drive-by: Default param for ToPredicate 2022-12-06 00:19:55 +00:00
Boxy
c9bab74fb2 support Expr in is_const_evaluatable and compute 2022-12-05 23:17:55 +00:00
Esteban Küber
e1649c442f Tweak "the following other types implement trait"
When *any* of the suggested impls is an exact match, *only* show the
exact matches. This is particularly relevant for integer types.

fix fmt
2022-12-05 14:59:30 -08:00
Michael Goulet
a1fbc14372 Point at GAT where clause when unsatisfied 2022-12-05 19:11:31 +00:00
bors
b9341bfdb1 Auto merge of #104920 - compiler-errors:avoid-infcx-build, r=jackh726
Avoid some `InferCtxt::build` calls

Either because we're inside of an `InferCtxt` already, or because we're not in a place where we'd ever see inference vars.

r? types
2022-12-05 02:51:06 +00:00
bors
d1449560e3 Auto merge of #105094 - Swatinem:generator-not-future, r=compiler-errors
Make sure async constructs do not `impl Generator`

Async lowering turns async functions and blocks into generators internally.
Though these special kinds of generators should not `impl Generator` themselves.
The other way around, normal generators should not `impl Future`.

This was discovered in https://github.com/rust-lang/rust/pull/105082#issuecomment-1332210907 and is a regression from https://github.com/rust-lang/rust/pull/104321.

r? `@compiler-errors`
2022-12-04 22:46:11 +00:00
Michael Goulet
e3072a24ad Avoid InferCtxt::build in report_similar_impl_candidates 2022-12-04 20:54:30 +00:00
Matthias Krüger
c89bff29e5
Rollup merge of #104199 - SarthakSingh31:issue-97417-1, r=cjgillot
Keep track of the start of the argument block of a closure

This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by #97417.

VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem.

r? `@cjgillot`
2022-12-03 17:37:41 +01:00
Yuki Okushi
8f368666b5
Rollup merge of #105181 - bhbs:skip-note, r=estebank
Don't add a note for implementing a trait if its inner type is erroneous

Fix #105138
2022-12-03 12:51:29 +09:00
Yuki Okushi
52e886279a
Rollup merge of #104903 - spastorino:consolidate-normalize-in-report_projection_error, r=lcnr
Use ocx.normalize in report_projection_error

r? `@lcnr`

cc `@compiler-errors`
2022-12-03 12:51:27 +09:00
bhbs
715d4a8949 Don't add a note for implementing a trait if its inner type is erroneous 2022-12-03 09:06:47 +09:00
Santiago Pastorino
89047430f1
Define values and err as non mutable 2022-12-02 17:31:45 -03:00
Santiago Pastorino
4dacf4f469
Use ocx.normalize in report_projection_error 2022-12-02 17:31:40 -03:00
Michael Goulet
02b64c5d26 Document normalization methods on At 2022-12-01 19:00:09 +00:00
Arpad Borsos
b5ae4c9629
Make sure async constructs do not impl Generator
Async lowering turns async functions and blocks into generators internally.
Though these special kinds of generators should not `impl Generator` themselves.
The other way around, normal generators should not `impl Future`.
2022-11-30 19:53:59 +01:00
bors
24606deaf4 Auto merge of #104905 - compiler-errors:normalization-changes, r=spastorino
Some initial normalization method changes

1. Rename `AtExt::normalize` to `QueryNormalizeExt::query_normalize` (using the `QueryNormalizer`)
2. Introduce `NormalizeExt::normalize` to replace `partially_normalize_associated_types_in` (using the `AssocTypeNormalizer`)
3. Rename `FnCtxt::normalize_associated_types_in` to `FnCtxt::normalize`
4. Remove some unused other normalization fns in `Inherited` and `FnCtxt`

Also includes one drive-by where we're no longer creating a `FnCtxt` inside of `check_fn`, but passing it in. This means we don't need such weird `FnCtxt` construction logic.

Stacked on top of #104835 for convenience.

r? types
2022-11-30 11:13:09 +00:00
Matthias Krüger
08a6c939a5
Rollup merge of #105066 - lcnr:mv-candidate_from_obligation, r=compiler-errors
move `candidate_from_obligation` out of assembly

it doesn't belong there as it also does winnowing

r? `@compiler-errors`
2022-11-29 22:43:22 +01:00
lcnr
bb982df771 move candidate_from_obligation out of assembly
it doesn't belong there as it also does winnowing
2022-11-29 20:32:48 +00:00
Michael Goulet
9512446a00 Explain why rematch_impl fails to be infallible 2022-11-29 19:02:40 +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
Matthias Krüger
e674b34d56
Rollup merge of #104959 - compiler-errors:revert-104269, r=lcnr
Revert #104269 (to avoid spurious hang/test failure in CI)

Causes hangs/memory overflows in the test suite apparently 😢

Reopens #104225
Fixes #104957
r? ``@lcnr``
2022-11-29 05:24:21 +01:00
Arpad Borsos
2db0dc3297
Simplify checking for GeneratorKind::Async
Adds a helper method around `generator_kind` that makes matching async constructs simpler.
2022-11-28 23:12:01 +01:00
Michael Goulet
1e236acd05 Make ObligationCtxt::normalize take cause by borrow 2022-11-28 17:35:40 +00:00
Michael Goulet
ce409b5200 Make normalize and normalize_to pub(crate) 2022-11-28 17:35:39 +00:00
Michael Goulet
fc710832ea partially_normalize_... -> At::normalize 2022-11-28 17:35:39 +00:00
Michael Goulet
f12e772b83 Rename At::normalize to At::query_normalize 2022-11-28 17:32:35 +00: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
Dylan DPC
9178bc059f
Rollup merge of #104907 - compiler-errors:selcx-infcx, r=oli-obk
Remove `SelectionContext::infcx()` in favor of field access

Encapsulation doesn't seem particularly important here, and having two choices is always more confusing than having one.

r? types
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
Sarthak Singh
8f705e2425 Keep track of the start of the argument block of a closure 2022-11-28 14:09:00 +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
Matthias Krüger
6e6c42c61c
Rollup merge of #104931 - Swatinem:async-pretty, r=eholk
Pretty-print generators with their `generator_kind`

After removing `GenFuture`, I special-cased async generators to pretty-print as `impl Future<Output = X>` mainly to avoid too much diagnostics changes originally.

This now reverses that change so that async fn/blocks are pretty-printed as `[$async-type@$source-position]` in various diagnostics, and updates the tests that this touches.
2022-11-27 16:03:08 +01: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