about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2023-11-08Rollup merge of #117625 - nnethercote:clippy-perf, r=cuviperMatthias Krüger-1/+1
Fix some clippy perf lints `@matthiaskrgr` gave me the output of a clippy run with perf lints enabled. This PR fixes ones that I thought were worth fixing. r? `@cuviper`
2023-11-08Rollup merge of #116399 - WaffleLapkin:erase_small_things, r=cjgillotMatthias Krüger-6/+16
Small changes w/ `query::Erase<_>` r? `@cjgillot` cc `@Zoxc`
2023-11-08Rollup merge of #113925 - clubby789:const-ctor-repeat, r=estebankMatthias Krüger-3/+23
Improve diagnostic for const ctors in array repeat expressions Fixes #113912
2023-11-08rustc: minor changes suggested by clippy perf lints.Nicholas Nethercote-1/+1
2023-11-07Add an explanation for `transmute_unchecked`Maybe Waffle-0/+9
2023-11-07Auto merge of #117229 - matthewjasper:thir-unsafeck-fixes, r=cjgillotbors-1/+2
Thir unsafeck fixes - Recognise thread local statics in THIR unsafeck - Add suggestion for unsafe_op_in_unsafe_fn - Fix unsafe checking of let expressions
2023-11-06Visit patterns in THIR let expressionsMatthew Jasper-1/+2
This fixes some THIR unsafety checking errors not being emitted for let expressions in these situations.
2023-11-06Auto merge of #117603 - HKalbasi:make-feature-additive, r=Nilstriebbors-1/+1
Make the randomize feature of rustc_abi additive The goal here is to make rust-analyzer able to build with the `rustc_private` versions of the rustc crates it depends on. See #116847
2023-11-05Make the randomize feature of rustc_abi additivehkalbasi-1/+1
2023-11-05Auto merge of #117589 - compiler-errors:global-vars-bug, r=jackh726bors-32/+12
Make sure that predicates with unmentioned bound vars are still considered global in the old solver In the old solver, we consider predicates with late-bound vars to not be "global": https://github.com/rust-lang/rust/blob/9c8a2694fadf3900c4d7880f6357cee60e9aa39b/compiler/rustc_trait_selection/src/traits/select/mod.rs#L1840-L1844 The implementation of `has_late_bound_vars` was modified in #115834 so that we'd properly anonymize binders that had late-bound vars but didn't reference them. This fixed an ICE. However, this also led to a behavioral change in https://github.com/rust-lang/rust/issues/117056#issuecomment-1775014545 for a couple of crates, which now consider `for<'a> GL33: Shader` (note the binder var that is *not* used in the predicate) to not be "global". This forces associated types to not be normalizable due to the old trait solver being dumb. This PR distinguishes types which *reference* late-bound vars and binders which *have* late-bound vars. The latter is represented with the new type flag `TypeFlags::HAS_BINDER_VARS`, which is used when we only care about knowing whether binders have vars in their bound var list (even if they're not used, like for binder anonymization). This should fix (after beta backport) the `luminance-gl` and `luminance-webgl` crates in #117056. r? types **(priority is kinda high on a review here given beta becomes stable on November 16.)**
2023-11-04Rollup merge of #117583 - compiler-errors:placeholderconst-lifetime, r=cjgillotMatthias Krüger-4/+4
Remove `'tcx` lifetime on `PlaceholderConst` The `'tcx` lifetime is not needed for anything, so this is a continuation of #117139.
2023-11-04Make sure that predicates with unmentioned bound vars are still considered ↵Michael Goulet-32/+12
global in the old solver
2023-11-04No lifetime on PlaceholderConstMichael Goulet-4/+4
2023-11-04Remove support for compiler plugins.Nicholas Nethercote-2/+1
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes #29597.
2023-11-03Auto merge of #117507 - nnethercote:rustc_span, r=Nilstriebbors-5/+4
`rustc_span` cleanups Just some things I found while looking over this crate. r? `@oli-obk`
2023-11-03Rollup merge of #117505 - estebank:issue-117501, r=TaKO8KiMatthias Krüger-0/+2
Fix incorrect trait bound restriction suggestion Suggest ``` error[E0308]: mismatched types --> $DIR/restrict-assoc-type-of-generic-bound.rs:9:12 | LL | pub fn foo<A: MyTrait, B>(a: A) -> B { | - - expected `B` because of return type | | | expected this type parameter LL | return a.bar(); | ^^^^^^^ expected type parameter `B`, found associated type | = note: expected type parameter `B` found associated type `<A as MyTrait>::T` help: consider further restricting this bound | LL | pub fn foo<A: MyTrait<T = B>, B>(a: A) -> B { | +++++++ ``` instead of ``` error[E0308]: mismatched types --> $DIR/restrict-assoc-type-of-generic-bound.rs:9:12 | LL | pub fn foo<A: MyTrait, B>(a: A) -> B { | - - expected `B` because of return type | | | expected this type parameter LL | return a.bar(); | ^^^^^^^ expected type parameter `B`, found associated type | = note: expected type parameter `B` found associated type `<A as MyTrait>::T` help: consider further restricting this bound | LL | pub fn foo<A: MyTrait + <T = B>, B>(a: A) -> B { | +++++++++ ``` Fix #117501.
2023-11-02Auto merge of #117134 - lcnr:dropck_outlives-coroutine, r=compiler-errorsbors-4/+6
dropck_outlives check whether generator witness needs_drop see https://rust-lang.zulipchat.com/#narrow/stream/326866-t-types.2Fnominated/topic/.23116242.3A.20Code.20no.20longer.20compiles.20after.20-Zdrop-tracking-mir.20.E2.80.A6/near/398311627 for an explanation. Fixes #116242 (or well, the repro by `@jamuraa` in https://github.com/rust-lang/rust/issues/116242#issuecomment-1739802047). I did not add a regression test as it depends on other crates. We do have 1 test going from fail to pass, showing the intended behavior. r? types
2023-11-02Fix incorrect trait bound restriction suggestionEsteban Küber-0/+2
Suggest ``` error[E0308]: mismatched types --> $DIR/restrict-assoc-type-of-generic-bound.rs:9:12 | LL | pub fn foo<A: MyTrait, B>(a: A) -> B { | - - expected `B` because of return type | | | expected this type parameter LL | return a.bar(); | ^^^^^^^ expected type parameter `B`, found associated type | = note: expected type parameter `B` found associated type `<A as MyTrait>::T` help: consider further restricting this bound | LL | pub fn foo<A: MyTrait<T = B>, B>(a: A) -> B { | +++++++ ``` instead of ``` error[E0308]: mismatched types --> $DIR/restrict-assoc-type-of-generic-bound.rs:9:12 | LL | pub fn foo<A: MyTrait, B>(a: A) -> B { | - - expected `B` because of return type | | | expected this type parameter LL | return a.bar(); | ^^^^^^^ expected type parameter `B`, found associated type | = note: expected type parameter `B` found associated type `<A as MyTrait>::T` help: consider further restricting this bound | LL | pub fn foo<A: MyTrait + <T = B>, B>(a: A) -> B { | +++++++++ ``` Fix #117501.
2023-11-02only erase param env regions where neededlcnr-1/+1
2023-11-02dropck_outlives check generator witness needs_droplcnr-4/+6
2023-11-02Rollup merge of #117394 - lcnr:proof-tree-cache4, r=compiler-errorsMatthias Krüger-25/+42
use global cache when computing proof trees we're writing the solver while relying on the existence of the global cache to avoid exponential blowup. By disabling the global cache when building proof trees, it is easy to get hangs, e.g. when computing intercrate ambiguity causes. Removes the unstable `-Zdump_solver_proof_tree_use_cache` option, as we now always return a full proof tree. r? `@compiler-errors`
2023-11-02use global cache when computing proof treeslcnr-25/+42
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-5/+4
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-11-01Rename hook.Camille GILLOT-2/+2
2023-11-01Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiserbors-7/+34
Support enum variants in offset_of! This MR implements support for navigating through enum variants in `offset_of!`, placing the enum variant name in the second argument to `offset_of!`. The RFC placed it in the first argument, but I think it interacts better with nested field access in the second, as you can then write things like ```rust offset_of!(Type, field.Variant.field) ``` Alternatively, a syntactic distinction could be made between variants and fields (e.g. `field::Variant.field`) but I'm not convinced this would be helpful. [RFC 3308 # Enum Support](https://rust-lang.github.io/rfcs/3308-offset_of.html#enum-support-offset_ofsomeenumstructvariant-field_on_variant) Tracking Issue #106655.
2023-11-01Auto merge of #116692 - Nadrieril:half-open-ranges, r=cjgillotbors-45/+282
Match usize/isize exhaustively with half-open ranges The long-awaited finale to the saga of [exhaustiveness checking for integers](https://github.com/rust-lang/rust/pull/50912)! ```rust match 0usize { 0.. => {} // exhaustive! } match 0usize { 0..usize::MAX => {} // helpful error message! } ``` Features: - Half-open ranges behave as expected for `usize`/`isize`; - Trying to use `0..usize::MAX` will tell you that `usize::MAX..` is missing and explain why. No more unhelpful "`_` is missing"; - Everything else stays the same. This should unblock https://github.com/rust-lang/rust/issues/37854. Review-wise: - I recommend looking commit-by-commit; - This regresses perf because of the added complexity in `IntRange`; hopefully not too much; - I measured each `#[inline]`, they all help a bit with the perf regression (tho I don't get why); - I did not touch MIR building; I expect there's an easy PR there that would skip unnecessary comparisons when the range is half-open.
2023-10-31Update MIR tests for offset_ofGeorge Bateman-1/+0
2023-10-31Enums in offset_of: update based on est31, scottmcm & llogiq reviewGeorge Bateman-18/+22
2023-10-31Support enum variants in offset_of!George Bateman-10/+34
2023-10-31Turn const_caller_location from a query to a hookOli Scherer-6/+5
2023-10-31Auto merge of #117444 - matthiaskrgr:rollup-43s0spc, r=matthiaskrgrbors-2/+4
Rollup of 5 pull requests Successful merges: - #116267 (Some codegen cleanups around SIMD checks) - #116712 (When encountering unclosed delimiters during lexing, check for diff markers) - #117416 (Also consider TAIT to be uncomputable if the MIR body is tainted) - #117421 (coverage: Replace impossible `coverage::Error` with assertions) - #117438 (Do not ICE on constant evaluation failure in GVN.) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-31Rollup merge of #117438 - cjgillot:deterministic-error, r=oli-obkMatthias Krüger-2/+4
Do not ICE on constant evaluation failure in GVN. Fixes https://github.com/rust-lang/rust/issues/117362
2023-10-31Do not ICE on constant evaluation failure in GVN.Camille GILLOT-2/+4
2023-10-31Auto merge of #117377 - dtolnay:deprecatedsince, r=cjgillotbors-52/+20
Store #[deprecated] attribute's `since` value in parsed form This PR implements the first followup bullet listed in https://github.com/rust-lang/rust/pull/117148#issue-1960240108. We centralize error handling to the attribute parsing code in `compiler/rustc_attr/src/builtin.rs`, and thereby remove some awkward error codepaths from later phases of compilation that had to make sense of these #\[deprecated\] attributes, namely `compiler/rustc_passes/src/stability.rs` and `compiler/rustc_middle/src/middle/stability.rs`.
2023-10-30Add method for checking if deprecation is a rustc versionDavid Tolnay-1/+1
2023-10-30Descriptive variant name deprecation versions outside the standard libraryDavid Tolnay-1/+3
2023-10-30Some more coroutine renamingsMichael Goulet-1/+1
2023-10-30Represent absence of 'since' attribute as a variant of DeprecatedSinceDavid Tolnay-5/+5
2023-10-30Add a DeprecatedSince::Err variant for versions that fail to parseDavid Tolnay-9/+10
2023-10-30Auto merge of #117415 - matthiaskrgr:rollup-jr2p1t2, r=matthiaskrgrbors-2/+3
Rollup of 7 pull requests Successful merges: - #116862 (Detect when trait is implemented for type and suggest importing it) - #117389 (Some diagnostics improvements of `gen` blocks) - #117396 (Don't treat closures/coroutine types as part of the public API) - #117398 (Correctly handle nested or-patterns in exhaustiveness) - #117403 (Poison check_well_formed if method receivers are invalid to prevent typeck from running on it) - #117411 (Improve some diagnostics around `?Trait` bounds) - #117414 (Don't normalize to an un-revealed opaque when we hit the recursion limit) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-30Rollup merge of #117389 - oli-obk:gen_fn, r=compiler-errorsMatthias Krüger-2/+3
Some diagnostics improvements of `gen` blocks These are leftovers from https://github.com/rust-lang/rust/pull/116447
2023-10-30Rollup merge of #117357 - tmiasko:terminate, r=wesleywiserGuillaume Gomez-1/+1
Rename a few remaining references to abort terminator Follow up to e3f2edc75bf2becb57d7d770bba20606da1c4224
2023-10-30Rollup merge of #117317 - RalfJung:track-caller, r=oli-obkGuillaume Gomez-0/+52
share some track_caller logic between interpret and codegen Also move the code that implements the track_caller intrinsics out of the core interpreter engine -- it's just a helper creating a const-allocation, doesn't need to be part of the interpreter core.
2023-10-30Rollup merge of #117068 - nnethercote:clean-up-Cargo-toml, r=wesleywiserGuillaume Gomez-7/+8
Clean up `compiler/rustc*/Cargo.toml` Mostly by sorting dependencies, plus some other minor things. r? ``@wesleywiser``
2023-10-30Move deprecation_in_effect to inherent method on DeprecationDavid Tolnay-16/+3
2023-10-30Add a custom panic message for resuming `gen` blocks after they panickedOli Scherer-2/+3
2023-10-29Store version of `deprecated` attribute in structured formDavid Tolnay-34/+12
2023-10-30Clean up `rustc_*/Cargo.toml`.Nicholas Nethercote-7/+8
- Sort dependencies and features sections. - Add `tidy` markers to the sorted sections so they stay sorted. - Remove empty `[lib`] sections. - Remove "See more keys..." comments. Excluded files: - rustc_codegen_{cranelift,gcc}, because they're external. - rustc_lexer, because it has external use. - stable_mir, because it has external use.
2023-10-29Ignore RPIT duplicated lifetimes in opaque_types_defined_byMichael Goulet-1/+1
2023-10-29Auto merge of #116270 - cjgillot:gvn-aggregate, r=oli-obk,RalfJungbors-0/+50
See through aggregates in GVN This PR is extracted from https://github.com/rust-lang/rust/pull/111344 The first 2 commit are cleanups to avoid repeated work. I propose to stop removing useless assignments as part of this pass, and let a later `SimplifyLocals` do it. This makes tests easier to read (among others). The next 3 commits add a constant folding mechanism to the GVN pass, presented in https://github.com/rust-lang/rust/pull/116012. ~This pass is designed to only use global allocations, to avoid any risk of accidental modification of the stored state.~ The following commits implement opportunistic simplifications, in particular: - projections of aggregates: `MyStruct { x: a }.x` gets replaced by `a`, works with enums too; - projections of arrays: `[a, b][0]` becomes `a`; - projections of repeat expressions: `[a; N][x]` becomes `a`; - transform arrays of equal operands into a repeat rvalue. Fixes https://github.com/rust-lang/miri/issues/3090 r? `@oli-obk`