Camille GILLOT
1ffe9059c3
Reject borrows of projections in ConstProp.
2023-05-04 21:51:44 +00:00
Matthias Krüger
0ac8ebdf11
Rollup merge of #110826 - cjgillot:place-mention-use, r=JakobDegen,lcnr
...
Make PlaceMention a non-mutating use.
Fixes https://github.com/rust-lang/rust/issues/110781
r? `@JakobDegen`
I don't agree with your statement in https://github.com/rust-lang/rust/issues/110781#issuecomment-1520841434 . I suggest that we start fixing `PlaceContext` to be accurate enough for optimizations to use it. This structure is very convenient to use in visitors, and we perhaps have an opportunity to make it less of a footgun.
2023-05-04 19:18:19 +02:00
bors
5133e15459
Auto merge of #109521 - tmiasko:const-prop-validation, r=wesleywiser
...
Don't validate constants in const propagation
Validation is neither necessary nor desirable.
The constant validation is already omitted at mir-opt-level >= 3, so there there are not changes in MIR test output (the propagation of invalid constants is covered by an existing test in tests/mir-opt/const_prop/invalid_constant.rs).
2023-05-02 03:42:37 +00:00
Camille GILLOT
9325a254f0
Make PlaceMention a non-mutating use.
2023-04-29 16:14:33 +00:00
bors
6ce22733b9
Auto merge of #110882 - BoxyUwU:rename-some-ty-flags, r=compiler-errors
...
rename `NEEDS_SUBST` and `NEEDS_INFER`
implements rust-lang/compiler-team#617
2023-04-27 09:55:37 +00:00
Boxy
842419712a
rename needs_subst
to has_param
2023-04-27 08:35:19 +01:00
bors
8b8110e146
Auto merge of #110728 - cjgillot:no-false-optes, r=oli-obk
...
Do not bother optimizing impossible functions.
This is currently checked by `ConstProp`, but I see no reason to restrict it to ConstProp only.
2023-04-27 04:29:49 +00:00
Tomasz Miąsko
4adb8fbda0
Remove workaround for CastKind::Transmute from const prop
...
Since constants are no longer validated before propagation the
workaround is obsolete. Remove it.
2023-04-27 00:33:52 +02:00
Tomasz Miąsko
6a8fcdc597
Don't validate constants before propagation
...
Validation is neither necessary nor desirable.
The validation is already omitted at mir-opt-level >= 3, so there there
are not changes in MIR test output (the propagation of invalid constants
is covered by an existing test in tests/mir-opt/const_prop/invalid_constant.rs).
2023-04-27 00:32:03 +02:00
Maybe Waffle
e496fbec92
Split {Idx, IndexVec, IndexSlice}
into their own modules
2023-04-24 13:53:35 +00:00
Camille GILLOT
15e5072147
Do not bother optimizing impossible functions.
2023-04-23 16:35:49 +00:00
Josh Soref
e09d0d2a29
Spelling - compiler
...
* account
* achieved
* advising
* always
* ambiguous
* analysis
* annotations
* appropriate
* build
* candidates
* cascading
* category
* character
* clarification
* compound
* conceptually
* constituent
* consts
* convenience
* corresponds
* debruijn
* debug
* debugable
* debuggable
* deterministic
* discriminant
* display
* documentation
* doesn't
* ellipsis
* erroneous
* evaluability
* evaluate
* evaluation
* explicitly
* fallible
* fulfill
* getting
* has
* highlighting
* illustrative
* imported
* incompatible
* infringing
* initialized
* into
* intrinsic
* introduced
* javascript
* liveness
* metadata
* monomorphization
* nonexistent
* nontrivial
* obligation
* obligations
* offset
* opaque
* opportunities
* opt-in
* outlive
* overlapping
* paragraph
* parentheses
* poisson
* precisely
* predecessors
* predicates
* preexisting
* propagated
* really
* reentrant
* referent
* responsibility
* rustonomicon
* shortcircuit
* simplifiable
* simplifications
* specify
* stabilized
* structurally
* suggestibility
* translatable
* transmuting
* two
* unclosed
* uninhabited
* visibility
* volatile
* workaround
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17 16:09:18 -04:00
Camille GILLOT
22bf5fd848
Remove useless methods in visit.
2023-04-15 07:46:46 +00:00
Camille GILLOT
8a515aab76
Only enable ConstProp at mir-opt-level >= 2.
2023-04-15 07:46:46 +00:00
bors
f8ed97ecc1
Auto merge of #110031 - compiler-errors:generic-elaboration, r=b-naber
...
Make elaboration generic over input
Combines all the `elaborate_*` family of functions into just one, which is an iterator over the same type that you pass in (e.g. elaborating `Predicate` gives `Predicate`s, elaborating `Obligation`s gives `Obligation`s, etc.)
2023-04-09 00:18:10 +00:00
Michael Goulet
758bedc104
Make elaborator generic
2023-04-06 23:30:22 +00:00
Gary Guo
e3f2edc75b
Rename Abort
terminator to Terminate
...
Unify terminology used in unwind action and terminator, and reflect
the fact that a nounwind panic is triggered instead of an immediate
abort is triggered for this terminator.
2023-04-06 09:34:16 +01:00
Gary Guo
5e6ed132fa
Add UnwindAction::Unreachable
...
This also makes eval machine's `StackPopUnwind`
redundant so that is replaced.
2023-04-06 09:34:16 +01:00
Gary Guo
daeb844e0c
Refactor unwind from Option to a new enum
2023-04-06 09:34:16 +01:00
Scott McMurray
a2ee7592d6
Use &IndexSlice
instead of &IndexVec
where possible
...
All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
2023-04-02 17:35:37 -07:00
Michael Goulet
1ce4b37900
Don't elaborate non-obligations into obligations
2023-03-26 20:33:54 +00:00
Scott McMurray
64cce5fc7d
Add CastKind::Transmute
to MIR
...
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic.
Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-22 15:15:41 -07:00
Dylan DPC
eda88a30c7
Rollup merge of #109435 - oli-obk: 🇨🇭 🥚 _copy_op, r=RalfJung
...
Detect uninhabited types early in const eval
r? `@RalfJung`
implements https://github.com/rust-lang/rust/pull/108442#discussion_r1143003840
this is a breaking change, as some UB during const eval is now detected instead of silently being ignored. Users can see this and other UB that may cause future breakage with `-Zextra-const-ub-checks` or just by running miri on their code, which sets that flag by default.
2023-03-23 00:00:35 +05:30
Oli Scherer
83dec62b26
Add a layout argument to enforce_validity
.
...
This is in preparation of checking the validity only of certain types.
2023-03-21 08:52:31 +00:00
Camille GILLOT
e5a55dc2c5
Prefer if cfg!.
2023-03-19 08:59:11 +00:00
Camille GILLOT
0e866af1f7
Only clear locals that are known to be written to.
2023-03-19 08:58:01 +00:00
bors
b05bb29008
Auto merge of #108872 - cjgillot:simp-const-prop, r=oli-obk
...
Strengthen state tracking in const-prop
Some/many of the changes are replicated between both the const-prop lint and the const-prop optimization.
Behaviour changes:
- const-prop opt does not give a span to propagated values. This was useless as that span's primary purpose is to diagnose evaluation failure in codegen.
- we remove the `OnlyPropagateInto` mode. It was only used for function arguments, which are better modeled by a write before entry.
- the tracking of assignments and discriminants make clearer that we do nothing in `NoPropagation` mode or on indirect places.
2023-03-12 23:27:52 +00:00
Camille GILLOT
8179b2e5f8
Remove useless parameter to operand_from_scalar.
2023-03-08 14:42:21 +00:00
Camille GILLOT
0d56034a25
Make comment more explicit.
2023-03-08 14:40:38 +00:00
Camille GILLOT
b55c4f8312
Separate checking rvalue from evaluation.
2023-03-08 14:40:38 +00:00
Camille GILLOT
f00be8b77b
Recurse into statement before applying its effect.
2023-03-08 14:40:38 +00:00
Camille GILLOT
d97a7ce69b
Refactor tracking of writes.
2023-03-08 14:40:38 +00:00
Camille GILLOT
9928d0e566
Remove OnlyPropagateInto.
2023-03-08 14:40:37 +00:00
Camille GILLOT
24dbf9c112
Only assign value in remove_const.
2023-03-08 14:40:37 +00:00
Camille GILLOT
0e64ce7c5e
Do not track span in ConstProp.
2023-03-08 14:40:37 +00:00
Camille GILLOT
2247cd6643
Simplify visit_statement.
2023-03-08 14:40:37 +00:00
Giacomo Pasini
c5d4e4d907
Remove DropAndReplace terminator
...
PR 107844 made DropAndReplace unused, let's remove it completely
from the codebase.
2023-03-07 14:25:22 +01:00
Alan Egerton
695072daa6
Remove type-traversal trait aliases
2023-02-22 17:04:58 +00:00
Camille GILLOT
f02d6c45e1
Remove use_ecx.
2023-02-20 18:25:37 +00:00
Camille GILLOT
d0934f14c7
Merge if-let and match.
2023-02-20 18:25:37 +00:00
Camille GILLOT
4a75995fbd
Move state fixup into a different method.
2023-02-20 18:25:37 +00:00
Camille GILLOT
e34caaf42d
Remove overflow checks from ConstProp.
2023-02-18 21:35:02 +00:00
Kyle Matsuda
c183110cc2
remove bound_type_of query; make type_of return EarlyBinder; change type_of in metadata
2023-02-16 17:05:56 -07:00
Kyle Matsuda
d822b97a27
change usages of type_of to bound_type_of
2023-02-16 17:01:52 -07:00
Maybe Waffle
f1d273cbfb
Replace some _ == _ || _ == _
s with matches!(_, _ | _)
s
2023-01-30 12:26:26 +00:00
Maybe Waffle
4d75f61832
Use Mutability::{is_mut, is_not}
2023-01-30 12:26:26 +00:00
Ben Kimock
82f0973dd5
Always take advantage of arithmetic identities
2023-01-01 23:12:29 -05:00
Matthias Krüger
0aa4cde747
avoid .into() conversion to identical types
2022-12-18 16:20:32 +01:00
Oli Scherer
d9d92ed7da
Move alignment failure error reporting to machine
2022-12-15 16:07:35 +00:00
Oli Scherer
d66824dbc4
Make alignment checks a future incompat lint
2022-12-15 16:07:28 +00:00