about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2023-05-04IAT: Introduce AliasKind::InherentLeón Orell Valerian Liehr-24/+89
2023-05-04Auto merge of #111174 - matthiaskrgr:rollup-ncnqivh, r=matthiaskrgrbors-6/+7
Rollup of 8 pull requests Successful merges: - #110859 (Explicitly reject negative and reservation drop impls) - #111020 (Validate resolution for SelfCtor too.) - #111024 (Use the full Fingerprint when stringifying Svh) - #111027 (Remove `allow(rustc::potential_query_instability)` for `builtin_macros`) - #111039 (Encode def span for foreign return-position `impl Trait` in trait) - #111070 (Don't suffix `RibKind` variants) - #111094 (Add needs-unwind annotations to tests that need stack unwinding) - #111103 (correctly recurse when expanding anon consts) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-05-04do not allow rustc::pass_by_value lintBoxy-6/+4
2023-05-04check array type of repeat exprs is wfBoxy-2/+21
2023-05-04Rollup merge of #111103 - BoxyUwU:normal_fold_with_gce_norm, r=compiler-errorsMatthias Krüger-1/+2
correctly recurse when expanding anon consts recursing with `super_fold_with` is wrong in case `bac` is itself normalizable, the test that was supposed to test for this being wrong did not actually test for this in reality because of the usage of `{ (N) }` instead of `{{ N }}`. The former resulting in a simple `ConstKind::Param` instead of `ConstKind::Unevaluated`. Tbh generally this test seems very brittle and it will be a lot easier to test once we have normalization of assoc consts since then we can just test that `T::ASSOC` normalizes to some `U::OTHER` which normalizes to some third thing. r? `@compiler-errors`
2023-05-04Rollup merge of #110859 - compiler-errors:no-negative-drop-impls, r=oli-obkMatthias Krüger-5/+5
Explicitly reject negative and reservation drop impls Fixes #110858 It doesn't really make sense for a type to have a `!Drop` impl. Or at least, I don't want us to implicitly assign a meaning to it by the way the compiler *currently* handles it (incompletely), and rather I would like to see a PR (or an RFC...) assign a meaning to `!Drop` if we actually wanted one for it.
2023-05-04Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnrbors-43/+78
Replace `tcx.mk_trait_ref` with `TraitRef::new` First step in implementing https://github.com/rust-lang/compiler-team/issues/616 r? `@lcnr`
2023-05-04Remove unneeded encode/decode methods.Nicholas Nethercote-9/+0
In #110927 the encode/decode methods for `i8`, `char`, `bool`, and `str` were made inherent. This commit removes some unnecessary implementations of these methods that were missed in that PR.
2023-05-04Reorder some `MemDecoder` methods.Nicholas Nethercote-6/+6
So they match the order in the `Decoder` trait.
2023-05-03Rollup merge of #111146 - petrochenkov:decident, r=compiler-errorsManish Goregaokar-4/+3
rustc_middle: Fix `opt_item_ident` for non-local def ids Noticed while working on https://github.com/rust-lang/rust/pull/110855.
2023-05-03Rollup merge of #105452 - rcvalle:rust-cfi-3, r=bjorn3Manish Goregaokar-0/+7
Add cross-language LLVM CFI support to the Rust compiler This PR adds cross-language LLVM Control Flow Integrity (CFI) support to the Rust compiler by adding the `-Zsanitizer-cfi-normalize-integers` option to be used with Clang `-fsanitize-cfi-icall-normalize-integers` for normalizing integer types (see https://reviews.llvm.org/D139395). It provides forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space). For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, see design document in the tracking issue #89653. Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and -Zsanitizer-cfi-normalize-integers, and requires proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto). Thank you again, ``@bjorn3,`` ``@nikic,`` ``@samitolvanen,`` and the Rust community for all the help!
2023-05-03Add cross-language LLVM CFI support to the Rust compilerRamon de C Valle-0/+7
This commit adds cross-language LLVM Control Flow Integrity (CFI) support to the Rust compiler by adding the `-Zsanitizer-cfi-normalize-integers` option to be used with Clang `-fsanitize-cfi-icall-normalize-integers` for normalizing integer types (see https://reviews.llvm.org/D139395). It provides forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space). For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, see design document in the tracking issue #89653. Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and -Zsanitizer-cfi-normalize-integers, and requires proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto).
2023-05-03Error message for ambiguous RTN from super boundsMichael Goulet-0/+6
2023-05-03Rename things to reflect that they're not item specificMichael Goulet-9/+4
2023-05-03Support RTN on associated methods from supertraitsMichael Goulet-1/+6
2023-05-04Rollup merge of #111097 - oli-obk:🚲_layout, r=compiler-errorsDylan DPC-0/+14
Avoid ICEing miri on layout query cycles Miri has special logic for catching panics during interpretation. Raising a fatal error in rustc uses unwinding to abort compilation. Thus miri ends up catching that fatal error and thinks it saw an ICE. While we should probably change that to ignore `Fatal` payloads, I think it's also neat to continue compilation after a layout query cycle 😆 Query cycles now (in addition to reporting an error just like before), return `Err(Cycle)` instead of raising a fatal error. This allows the interpreter to wind down via the regular error paths. r? `@RalfJung` for a first round, feel free to reroll for the compiler team once the miri side looks good
2023-05-04Rollup merge of #110943 - RalfJung:interpret-unsized-arg-ice, r=oli-obkDylan DPC-0/+4
interpret: fail more gracefully on uninit unsized locals r? `@oli-obk` Fixes https://github.com/rust-lang/rust/issues/68538
2023-05-04Rollup merge of #110908 - petrochenkov:notagain4, r=compiler-errorsDylan DPC-17/+7
resolve: One more attempt to simplify `module_children` If the next step is performed and `fn module_children_local` is merged with the `module_children` query, then it causes perf regressions, regardless of whether query result feeding is [used](https://perf.rust-lang.org/compare.html?start=43a78029b4f4d92978b8fde0a677ea300b113c41&end=2eb5bcc5068b9d92f74bcb1797da664865d6981d&stat=instructions:u) or [not](https://perf.rust-lang.org/compare.html?start=2fce2290865f012391b8f3e581c3852a248031fa&end=2a33d6cd99481d1712037a79e7d66a8aefadbf72&stat=instructions:u).
2023-05-04Rollup merge of #110791 - compiler-errors:negative-bounds, r=oli-obkDylan DPC-0/+3
Implement negative bounds for internal testing purposes Implements partial support the `!` negative polarity on trait bounds. This is incomplete, but should allow us to at least be able to play with the feature. Not even gonna consider them as a public-facing feature, but I'm implementing them because would've been nice to have in UI tests, for example in #110671.
2023-05-03rustc_middle: Fix `opt_item_ident` for non-local def idsVadim Petrochenkov-4/+3
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-21/+18
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-05-02Implement negative boundsMichael Goulet-0/+3
2023-05-02Auto merge of #111028 - compiler-errors:attr-query-no-caching, r=cjgillotbors-10/+0
Make some simple queries no longer cache on disk I don't think we need to cache queries with really simple local providers, like loading hir and accessing an attr r? `@ghost`
2023-05-02correctly recurse when expanding anon constsBoxy-1/+2
2023-05-02Avoid ICEing miri on layout query cyclesOli Scherer-0/+14
2023-05-02resolve: One more attempt to simplify `module_children`Vadim Petrochenkov-17/+7
2023-05-01Box AssertKindBen Kimock-4/+4
2023-05-01Auto merge of #111026 - compiler-errors:only-typeck-root, r=cjgillotbors-1/+1
Only cache typeck results if it's the typeck root context: https://rust-lang.zulipchat.com/#narrow/stream/241847-t-compiler.2Fwg-incr-comp/topic/incr_comp_query_cache_promotion.20taking.20forever Basically, typeck children just copy the typeck results of their typeck root item, so caching their results means copying the same typeck results for each child item. r? `@ghost`
2023-05-01Make some simple queries no longer cache on diskMichael Goulet-10/+0
2023-05-01Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naberMatthias Krüger-0/+5
Tweak await span to not contain dot Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue. Fixes #110761 This mostly touches a bunch of tests to tighten their `await` span.
2023-04-30Only cache typeck results if it's the typeck rootMichael Goulet-1/+1
2023-04-30Bail out of MIR construction if `check_match` failsclubby789-1/+1
2023-04-30Use dynamic dispatch for queriesJohn Kåre Alsaker-29/+39
2023-04-29Auto merge of #109611 - Zoxc:query-engine-rem, r=cjgillotbors-79/+1194
Remove `QueryEngine` trait This removes the `QueryEngine` trait and `Queries` from `rustc_query_impl` and replaced them with function pointers and fields in `QuerySystem`. As a side effect `OnDiskCache` is moved back into `rustc_middle` and the `OnDiskCache` trait is also removed. This has a couple of benefits. - `TyCtxt` is used in the query system instead of the removed `QueryCtxt` which is larger. - Function pointers are more flexible to work with. A variant of https://github.com/rust-lang/rust/pull/107802 is included which avoids the double indirection. For https://github.com/rust-lang/rust/pull/108938 we can name entry point `__rust_end_short_backtrace` to avoid some overhead. For https://github.com/rust-lang/rust/pull/108062 it avoids the duplicate `QueryEngine` structs. - `QueryContext` now implements `DepContext` which avoids many `dep_context()` calls in `rustc_query_system`. - The `rustc_driver` size is reduced by 0.33%, hopefully that means some bootstrap improvements. - This avoids the unsafe code around the `QueryEngine` trait. r? `@cjgillot`
2023-04-29Expand comment on NonMutatingUseContext.Camille GILLOT-0/+3
2023-04-29Make PlaceMention a non-mutating use.Camille GILLOT-3/+3
2023-04-28Rollup merge of #110927 - nnethercote:Encoder-Decoder-cleanups, r=scottmcmMatthias Krüger-11/+11
Encoder/decoder cleanups Best reviewed one commit at a time. r? ``@scottmcm``
2023-04-28interpret: fail more gracefully on uninit unsized localsRalf Jung-0/+4
2023-04-28Remove some unnecessary derives.Nicholas Nethercote-11/+11
I was curious about how many `Encodable`/`Decodable` derives we have. Some grepping revealed that it's over 500 of each, but the number of `Encodable` ones was higher, which was weird. Most of the `Encodable`-only ones were in `hir.rs`. This commit removes them all, plus some other unnecessary derives in that file and others that I found via trial and error.
2023-04-27Rollup merge of #110838 - nnethercote:more-Folder-Visitable-cleanups, r=lcnrMatthias Krüger-52/+9
More `Typefoldable`/`TypeVisitable` cleanups r? ``@lcnr``
2023-04-27Don't call await a methodMichael Goulet-0/+5
2023-04-27Explicitly reject negative and reservation drop implsMichael Goulet-5/+5
2023-04-27rename `needs_subst` to `has_param`Boxy-5/+5
2023-04-27rename `needs_infer` to `has_infer`Boxy-6/+6
2023-04-26Rollup merge of #110835 - nnethercote:strict-region-folders-2, r=compiler-errorsMatthias Krüger-1/+7
Make some region folders a little stricter. Because certain regions cannot occur in them. r? ``@compiler-errors``
2023-04-26Don't return a `Binder` from `TraitRef::identity`Maybe Waffle-6/+2
2023-04-26Add new `ToPredicate` impls and `TraitRef` methods to remove some ↵Maybe Waffle-0/+30
`ty::Binber::dummy` calls
2023-04-26Switch `ty::TraitRef::from_lang_item` from using `TyCtxtAt` to `TyCtxt` and ↵Maybe Waffle-4/+4
a `Span`
2023-04-26Inline tweaksJohn Kåre Alsaker-4/+24
2023-04-26Add query accessor functionsJohn Kåre Alsaker-32/+55