about summary refs log tree commit diff
path: root/compiler/rustc_monomorphize
AgeCommit message (Collapse)AuthorLines
2023-12-19Add `level` arg to `into_diagnostic`.Nicholas Nethercote-8/+5
And make all hand-written `IntoDiagnostic` impls generic, by using `DiagnosticBuilder::new(dcx, level, ...)` instead of e.g. `dcx.struct_err(...)`. This means the `create_*` functions are the source of the error level. This change will let us remove `struct_diagnostic`. Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`, it's necessary to pass diagnostics tests now that it's used in `into_diagnostic` functions.
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-2/+2
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-2/+2
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-1/+1
2023-12-15Auto merge of #118770 - saethlin:fix-inline-never-uses, r=nnethercotebors-3/+25
Fix cases where std accidentally relied on inline(never) This PR increases the power of `-Zcross-crate-inline-threshold=always` so that it applies through `#[inline(never)]`. Note that though this is called "cross-crate-inlining" in this case especially it is _just_ lazy per-CGU codegen. The MIR inliner and LLVM still respect the attribute as much as they ever have. Trying to bootstrap with the new `-Zcross-crate-inline-threshold=always` change revealed two bugs: We have special intrinsics `assert_inhabited`, `assert_zero_valid`, and `assert_mem_uniniitalized_valid` which codegen backends will lower to nothing or a call to `panic_nounwind`. Since we may not have any call to `panic_nounwind` in MIR but emit one anyway, we need to specially tell `MirUsedCollector` about this situation. `#[lang = "start"]` is special-cased already so that `MirUsedCollector` will collect it, but then when we make it cross-crate-inlinable it is only assigned to a CGU based on whether `MirUsedCollector` saw a call to it, which of course we didn't. --- I started looking into this because https://github.com/rust-lang/rust/pull/118683 revealed a case where we were accidentally relying on a function being `#[inline(never)]`, and cranking up cross-crate-inlinability seems like a way to find other situations like that. r? `@nnethercote` because I don't like what I'm doing to the CGU partitioning code here but I can't come up with something much better
2023-12-14Fix cases where std accidentally relied on inline(never)Ben Kimock-3/+25
2023-12-13Add unstable `-Zdefault-hidden-visibility` cmdline flag for `rustc`.Lukasz Anforowicz-1/+1
The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/656
2023-12-08Rollup merge of #118693 - saethlin:alignment-check-symbol-reachable, r=bjorn3Matthias Krüger-0/+3
Tell MirUsedCollector that the pointer alignment checks calls its panic symbol Fixes https://github.com/rust-lang/rust/pull/118683 (not an issue, but that PR is a basically a bug report) When we had `panic_immediate_abort` start adding `#[inline]` to this panic function, builds started breaking because we failed to write up the MIR assert terminator to the correct panic shim. Things happened to work before by pure luck because without this feature enabled, the function we're inserting calls to is `#[inline(never)]` so we always generated code for it. r? bjorn3
2023-12-07ctfe interpreter: extend provenance so that it can track whether a pointer ↵Ralf Jung-7/+7
is immutable
2023-12-06Tell MirUsedCollector that the pointer alignment checks calls its panic symbolBen Kimock-0/+3
2023-11-26merge `DefKind::Coroutine` into `DefKind::Closure`bohan-2/+2
2023-11-26Use `rustc_fluent_macro::fluent_messages!` directly.Nicholas Nethercote-2/+1
Currently we always do this: ``` use rustc_fluent_macro::fluent_messages; ... fluent_messages! { "./example.ftl" } ``` But there is no need, we can just do this everywhere: ``` rustc_fluent_macro::fluent_messages! { "./example.ftl" } ``` which is shorter.
2023-11-26Avoid need for `{D,Subd}iagnosticMessage` imports.Nicholas Nethercote-1/+0
The `fluent_messages!` macro produces uses of `crate::{D,Subd}iagnosticMessage`, which means that every crate using the macro must have this import: ``` use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; ``` This commit changes the macro to instead use `rustc_errors::{D,Subd}iagnosticMessage`, which avoids the need for the imports.
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-10/+10
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-1/+2
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-10-30Clean up `rustc_*/Cargo.toml`.Nicholas Nethercote-6/+6
- 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-21coverage: Change query `codegened_and_inlined_items` to a plain functionZalathar-31/+0
This query has a name that sounds general-purpose, but in fact it has coverage-specific semantics, and (fortunately) is only used by coverage code. Because it is only ever called once (from one designated CGU), it doesn't need to be a query, and we can change it to a regular function instead.
2023-10-20s/generator/coroutine/Oli Scherer-4/+4
2023-10-20s/Generator/Coroutine/Oli Scherer-4/+4
2023-10-18Remove `UnknownPartitionStrategy` error.Nicholas Nethercote-6/+0
This became unused in #112053, when `-Zcgu-partitioning-strategy` was removed.
2023-10-18Streamline `build_skip_move_check_fns`.Nicholas Nethercote-31/+10
It's just a `filter_map(...).collect()`.
2023-10-18Inline and remove `item_requires_monomorphization`.Nicholas Nethercote-7/+2
It's very simple and has a single call site.
2023-10-18Remove empty `MirUsedCollector::visit_local`.Nicholas Nethercote-8/+0
It has not effect, because the default `visit_local` in `mir::Visitor` is already empty.
2023-10-18Remove unneeded dependencies from `rustc_monomorphize`.Nicholas Nethercote-1/+0
2023-10-07rustc_monomorphize: Introduce check_fn_args_move_size()Martin Nordholts-56/+76
So that we later can improve the accuracy of diagnostics.
2023-10-07rustc_monomorphize: Move limit check into check_move_size()Martin Nordholts-5/+10
And rename to check_operand_move_size(). Later we will introduce check_fn_args_move_size().
2023-10-06Rollup merge of #116277 - RalfJung:post-mono, r=oli-obkJubilee-0/+2
dont call mir.post_mono_checks in codegen It seems like all tests are still passing when I remove this... let's see what CI says.
2023-10-06add some comments explaining how the required_consts stuff fits togetherRalf Jung-0/+2
2023-10-03Rollup merge of #115863 - chenyukang:yukang-add-message-tidy-check, r=davidtwcoMatthias Krüger-2/+0
Add check_unused_messages in tidy From https://github.com/rust-lang/rust/pull/115728#issuecomment-1715490553 The check is not 100% accurate, I guess it's enough for now.
2023-09-27Auto merge of #116163 - compiler-errors:lazyness, r=oli-obkbors-1/+1
Don't store lazyness in `DefKind::TyAlias` 1. Don't store lazyness of a type alias in its `DefKind`, but instead via a query. 2. This allows us to treat type aliases as lazy if `#[feature(lazy_type_alias)]` *OR* if the alias contains a TAIT, rather than having checks for both in separate parts of the codebase. r? `@oli-obk` cc `@fmease`
2023-09-26subst -> instantiatelcnr-4/+4
2023-09-26Don't store lazyness in DefKindMichael Goulet-1/+1
2023-09-21Rollup merge of #115972 - RalfJung:const-consistency, r=oli-obkGuillaume Gomez-14/+14
rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const Also, be more consistent with the `to/eval_bits` methods... we had some that take a type and some that take a size, and then sometimes the one that takes a type is called `bits_for_ty`. Turns out that `ty::Const`/`mir::ConstKind` carry their type with them, so we don't need to even pass the type to those `eval_bits` functions at all. However this is not properly consistent yet: in `ty` we have most of the methods on `ty::Const`, but in `mir` we have them on `mir::ConstKind`. And indeed those two types are the ones that correspond to each other. So `mir::ConstantKind` should actually be renamed to `mir::Const`. But what to do with `mir::Constant`? It carries around a span, that's really more like a constant operand that appears as a MIR operand... it's more suited for `syntax.rs` than `consts.rs`, but the bigger question is, which name should it get if we want to align the `mir` and `ty` types? `ConstOperand`? `ConstOp`? `Literal`? It's not a literal but it has a field called `literal` so it would at least be consistently wrong-ish... ``@oli-obk`` any ideas?
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-14/+14
2023-09-20Cleanup unused messages in ftl filesyukang-2/+0
2023-09-19adjust constValue::Slice to work for arbitrary slice typesRalf Jung-1/+1
2023-09-19move ConstValue into mirRalf Jung-6/+7
this way we have mir::ConstValue and ty::ValTree as reasonably parallel
2023-09-14move required_consts check to general post-mono-check functionRalf Jung-2/+2
2023-09-14Auto merge of #115804 - RalfJung:valtree-to-const-val, r=oli-obkbors-33/+9
consistently pass ty::Const through valtrees Some drive-by things extracted from https://github.com/rust-lang/rust/pull/115748.
2023-09-14Auto merge of #115817 - fee1-dead-contrib:fix-codegen, r=oli-obkbors-3/+4
treat host effect params as erased in codegen This fixes the changes brought to codegen tests when effect params are added to libcore, by not attempting to monomorphize functions that get the host param by being `const fn`. r? `@oli-obk`
2023-09-14treat host effect params as erased generics in codegenDeadbeef-3/+4
This fixes the changes brought to codegen tests when effect params are added to libcore, by not attempting to monomorphize functions that get the host param by being `const fn`.
2023-09-14found another place where we can eval() a const, and go through valtreesRalf Jung-33/+9
2023-09-14cleanup op_to_const a bit; rename ConstValue::ByRef → IndirectRalf Jung-1/+1
2023-09-14use AllocId instead of Allocation in ConstValue::ByRefRalf Jung-2/+3
2023-09-05Rollup merge of #115492 - Enselic:large-box-move, r=oli-obkMatthias Krüger-10/+91
Allow `large_assignments` for Box/Arc/Rc initialization Does the `stop linting in box/arc initialization` task of #83518. r? `@oli-obk` who is E-mentor.
2023-09-05Rollup merge of #115353 - Enselic:no-optimized-mir, r=oli-obkMatthias Krüger-3/+19
Emit error instead of ICE when optimized MIR is missing Closes #51388
2023-09-03Allow `large_assignments` for Box/Arc/Rc initializationMartin Nordholts-10/+91
Does the `stop linting in box/arc initialization` task of 83518.
2023-08-30Emit error instead of ICE when optimized MIR is missingMartin Nordholts-3/+19
Closes 51388.
2023-08-28Auto merge of #114774 - Enselic:less-move-size-noise, r=oli-obkbors-35/+46
Avoid duplicate `large_assignments` lints By checking for overlapping spans. This PR does the "reduce noisiness" task in #83518. r? `@oli-obk` who added E-mentor and E-help-wanted and wrote the initial code. (The fix itself is in https://github.com/rust-lang/rust/pull/114774/commits/dc82736677a134a1b52def496db111681c053e82. The two commits before that are just small refactorings.)
2023-08-24when terminating during unwinding, show the reason whyRalf Jung-20/+12