about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2022-04-06get rid of visit_constant in thir visitorb-naber-8/+16
2022-04-05trivial cfg(bootstrap) changesPietro Albini-2/+2
2022-04-05Auto merge of #94527 - oli-obk:undef_scalars, r=nagisa,erikdesjardinbors-30/+39
Let CTFE to handle partially uninitialized unions without marking the entire value as uninitialized. follow up to #94411 To fix https://github.com/rust-lang/rust/issues/69488 and by extension fix https://github.com/rust-lang/rust/issues/94371, we should stop treating types like `MaybeUninit<usize>` as something that the `Scalar` type in the interpreter engine can represent. So we add a new field to `abi::Primitive` that records whether the primitive is nested in a union cc `@RalfJung` r? `@ghost`
2022-04-05Use WrappingRange::full instead of hand-rolling itOli Scherer-4/+1
2022-04-05Mark scalar layout unions so that backends that do not support partially ↵Oli Scherer-30/+42
initialized scalars can special case them.
2022-04-05macros: add args for non-subdiagnostic fieldsDavid Wood-1/+7
Non-subdiagnostic fields (i.e. those that don't have `#[label]` attributes or similar and are just additional context) have to be added as arguments for Fluent messages to refer them. This commit extends the `SessionDiagnostic` derive to do this for all fields that do not have attributes and introduces an `IntoDiagnosticArg` trait that is implemented on all types that can be converted to a argument for Fluent. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05span: move `MultiSpan`David Wood-7/+8
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-04Mention implementers of unsatisfied traitEsteban Kuber-2/+7
When encountering an unsatisfied trait bound, if there are no other suggestions, mention all the types that *do* implement that trait: ``` error[E0277]: the trait bound `f32: Foo` is not satisfied --> $DIR/impl_wf.rs:22:6 | LL | impl Baz<f32> for f32 { } | ^^^^^^^^ the trait `Foo` is not implemented for `f32` | = help: the following other types implement trait `Foo`: Option<T> i32 str note: required by a bound in `Baz` --> $DIR/impl_wf.rs:18:31 | LL | trait Baz<U: ?Sized> where U: Foo { } | ^^^ required by this bound in `Baz` ``` Mention implementers of traits in `ImplObligation`s. Do not mention other `impl`s for closures, ranges and `?`.
2022-04-04Auto merge of #95031 - compiler-errors:param-env-cache, r=Aaron1011bors-3/+10
Do not use `ParamEnv::and` when building a cache key from a param-env and trait eval candidate Do not use `ParamEnv::and` to cache a param-env with a selection/evaluation candidate. This is because if the param-env is `RevealAll` mode, and the candidate looks global (i.e. it has erased regions, which can show up when we normalize a projection type under a binder<sup>1</sup>), then when we use `ParamEnv::and` to pair the candidate and the param-env for use as a cache key, we will throw away the param-env's caller bounds, and we'll end up caching a candidate that we inferred from the param-env with a empty param-env, which may cause cache-hit later when we have an empty param-env, and possibly mess with normalization like we see in the referenced issue during codegen. Not sure how to trigger this with a more structured test, but changing `check-pass` to `build-pass` triggers the case that https://github.com/rust-lang/rust/issues/94903 detected. <sup>1.</sup> That is, we will replace the late-bound region with a placeholder, which gets canonicalized and turned into an infererence variable, which gets erased during region freshening right before we cache the result. Sorry, it's quite a few steps. Fixes #94903 r? `@Aaron1011` (or reassign as you see fit)
2022-04-02Auto merge of #95537 - GuillaumeGomez:type_of-doc, r=Dylan-DPCbors-1/+4
Improve TyCtxt::type_of documentation r? `@oli-obk`
2022-04-02Improve TyCtxt::type_of documentationGuillaume Gomez-1/+4
2022-04-02rebase and remove dead codeb-naber-131/+2
2022-04-02try to evaluate in from_opt_const_arg_anon_constb-naber-6/+73
2022-04-02rebase and use ty::Const in patterns againb-naber-13/+4
2022-04-02do use ty::Const in patterns and abstract constsb-naber-11/+15
2022-04-02change thir to use mir::ConstantKind instead of ty::Constb-naber-28/+254
2022-04-02Rollup merge of #95560 - lcnr:obligation-cause, r=oli-obkDylan DPC-5/+4
convert more `DefId`s to `LocalDefId`
2022-04-02Rollup merge of #95559 - lcnr:inferctxt-typeck, r=oli-obkDylan DPC-27/+2
small type system refactoring
2022-04-01Auto merge of #94883 - cjgillot:flat-metadata, r=oli-obkbors-17/+14
Encode even more metadata through tables instead of EntryKind This should move us closer to getting rid of `EntryKind`.
2022-04-01update commentlcnr-2/+1
2022-04-01convert more `DefId`s to `LocalDefId`lcnr-3/+3
2022-04-01remove unused incorrect `EqUnifyValue` impllcnr-3/+1
2022-04-01remove `unify_key::replace_if_possible`lcnr-25/+2
2022-04-01Rollup merge of #95388 - RalfJung:rust-val-limit, r=oli-obkMatthias Krüger-0/+5
interpret: make isize::MAX the limit for dynamic value sizes We are currently enforcing `data_layout.obj_size_bound()` as the maximal dynamic size of a Rust value (including for `size_of_val_raw`), but that does not match the docs. In particular, Miri currently falsely says that this code has UB: ```rust #![feature(layout_for_ptr)] fn main() { let size = isize::MAX as usize; // Creating a raw slice of size isize::MAX and asking for its size is okay. let s = std::ptr::slice_from_raw_parts(1usize as *const u8, size); assert_eq!(size, unsafe { std::mem::size_of_val_raw(s) }); } ```
2022-04-01Rollup merge of #95260 - compiler-errors:fn, r=davidtwcoMatthias Krüger-3/+15
Better suggestions for `Fn`-family trait selection errors 1. Suppress suggestions to add `std::ops::Fn{,Mut,Once}` bounds when a type already implements `Fn{,Mut,Once}` 2. Add a note that points out that a type does in fact implement `Fn{,Mut,Once}`, but the arguments vary (either by number or by actual arguments) 3. Add a note that points out that a type does in fact implement `Fn{,Mut,Once}`, but not the right one (e.g. implements `FnMut`, but `Fn` is required). Fixes #95147
2022-03-31remove find_use_placementFausto-2/+2
A more robust solution to finding where to place use suggestions was added. The algorithm uses the AST to find the span for the suggestion so we pass this span down to the HIR during lowering and use it. Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-03-31Merge impl_constness and is_const_fn_raw.Camille GILLOT-6/+12
2022-03-31Create trait_def table.Camille GILLOT-11/+2
2022-03-31inline a trivial functionOli Scherer-0/+1
2022-03-31Move stable hash from TyS into a datastructure that can be shared with other ↵Oli Scherer-64/+59
interned types.
2022-03-31interpret: make isize::MAX the limit for dynamic value sizesRalf Jung-0/+5
2022-03-31obligation cause: `RepeatVec` -> `RepeatValueCopy`lcnr-5/+6
2022-03-31Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errorsDylan DPC-17/+17
Spellchecking compiler comments This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-31Rollup merge of #95263 - compiler-errors:async-block-pretty, r=jackh726Dylan DPC-7/+20
Restore `impl Future<Output = Type>` to async blocks I was sad when I undid some of the code I wrote in #91096 in the PR #95225, so I fixed it here to not print `[async output]`. This PR "manually" normalizes the associated type `<[generator] as Generator>::Return` type which appears very frequently in `impl Future` types that result from async block desugaring.
2022-03-30Restore `impl Future<Output = Type>` to async blocksMichael Goulet-7/+20
2022-03-31Auto merge of #95501 - Dylan-DPC:rollup-arx6sdc, r=Dylan-DPCbors-0/+47
Rollup of 6 pull requests Successful merges: - #93901 (Stabilize native library modifier syntax and the `whole-archive` modifier specifically) - #94806 (Fix `cargo run tidy`) - #94869 (Add the generic_associated_types_extended feature) - #95011 (async: Give predictable name to binding generated from .await expressions.) - #95251 (Reduce max hash in raw strings from u16 to u8) - #95298 (Fix double drop of allocator in IntoIter impl of Vec) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-31Rollup merge of #94869 - jackh726:gats_extended, r=compiler-errorsDylan DPC-0/+47
Add the generic_associated_types_extended feature Right now, this only ignore obligations that reference new placeholders in `poly_project_and_unify_type`. In the future, this might do other things, like allowing object-safe GATs. **This feature is *incomplete* and quite likely unsound. This is mostly just for testing out potential future APIs using a "relaxed" set of rules until we figure out *proper* rules.** Also drive by cleanup of adding a `ProjectAndUnifyResult` enum instead of using a `Result<Result<Option>>`. r? `@nikomatsakis`
2022-03-30Auto merge of #95436 - cjgillot:static-mut, r=oli-obkbors-33/+30
Remember mutability in `DefKind::Static`. This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-30Add the generic_associated_types_extended featureJack Huey-0/+47
2022-03-30a few mode feedback fixes per @bjorn3Yuri Astrakhan-1/+1
2022-03-30Addressed comments by @compiler-errors and @bjorn3Yuri Astrakhan-1/+1
2022-03-30Spellchecking compiler commentsYuri Astrakhan-19/+19
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30Auto merge of #94963 - lcnr:inherent-impls-std, r=oli-obk,m-ou-sebors-4/+52
allow arbitrary inherent impls for builtin types in core Part of https://github.com/rust-lang/compiler-team/issues/487. Slightly adjusted after some talks with `@m-ou-se` about the requirements of `t-libs-api`. This adds a crate attribute `#![rustc_coherence_is_core]` which allows arbitrary impls for builtin types in core. For other library crates impls for builtin types should be avoided if possible. We do have to allow the existing stable impls however. To prevent us from accidentally adding more of these in the future, there is a second attribute `#[rustc_allow_incoherent_impl]` which has to be added to **all impl items**. This only supports impls for builtin types but can easily be extended to additional types in a future PR. This implementation does not check for overlaps in these impls. Perfectly checking that requires us to check the coherence of these incoherent impls in every crate, as two distinct dependencies may add overlapping methods. It should be easy enough to detect if it goes wrong and the attribute is only intended for use inside of std. The first two commits are mostly unrelated cleanups.
2022-03-30get clippy to compile againlcnr-4/+1
2022-03-30rework implementation for inherent impls for builtin typeslcnr-0/+51
2022-03-30Auto merge of #95466 - Dylan-DPC:rollup-g7ddr8y, r=Dylan-DPCbors-2/+2
Rollup of 5 pull requests Successful merges: - #95294 (Document Linux kernel handoff in std::io::copy and std::fs::copy) - #95443 (Clarify how `src/tools/x` searches for python) - #95452 (fix since field version for termination stabilization) - #95460 (Spellchecking compiler code) - #95461 (Spellchecking some comments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-30Rollup merge of #95461 - nyurik:spelling, r=lcnrDylan DPC-1/+1
Spellchecking some comments This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30Spellchecking compiler codeYuri Astrakhan-1/+1
Address some spelling mistakes in strings, private function names, and function params.
2022-03-30Spellchecking some commentsYuri Astrakhan-1/+1
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-29Remember mutability in `DefKind::Static`.Camille GILLOT-33/+30
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.