Commit graph

2928 commits

Author SHA1 Message Date
Yuki Okushi 645e5c475a
Rollup merge of #98371 - compiler-errors:better-opaque-printing, r=oli-obk
Fix printing `impl trait` under binders

Before, we would render `impl for<'a> Trait<'a>` like `impl Trait<for<'a> 'a>`, lol.
2022-06-26 13:14:56 +09: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
Michael Goulet e80ccedbae Use write! instead of p! to avoid having to use weird scoping 2022-06-24 15:47:59 -07:00
Michael Goulet 20cea3ebb4 Fix printing impl trait under binders 2022-06-24 15:36:55 -07:00
Yuki Okushi 964fc41b89
Rollup merge of #98280 - compiler-errors:better-call-closure-on-type-err, r=estebank
Improve suggestion for calling fn-like expr on type mismatch

1.) Suggest calling values of with RPIT types (and probably TAIT) when we expect `Ty` and have `impl Fn() -> Ty`
2.) Suggest calling closures even when they're not assigned to a local variable first
3.) Drive-by fix of a pretty-printing bug (`impl Fn()-> Ty` => `impl Fn() -> Ty`)

r? ```@estebank```
2022-06-24 16:43:46 +09:00
Yuki Okushi 2c6feb51da
Rollup merge of #96955 - Aaron1011:pretty-print-sort, r=petrochenkov
Remove (transitive) reliance on sorting by DefId in pretty-printer

This moves us a step closer to removing the `PartialOrd/`Ord` impls
for `DefId`. See #90317
2022-06-24 16:43:42 +09:00
Michael Goulet aafddd2a8a
Rollup merge of #98388 - rosehuds:master, r=davidtwco
implement `iter_projections` function on `PlaceRef`

this makes the api more flexible. the original function now calls the PlaceRef
version to avoid duplicating the code.
2022-06-23 14:39:15 -07:00
Michael Goulet 667a54623d
Rollup merge of #98365 - jyn514:improve-obligation-errors-review-comments, r=eholk
Address review comments from #98259

It got approved so fast I didn't have time to make changes xD

r? ``@eholk``
2022-06-23 14:39:14 -07:00
Aaron Hill 36ccdbefbb
Remove (transitive) reliance on sorting by DefId in pretty-printer
This moves us a step closer to removing the `PartialOrd/`Ord` impls
for `DefId`. See #90317
2022-06-22 12:58:56 -05:00
Rose Hudson 53481a5a8f implement iter_projections function on PlaceRef
this makes the api more flexible. the original function now calls the PlaceRef
version to avoid duplicating the code.
2022-06-22 14:06:13 +01:00
Yuki Okushi 8f861dae7a
Rollup merge of #97895 - nbdd0121:unlikely, r=estebank
Simplify `likely!` and `unlikely!` macro

The corresponding intrinsics have long been safe-to-call, so the unsafe block is no longer needed.
2022-06-22 15:16:13 +09:00
Yuki Okushi dfc6d7ac76
Rollup merge of #97818 - compiler-errors:rpit-error-spanned, r=oli-obk
Point at return expression for RPIT-related error

Certainly this needs some diagnostic refining, but I wanted to show that it was possible first and foremost. Not sure if this is the right approach. Open to feedback.

Fixes #80583
2022-06-22 15:16:12 +09:00
Michael Goulet 52409c4c90 Point at return expression for RPIT-related error 2022-06-21 18:23:37 -07:00
Michael Goulet d15fed79b8 Improve suggestion for calling closure on type mismatch 2022-06-21 18:12:43 -07:00
Joshua Nelson b052d76586 Address review comments from #98259
It got merged so fast I didn't have time to make changes xD
2022-06-21 19:44:53 -05:00
Yuki Okushi e3ae9f5b20
Rollup merge of #98099 - RalfJung:convert_tag_add_extra, r=oli-obk
interpret: convert_tag_add_extra: allow tagger to raise errors

Needed for https://github.com/rust-lang/miri/issues/2234

r? `@oli-obk`
2022-06-22 07:03:59 +09:00
Alan Egerton 75203eef19
Remove unecessary references to TypeFolder::Error 2022-06-21 17:39:44 +01:00
Alan Egerton 6ac6866bec
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-21 17:38:22 +01:00
bors 72fd41a8b4 Auto merge of #98335 - JohnTitor:rollup-j2zudxv, r=JohnTitor
Rollup of 11 pull requests

