about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2023-11-26Use helpersMichael Goulet-10/+10
2023-11-22Auto merge of #118120 - compiler-errors:closure-kind, r=lcnrbors-102/+53
Remove `PredicateKind::ClosureKind` We don't need the `ClosureKind` predicate kind -- instead, `Fn`-family trait goals are left as ambiguous, and we only need to make progress on `FnOnce` projection goals for inference purposes. This is similar to how we do confirmation of `Fn`-family trait and projection goals in the new trait solver, which also doesn't use the `ClosureKind` predicate. Some hacky logic is added in the second commit so that we can keep the error messages the same.
2023-11-22Auto merge of #118178 - compiler-errors:rollup-0i11w85, r=compiler-errorsbors-243/+666
Rollup of 6 pull requests Successful merges: - #118012 (Add support for global allocation in smir) - #118013 (Enable Rust to use the EHCont security feature of Windows) - #118100 (Enable profiler in dist-powerpc64-linux) - #118142 (Tighten up link attributes for llvm-wrapper bindings) - #118147 (Fix some unnecessary casts) - #118161 (Allow defining opaques in `check_coroutine_obligations`) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-22Rollup merge of #118161 - compiler-errors:coroutine-obligation-opaques, r=lcnrMichael Goulet-5/+36
Allow defining opaques in `check_coroutine_obligations` In the new trait solver, when an obligation stalls on an unresolved coroutine witness, we will stash away the *root* obligation, even if the stalled obligation is only a distant descendent of the root obligation, since the new solver is purely recursive. This means that we may need to reprocess alias-relate obligations (and others) which may define opaque types in the new solver. Currently, we use the coroutine's def id as the defining anchor in `check_coroutine_obligations`, which will allow defining no opaque types, resulting in errors like: ``` error[E0271]: type mismatch resolving `{coroutine@<source>:6:5: 6:17} <: impl Clone` --> <source>:6:5 | 6 | / move |_: ()| { 7 | | let () = yield (); 8 | | } | |_____^ types differ ``` So this PR fixes the defining anchor and does the same trick as `check_opaque_well_formed`, where we manually compare opaques that were defined against their hidden types to make sure they weren't defined differently when processing these stalled coroutine obligations. r? `@lcnr` cc `@cjgillot`
2023-11-22Rollup merge of #118147 - Nilstrieb:no-redundant-casts, r=WaffleLapkinMichael Goulet-30/+18
Fix some unnecessary casts `x clippy compiler -Aclippy::all -Wclippy::unnecessary_cast --fix` with some manual review to ensure every fix is correct.
2023-11-22Rollup merge of #118142 - saethlin:llvm-linkage, r=tmiaskoMichael Goulet-180/+206
Tighten up link attributes for llvm-wrapper bindings Fixes https://github.com/rust-lang/rust/issues/118084 by moving all of the declarations of symbols from `llvm_rust` into a separate extern block with `#[link(name = "llvm-wrapper", kind = "static")]`. This also renames `LLVMTimeTraceProfiler*` to `LLVMRustTimeTraceProfiler*` because those are functions from `llvm_rust`. r? tmiasko
2023-11-22Rollup merge of #118100 - ecnelises:ppc64_profiler, r=KobzolMichael Goulet-1/+1
Enable profiler in dist-powerpc64-linux
2023-11-22Rollup merge of #118013 - sivadeilra:user/ardavis/ehcont, r=wesleywiserMichael Goulet-1/+76
Enable Rust to use the EHCont security feature of Windows In the future Windows will enable Control-flow Enforcement Technology (CET aka Shadow Stacks). To protect the path where the context is updated during exception handling, the binary is required to enumerate valid unwind entrypoints in a dedicated section which is validated when the context is being set during exception handling. The required support for EHCONT Guard has already been merged into LLVM, long ago. This change simply adds the Rust codegen option to enable it. Relevant LLVM change: https://reviews.llvm.org/D40223 This also adds a new `ehcont-guard` option to the bootstrap config which enables EHCont Guard when building std. We at Microsoft have been using this feature for a significant period of time; we are confident that the LLVM feature, when enabled, generates well-formed code. We currently enable EHCONT using a codegen feature, but I'm certainly open to refactoring this to be a target feature instead, or to use any appropriate mechanism to enable it.
2023-11-22Rollup merge of #118012 - celinval:smir-alloc, r=ouz-aMichael Goulet-26/+329
Add support for global allocation in smir Add APIs to StableMir to support global allocation. Before this change, StableMir users had no API available to retrieve Allocation provenance information. They had to resource to internal APIs instead. One example is retrieving the Allocation of an `&str`. See test for an example on how the API can be used.
2023-11-22Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkinbors-347/+97
Stabilize RFC3324 dyn upcasting coercion This PR stabilize the `trait_upcasting` feature, aka https://github.com/rust-lang/rfcs/pull/3324. The FCP was completed here: https://github.com/rust-lang/rust/issues/65991#issuecomment-1817552398. ~~And also remove the `deref_into_dyn_supertrait` lint which is now handled by dyn upcasting coercion.~~ Heavily inspired by https://github.com/rust-lang/rust/pull/101718 Fixes https://github.com/rust-lang/rust/issues/65991
2023-11-22Auto merge of #112380 - jieyouxu:useless-bindings-lint, r=WaffleLapkinbors-2/+88
Add allow-by-default lint for unit bindings ### Example ```rust #![warn(unit_bindings)] macro_rules! owo { () => { let whats_this = (); } } fn main() { // No warning if user explicitly wrote `()` on either side. let expr = (); let () = expr; let _ = (); let _ = expr; //~ WARN binding has unit type let pat = expr; //~ WARN binding has unit type let _pat = expr; //~ WARN binding has unit type // No warning for let bindings with unit type in macro expansions. owo!(); // No warning if user explicitly annotates the unit type on the binding. let pat: () = expr; } ``` outputs ``` warning: binding has unit type `()` --> $DIR/unit-bindings.rs:17:5 | LL | let _ = expr; | ^^^^-^^^^^^^^ | | | this pattern is inferred to be the unit type `()` | note: the lint level is defined here --> $DIR/unit-bindings.rs:3:9 | LL | #![warn(unit_bindings)] | ^^^^^^^^^^^^^ warning: binding has unit type `()` --> $DIR/unit-bindings.rs:18:5 | LL | let pat = expr; | ^^^^---^^^^^^^^ | | | this pattern is inferred to be the unit type `()` warning: binding has unit type `()` --> $DIR/unit-bindings.rs:19:5 | LL | let _pat = expr; | ^^^^----^^^^^^^^ | | | this pattern is inferred to be the unit type `()` warning: 3 warnings emitted ``` This lint is not triggered if any of the following conditions are met: - The user explicitly annotates the binding with the `()` type. - The binding is from a macro expansion. - The user explicitly wrote `let () = init;` - The user explicitly wrote `let pat = ();`. This is allowed for local lifetimes. ### Known Issue It is known that this lint can trigger on some proc-macro generated code whose span returns false for `Span::from_expansion` because e.g. the proc-macro simply forwards user code spans, and otherwise don't have distinguishing syntax context compared to non-macro-generated code. For those kind of proc-macros, I believe the correct way to fix them is to instead emit identifers with span like `Span::mixed_site().located_at(user_span)`. Closes #71432.
2023-11-22Stabilize RFC3324 dyn upcasting coercionUrgau-347/+97
Aka trait_upcasting feature. And also adjust the `deref_into_dyn_supertrait` lint.
2023-11-22Auto merge of #118086 - nnethercote:queries-cleanups, r=bjorn3bors-59/+47
Queries cleanups r? `@bjorn3`
2023-11-22Auto merge of #118125 - nnethercote:custom_encodable, r=compiler-errorsbors-34/+83
Make some `newtype_index!` derived impls opt-in instead of opt-out Opt-in is the standard Rust way of doing things, and avoids some unnecessary dependencies on the `rustc_serialize` crate. r? `@lcnr`
2023-11-22Document `newtype_index` attributes.Nicholas Nethercote-2/+13
2023-11-22Replace `no_ord_impl` with `orderable`.Nicholas Nethercote-4/+43
Similar to the previous commit, this replaces `newtype_index`'s opt-out `no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-22Replace `custom_encodable` with `encodable`.Nicholas Nethercote-28/+27
By default, `newtype_index!` types get a default `Encodable`/`Decodable` impl. You can opt out of this with `custom_encodable`. Opting out is the opposite to how Rust normally works with autogenerated (derived) impls. This commit inverts the behaviour, replacing `custom_encodable` with `encodable` which opts into the default `Encodable`/`Decodable` impl. Only 23 of the 59 `newtype_index!` occurrences need `encodable`. Even better, there were eight crates with a dependency on `rustc_serialize` just from unused default `Encodable`/`Decodable` impls. This commit removes that dependency from those eight crates.
2023-11-22Auto merge of #118071 - Urgau:check-cfg-cargo-feature, r=petrochenkovbors-19/+80
Remove `feature` from the list of well known check-cfg name This PR removes `feature` from the list of well known check-cfg. This is done for multiple reasons: - Cargo is the source of truth, rustc shouldn't have any knowledge of it - It creates a conflict between Cargo and rustc when there are no features defined. In this case Cargo won't pass any `--check-cfg` for `feature` since no feature will ever be passed, but rustc by having in it's list adds a implicit `cfg(feature, values(any()))` which is completely wrong. Having any cfg `feature` is unexpected not allow any `feature` value. While doing this, I took the opportunity to specialise the diagnostic a bit for the case above. r? `@petrochenkov`
2023-11-22Auto merge of #117928 - nnethercote:rustc_ast_pretty, r=fee1-deadbors-240/+183
`rustc_ast_pretty` cleanups Some improvements I found while looking at this code. r? `@fee1-dead`
2023-11-22Allow defining opaques in check_coroutine_obligationsMichael Goulet-5/+36
2023-11-21Add allocation test and a bit more documentationCelina G. Val-0/+126
2023-11-21Add support to get virtual table allocationCelina G. Val-3/+54
2023-11-21Add support to global allocation to stable-mirCelina G. Val-24/+150
2023-11-22Auto merge of #117582 - compiler-errors:uplift-canonical-var, r=jackh726bors-165/+322
Uplift `CanonicalVarInfo` and friends into `rustc_type_ir` Depends on #117580 and #117578 Uplift `CanonicalVarInfo` and friends into `rustc_type_ir` so they can be consumed by an interner-agnostic `Canonicalizer` implementation for the new trait solver ❤️ r? `@ghost`
2023-11-22Merge `Queries::{ongoing_codegen,linker}`.Nicholas Nethercote-21/+15
There is no real need for them to be separate.
2023-11-22Make `Compiler::{sess,codegen_backend}` public.Nicholas Nethercote-41/+28
And remove the relevant getters on `Compiler` and `Queries`.
2023-11-22Add two useful comments.Nicholas Nethercote-0/+4
2023-11-22Add comments about a timer.Nicholas Nethercote-0/+3
2023-11-22Auto merge of #118152 - matthiaskrgr:rollup-bqcck4w, r=matthiaskrgrbors-115/+286
Rollup of 5 pull requests Successful merges: - #117972 (Add VarDebugInfo to Stable MIR) - #118109 (rustdoc-search: simplify `checkPath` and `sortResults`) - #118110 (Document `DefiningAnchor` a bit more) - #118112 (Don't ICE when ambiguity is found when selecting `Index` implementation in typeck) - #118135 (Remove quotation from filename in stable_mir) Failed merges: - #118012 (Add support for global allocation in smir) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-22Remove outdated reference to compiler plugins.Nicholas Nethercote-1/+1
2023-11-22Add some comments.Nicholas Nethercote-0/+8
2023-11-21Rollup merge of #118135 - ouz-a:fix_stable_span, r=celinvalMatthias Krüger-10/+8
Remove quotation from filename in stable_mir Previously we had quotation marks in filenames which is obviously wrong this fixes that. r? ```@celinval```
2023-11-21Rollup merge of #118112 - compiler-errors:index-ambiguity-ice, r=aliemjayMatthias Krüger-4/+56
Don't ICE when ambiguity is found when selecting `Index` implementation in typeck Fixes #118111 The problem here is when we're manually "selecting" an impl for `base_ty: Index<?0>`, we don't consider placeholder region errors (leak check) or ambiguous predicates. Those can lead to us not actually emitting any fulfillment errors on line 3131.
2023-11-21Rollup merge of #118110 - compiler-errors:defining-anchor, r=aliemjayMatthias Krüger-4/+17
Document `DefiningAnchor` a bit more r? types
2023-11-21Rollup merge of #118109 - notriddle:notriddle/search-cleanup-2, r=GuillaumeGomezMatthias Krüger-92/+77
rustdoc-search: simplify `checkPath` and `sortResults` These two commits reduce the amount of code in search.js with no noticeable change in performance. https://notriddle.com/rustdoc-html-demo-5/profile-5/index.html
2023-11-21Rollup merge of #117972 - ouz-a:stable_debuginfo, r=celinvalMatthias Krüger-5/+128
Add VarDebugInfo to Stable MIR Previously we omitted `VarDebugInfo` because we didn't have `Projection` now that https://github.com/rust-lang/rust/pull/117517 is merged it's possible to add `VarDebugInfo` information in `Body`. This PR adds stable version of the `VarDebugInfo` to `Body` r? ```@celinval```
2023-11-21update -Cehcont-guard and commentArlie Davis-3/+7
2023-11-21Auto merge of #118143 - Nilstrieb:only-borrow-what-you-need, r=compiler-errorsbors-1174/+1101
Fix `clippy::needless_borrow` in the compiler `x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now. r? `@compiler-errors` you told me you want to review this I will do a self review first (which, for this, is easiest on GitHub once the PR is open) - did it
2023-11-21convert ehcont-guard to an unstable optionArlie Davis-5/+6
2023-11-21x.py fmtArlie Davis-5/+1
2023-11-21Add support for generating the EHCont sectionArlie Davis-2/+76
In the future Windows will enable Control-flow Enforcement Technology (CET aka Shadow Stacks). To protect the path where the context is updated during exception handling, the binary is required to enumerate valid unwind entrypoints in a dedicated section which is validated when the context is being set during exception handling. The required support for EHCONT has already been merged into LLVM, long ago. This change adds the Rust codegen option to enable it. Reference: * https://reviews.llvm.org/D40223 This also adds a new `ehcont-guard` option to the bootstrap config which enables EHCont Guard when building std.
2023-11-22Factor out common code in `PrintState`.Nicholas Nethercote-8/+11
The AST and HIR versions of `State::print_ident` are textually identical, but the types differ slightly. This commit factors out the common code they both have by replacing `print_ident` with `ann_post`, which is a smaller function that still captures the type difference.
2023-11-22Streamline `PrintState`.Nicholas Nethercote-99/+83
`PrintState` is a trait containing code that can be used by both AST and HIR pretty-printing. But several of its methods are only used by AST printing. This commit moves those methods out of the trait and into the AST `State` impl, so they are not exposed unnecessarily. This commit also removes four unused methods: `param_to_string`, `foreign_item_to_string`, `assoc_item_to_string`, and `print_inner_attributes_inline`.
2023-11-22Remove unused `PrintState::generic_params_to_string` method.Nicholas Nethercote-4/+0
2023-11-22Remove or downgrade unnecessary `pub` visibility markers.Nicholas Nethercote-50/+44
2023-11-22Remove `NO_ANN`.Nicholas Nethercote-4/+4
This makes `rustc_hir_pretty` more like `rustc_ast_pretty`.
2023-11-22Remove `IterDelimited`.Nicholas Nethercote-52/+13
itertools has `with_position` which does the same thing.
2023-11-22Update itertools to 0.11.Nicholas Nethercote-18/+18
Because the API for `with_position` improved in 0.11 and I want to use it.
2023-11-22Remove unnecessary derives.Nicholas Nethercote-2/+1
2023-11-22Remove unneeded features.Nicholas Nethercote-2/+0