about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/consts
AgeCommit message (Collapse)AuthorLines
2023-04-01use and_then/flat_map for map().flatten()Matthias Krüger-1/+1
2023-03-15unequal → not equalgimbles-7/+7
2023-02-22Remove type-traversal trait aliasesAlan Egerton-1/+1
2023-02-18Auto merge of #107542 - ↵bors-6/+4
compiler-errors:param-envs-with-inference-vars-are-cursed, r=jackh726 Don't call `with_reveal_all_normalized` in const-eval when `param_env` has inference vars in it **what:** This slightly shifts the order of operations from an existing hack: https://github.com/rust-lang/rust/blob/5b6ed253c42a69b93e7447fb0874a89ab6bc1cfb/compiler/rustc_middle/src/ty/consts/kind.rs#L225-L230 in order to avoid calling a tcx query (`TyCtxt::reveal_opaque_types_in_bounds`, via `ParamEnv::with_reveal_all_normalized`) when a param-env has inference variables in it. **why:** This allows us to enable fingerprinting of query keys/values outside of incr-comp in deubg mode, to make sure we catch other places where we're passing infer vars and other bad things into query keys. Currently that (bbf33836b9adfe4328aefa108c421e670a3923b7) crashes because we introduce inference vars into a param-env in the blanket-impl finder in rustdoc :sweat: https://github.com/rust-lang/rust/blob/5b6ed253c42a69b93e7447fb0874a89ab6bc1cfb/src/librustdoc/clean/blanket_impl.rs#L43 See the CI failure here: https://github.com/rust-lang/rust/actions/runs/4058194838/jobs/6984834619
2023-02-15Use target instead of machine for mir interpreter integer handling.Oli Scherer-5/+5
The naming of `machine` only makes sense from a mir interpreter internals perspective, but outside users talk about the `target` platform
2023-02-01Don't call with_reveal_all_normalized in evaluate when param-env has ↵Michael Goulet-6/+4
inference vars in it
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-1/+1
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-3/+0
2022-11-28Make `tcx.mk_const` more permissive wrt `kind` argumentMaybe Waffle-0/+8
- Accept `impl Into` - Implement `From<>` for `ConstKind` Note: this adds a dependency on `derive_more` (MIT license). It allows to derive a lot of traits (like `From` here) that would be otherwise tedious to implement.
2022-11-27Auto merge of #103917 - oli-obk:layout_math, r=RalfJung,lcnrbors-0/+12
Various cleanups around scalar layout restrictions Pulled out of https://github.com/rust-lang/rust/pull/103724
2022-11-25Add empty ConstKind::Abstractkadmin-1/+18
Initial pass at expr/abstract const/s Address comments Switch to using a list instead of &[ty::Const], rm `AbstractConst` Remove try_unify_abstract_consts Update comments Add edits Recurse more More edits Prevent equating associated consts Move failing test to ui Changes this test from incremental to ui, and mark it as failing and a known bug. Does not cause the compiler to ICE, so should be ok.
2022-11-25Add helper method to `ScalarInt`Oli Scherer-0/+12
2022-11-16cleanup and dedupe CTFE and Miri error reportingRalf Jung-2/+2
2022-11-02deprecate DelaySpanBugEmitted and use ErrorGuaranteed directlyyukang-1/+1
2022-10-22Auto merge of #103227 - lcnr:bye-bye-unevaluated-const, r=oli-obkbors-1/+1
stop using `ty::UnevaluatedConst` directly best reviewed commit by commit. simplifies #99798 because we now don't have to expand `ty::UnevaluatedConst` to `ty::Const`. I also remember some other places where using `ty::UnevaluatedConst` directly was annoying and caused issues, though I don't quite remember what they were rn '^^ r? `@oli-obk` cc `@JulianKnodt`
2022-10-19Deny const variables as wellMichael Goulet-1/+10
2022-10-19stop folding `UnevaluatedConst`lcnr-1/+1
2022-09-23rename Unevaluated to UnevaluatedConstb-naber-10/+13
2022-09-22introduce mir::Unevaluatedb-naber-21/+9
2022-09-17Auto merge of #98588 - b-naber:valtrees-cleanup, r=lcnrbors-4/+7
Use only ty::Unevaluated<'tcx, ()> in type system r? `@lcnr`
2022-09-15Replace more manual TypeFoldable and TypeVisitable impls with derivesOli Scherer-1/+1
2022-09-13use ty::Unevaluated<'tcx, ()> in type systemb-naber-4/+7
2022-09-08don't evaluate with escaping bound varslcnr-0/+1
2022-09-04Make `const_eval_select` a real intrinsicDeadbeef-1/+4
2022-09-01Porting 'compiler/rustc_trait_selection' to translatable diagnostics - Part 1Gabriel Bustamante-0/+6
2022-07-26Allow try_to_raw_bytes on u8 arrayMichael Goulet-20/+14
2022-07-20clippy::perf fixesMatthias Krüger-6/+4
2022-07-09don't allow ZST in ScalarIntRalf Jung-26/+20
There are several indications that we should not ZST as a ScalarInt: - We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it. `ValTree::zst()` used the former, but the latter could possibly arise as well. - Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`. - LLVM codegen already had to special-case ZST ScalarInt. So instead add new ZST variants to those types that did not have other variants which could be used for this purpose.
2022-07-06Update TypeVisitor pathsAlan Egerton-1/+1
2022-07-02add AllocRange Debug impl; remove redundant AllocId Display implRalf Jung-0/+4
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-13/+129
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-3/+3
There are two impls of the `Encoder` trait: `opaque::Encoder` and `opaque::FileEncoder`. The former encodes into memory and is infallible, the latter writes to file and is fallible. Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a bit verbose and has non-trivial cost, which is annoying given how rare failures are (especially in the infallible `opaque::Encoder` case). This commit changes how `Encoder` fallibility is handled. All the `emit_*` methods are now infallible. `opaque::Encoder` requires no great changes for this. `opaque::FileEncoder` now implements a delayed error handling strategy. If a failure occurs, it records this via the `res` field, and all subsequent encoding operations are skipped if `res` indicates an error has occurred. Once encoding is complete, the new `finish` method is called, which returns a `Result`. In other words, there is now a single `Result`-producing method instead of many of them. This has very little effect on how any file errors are reported if `opaque::FileEncoder` has any failures. Much of this commit is boring mechanical changes, removing `Result` return values and `?` or `unwrap` from expressions. The more interesting parts are as follows. - serialize.rs: The `Encoder` trait gains an `Ok` associated type. The `into_inner` method is changed into `finish`, which returns `Result<Vec<u8>, !>`. - opaque.rs: The `FileEncoder` adopts the delayed error handling strategy. Its `Ok` type is a `usize`, returning the number of bytes written, replacing previous uses of `FileEncoder::position`. - Various methods that take an encoder now consume it, rather than being passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-04-21implement valtree -> constvalue conversionb-naber-0/+3
2022-04-21add helper methods on ValTreeb-naber-0/+16
2022-04-21add some helper methods to ScalarIntb-naber-0/+92
2022-04-16Rollup merge of #95426 - b-naber:valtrees-slice, r=RalfJung,oli-obkDylan DPC-1/+1
Include Refs in Valtree Creation This adds references to `const_to_valtree`, which isn't used in the compiler yet, but after the previous changes we made to the thir and mir representations and this change we should be able to finally introduce them in the next PR. I wasn't able to properly test this code, except indirectly by including a call of `const_to_valtree` in the code that currently creates constants (`turn_into_const_value`). r? `@lcnr` cc `@oli-obk` `@RalfJung`
2022-04-08create leafs for slicesb-naber-28/+0
2022-04-02rebase and use ty::Const in patterns againb-naber-5/+1
2022-04-02do use ty::Const in patterns and abstract constsb-naber-1/+6
2022-04-02change thir to use mir::ConstantKind instead of ty::Constb-naber-1/+1
2022-03-29Add type for slices in ValTreesb-naber-1/+29
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-2/+2
2022-02-20Rollup merge of #94091 - GuillaumeGomez:rustdoc-const-computed-value, r=oli-obkMatthias Krüger-0/+7
Fix rustdoc const computed value Fixes #85088. It looks like this now (instead of hexadecimal): ![Screenshot from 2022-02-17 17-55-39](https://user-images.githubusercontent.com/3050060/154532115-0f9861a0-406f-4c9c-957f-32bedd8aca7d.png) r? ````@oli-obk````
2022-02-19Don't render Const computed values in hexadecimal for DisplayGuillaume Gomez-0/+7
2022-02-17Fix ScalarInt to char conversionTomasz Miąsko-4/+14
to avoid panic for invalid Unicode scalar values
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-2/+2
`Decoder` has two impls: - opaque: this impl is already partly infallible, i.e. in some places it currently panics on failure (e.g. if the input is too short, or on a bad `Result` discriminant), and in some places it returns an error (e.g. on a bad `Option` discriminant). The number of places where either happens is surprisingly small, just because the binary representation has very little redundancy and a lot of input reading can occur even on malformed data. - json: this impl is fully fallible, but it's only used (a) for the `.rlink` file production, and there's a `FIXME` comment suggesting it should change to a binary format, and (b) in a few tests in non-fundamental ways. Indeed #85993 is open to remove it entirely. And the top-level places in the compiler that call into decoding just abort on error anyway. So the fallibility is providing little value, and getting rid of it leads to some non-trivial performance improvements. Much of this commit is pretty boring and mechanical. Some notes about a few interesting parts: - The commit removes `Decoder::{Error,error}`. - `InternIteratorElement::intern_with`: the impl for `T` now has the same optimization for small counts that the impl for `Result<T, E>` has, because it's now much hotter. - Decodable impls for SmallVec, LinkedList, VecDeque now all use `collect`, which is nice; the one for `Vec` uses unsafe code, because that gave better perf on some benchmarks.
2022-01-15nyahggdshjjghsdfhgsfEllen-0/+3
2022-01-15attempt to re-add `ty::Unevaluated` visitor and friendsEllen-13/+35
2022-01-15initial revertEllen-59/+14
2021-12-15Remove `in_band_lifetimes` from `rustc_middle`Aaron Hill-2/+2
See #91867 This was mostly straightforward. In several places, I take advantage of the fact that lifetimes are non-hygenic: a macro declares the 'tcx' lifetime, which is then used in types passed in as macro arguments.