Successful merges:

 - #94033 (Improve docs for `is_running` to explain use case)
 - #97269 (adjust transmute const stabilization version)
 - #97805 (Add proper tracing spans to rustc_trait_selection::traits::error_reporting)
 - #98022 (Fix erroneous span for borrowck error)
 - #98124 (Improve loading of crates.js and sidebar-items.js)
 - #98278 (Some token stream cleanups)
 - #98306 (`try_fold_unevaluated` for infallible folders)
 - #98313 (Remove lies in comments.)
 - #98323 (⬆️ rust-analyzer)
 - #98329 (Avoid an ICE and instead let the compiler report a useful error)
 - #98330 (update ioslice docs to use shared slices)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-21 13:41:37 +00:00
Yuki Okushi 51a60911fb
Rollup merge of #98306 - eggyal:add-unevaluated-to-blanket-fallibletypefolder, r=nnethercote
`try_fold_unevaluated` for infallible folders

#97447 added folding of unevaluated constants, but did not include an override of the default (fallible) operation in the blanket impl of `FallibleTypeFolder` for infallible folders.  Here we provide that missing override.

r? ```@nnethercote```
2022-06-21 20:08:13 +09:00
bors a25b1315ee Auto merge of #95576 - DrMeepster:box_erasure, r=oli-obk
Remove dereferencing of Box from codegen

Through #94043, #94414, #94873, and #95328, I've been fixing issues caused by Box being treated like a pointer when it is not a pointer. However, these PRs just introduced special cases for Box. This PR removes those special cases and instead transforms a deref of Box into a deref of the pointer it contains.

Hopefully, this is the end of the Box<T, A> ICEs.
2022-06-21 11:00:39 +00: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
Alan Egerton bd604750ae
try_fold_unevaluated for infallible folders
#97447 added folding of unevaluated constants, but did not include an override of the default (fallible) operation in the blanket impl of `FallibleTypeFolder` for infallible folders.  Here we provide that missing override.

r? @nnethercote
2022-06-20 19:03:37 +01:00
Michael Goulet 52c9906c4b Use Span::eq_ctxt method instead of .ctxt() == .ctxt() 2022-06-19 16:46:59 -07:00
bors bb8c2f4117 Auto merge of #98247 - jackh726:regionkind-rustc-type-ir, r=compiler-errors
Move RegionKind to rustc_type_ir

(Also UniverseIndex)

r? rust-lang/types
2022-06-19 19:55:45 +00:00
bors 68d0b29098 Auto merge of #98255 - Dylan-DPC:rollup-hr129rg, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #98105 (rustdoc: remove tuple link on round braces)
 - #98136 (Rename `impl_constness` to `constness`)
 - #98146 (Remove --memory-init-file flag when linking with Emscripten)
 - #98219 (Skip late bound regions in GATSubstCollector)
 - #98233 (Remove accidental uses of `&A: Allocator`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-19 14:51:28 +00:00
Dylan DPC 6e8f541fff
Rollup merge of #98136 - fee1-dead-contrib:rename_impl_constness, r=oli-obk
Rename `impl_constness` to `constness`

The current code is a basis for `is_const_fn_raw`, and `impl_constness`
is no longer a valid name, which is previously used for determining the
constness of impls, and not items in general.

r? `@oli-obk`
2022-06-19 15:26:28 +02:00
Camille GILLOT 47b8d26eff Use ensure for UnusedBrokenConst. 2022-06-19 09:44:32 +02:00
Jack Huey 1e9f8df6bb Move RegionKind to rustc_type_ir 2022-06-19 00:20:27 -04:00
bors cdcc53b7dc Auto merge of #98153 - nnethercote:fix-MissingDoc-quadratic-behaviour, r=cjgillot
Fix `MissingDoc` quadratic behaviour

Best reviewed one commit at a time.

r? `@cjgillot`
2022-06-18 09:57:00 +00:00
Gary Guo 8b7299dd12 Remove likely! and unlikely! macro from compiler 2022-06-18 04:52:11 +01:00
bors 43c47db0b0 Auto merge of #98097 - lqd:const-alloc-hash, r=oli-obk
ctfe: limit hashing of big const allocations when interning

Const allocations are only hashed for interning. However, they can be large, making the hashing expensive especially since it uses `FxHash`: it's better suited to short keys, not potentially big buffers like the actual bytes of allocation and the associated 1/8th sized `InitMask`.

