about summary refs log tree commit diff
path: root/compiler/rustc_monomorphize/src
AgeCommit message (Collapse)AuthorLines
2024-10-25Revert "Emit error when calling/declaring functions with unavailable vectors."Rémy Rakic-134/+0
This reverts commit 5af56cac38fa48e4228e5e123d060e85eb1acbf7.
2024-10-25Auto merge of #127731 - veluca93:abi_checks, r=RalfJungbors-0/+134
Emit future-incompatibility lint when calling/declaring functions with vectors that require missing target feature On some architectures, vector types may have a different ABI depending on whether the relevant target features are enabled. (The ABI when the feature is disabled is often not specified, but LLVM implements some de-facto ABI.) As discussed in https://github.com/rust-lang/lang-team/issues/235, this turns out to very easily lead to unsound code. This commit makes it a post-monomorphization error to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant. This ensures that these functions are always called with a consistent ABI. See the [nomination comment](https://github.com/rust-lang/rust/pull/127731#issuecomment-2288558187) for more discussion. r? RalfJung Part of https://github.com/rust-lang/rust/issues/116558
2024-10-25Emit error when calling/declaring functions with unavailable vectors.Luca Versari-0/+134
On some architectures, vector types may have a different ABI when relevant target features are enabled. As discussed in https://github.com/rust-lang/lang-team/issues/235, this turns out to very easily lead to unsound code. This commit makes it an error to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant.
2024-10-24Remove associated type based effects logicMichael Goulet-1/+0
2024-10-14Add fast-path when computing the default visibilityUrgau-0/+7
2024-10-04Use wide pointers consistenly across the compilerUrgau-4/+4
2024-10-01Replace -Z default-hidden-visibility with -Z default-visibilityDavid Lattimore-19/+15
MCP: https://github.com/rust-lang/compiler-team/issues/782 Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2024-09-27Rollup merge of #130826 - fmease:compiler-mv-obj-safe-dyn-compat, ↵Matthias Krüger-1/+1
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-25Compiler: Rename "object safe" to "dyn compatible"León Orell Valerian Liehr-1/+1
2024-09-25Auto merge of #130803 - cuviper:file-buffered, r=joshtriplettbors-3/+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-1/+1
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-3/+3
2024-09-24be even more precise about "cast" vs "coercion"Lukas Markeffsky-4/+4
2024-09-24unify dyn* coercions with other pointer coercionsLukas Markeffsky-3/+3
2024-09-24Separate collection of crate-local inherent impls from error reportingMichael Goulet-1/+1
2024-09-23Check vtable projections for validity in miriMichael Goulet-2/+2
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-16/+19
2024-09-12Rollup merge of #130235 - compiler-errors:nested-if, r=michaelwoeristerStuart Cook-4/+2
Simplify some nested `if` statements Applies some but not all instances of `clippy::collapsible_if`. Some ended up looking worse afterwards, though, so I left those out. Also applies instances of `clippy::collapsible_else_if` Review with whitespace disabled please.
2024-09-11Simplify some nested if statementsMichael Goulet-4/+2
2024-09-09Remove needless returns detected by clippy in the compilerEduardo Sánchez Muñoz-1/+1
2024-09-06Make `Ty::boxed_ty` return an `Option`Pavel Grigorenko-2/+7
2024-09-02chore: Fix typos in 'compiler' (batch 2)Alexander Cyon-1/+1
2024-08-29Add `warn(unreachable_pub)` to `rustc_monomorphize`.Nicholas Nethercote-17/+22
2024-08-26Stop using a special inner body for the coroutine by-move body for async ↵Michael Goulet-4/+1
closures
2024-08-25Avoid taking reference of &TyKindMichael Goulet-2/+2
2024-08-21Use bool in favor of Option<()> for diagnosticsMichael Goulet-3/+3
2024-08-19Don't generate functions with the `rustc_intrinsic_must_be_overridden` attributeDianQK-1/+3
2024-08-15Rollup merge of #129067 - cuviper:append, r=wesleywiserMatthias Krüger-2/+2
Use `append` instead of `extend(drain(..))` The first commit adds `IndexVec::append` that forwards to `Vec::append`, and uses it in a couple places. The second commit updates `indexmap` for its new `IndexMap::append`, and also uses that in a couple places. These changes are similar to what [`clippy::extend_with_drain`](https://rust-lang.github.io/rust-clippy/master/index.html#/extend_with_drain) would suggest, just for other collection types.
2024-08-13Update `indexmap` and use `IndexMap::append`Josh Stone-2/+2
2024-08-13Use is_lang_item moreMichael Goulet-1/+3
2024-08-08Rename struct_tail_erasing_lifetimes to struct_tail_for_codegenMichael Goulet-2/+2
2024-08-01MIR required_consts, mentioned_items: ensure we do not forget to fill these ↵Ralf Jung-2/+2
lists
2024-07-29Reformat `use` declarations.Nicholas Nethercote-25/+21
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28stabilize `is_sorted`Slanterns-1/+0
2024-07-15Move compiler_builtin check to the use caseMohammad Omidvar-32/+0
2024-07-15Use the hook on tcx instead of the local functionMohammad Omidvar-26/+18
2024-07-15Introduce and provide a hook for `should_codegen_locally`Mohammad Omidvar-4/+18
2024-07-08Auto merge of #113128 - WaffleLapkin:become_trully_unuwuable, r=oli-obk,RalfJungbors-1/+2
Support tail calls in mir via `TerminatorKind::TailCall` This is one of the interesting bits in tail call implementation — MIR support. This adds a new `TerminatorKind` which represents a tail call: ```rust TailCall { func: Operand<'tcx>, args: Vec<Operand<'tcx>>, fn_span: Span, }, ``` *Structurally* this is very similar to a normal `Call` but is missing a few fields: - `destination` — tail calls don't write to destination, instead they pass caller's destination to the callee (such that eventual `return` will write to the caller of the function that used tail call) - `target` — similarly to `destination` tail calls pass the caller's return address to the callee, so there is nothing to do - `unwind` — I _think_ this is applicable too, although it's a bit confusing - `call_source` — `become` forbids operators and is not created as a lowering of something else; tail calls always come from HIR (at least for now) It might be helpful to read the interpreter implementation to understand what `TailCall` means exactly, although I've tried documenting it too. ----- There are a few `FIXME`-questions still left, ideally we'd be able to answer them during review ':) ----- r? `@oli-obk` cc `@scottmcm` `@DrMeepster` `@JakobDegen`
2024-07-07Support tail calls in mir via `TerminatorKind::TailCall`Maybe Waffle-1/+2
2024-07-04Auto merge of #123781 - RalfJung:miri-fn-identity, r=oli-obkbors-4/+4
Miri function identity hack: account for possible inlining Having a non-lifetime generic is not the only reason a function can be duplicated. Another possibility is that the function may be eligible for cross-crate inlining. So also take into account the inlining attribute in this Miri hack for function pointer identity. That said, `cross_crate_inlinable` will still sometimes return true even for `inline(never)` functions: - when they are `DefKind::Ctor(..) | DefKind::Closure` -- I assume those cannot be `InlineAttr::Never` anyway? - when `cross_crate_inline_threshold == InliningThreshold::Always` so maybe this is still not quite the right criterion to use for function pointer identity.
2024-07-02Fix spansMichael Goulet-17/+7
2024-07-02Re-implement a type-size based limitMichael Goulet-79/+3
2024-07-02Give Instance::expect_resolve a spanMichael Goulet-4/+16
2024-07-02Miri function identity hack: account for possible inliningRalf Jung-4/+4
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-2/+2
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-16Rename InstanceDef -> InstanceKindMichael Goulet-53/+53
2024-06-15Rollup merge of #126410 - RalfJung:smir-const-operand, r=oli-obkGuillaume Gomez-2/+2
smir: merge identical Constant and ConstOperand types The first commit renames the const operand visitor functions on regular MIR to match the type name, that was forgotten in the original rename. The second commit changes stable MIR, fixing https://github.com/rust-lang/project-stable-mir/issues/71. Previously there were two different smir types for the MIR type `ConstOperand`, one used in `Operand` and one in `VarDebugInfoContents`. Maybe we should have done this with https://github.com/rust-lang/rust/pull/125967, so there's only a single breaking change... but I saw that PR too late. Fixes https://github.com/rust-lang/project-stable-mir/issues/71
2024-06-14Use is_lang_item more aggressivelyMichael Goulet-2/+3
2024-06-14Add TyCtxt::is_lang_itemMichael Goulet-1/+1
2024-06-13MIR visitor: constant -> const_operandRalf Jung-2/+2