about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2024-10-03Handle `rustc_metadata` cases of `rustc::potential_query_instability` lintismailarilik-2/+2
2024-10-02Move in_trait into OpaqueTyOriginMichael Goulet-7/+1
2024-10-02Remove redundant in_trait from hir::TyKind::OpaqueDefMichael Goulet-1/+1
2024-10-02Auto merge of #130821 - lcnr:nalgebra-hang-2, r=compiler-errorsbors-3/+25
add caching to most type folders, rm region uniquification Fixes the new minimization of the hang in nalgebra and nalgebra itself :3 this is a bit iffy, especially the cache in `TypeRelating`. I believe all the caches are correct, but it definitely adds some non-local complexity in places. The first commit removes region uniquification, reintroducing the ICE from https://github.com/rust-lang/trait-system-refactor-initiative/issues/27. This does not affect coherence and I would like to fix this by introducing OR-region constraints r? `@compiler-errors`
2024-10-02Rollup merge of #131152 - fee1-dead-contrib:fxdiag, r=compiler-errorsMatthias Krüger-13/+35
Improve const traits diagnostics for new desugaring r? project-const-traits
2024-10-02Rollup merge of #131150 - bvanjoi:issue-128327, r=chenyukangMatthias Krüger-1/+1
only query `params_in_repr` if def kind is adt Fixes #128327 `params_in_repr` was only stored in `encode_info_for_adt`, so we only query it when the def kind belongs to them. https://github.com/rust-lang/rust/blob/9e3e5174462afaf6c3b9db9b35c6d1934521848a/compiler/rustc_metadata/src/rmeta/encoder.rs#L1566-L1567
2024-10-02Rollup merge of #131140 - ↵Matthias Krüger-6/+6
ismailarilik:handle-potential-query-instability-lint-for-rustc-hir-analysis, r=compiler-errors Handle `rustc_hir_analysis` cases of `potential_query_instability` lint This PR removes `#![allow(rustc::potential_query_instability)]` line from [`compiler/rustc_hir_analysis/src/lib.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_hir_analysis/src/lib.rs#L61) and converts `FxHash{Map,Set}` types into `FxIndex{Map,Set}` to suppress lint errors. A somewhat tracking issue: https://github.com/rust-lang/rust/issues/84447
2024-10-02reviewlcnr-8/+9
2024-10-02Improve const traits diagnostics for new desugaringDeadbeef-13/+35
2024-10-02only query `params_in_repr` if def kind is adtbohan-1/+1
2024-10-01Rollup merge of #130885 - RalfJung:interp-error-discard, r=oli-obkJubilee-34/+223
panic when an interpreter error gets unintentionally discarded One important invariant of Miri is that when an interpreter error is raised (*in particular* a UB error), those must not be discarded: it's not okay to just check `foo().is_err()` and then continue executing. This seems to catch new contributors by surprise fairly regularly, so this PR tries to make it so that *if* this ever happens, we get a panic rather than a silent missed UB bug. The interpreter error type now contains a "guard" that panics on drop, and that is explicitly passed to `mem::forget` when an error is deliberately discarded. Fixes https://github.com/rust-lang/miri/issues/3855
2024-10-02Handle `rustc-hir-analysis` cases of `rustc::potential_query_instability` lintismailarilik-6/+6
2024-10-01make InterpResult a dedicated type to avoid accidentally discarding the errorRalf Jung-89/+223
2024-10-01Remove unnamed field featureMichael Goulet-56/+4
2024-10-01add caches to multiple type folderslcnr-2/+23
2024-10-01Replace -Z default-hidden-visibility with -Z default-visibilityDavid Lattimore-0/+11
MCP: https://github.com/rust-lang/compiler-team/issues/782 Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2024-09-30panic when an interpreter error gets unintentionally discardedRalf Jung-9/+64
2024-09-30Validate ExistentialPredicate argsMichael Goulet-0/+20
2024-09-30Debug assert that unevaluated consts have the right substsMichael Goulet-0/+1
2024-09-30Auto merge of #129499 - fee1-dead-contrib:supereffects, r=compiler-errorsbors-0/+2
properly elaborate effects implied bounds for super traits Summary: This PR makes it so that we elaborate `<T as Tr>::Fx: EffectsCompat<somebool>` into `<T as SuperTr>::Fx: EffectsCompat<somebool>` when we know that `trait Tr: ~const SuperTr`. Some discussion at https://github.com/rust-lang/project-const-traits/issues/2. r? project-const-traits `@rust-lang/project-const-traits:` how do we feel about this approach?
2024-09-29Rollup merge of #130990 - RalfJung:mir-const-normalize, r=compiler-errorsMatthias Krüger-13/+3
try to get rid of mir::Const::normalize It was easy to make this compile, let's see if anything breaks... r? `@compiler-errors`
2024-09-29cleanup: don't clone types that are CopyMatthias Krüger-1/+1
2024-09-28tweak Const::identity_unevaluated name and docsRalf Jung-1/+3
2024-09-28try to get rid of mir::Const::normalizeRalf Jung-12/+0
2024-09-27Auto merge of #130946 - matthiaskrgr:rollup-ia4mf0y, r=matthiaskrgrbors-67/+73
Rollup of 6 pull requests Successful merges: - #130718 (Cleanup some known-bug issues) - #130730 (Reorganize Test Headers) - #130826 (Compiler: Rename "object safe" to "dyn compatible") - #130915 (fix typo in triagebot.toml) - #130926 (Update cc to 1.1.22 in library/) - #130932 (etc: Add sample rust-analyzer configs for eglot & helix) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-27Rollup merge of #130826 - fmease:compiler-mv-obj-safe-dyn-compat, ↵Matthias Krüger-67/+73
r=compiler-errors Compiler: Rename "object safe" to "dyn compatible" Completed T-lang FCP: https://github.com/rust-lang/lang-team/issues/286#issuecomment-2338905118. Tracking issue: https://github.com/rust-lang/rust/issues/130852 Excludes `compiler/rustc_codegen_cranelift` (to be filed separately). Includes Stable MIR. Regarding https://github.com/rust-lang/rust/labels/relnotes, I guess I will manually open a https://github.com/rust-lang/rust/labels/relnotes-tracking-issue since this change affects everything (compiler, library, tools, docs, books, everyday language). r? ghost
2024-09-27properly elaborate effects implied bounds for super traitsDeadbeef-0/+2
2024-09-26Use `&raw` in the compilerJosh Stone-7/+7
Like #130865 did for the standard library, we can use `&raw` in the compiler now that stage0 supports it. Also like the other issue, I did not make any doc or test changes at this time.
2024-09-25Compiler: Rename "object safe" to "dyn compatible"León Orell Valerian Liehr-67/+73
2024-09-25Auto merge of #130803 - cuviper:file-buffered, r=joshtriplettbors-2/+3
Add `File` constructors that return files wrapped with a buffer In addition to the light convenience, these are intended to raise visibility that buffering is something you should consider when opening a file, since unbuffered I/O is a common performance footgun to Rust newcomers. ACP: https://github.com/rust-lang/libs-team/issues/446 Tracking Issue: #130804
2024-09-24Rollup merge of #130764 - compiler-errors:inherent, r=estebankTrevor Gross-21/+19
Separate collection of crate-local inherent impls from error tracking #119895 changed the return type of the `crate_inherent_impls` query from `CrateInherentImpls` to `Result<CrateInherentImpls, ErrorGuaranteed>` to avoid needing to use the non-parallel-friendly `track_errors()` to track if an error was reporting from within the query... This was mostly fine until #121113, which stopped halting compilation when we hit an `Err(ErrorGuaranteed)` in the `crate_inherent_impls` query. Thus we proceed onwards to typeck, and since a return type of `Result<CrateInherentImpls, ErrorGuaranteed>` means that the query can *either* return one of "the list inherent impls" or "error has been reported", later on when we want to assemble method or associated item candidates for inherent impls, we were just treating any `Err(ErrorGuaranteed)` return value as if Rust had no inherent impls defined anywhere at all! This leads to basically every inherent method call failing with an error, lol, which was reported in #127798. This PR changes the `crate_inherent_impls` query to return `(CrateInherentImpls, Result<(), ErrorGuaranteed>)`, i.e. returning the inherent impls collected *and* whether an error was reported in the query itself. It firewalls the latter part of that query into a new `crate_inherent_impls_validity_check` just for the `ensure()` call. This fixes #127798.
2024-09-24Dogfood `feature(file_buffered)`Josh Stone-2/+3
2024-09-24update doc commentLukas Markeffsky-2/+4
2024-09-24be even more precise about "cast" vs "coercion"Lukas Markeffsky-6/+19
2024-09-24replace "cast" with "coercion" where applicableLukas Markeffsky-1/+3
This changes the remaining span for the cast, because the new `Cast` category has a higher priority (lower `Ord`) than the old `Coercion` category, so we no longer report the region error for the "unsizing" coercion from `*const Trait` to itself.
2024-09-24use more accurate spans for user type ascriptionsLukas Markeffsky-2/+5
2024-09-24unify dyn* coercions with other pointer coercionsLukas Markeffsky-12/+3
2024-09-24Separate collection of crate-local inherent impls from error reportingMichael Goulet-21/+19
2024-09-23Rollup merge of #130727 - compiler-errors:objects, r=RalfJungMichael Goulet-16/+19
Check vtable projections for validity in miri Currently, miri does not catch when we transmute `dyn Trait<Assoc = A>` to `dyn Trait<Assoc = B>`. This PR implements such a check, and fixes https://github.com/rust-lang/miri/issues/3905. To do this, we modify `GlobalAlloc::VTable` to contain the *whole* list of `PolyExistentialPredicate`, and then modify `check_vtable_for_type` to validate the `PolyExistentialProjection`s of the vtable, along with the principal trait that was already being validated. cc ``@RalfJung`` r? ``@lcnr`` or types I also tweaked the diagnostics a bit. --- **Open question:** We don't validate the auto traits. You can transmute `dyn Foo` into `dyn Foo + Send`. Should we check that? We currently have a test that *exercises* this as not being UB: https://github.com/rust-lang/rust/blob/6c6d210089e4589afee37271862b9f88ba1d7755/src/tools/miri/tests/pass/dyn-upcast.rs#L14-L20 I'm not actually sure if we ever decided that's actually UB or not 🤔 We could perhaps still check that the underlying type of the object (i.e. the concrete type that was unsized) implements the auto traits, to catch UB like: ```rust fn main() { let x: &dyn Trait = &std::ptr::null_mut::<()>(); let _: &(dyn Trait + Send) = std::mem::transmute(x); //~^ this vtable is not allocated for a type that is `Send`! } ```
2024-09-23Rollup merge of #130618 - m-ou-se:skip-query, r=compiler-errorsMichael Goulet-1/+4
Skip query in get_parent_item when possible. For HirIds with a non-zero item local id, `self.parent_owner_iter(hir_id).next()` just returns the same HirId with the item local id set to 0, but also does a query to retrieve the Node which is ignored here, which seems wasteful.
2024-09-23Check vtable projections for validity in miriMichael Goulet-16/+19
2024-09-23Allow reborrowing pinned self methodsEric Holk-0/+10
2024-09-23Update compiler/rustc_middle/src/hir/map/mod.rsMara Bos-1/+2
Co-authored-by: Michael Goulet <michael@errs.io>
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-207/+189
2024-09-21Rollup merge of #127766 - folkertdev:c-cmse-nonsecure-entry, r=jackh726Michael Goulet-3/+2
add `extern "C-cmse-nonsecure-entry" fn` tracking issue #75835 in https://github.com/rust-lang/rust/issues/75835#issuecomment-1183517255 it was decided that using an abi, rather than an attribute, was the right way to go for this feature. This PR adds that ABI and removes the `#[cmse_nonsecure_entry]` attribute. All relevant tests have been updated, some are now obsolete and have been removed. Error 0775 is no longer generated. It contains the list of targets that support the CMSE feature, and maybe we want to still use this? right now a generic "this abi is not supported on this platform" error is returned when this abi is used on an unsupported platform. On the other hand, users of this abi are likely to be experienced rust users, so maybe the generic error is good enough.
2024-09-21Auto merge of #127546 - workingjubilee:5-level-paging-exists, r=saethlinbors-2/+2
Correct outdated object size limit The comment here about 48 bit addresses being enough was written in 2016 but was made incorrect in 2019 by 5-level paging, and then persisted for another 5 years before being noticed and corrected. The bolding of the "exclusive" part is merely to call attention to something I missed when reading it and doublechecking the math. try-job: i686-msvc try-job: test-various
2024-09-21Auto merge of #129283 - saethlin:unreachable-allocas, r=scottmcmbors-25/+86
Don't alloca for unused locals We already have a concept of mono-unreachable basic blocks; this is primarily useful for ensuring that we do not compile code under an `if false`. But since we never gave locals the same analysis, a large local only used under an `if false` will still have stack space allocated for it. There are 3 places we traverse MIR during monomorphization: Inside the collector, `non_ssa_locals`, and the walk to generate code. Unfortunately, https://github.com/rust-lang/rust/pull/129283#issuecomment-2297925578 indicates that we cannot afford the expense of tracking reachable locals during the collector's traversal, so we do need at least two mono-reachable traversals. And of course caching is of no help here because the benchmarks that regress are incr-unchanged; they don't do any codegen. This fixes the second problem in https://github.com/rust-lang/rust/issues/129282, and brings us anther step toward `const if` at home.
2024-09-21remove `#[cmse_nonsecure_entry]`Folkert-3/+1
2024-09-21add `C-cmse-nonsecure-entry` ABIFolkert de Vries-0/+1
2024-09-21Compute reachable locals as part of non_ssa_localsBen Kimock-83/+41