We can partially hash these fields when they're large, hashing the length, and head and tail of these buffers, to
limit possible collisions while avoiding most of the hashing work.

r? `@ghost`
2022-06-17 15:10:04 +00:00
bors 3a8b0144c8 Auto merge of #98106 - cjgillot:split-definitions, r=michaelwoerister
Split up `Definitions` and `ResolverAstLowering`.

Split off https://github.com/rust-lang/rust/pull/95573

r? `@michaelwoerister`
2022-06-17 10:00:11 +00:00
Rémy Rakic 61dc080375 adjust const alloc interning partial hash comments 2022-06-16 23:07:43 +02:00
Rémy Rakic b1f31f853e ctfe: limit hashing of big const allocations when interning
Big const allocations hash a large amount of data for interning:
the whole bytes buffer, and the 1/8th sized initmask, with FxHash.
This hash function is made for shorter keys.

This only hashes the length, and head and tail of these buffers, to
limit possible collisions while avoiding most of the hashing work.
2022-06-16 19:36:51 +02:00
Ralf Jung 1c1a60f0a3 interpret: convert_tag_add_extra, init_allocation_extra: allow tagger to raise errors 2022-06-16 09:41:07 -07:00
Matthias Krüger 95be954af4
Rollup merge of #97757 - xFrednet:rfc-2383-expect-with-force-warn, r=wesleywiser,flip1995
Support lint expectations for `--force-warn` lints (RFC 2383)

Rustc has a `--force-warn` flag, which overrides lint level attributes and forces the diagnostics to always be warn. This means, that for lint expectations, the diagnostic can't be suppressed as usual. This also means that the expectation would not be fulfilled, even if a lint had been triggered in the expected scope.

This PR now also tracks the expectation ID in the `ForceWarn` level. I've also made some minor adjustments, to possibly catch more bugs and make the whole implementation more robust.

This will probably conflict with https://github.com/rust-lang/rust/pull/97718. That PR should ideally be reviewed and merged first. The conflict itself will be trivial to fix.

---

r? `@wesleywiser`

cc: `@flip1995` since you've helped with the initial review and also discussed this topic with me. 🙃

Follow-up of: https://github.com/rust-lang/rust/pull/87835

Issue: https://github.com/rust-lang/rust/issues/85549

Yeah, and that's it.
2022-06-16 09:10:20 +02:00
xFrednet 8527a3d369
Support lint expectations for --force-warn lints (RFC 2383) 2022-06-16 08:16:43 +02:00
DrMeepster 6cb38fb339 correct mirphase docs 2022-06-15 18:39:22 -07:00
DrMeepster cb417881a9 remove box derefs from codgen 2022-06-15 18:38:26 -07:00
Nicholas Nethercote c9e97251ad Remove unused hir_id arg from visit_attribute. 2022-06-16 09:52:04 +10:00
Camille GILLOT ae5959f4ba Consume resolutions for lowering separately. 2022-06-15 19:42:43 +02:00
Camille GILLOT 52f22c7d01 Remove unused item_generics_num_lifetimes. 2022-06-15 19:19:53 +02:00
Deadbeef 26ac45614b Rename impl_constness to constness
The current code is a basis for `is_const_fn_raw`, and `impl_constness`
is no longer a valid name, which is previously used for determining the
constness of impls, and not items in general.
2022-06-15 20:54:43 +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
Yuki Okushi 97b9347c93
Rollup merge of #98083 - nnethercote:rename-Encoder, r=bjorn3
Rename rustc_serialize::opaque::Encoder as MemEncoder.

This avoids the name clash with `rustc_serialize::Encoder` (a trait),
and allows lots qualifiers to be removed and imports to be simplified
(e.g. fewer `as` imports).

(This was previously merged as commit 5 in #94732 and then was reverted
in #97905 because of a perf regression caused by commit 4 in #94732.)

r? ```@bjorn3```
2022-06-15 12:02:04 +09:00
Camille GILLOT 34e4d72929 Separate source_span and expn_that_defined from Definitions. 2022-06-14 22:45:51 +02:00
Camille GILLOT 603746a35e Make ResolverAstLowering a struct. 2022-06-14 22:44:27 +02:00
Camille GILLOT 47799de35a Separate Definitions and CrateStore from ResolverOutputs. 2022-06-14 22:44:27 +02:00
b-naber 15c1c06522 rebase 2022-06-14 17:57:51 +02:00