about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2023-02-27Implement checked Shl/Shr at MIR building.Camille GILLOT-12/+12
2023-02-27Auto merge of #108538 - matthiaskrgr:rollup-vw6h5ea, r=matthiaskrgrbors-9/+0
Rollup of 8 pull requests Successful merges: - #104265 (Move IpAddr, SocketAddr and V4+V6 related types to `core`) - #107110 ([stdio][windows] Use MBTWC and WCTMB) - #108308 (Allow building serde and serde_derive in parallel) - #108363 (Move the unused extern crate check back to the resolver.) - #108519 (Bages for easy access links to Rust community) - #108522 (Commit some new solver tests) - #108523 (Avoid `&str` to `String` conversions) - #108533 (diagnostics: avoid querying `associated_item` in the resolver) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-27Rollup merge of #108363 - cjgillot:unused-crate, r=WaffleLapkinMatthias Krüger-9/+0
Move the unused extern crate check back to the resolver. It doesn't have anything to do in `rustc_hir_typeck`.
2023-02-27Auto merge of #108493 - cjgillot:thir-print, r=compiler-errorsbors-882/+0
Move THIR printing to rustc_mir_build. https://github.com/rust-lang/rust/pull/107451 increased the compilation time of `rustc_middle` by 10% = 3s. As https://github.com/rust-lang/rust/pull/107006 adds quite a lot of code to rustc_middle, I suspect it to be the cause. This PR moves the THIR printing code to `rustc_mir_build`, where the query provider lives, in order to benefit from higher parallelism when compiling rustc.
2023-02-27Unify all validity check intrinsicsNilstrieb-9/+23
Also merges the inhabitedness check into the query to further unify the code paths.
2023-02-27Rollup merge of #108486 - cjgillot:owner-ditem, r=NilstriebMatthias Krüger-5/+9
Merge diagnostic_items duplicate diagnostics To deduplicate how we diagnose duplication.
2023-02-27Rollup merge of #108364 - Nilstrieb:validity-checks-refactor, r=compiler-errorsMatthias Krüger-7/+43
Unify validity checks into a single query Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check in #100423, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one. I am not entirely happy with the naming and key type and open for improvements. r? oli-obk
2023-02-26Move THIR printing to rustc_mir_build.Camille GILLOT-882/+0
2023-02-26Wrap more into into closure_typeinfo query.Camille GILLOT-11/+36
2023-02-26Access upvars through a query.Camille GILLOT-25/+27
2023-02-26Store the body type in THIR.Camille GILLOT-3/+23
2023-02-26Simplify diagnostic_items.Camille GILLOT-5/+9
2023-02-26Auto merge of #108375 - Zoxc:query-inline, r=cjgillotbors-0/+1
Add inlining attributes for query system functions These only have a single caller, but don't always get inlined.
2023-02-25Auto merge of #108450 - matthiaskrgr:rollup-rqvfgu3, r=matthiaskrgrbors-2/+3
Rollup of 7 pull requests Successful merges: - #108354 (Update `fuchsia-test-runner.py` and docs) - #108404 (support `x fmt` for sub and outside of rust directories) - #108407 (docs: use intra-doc links for `Vec::get(_mut)`) - #108410 (rustdoc: avoid including `<li>` tags in item table short desc) - #108412 (Fix GUI test navigation bug) - #108433 (Wrap missing provider message correctly) - #108434 (Migrate `rustc_hir_analysis` to session diagnostic [Part One]) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-25Add inlining attributes for query system functionsJohn Kåre Alsaker-0/+1
2023-02-24Wrap missing provider message correctlyMichael Goulet-2/+3
2023-02-24Use `List::empty()` instead of `mk_substs(&[])`.Nicholas Nethercote-1/+1
2023-02-24Add `mk_canonical_var_infos_from_iter`.Nicholas Nethercote-3/+11
It's missing, and is useful in two places.
2023-02-24Rename `mk_{ty,region}` as `mk_{ty,region}_from_kind`.Nicholas Nethercote-33/+41
To discourage accidental use -- there are more specific `mk_*` functions for all `Ty` and `Region` kinds.
2023-02-24Rename many interner functions.Nicholas Nethercote-138/+148
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
2023-02-24Tweak the slice interners.Nicholas Nethercote-59/+24
All the slice interners have a wrapper that handles the empty slice case. We can instead handle this in the `slice_interners!` macro, avoiding the need for most of the wrappers, and allowing the interner functions to be renamed from `_intern_foos` to `intern_foos`. The two exceptions: - intern_predicates: I kept this wrapper because there's a FIXME comment about a possible future change. - intern_poly_existential_predicates: I kept this wrapper because it asserts that the slice is empty and sorted.
2023-02-23Lazily compute crate name for consider_optimizingNilstrieb-2/+1
The extra query is unnecessary in the common case of not having fuel.
2023-02-23Unify validity checks into a single queryNilstrieb-7/+43
Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one.
2023-02-23Auto merge of #108369 - compiler-errors:ty-error-more, r=BoxyUwUbors-13/+12
Use `tcx.ty_error_with_guaranteed` in more places, rename variants 1. Use `ty_error_with_guaranteed` more so we don't delay so many span bugs 2. Rename `ty_error_with_guaranteed` to `ty_error`, `ty_error` to `ty_error_misc`. This is to incentivize using the former over the latter in cases where we already are witness to a `ErrorGuaranteed` token. Second commit is just name replacement, so the first commit can be reviewed on its own with more scrutiny.
2023-02-23Rollup merge of #108350 - compiler-errors:assoc-type-bound-dogfooding, r=oli-obkMatthias Krüger-7/+7
Use associated type bounds in some places in the compiler Use associated type bounds for some nested `impl Trait<Assoc = impl Trait2>` cases. I'm generally keen to introduce new lang features that are more mature into the compiler, but maybe let's see what others think? Side-note: I was surprised that the only use-cases of nested impl trait in the compiler are just iterator related?!
2023-02-23Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, ↵bors-9/+38
r=compiler-errors,davidtwco,estebank,oli-obk diagnostics: if AssocFn has self argument, describe as method Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods. For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods> > Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html), for example, `x.foo()`, as well as the usual function call notation. In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-22Rename ty_error_with_guaranteed to ty_error, ty_error to ty_error_miscMichael Goulet-11/+9
2023-02-22Use ty_error_with_guaranteed in many more placesMichael Goulet-2/+3
2023-02-22Remove some resolver outputs.Camille GILLOT-9/+0
2023-02-22Auto merge of #108340 - eggyal:remove_traversal_trait_aliases, r=oli-obkbors-246/+304
Remove type-traversal trait aliases #107924 moved the type traversal (folding and visiting) traits into the type library, but created trait aliases in `rustc_middle` to minimise both the API churn for trait consumers and the arising boilerplate. As mentioned in that PR, an alternative approach of defining subtraits with blanket implementations of the respective supertraits was also considered at that time but was ruled out as not adding much value. Unfortunately, it has since emerged that rust-analyzer has difficulty with these trait aliases at present, resulting in a degraded contributor experience (see the recent [r-a has become useless](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/r-a.20has.20become.20useless) topic on the #t-compiler/help Zulip stream). This PR removes the trait aliases, and accordingly the underlying type library traits are now used directly; they are parameterised by `TyCtxt<'tcx>` rather than just the `'tcx` lifetime, and imports have been updated to reflect the fact that the trait aliases' explicitly named traits are no longer automatically brought into scope. These changes also roll-back the (no-longer required) workarounds to #107747 that were made in b409329c624b9e3bbd7d8e07697e2e9f861a45b6. Since this PR is just a find+replace together with the changes necessary for compilation & tidy to pass, it's currently just one mega-commit. Let me know if you'd like it broken up. r? `@oli-obk`
2023-02-22Remove type-traversal trait aliasesAlan Egerton-246/+304
2023-02-22diagnostics: if AssocFn has self argument, describe as methodMichael Howell-9/+38
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods.
2023-02-22Auto merge of #103042 - davidtwco:translation-distributed-ftl, r=oli-obkbors-3/+53
errors: generate typed identifiers in each crate Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. There are advantages and disadvantages to this change.. #### Advantages - Changing a diagnostic now only recompiles the crate for that diagnostic and those crates that depend on it, rather than `rustc_error_messages` and all crates thereafter. - This approach can be used to support first-party crates that want to supply translatable diagnostics (e.g. `rust-lang/thorin` in https://github.com/rust-lang/rust/pull/102612#discussion_r985372582, cc `@JhonnyBillM)` - We can extend this a little so that tools built using rustc internals (like clippy or rustdoc) can add their own diagnostic resources (much more easily than those resources needing to be available to `rustc_error_messages`) #### Disadvantages - Crates can only refer to the diagnostic messages defined in the current crate (or those from dependencies), rather than all diagnostic messages. - `rustc_driver` (or some other crate we create for this purpose) has to directly depend on *everything* that has error messages. - It already transitively depended on all these crates. #### Pending work - [x] I don't know how to make `rustc_codegen_gcc`'s translated diagnostics work with this approach - because `rustc_driver` can't depend on that crate and so can't get its resources to provide to the diagnostic emission. I don't really know how the alternative codegen backends are actually wired up to the compiler at all. - [x] Update `triagebot.toml` to track the moved FTL files. r? `@compiler-errors` cc #100717
2023-02-22Auto merge of #108339 - GuillaumeGomez:rollup-4z02kas, r=GuillaumeGomezbors-2/+3
Rollup of 8 pull requests Successful merges: - #108110 (Move some `InferCtxt` methods to `EvalCtxt` in new solver) - #108168 (Fix ICE on type alias in recursion) - #108230 (Convert a hard-warning about named static lifetimes into lint "unused_lifetimes") - #108239 (Fix overlapping spans in removing extra arguments) - #108246 (Add an InstCombine for redundant casts) - #108264 (no-fail-fast support for tool testsuites) - #108310 (rustdoc: Fix duplicated attributes for first reexport) - #108318 (Remove unused FileDesc::get_cloexec) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-22Rollup merge of #108168 - clubby789:recursive-type-alias, r=compiler-errorsGuillaume Gomez-2/+3
Fix ICE on type alias in recursion Fixes #108160
2023-02-22errors: generate typed identifiers in each crateDavid Wood-3/+53
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22Auto merge of #108300 - oli-obk:elsa, r=eholkbors-3/+2
Use a lock-free datastructure for source_span follow up to the perf regression in https://github.com/rust-lang/rust/pull/105462 The main regression is likely the CStore, but let's evaluate the perf impact of this on its own
2023-02-21Rollup merge of #104239 - b-naber:sccs-info, r=jackh726Matthias Krüger-1/+8
Better debug logs for borrowck constraint graph It's really cumbersome to work with `RegionVar`s when trying to debug borrowck code or when trying to understand how the borrowchecker works. This PR collects some region information (behind `cfg(debug_assertions)`) for created `RegionVar`s (NLL region vars, this PR doesn't touch canonicalization) and prints the nodes and edges of the strongly connected constraints graph using representatives that use that region information (either lifetime names, locations in MIR or spans).
2023-02-21address reviewb-naber-1/+1
2023-02-21Auto merge of #108301 - Dylan-DPC:rollup-70zpkt0, r=Dylan-DPCbors-7/+37
Rollup of 7 pull requests Successful merges: - #108000 (lint: don't suggest MaybeUninit::assume_init for uninhabited types) - #108105 (Explain the default panic hook better) - #108141 (Add rpitit queries) - #108272 (docs: wrong naming convention in struct keyword doc) - #108285 (remove unstable `pick_stable_methods_before_any_unstable` flag) - #108289 (Name placeholder in some region errors) - #108290 (Add a test for default trait method with RPITITs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-21Rollup merge of #108141 - spastorino:add_rpitit_queries, r=compiler-errorsDylan DPC-7/+37
Add rpitit queries This is part of the changes we are making to lower RPITITs as an associated type. The rest of the stuff will follow under a `-Z` flag. I still need to add comments to the code, explain stuff and also I'd need to avoid encoding in metadata when rpitit queries return `&[]` r? `@compiler-errors`
2023-02-21Use a lock-free datastructure for `source_span`Oli Scherer-3/+2
2023-02-21Auto merge of #104754 - nnethercote:more-ThinVec-in-ast, r=the8472bors-1/+1
Use `ThinVec` more in the AST r? `@ghost`
2023-02-21Associated type bounds in some places in the compilerMichael Goulet-7/+7
2023-02-21Upgrade `thin-vec` from 0.2.9 to 0.2.12.Nicholas Nethercote-1/+1
Because 0.2.10 added supports for `ThinVec::splice`, and 0.2.12 is the latest release.
2023-02-20Minimal changes to make miri workRune Tynan-14/+4
2023-02-20Remove unused lifetimeRune Tynan-1/+1
2023-02-20Add mentioned from_raw_bytes constructorRune Tynan-0/+17
2023-02-20Allow non-`Box` allocations in preparation for aligned const allocations for ↵Rune Tynan-28/+84
miri. Credit to emarteca for the code.
2023-02-20Remove IntoDefIdTreeOli Scherer-17/+8