Commit Graph

808 Commits

Author SHA1 Message Date
Matthias Krüger
297b222066
Rollup merge of #110556 - kylematsuda:earlybinder-explicit-item-bounds, r=compiler-errors
Switch to `EarlyBinder` for `explicit_item_bounds`

Part of the work to finish https://github.com/rust-lang/rust/issues/105779.

This PR adds `EarlyBinder` to the return type of the `explicit_item_bounds` query and removes `bound_explicit_item_bounds`.

r? `@compiler-errors` (hope it's okay to request you, since you reviewed #110299 and #110498 😃)
2023-04-25 21:06:32 +02:00
bors
a7aa20517c Auto merge of #110325 - obeis:hir-analysis-migrate-diagnostics-4, r=davidtwco
Migrate `rustc_hir_analysis` to session diagnostic [Part 4]

Part 4: Finishing `check/mod.rs` file

r? `@compiler-errors`
2023-04-25 13:45:20 +00:00
Yuki Okushi
a373623d55
Rollup merge of #110681 - klensy:cut-dep, r=lcnr
drop few unused crates, gate libc under unix for rustc_codegen_ssa

Small cleanup.
2023-04-25 02:33:29 +09:00
Yuki Okushi
cefb479242
Rollup merge of #110539 - WaffleLapkin:split_index_vec&slice, r=cjgillot
Move around `{Idx, IndexVec, IndexSlice}` adjacent code

r? ``@scottmcm``
2023-04-25 02:33:25 +09:00
Maybe Waffle
e496fbec92 Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
bors
b72460fe46 Auto merge of #110672 - Ezrashaw:allow-array-simd-in-inline-asm, r=workingjubilee
allow array-style simd in inline asm

Required for [MCP#621](https://github.com/rust-lang/compiler-team/issues/621) to be implemented.

r? `@workingjubilee`
2023-04-24 13:51:04 +00:00
Matthias Krüger
3ecae2932c
Rollup merge of #110706 - scottmcm:transmute_unchecked, r=oli-obk
Add `intrinsics::transmute_unchecked`

This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.

See also https://github.com/rust-lang/rust/pull/108442#issuecomment-1474777273, where `CastKind::Transmute` was added having exactly these semantics before the lang meeting (which I wasn't in) independently expressed interest.
2023-04-24 07:53:25 +02:00
Matthias Krüger
12858d9a61
Rollup merge of #110700 - compiler-errors:fn-ret-fn, r=oli-obk
Don't infer fn return type to return itself

Fixes #110687
2023-04-23 20:06:33 +02:00
Ezra Shaw
d31e8a499b
allow array-style simd in inline asm 2023-04-23 19:28:50 +12:00
Scott McMurray
1de2257c3f Add intrinsics::transmute_unchecked
This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.
2023-04-22 17:22:03 -07:00
Michael Goulet
c8874e2445 Don't infer fn return type to return itself 2023-04-22 19:30:47 +00:00
klensy
3338ee3ca7 drop unused deps, gate libc under unix for one crate 2023-04-22 15:22:21 +03:00
Oli Scherer
1ce80e210d Allow LocalDefId as the argument to def_path_str 2023-04-21 22:27:20 +00:00
Oli Scherer
e18d1f8d2e Leave it to the query system to invoke the typeck query instead of invoking it eagerly.
Later queries that are run on all body owners will invoke typeck as they need information from its result to perform their own logic
2023-04-21 22:12:45 +00:00
Obei Sideg
06ff310cf9 Migrate rustc_hir_analysis to session diagnostic
Part 4: Finishing `check/mod.rs` file
2023-04-21 23:50:03 +03:00
bors
1f5768bc67 Auto merge of #96840 - cjgillot:query-feed, r=oli-obk
Allow to feed a value in another query's cache and remove `WithOptConstParam`

I used it to remove `WithOptConstParam` queries, as an example.

The idea is that a query (here `typeck(function)`) can write into another query's cache (here `type_of(anon const)`). The dependency node for `type_of` would depend on all the current dependencies of `typeck`.

There is still an issue with cycles: if `type_of(anon const)` is accessed before `typeck(function)`, we will still have the usual cycle.  The way around this issue is to `ensure` that `typeck(function)` is called before accessing `type_of(anon const)`.

When replayed, we may the following cases:
- `typeck` is green, in that case `type_of` is green too, and all is right;
- `type_of` is green, `typeck` may still be marked as red (it depends on strictly more things than `type_of`) -> we verify that the saved value and the re-computed value of `type_of` have the same hash;
- `type_of` is red, then `typeck` is red -> it's the caller responsibility to ensure `typeck` is recomputed *before* `type_of`.

As `anon consts` have their own `DefPathData`, it's not possible to have the def-id of the anon-const point to something outside the original function, but the general case may have to be resolved before using this device more broadly.

There is an open question about loading from the on-disk cache.  If `typeck` is loaded from the on-disk cache, the side-effect does not happen. The regular `type_of` implementation can go and fetch the correct value from the decoded `typeck` results, and the dep-graph will check that the hashes match, but I'm not sure we want to rely on this behaviour.

I specifically allowed to feed the value to `type_of` from inside a call to `type_of`.  In that case, the dep-graph will check that the fingerprints of both values match.

This implementation is still very sensitive to cycles, and requires that we call `typeck(function)` before `typeck(anon const)`.  The reason is that `typeck(anon const)` calls `type_of(anon const)`, which calls `typeck(function)`, which feeds `type_of(anon const)`, and needs to build the MIR so needs `typeck(anon const)`.  The latter call would not cycle, since `type_of(anon const)` has been set, but I'd rather not remove the cycle check.
2023-04-21 08:04:58 +00:00
Matthias Krüger
7d046551a7
Rollup merge of #110555 - compiler-errors:subst-missing-trait-items, r=cjgillot
Substitute missing trait items suggestion correctly

Properly substitute missing item suggestions, so that when they reference generics from their parent trait they actually have the right time for the impl.

Also, some other minor tweaks like using `/* Type */` to signify a GAT's type is actually missing, and fixing generic arg suggestions for GATs in general.
2023-04-21 06:44:29 +02:00
Kyle Matsuda
e54854f6a9 add subst_identity_iter and subst_identity_iter_copied methods on EarlyBinder; use this to simplify some EarlyBinder noise around explicit_item_bounds calls 2023-04-20 12:36:50 -06:00
Kyle Matsuda
f3b279fcc5 add EarlyBinder to output of explicit_item_bounds; replace bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query 2023-04-20 12:36:50 -06:00
Kyle Matsuda
0892a7380b change usages of explicit_item_bounds to bound_explicit_item_bounds 2023-04-20 12:36:50 -06:00
Camille GILLOT
f65f506d60 Remove opt_const_param_of. 2023-04-20 17:48:52 +00:00
Camille GILLOT
b275d2c30b Remove WithOptconstParam. 2023-04-20 17:48:32 +00:00
Camille GILLOT
0e017fc94a Feed type_of query instead of using WithOptconstParam. 2023-04-20 17:13:39 +00:00
Michael Goulet
f362f6e9e6 Format missing GATs correctly 2023-04-19 23:37:41 +00:00
Michael Goulet
73038d3a64 Make missing impl item suggestions more obvious that they're missing 2023-04-19 17:57:37 +00:00
Michael Goulet
204c516293 Substitute missing item suggestion correctly 2023-04-19 17:47:39 +00:00
bors
d7f9e81650 Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco
Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`

Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-19 08:26:47 +00:00
Matthias Krüger
9f0b16b2bb
Rollup merge of #110498 - kylematsuda:earlybinder-rpitit-tys, r=compiler-errors
Switch to `EarlyBinder` for `collect_return_position_impl_trait_in_trait_tys`

Part of the work to finish https://github.com/rust-lang/rust/issues/105779.

This PR adds `EarlyBinder` to the return type of the `collect_return_position_impl_trait_in_trait_tys` query and removes `bound_return_position_impl_trait_in_trait_tys`.

r? `@lcnr`
2023-04-19 06:35:35 +02:00
Kyle Matsuda
522bc5f817 add EarlyBinder to return type of collect_return_position_impl_trait_in_trait_tys query; remove bound_X version 2023-04-18 16:33:06 -06:00
Nilstrieb
b5d3d970fa Add rustc_fluent_macro to decouple fluent from rustc_macros
Fluent, with all the icu4x it brings in, takes quite some time to
compile. `fluent_messages!` is only needed in further downstream rustc
crates, but is blocking more upstream crates like `rustc_index`. By
splitting it out, we allow `rustc_macros` to be compiled earlier, which
speeds up `x check compiler` by about 5 seconds (and even more after the
needless dependency on `serde_json` is removed from
`rustc_data_structures`).
2023-04-18 18:56:22 +00:00
Guillaume Gomez
aa87addfb3
Rollup merge of #110417 - jsoref:spelling-compiler, r=Nilstrieb
Spelling compiler

This is per https://github.com/rust-lang/rust/pull/110392#issuecomment-1510193656

I'm going to delay performing a squash because I really don't expect people to be perfectly happy w/ my changes, I really am a human and I really do make mistakes.

r? Nilstrieb

I'm going to be flying this evening, but I should be able to squash / respond to reviews w/in a day or two.

I tried to be careful about dropping changes to `tests`, afaict only two files had changes that were likely related to the changes for a given commit (this is where not having eagerly squashed should have given me an advantage), but, that said, picking things apart can be error prone.
2023-04-18 14:50:51 +02:00
Josh Soref
e09d0d2a29 Spelling - compiler
* account
* achieved
* advising
* always
* ambiguous
* analysis
* annotations
* appropriate
* build
* candidates
* cascading
* category
* character
* clarification
* compound
* conceptually
* constituent
* consts
* convenience
* corresponds
* debruijn
* debug
* debugable
* debuggable
* deterministic
* discriminant
* display
* documentation
* doesn't
* ellipsis
* erroneous
* evaluability
* evaluate
* evaluation
* explicitly
* fallible
* fulfill
* getting
* has
* highlighting
* illustrative
* imported
* incompatible
* infringing
* initialized
* into
* intrinsic
* introduced
* javascript
* liveness
* metadata
* monomorphization
* nonexistent
* nontrivial
* obligation
* obligations
* offset
* opaque
* opportunities
* opt-in
* outlive
* overlapping
* paragraph
* parentheses
* poisson
* precisely
* predecessors
* predicates
* preexisting
* propagated
* really
* reentrant
* referent
* responsibility
* rustonomicon
* shortcircuit
* simplifiable
* simplifications
* specify
* stabilized
* structurally
* suggestibility
* translatable
* transmuting
* two
* unclosed
* uninhabited
* visibility
* volatile
* workaround

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17 16:09:18 -04:00
Maybe Waffle
9534541dd4 Use Item::expect_* and ImplItem::expect_* more 2023-04-17 18:00:27 +00:00
bors
8a778ca1e3 Auto merge of #110405 - fee1-dead-contrib:rollup-9rkree6, r=fee1-dead
Rollup of 4 pull requests

Successful merges:

 - #110397 (Move some utils out of `rustc_const_eval`)
 - #110398 (use matches! macro in more places)
 - #110400 (more clippy fixes: clippy::{iter_cloned_collect, unwarp_or_else_defau…)
 - #110402 (Remove the loop in `Align::from_bytes`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-16 13:12:53 +00:00
fee1-dead
1d30adb068
Rollup merge of #110400 - matthiaskrgr:style_mix, r=fee1-dead
more clippy fixes: clippy::{iter_cloned_collect, unwarp_or_else_defau…

…lt, option_map_or_none}

r? `@Nilstrieb`
2023-04-16 19:36:02 +08:00
fee1-dead
7fb14ae84d
Rollup merge of #110396 - Nilstrieb:speedy-bootstrap, r=jyn514
Use lint via `lint_defs` instead of `lints`

This gets rid of a blocking dependency edge from `rustc_lint->rustc_analysis->rustc_hir_typeck->rustc_interface`

![image](https://user-images.githubusercontent.com/48135649/232291152-fc61e6c5-9b1e-4db1-8101-dfaa3b7d30c6.png)
2023-04-16 18:55:39 +08:00
fee1-dead
eba419195c
Rollup merge of #110345 - nnethercote:rm-Super-impls-for-Region, r=compiler-errors
Remove `TypeSuper{Foldable,Visitable}` impls for `Region`.

These traits exist so that folders/visitors can recurse into types of interest: binders, types, regions, predicates, and consts. But `Region` is non-recursive and cannot contain other types of interest, so its methods in these traits are trivial.

This commit inlines and removes those trivial methods.

r? `@compiler-errors`
2023-04-16 18:55:38 +08:00
Matthias Krüger
6ef8648a48 more clippy fixes: clippy::{iter_cloned_collect, unwarp_or_else_default, option_map_or_none} 2023-04-16 12:45:51 +02:00
Matthias Krüger
bcc15bba95 use matches! macro in more places 2023-04-16 12:08:30 +02:00
Nilstrieb
ee8f92ba0a Use lints via lint_defs instead of lints
This gets rid of a blocking dependency edge from
`rustc_lint->rustc_analysis->rustc_hir_typeck->rustc_interface`
2023-04-16 11:48:01 +02:00
Nicholas Nethercote
4460a1dc28 Remove TypeSuper{Foldable,Visitable} impls for Region.
These traits exist so that folders/visitors can recurse into types of
interest: binders, types, regions, predicates, and consts. But `Region`
is non-recursive and cannot contain other types of interest, so its
methods in these traits are trivial.

This commit inlines and removes those trivial methods.
2023-04-16 09:11:43 +10:00
Matthias Krüger
bcd79c222a fix clippy::{clone_on_copy, useless_conversion} 2023-04-15 19:02:26 +02:00
Matthias Krüger
6f1500aec2
Rollup merge of #110220 - lcnr:regionzz, r=compiler-errors
cleanup our region error API

- require `TypeErrCtxt` to always result in an error, closing #108810
- move `resolve_regions_and_report_errors` to the `ObligationCtxt`
- call `process_registered_region_obligations` in `resolve_regions`
- move `resolve_regions` into the `outlives` submodule
- add `#[must_use]` to functions returning lists of errors

r? types
2023-04-13 11:21:05 +02:00
Matthias Krüger
35c4ea59a5
Rollup merge of #110218 - nnethercote:rm-ToRegionVid, r=compiler-errors
Remove `ToRegionVid`

r? ```@compiler-errors```
2023-04-13 11:21:01 +02:00
Matthias Krüger
958413cc08
Rollup merge of #110195 - compiler-errors:issue-110052, r=aliemjay
Erase lifetimes above `ty::INNERMOST` when probing ambiguous types

Turns out that `TyCtxt::replace_escaping_bound_vars_uncached` only erases bound vars exactly at `ty::INNERMOST`, and not everything above. This regresses the suggestions for non-lifetime binders, but oh well, I don't really care about those.

Fixes #110052
2023-04-13 11:21:00 +02:00
Nicholas Nethercote
72605cd267 Remove some unused type folders.
I'm surprised the compiler doesn't warn about these. It appears having
an `impl` on a struct is enough to avoid a warning about it never being
constructed.
2023-04-13 12:20:44 +10:00
Matthias Krüger
331e7c3659
Rollup merge of #110153 - DaniPopes:compiler-typos, r=Nilstrieb
Fix typos in compiler

I ran [`typos -w compiler`](https://github.com/crate-ci/typos) to fix typos in the `compiler` directory.

Refs #110150
2023-04-12 20:56:21 +02:00
lcnr
a19adefa0e region error cleanup
- require `TypeErrCtxt` to always result in an error
- move `resolve_regions_and_report_errors` to the `ObligationCtxt`
- merge `process_registered_region_obligations` into `resolve_regions`
2023-04-12 10:24:36 +02:00
Michael Goulet
7ec72efe10 Allow the elaborator to only filter to real supertraits 2023-04-11 17:45:42 +00:00
Michael Goulet
25c342f30a Split implied and super predicate queries 2023-04-11 17:45:42 +00:00