summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2022-04-24Backport fixes -- drop uses of NodeIdHashingModeMark Rousskov-6/+2
2022-04-24Remove NodeIdHashingMode.Camille GILLOT-96/+10
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-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-31Merge impl_constness and is_const_fn_raw.Camille GILLOT-6/+12
2022-03-31Create trait_def table.Camille GILLOT-11/+2
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-30Rollup merge of #95460 - nyurik:spelling-str, r=lcnrDylan DPC-1/+1
Spellchecking compiler code Address some spelling mistakes in strings, private function names, and function params.
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-30Auto merge of #94081 - oli-obk:lazy_tait_take_two, r=nikomatsakisbors-28/+88
Lazy type-alias-impl-trait take two ### user visible change 1: RPIT inference from recursive call sites Lazy TAIT has an insta-stable change. The following snippet now compiles, because opaque types can now have their hidden type set from wherever the opaque type is mentioned. ```rust fn bar(b: bool) -> impl std::fmt::Debug { if b { return 42 } let x: u32 = bar(false); // this errors on stable 99 } ``` The return type of `bar` stays opaque, you can't do `bar(false) + 42`, you need to actually mention the hidden type. ### user visible change 2: divergence between RPIT and TAIT in return statements Note that `return` statements and the trailing return expression are special with RPIT (but not TAIT). So ```rust #![feature(type_alias_impl_trait)] type Foo = impl std::fmt::Debug; fn foo(b: bool) -> Foo { if b { return vec![42]; } std::iter::empty().collect() //~ ERROR `Foo` cannot be built from an iterator } fn bar(b: bool) -> impl std::fmt::Debug { if b { return vec![42] } std::iter::empty().collect() // Works, magic (accidentally stabilized, not intended) } ``` But when we are working with the return value of a recursive call, the behavior of RPIT and TAIT is the same: ```rust type Foo = impl std::fmt::Debug; fn foo(b: bool) -> Foo { if b { return vec![]; } let mut x = foo(false); x = std::iter::empty().collect(); //~ ERROR `Foo` cannot be built from an iterator vec![] } fn bar(b: bool) -> impl std::fmt::Debug { if b { return vec![]; } let mut x = bar(false); x = std::iter::empty().collect(); //~ ERROR `impl Debug` cannot be built from an iterator vec![] } ``` ### user visible change 3: TAIT does not merge types across branches In contrast to RPIT, TAIT does not merge types across branches, so the following does not compile. ```rust type Foo = impl std::fmt::Debug; fn foo(b: bool) -> Foo { if b { vec![42_i32] } else { std::iter::empty().collect() //~^ ERROR `Foo` cannot be built from an iterator over elements of type `_` } } ``` It is easy to support, but we should make an explicit decision to include the additional complexity in the implementation (it's not much, see a721052457cf513487fb4266e3ade65c29b272d2 which needs to be reverted to enable this). ### PR formalities previous attempt: #92007 This PR also includes #92306 and #93783, as they were reverted along with #92007 in #93893 fixes #93411 fixes #88236 fixes #89312 fixes #87340 fixes #86800 fixes #86719 fixes #84073 fixes #83919 fixes #82139 fixes #77987 fixes #74282 fixes #67830 fixes #62742 fixes #54895
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.
2022-03-28Rollup merge of #93787 - klensy:really-not-a-features, r=wesleywiserDylan DPC-2/+5
parallel_compiler: hide dependencies behind feature Separate dependencies for `parallel_compiler` feature, so they will not be compiled if feature not selected, reducing number of compiled crates from 238 to 224.
2022-03-28Remove opaque type obligation and just register opaque types as they are ↵Oli Scherer-20/+0
encountered. This also registers obligations for the hidden type immediately.
2022-03-28Have the spans of TAIT type conflict errors point to the actual site instead ↵Oli Scherer-2/+34
of the owning function
2022-03-28Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"Oli Scherer-26/+74
This reverts commit 6499c5e7fc173a3f55b7a3bd1e6a50e9edef782d, reversing changes made to 78450d2d602b06d9b94349aaf8cece1a4acaf3a8.
2022-03-28Propagate `parallel_compiler` feature through rustc crates. Turned off ↵klensy-2/+5
feature gives change of builded crates: 238 -> 224.
2022-03-28Auto merge of #95333 - GuillaumeGomez:auto-trait-perf-issue, r=oli-obkbors-0/+9
Fix perf issue for auto trait selection Follow-up of https://github.com/rust-lang/rust/pull/95069 which fixes the perf issue introduced by it. r? `@oli-obk`
2022-03-27Rollup merge of #95120 - smoelius:backward-switch-int, r=ecstatic-morseDylan DPC-0/+95
Implement `apply_switch_int_edge_effects` for backward analyses See #94576 for some discussion. r? `@ecstatic-morse`
2022-03-26Do not use ParamEnv::and to cache param-env with candidateMichael Goulet-3/+10
2022-03-26Fix perf issue for auto trait selectionGuillaume Gomez-0/+9
2022-03-26Address review commentsSamuel E. Moelius III-0/+95
* Add lazily computed `switch_sources` data structure * Don't assume a target has only one associated value
2022-03-26Auto merge of #95149 - cjgillot:once-diag, r=estebankbors-63/+26
Remove `Session::one_time_diagnostic` This is untracked mutable state, which modified the behaviour of queries. It was used for 2 things: some full-blown errors, but mostly for lint declaration notes ("the lint level is defined here" notes). It is replaced by the diagnostic deduplication infra which already exists in the diagnostic emitter. A new diagnostic level `OnceNote` is introduced specifically for lint notes, to deduplicate subdiagnostics. As a drive-by, diagnostic emission takes a `&mut` to allow dropping the `SubDiagnostic`s.
2022-03-25Auto merge of #95280 - InfRandomness:infrandomness/Dtorck_clarification, ↵bors-10/+10
r=oli-obk Swap DtorckConstraint to DropckConstraint This change was made as per suspicion that this struct was never renamed after consistent use of DropCk. This also clarifies the meaning behind the name of this structure. Fixes https://github.com/rust-lang/rust/issues/94310