Trevor Gross
80bb15ed91
Add compiler support for parsing f16 and f128
2024-03-14 00:40:22 -05:00
Zalathar
f9cdaeb6fd
coverage: Data structures for recording branch info during MIR building
2024-03-14 16:27:42 +11:00
Vadim Petrochenkov
b6312eb943
Create some minimal HIR for associated opaque types
2024-03-13 17:33:09 +03:00
Zalathar
c921ab1713
coverage: Add CoverageKind::BlockMarker
2024-03-13 20:43:35 +11:00
Zalathar
73475d0d59
coverage: Make is_eligible_for_coverage a hook method
...
This will allow MIR building to check whether a function is eligible for
coverage instrumentation, and avoid collecting branch coverage info if it is
not.
2024-03-13 20:43:35 +11:00
Ben Kimock
81d630453b
Avoid lowering code under dead SwitchInt targets
2024-03-12 19:01:04 -04:00
Michael Goulet
dd0f41f003
Fix WF for AsyncFnKindHelper in new trait solver
2024-03-12 16:07:01 -04:00
Oli Scherer
926bfe5078
s/mt/mutability/
2024-03-12 05:53:46 +00:00
Oli Scherer
d3514a036d
Ensure nested allocations in statics do not get deduplicated
2024-03-12 05:53:46 +00:00
Oli Scherer
0b4cbee660
Add nested bool to DefKind::Static.
...
Will be used in the next commit
2024-03-12 05:53:46 +00:00
Oli Scherer
9816915954
Change DefKind::Static to a struct variant
2024-03-12 05:53:46 +00:00
Oli Scherer
7348dd1950
Eliminate DefiningAnchor::Error, it is indistinguishable from DefiningAnchor::Bind with an empty list
2024-03-11 17:19:37 +00:00
Oli Scherer
40d5609548
Make DefiningAnchor::Bind only store the opaque types that may be constrained, instead of the current infcx root item.
...
This makes `Bind` almost always be empty, so we can start forwarding it to queries, allowing us to remove `Bubble` entirely
2024-03-11 17:19:37 +00:00
bors
cd81f5b27e
Auto merge of #122132 - nnethercote:diag-renaming3, r=nnethercote
...
Diagnostic renaming 3
A sequel to https://github.com/rust-lang/rust/pull/121780 .
r? `@davidtwco`
2024-03-11 00:34:44 +00:00
Nicholas Nethercote
e9f0d9be0e
Rename DecorateLint as LintDiagnostic.
...
To match `derive(LintDiagnostic)`.
2024-03-11 10:04:50 +11:00
Nicholas Nethercote
7a294e998b
Rename IntoDiagnostic as Diagnostic.
...
To match `derive(Diagnostic)`.
Also rename `into_diagnostic` as `into_diag`.
2024-03-11 09:15:09 +11:00
Nicholas Nethercote
a09b1d33a7
Rename IntoDiagnosticArg as IntoDiagArg.
...
Also rename `into_diagnostic_arg` as `into_diag_arg`, and
`NotIntoDiagnosticArg` as `NotInotDiagArg`.
2024-03-11 09:12:19 +11:00
Ralf Jung
7d99e80c55
MIR printing: print the path of uneval'd const; refer to promoteds in a consistent way
2024-03-10 14:59:41 +01:00
daxpedda
f09c19ac3a
Introduce perma-unstable wasm-c-abi flag
2024-03-10 09:00:01 +01:00
bors
094a6204f5
Auto merge of #122064 - Zoxc:dep-graph-encode-tweaks, r=cjgillot
...
Dep node encoding cleanups
This does some cleanups around dep node encoding.
Performance change with `-Zthreads=2`:
<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th><td align="right">Memory</td><td align="right">Memory</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check:unchanged</td><td align="right">0.4337s</td><td align="right">0.4306s</td><td align="right"> -0.72%</td><td align="right">88.90 MiB</td><td align="right">89.04 MiB</td><td align="right"> 0.15%</td></tr><tr><td>🟣 <b>hyper</b>:check:unchanged</td><td align="right">0.1541s</td><td align="right">0.1528s</td><td align="right"> -0.86%</td><td align="right">51.99 MiB</td><td align="right">52.03 MiB</td><td align="right"> 0.07%</td></tr><tr><td>🟣 <b>regex</b>:check:unchanged</td><td align="right">0.3286s</td><td align="right">0.3248s</td><td align="right">💚 -1.15%</td><td align="right">71.89 MiB</td><td align="right">71.74 MiB</td><td align="right"> -0.21%</td></tr><tr><td>🟣 <b>syn</b>:check:unchanged</td><td align="right">0.6118s</td><td align="right">0.6057s</td><td align="right">💚 -1.01%</td><td align="right">106.59 MiB</td><td align="right">106.66 MiB</td><td align="right"> 0.06%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check:unchanged</td><td align="right">1.4570s</td><td align="right">1.4463s</td><td align="right"> -0.74%</td><td align="right">197.29 MiB</td><td align="right">197.33 MiB</td><td align="right"> 0.02%</td></tr><tr><td>Total</td><td align="right">2.9852s</td><td align="right">2.9601s</td><td align="right"> -0.84%</td><td align="right">516.66 MiB</td><td align="right">516.80 MiB</td><td align="right"> 0.03%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9911s</td><td align="right"> -0.89%</td><td align="right">1 byte</td><td align="right">1.00 bytes</td><td align="right"> 0.02%</td></tr></table>
r? `@cjgillot`
2024-03-10 06:27:41 +00:00
bors
768408af12
Auto merge of #121662 - saethlin:precondition-unification, r=RalfJung
...
Distinguish between library and lang UB in assert_unsafe_precondition
As described in https://github.com/rust-lang/rust/pull/121583#issuecomment-1963168186 , `assert_unsafe_precondition` now explicitly distinguishes between language UB (conditions we explicitly optimize on) and library UB (things we document you shouldn't do, and maybe some library internals assume you don't do).
`debug_assert_nounwind` was originally added to avoid the "only at runtime" aspect of `assert_unsafe_precondition`. Since then the difference between the macros has gotten muddied. This totally revamps the situation.
Now _all_ preconditions shall be checked with `assert_unsafe_precondition`. If you have a precondition that's only checkable at runtime, do a `const_eval_select` hack, as done in this PR.
r? RalfJung
2024-03-10 01:23:54 +00:00
Guillaume Boisseau
bc3bc2ba6b
Rollup merge of #121584 - klensy:itertools-up, r=Mark-Simulacrum
...
bump itertools to 0.12
still depend on 0.11 (temporary dupes version):
* <del>clippy</del>, https://github.com/rust-lang/rust-clippy/pull/12346
* rustfmt, sigh, https://github.com/rust-lang/rustfmt/pull/6093
https://github.com/rust-itertools/itertools/blob/v0.12.1/CHANGELOG.md
removed unused `derive_more` dep from `rustc_middle`
2024-03-09 21:40:08 +01:00
Matthias Krüger
7193ce0061
Rollup merge of #122237 - fee1-dead-contrib:rmord, r=compiler-errors
...
Remove `Ord` from `ClosureKind`
Using `Ord` to accomplish a meaning of subset relationship can be hard to read. The existing uses for that are easily replaced with a `match`, and in my opinion, more readable without needing to resorting to comments to explain the intention.
cc `@compiler-errors`
2024-03-09 16:21:21 +01:00
Deadbeef
7e1969ac13
Remove Ord from ClosureKind
...
Using `Ord` to accomplish a meaning of subset relationship
can be hard to read. The existing uses for that are easily
replaced with a `match`, and in my opinion, more readable
without needing to resorting to comments to explain the
intention.
2024-03-09 21:16:43 +08:00
Ralf Jung
e632e3f9a5
miri: do not apply aliasing restrictions to Box with custom allocator
2024-03-09 13:08:55 +01:00
bors
4d4bb491b6
Auto merge of #122010 - oli-obk:intrinsics3.0, r=pnkfelix
...
Avoid invoking the `intrinsic` query for DefKinds other than `Fn` or `AssocFn`
fixes the perf regression from https://github.com/rust-lang/rust/pull/120675 by only invoking (and thus inserting into the dep graph) the `intrinsic` query if the `DefKind` matches items that can actually be intrinsics
2024-03-09 01:18:13 +00:00
Ben Kimock
5a93a59fd5
Distinguish between library and lang UB in assert_unsafe_precondition
2024-03-08 18:53:58 -05:00
Michael Goulet
c63f3feb0f
Stabilize associated type bounds
2024-03-08 20:56:25 +00:00
Matthias Krüger
bf939fcb99
Rollup merge of #122197 - lcnr:proof-tree-braces, r=BoxyUwU
...
inspect formatter: add braces
This makes it easier to hide subtrees when looking through proof trees. Looking at the proof tree for `usize: Clone`:
nightly:
```
ROOT GOAL: Goal { predicate: Binder { value: TraitPredicate(<usize as std::clone::Clone>, polarity:Positive), bound_vars: [] }, param_env: ParamEnv { caller_bounds: [], reveal: UserFacing } }
GOAL: Canonical { value: QueryInput { goal: Goal { predicate: Binder { value: TraitPredicate(<usize as std::clone::Clone>, polarity:Positive), bound_vars: [] }, param_env: ParamEnv { caller_bounds: [], reveal: UserFacing } }, anchor: Bind(DefId(0:5 ~ main[8e4b]::main)), predefined_opaques_in_body: PredefinedOpaques(PredefinedOpaquesData { opaque_types: [] }) }, max_universe: U0, variables: [] }
REVISION 0
INSTANTIATED: QueryInput { goal: Goal { predicate: Binder { value: TraitPredicate(<usize as std::clone::Clone>, polarity:Positive), bound_vars: [] }, param_env: ParamEnv { caller_bounds: [], reveal: UserFacing } }, anchor: Bind(DefId(0:5 ~ main[8e4b]::main)), predefined_opaques_in_body: PredefinedOpaques(PredefinedOpaquesData { opaque_types: [] }) }
ROOT RESULT: Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: QueryRegionConstraints { outlives: [], member_constraints: [] }, opaque_types: [] }) }, max_universe: U0, variables: [] })
CANDIDATE Impl(DefId(2:30665 ~ core[a9f5]::clone::impls::{impl#5})): Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: QueryRegionConstraints { outlives: [], member_constraints: [] }, opaque_types: [] }) }, max_universe: U0, variables: [] })
TRY_EVALUATE_ADDED_GOALS: Ok(Yes)
ITERATION 0
CANDIDATE constituent tys: Err(NoSolution)
NORMALIZING SELF TY FOR ASSEMBLY:
NORMALIZING SELF TY FOR ASSEMBLY:
RESULT: Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: QueryRegionConstraints { outlives: [], member_constraints: [] }, opaque_types: [] }) }, max_universe: U0, variables: [] })
```
with this PR:
```
ROOT GOAL: Goal { predicate: Binder { value: TraitPredicate(<usize as std::clone::Clone>, polarity:Positive), bound_vars: [] }, param_env: ParamEnv { caller_bounds: [], reveal: UserFacing } } {
GOAL: Canonical { value: QueryInput { goal: Goal { predicate: Binder { value: TraitPredicate(<usize as std::clone::Clone>, polarity:Positive), bound_vars: [] }, param_env: ParamEnv { caller_bounds: [], reveal: UserFacing } }, anchor: Bind(DefId(0:5 ~ main[4f74]::main)), predefined_opaques_in_body: PredefinedOpaques(PredefinedOpaquesData { opaque_types: [] }) }, max_universe: U0, variables: [] }
REVISION 0: {
INSTANTIATED: QueryInput { goal: Goal { predicate: Binder { value: TraitPredicate(<usize as std::clone::Clone>, polarity:Positive), bound_vars: [] }, param_env: ParamEnv { caller_bounds: [], reveal: UserFacing } }, anchor: Bind(DefId(0:5 ~ main[4f74]::main)), predefined_opaques_in_body: PredefinedOpaques(PredefinedOpaquesData { opaque_types: [] }) }
ROOT RESULT: Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: QueryRegionConstraints { outlives: [], member_constraints: [] }, opaque_types: [] }) }, max_universe: U0, variables: [] }) {
CANDIDATE Impl(DefId(2:30468 ~ core[d1d7]::clone::impls::{impl#5})): Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: QueryRegionConstraints { outlives: [], member_constraints: [] }, opaque_types: [] }) }, max_universe: U0, variables: [] }) {
TRY_EVALUATE_ADDED_GOALS: Ok(Yes)
ITERATION 0 {}
}
CANDIDATE constituent tys: Err(NoSolution) {}
NORMALIZING SELF TY FOR ASSEMBLY: {}
NORMALIZING SELF TY FOR ASSEMBLY: {}
}
}
RESULT: Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: QueryRegionConstraints { outlives: [], member_constraints: [] }, opaque_types: [] }) }, max_universe: U0, variables: [] })
}
```
r? `@BoxyUwU`
2024-03-08 21:02:03 +01:00
lcnr
309d85b06f
inspect formatter: add braces
2024-03-08 17:03:04 +01:00
bors
74acabe9b0
Auto merge of #121500 - oli-obk:track_errors12, r=petrochenkov
...
Merge `collect_mod_item_types` query into `check_well_formed`
follow-up to https://github.com/rust-lang/rust/pull/121154
this removes more potential parallel-compiler bottlenecks and moves diagnostics for the same items next to each other, instead of grouping diagnostics by analysis kind
2024-03-08 15:06:36 +00:00
klensy
2de98c8b7e
remove unused derive_more dep
2024-03-08 12:34:14 +03:00
bors
1b2c53a15d
Auto merge of #122182 - matthiaskrgr:rollup-gzimi4c, r=matthiaskrgr
...
Rollup of 8 pull requests
Successful merges:
- #118623 (Improve std::fs::read_to_string example)
- #119365 (Add asm goto support to `asm!`)
- #120608 (Docs for std::ptr::slice_from_raw_parts)
- #121832 (Add new Tier-3 target: `loongarch64-unknown-linux-musl`)
- #121938 (Fix quadratic behavior of repeated vectored writes)
- #122099 (Add `#[inline]` to `BTreeMap::new` constructor)
- #122103 (Make TAITs and ATPITs capture late-bound lifetimes in scope)
- #122143 (PassWrapper: update for llvm/llvm-project@a331937197 )
Failed merges:
- #122076 (Tweak the way we protect in-place function arguments in interpreters)
r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-08 09:34:05 +00:00
Matthias Krüger
d4d18d240b
Rollup merge of #122103 - compiler-errors:taits-capture-everything, r=oli-obk
...
Make TAITs and ATPITs capture late-bound lifetimes in scope
This generalizes the behavior that RPITs have, where they duplicate their in-scope lifetimes so that they will always *reify* late-bound lifetimes that they capture. This allows TAITs and ATPITs to properly error when they capture in-scope late-bound lifetimes.
r? `@oli-obk` cc `@aliemjay`
Fixes #122093 and therefore https://github.com/rust-lang/rust/pull/120700#issuecomment-1981213868
2024-03-08 08:19:20 +01:00
Matthias Krüger
d774fbea7c
Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu
...
Add asm goto support to `asm!`
Tracking issue: #119364
This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto ).
Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary.
r? ``@Amanieu``
cc ``@ojeda``
2024-03-08 08:19:17 +01:00
bors
14fbc3c005
Auto merge of #120268 - DianQK:otherwise_is_last_variant_switchs, r=oli-obk
...
Replace the default branch with an unreachable branch If it is the last variant
Fixes #119520 . Fixes #110097 .
LLVM currently has limited ability to eliminate dead branches in switches, even with the patch of https://github.com/llvm/llvm-project/issues/73446 .
The main reasons are as follows:
- Additional costs are required to calculate the range of values, and there exist many scenarios that cannot be analyzed accurately.
- Matching values by bitwise calculation cannot handle odd branches, nor can it handle values like `-1, 0, 1`. See [SimplifyCFG.cpp#L5424](https://github.com/llvm/llvm-project/blob/llvmorg-17.0.6/llvm/lib/Transforms/Utils/SimplifyCFG.cpp#L5424 ) and https://llvm.godbolt.org/z/qYMqhvMa8
- The current range information is continuous, even if the metadata for the range is submitted. See [ConstantRange.cpp#L1869-L1870](https://github.com/llvm/llvm-project/blob/llvmorg-17.0.6/llvm/lib/IR/ConstantRange.cpp#L1869-L1870 ).
- The metadata of the range may be lost in passes such as SROA. See https://rust.godbolt.org/z/e7f87vKMK .
Although we can make improvements, I think it would be more appropriate to put this issue to rustc first. After all, we can easily know the possible values.
Note that we've currently found a slow compilation problem in the presence of unreachable branches. See
https://github.com/llvm/llvm-project/issues/78578 .
r? compiler
2024-03-08 07:18:17 +00:00
Michael Goulet
74d5bbbf94
Rename some functions to represent their generalized behavior
2024-03-08 02:10:11 +00:00
Michael Goulet
cf299ddb6e
Make TAITs capture all higher-ranked lifetimes in scope
2024-03-08 02:10:11 +00:00
DianQK
b5bd98d540
Update MIR with MirPatch in UninhabitedEnumBranching
2024-03-08 08:15:14 +08:00
Guillaume Gomez
010fc20215
Rollup merge of #122141 - klensy:sync-me, r=lcnr
...
sync (try_)instantiate_mir_and_normalize_erasing_regions implementation
`try_instantiate_mir_and_normalize_erasing_regions` was changed in dbc2cc8717 , but not `instantiate_mir_and_normalize_erasing_regions`, sync them.
see https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/instantiate_mir_and_normalize_erasing_regions.20vs.20try_*.20ver
r? `@lcnr`
2024-03-07 18:32:50 +01:00
Guillaume Gomez
4de78d2a8d
Rollup merge of #121089 - oli-obk:create_def_feed, r=petrochenkov
...
Remove `feed_local_def_id`
best reviewed commit by commit
Basically I returned `TyCtxtFeed` from `create_def` and then preserved that in the local caches
based on https://github.com/rust-lang/rust/pull/121084
r? ````@petrochenkov````
2024-03-07 18:32:47 +01:00
DianQK
08ae8380ce
Replace the default branch with an unreachable branch If it is the last variant
2024-03-07 22:58:51 +08:00
klensy
cd549aeffd
sync (try_)instantiate_mir_and_normalize_erasing_regions implementation
...
try_instantiate_mir_and_normalize_erasing_regions was changed in dbc2cc8717 , but not instantiate_mir_and_normalize_erasing_regions
2024-03-07 17:33:08 +03:00
Oli Scherer
ae50e36dfa
Merge collect_mod_item_types query into check_well_formed
2024-03-07 14:26:31 +00:00
Yoshitomo Nakanishi
9669934798
Apply EarlyBinder only to TraitRef in ImplTraitHeader
2024-03-07 13:56:29 +01:00
Oli Scherer
8206cffc48
Merge check_mod_impl_wf and check_mod_type_wf
2024-03-07 06:27:09 +00:00
bors
aa029ce4d8
Auto merge of #122113 - matthiaskrgr:rollup-5d1jnwi, r=matthiaskrgr
...
Rollup of 9 pull requests
Successful merges:
- #121958 (Fix redundant import errors for preload extern crate)
- #121976 (Add an option to have an external download/bootstrap cache)
- #122022 (loongarch: add frecipe and relax target feature)
- #122026 (Do not try to format removed files)
- #122027 (Uplift some feeding out of `associated_type_for_impl_trait_in_impl` and into queries)
- #122063 (Make the lowering of `thir::ExprKind::If` easier to follow)
- #122074 (Add missing PartialOrd trait implementation doc for array)
- #122082 (remove outdated fixme comment)
- #122091 (Note why we're using a new thread in `test_get_os_named_thread`)
r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-07 02:30:40 +00:00
Matthias Krüger
34cffae24c
Rollup merge of #122027 - compiler-errors:rpitit-cycle, r=spastorino
...
Uplift some feeding out of `associated_type_for_impl_trait_in_impl` and into queries
This PR moves the `type_of` and `generics_of` query feeding out of `associated_type_for_impl_trait_in_impl`, since eagerly feeding results in query cycles due to a subtle interaction with `resolve_bound_vars`.
Fixes #122019
r? spastorino
2024-03-06 22:41:55 +01:00
Matthias Krüger
efe9deace8
Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, r=davidtwco
...
Rework `untranslatable_diagnostic` lint
Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This PR changes it to check calls to any function with an `impl Into<{D,Subd}iagnosticMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. It also lets us add `#[rustc_lint_diagnostics]` to a number of functions that don't have an `impl Into<{D,Subd}iagnosticMessage>`, such as `Diag::span`.
r? ``@davidtwco``
2024-03-06 22:02:46 +01:00
John Kåre Alsaker
29cc76f0fc
Add a profiler reference to GraphEncoder
2024-03-06 04:17:17 +01:00