about summary refs log tree commit diff
path: root/compiler/rustc_infer
AgeCommit message (Collapse)AuthorLines
2021-09-21Auto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebankbors-1/+1
Migrate in-tree crates to 2021 This replaces #89075 (cherry picking some of the commits from there), and closes #88637 and fixes #89074. It excludes a migration of the library crates for now (see tidy diff) because we have some pending bugs around macro spans to fix there. I instrumented bootstrap during the migration to make sure all crates moved from 2018 to 2021 had the compatibility warnings applied first. Originally, the intent was to support cargo fix --edition within bootstrap, but this proved fairly difficult to pull off. We'd need to architect the check functionality to support running cargo check and cargo fix within the same x.py invocation, and only resetting sysroots on check. Further, it was found that cargo fix doesn't behave too well with "not quite workspaces", such as Clippy which has several crates. Bootstrap runs with --manifest-path ... for all the tools, and this makes cargo fix only attempt migration for that crate. We can't use e.g. --workspace due to needing to maintain sysroots for different phases of compilation appropriately. It is recommended to skip the mass migration of Cargo.toml's to 2021 for review purposes; you can also use `git diff d6cd2c6c877110748296760aefddc21a0ea1d316 -I'^edition = .20...$'` to ignore the edition = 2018/21 lines in the diff.
2021-09-20Remove Drop-caused migration-added capturesMark Rousskov-16/+16
All of these were added due to insignificant Drop types being present.
2021-09-20Migrate to 2021Mark Rousskov-1/+1
2021-09-20Add a doc comment to infer_projectionOli Scherer-0/+6
2021-09-20Add helper function to `InferCtxt` that generates inference vars for ↵Oli Scherer-0/+34
unresolved associated types
2021-09-20Enable 2021 compatibility lints for all in-tree codeMark Rousskov-16/+16
This just applies the suggested fixes from the compatibility warnings, leaving any that are in practice spurious in. This is primarily intended to provide a starting point to identify possible fixes to the migrations (e.g., by avoiding spurious warnings). A secondary commit cleans these up where they are false positives (as is true in many of the cases).
2021-09-18Auto merge of #89000 - Mark-Simulacrum:no-new-lrc, r=petrochenkovbors-2/+2
Reuse existing shared Lrc for MatchImpl parent This is a small performance win for the hot path, which helps to address this regression: https://github.com/rust-lang/rust/pull/87244#issuecomment-883635813.
2021-09-17Add another case of fallback to () avoid breakageMark Rousskov-0/+3
This adds src/test/ui/never_type/fallback-closure-ret.rs as a test case which showcases the failure mode fixed by this commit.
2021-09-17stop categorizing inference variables as diverging when createdNiko Matsakis-62/+16
Instead, we now rely on the code that looks for a NeverToAny adjustment.
2021-09-17remove diverging type variables from fn checkNiko Matsakis-1/+5
The comment seems incorrect. Testing revealed that the examples in question still work (as well as some variants) even without the special casing here.
2021-09-17introduce new fallback algorithmNiko Matsakis-1/+12
We now fallback type variables using the following rules: * Construct a coercion graph `A -> B` where `A` and `B` are unresolved type variables or the `!` type. * Let D be those variables that are reachable from `!`. * Let N be those variables that are reachable from a variable not in D. * All variables in (D \ N) fallback to `!`. * All variables in (D & N) fallback to `()`.
2021-09-17Auto merge of #88945 - Aaron1011:no-projection-completion, ↵bors-41/+0
r=wesleywiser,jackh726 Remove concept of 'completion' from the projection cache Fixes #88910 When we initially store a `NormalizedTy` in the projection cache, we discard all obligations that we can (while ensuring that we don't cause any issues with incremental compilation). Marking a projection cache entry as 'completed' discards all obligations associated with it. This can only cause problems, since any obligations stored in the cache are there for a reason (e.g. they evaluate to `EvaluatedToOkModuloRegions`). This commit removes `complete` and `complete_normalized` entirely.
2021-09-17Make diagnostics clearer for `?` operatorsYuki Okushi-3/+16
2021-09-16Auto merge of #88719 - estebank:point-at-arg-for-obligation, r=nagisabors-6/+8
Point at argument instead of call for their obligations When an obligation is introduced by a specific `fn` argument, point at the argument instead of the `fn` call if the obligation fails to be fulfilled. Move the information about pointing at the call argument expression in an unmet obligation span from the `FulfillmentError` to a new `ObligationCauseCode`. When giving an error about an obligation introduced by a function call that an argument doesn't fulfill, and that argument is a block, add a span_label pointing at the innermost tail expression. Current output: ``` error[E0425]: cannot find value `x` in this scope --> f10.rs:4:14 | 4 | Some(x * 2) | ^ not found in this scope error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>` --> f10.rs:2:31 | 2 | let p = Some(45).and_then({ | ______________________--------_^ | | | | | required by a bound introduced by this call 3 | | |x| println!("doubling {}", x); 4 | | Some(x * 2) | | ----------- 5 | | }); | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>` | = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>` ``` Previous output: ``` error[E0425]: cannot find value `x` in this scope --> f10.rs:4:14 | 4 | Some(x * 2) | ^ not found in this scope error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>` --> f10.rs:2:22 | 2 | let p = Some(45).and_then({ | ^^^^^^^^ expected an `FnOnce<({integer},)>` closure, found `Option<_>` | = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>` ``` Partially address #27300. Will require rebasing on top of #88546.
2021-09-16Refactor `FulfillmentError` to track less dataEsteban Kuber-6/+8
Move the information about pointing at the call argument expression in an unmet obligation span from the `FulfillmentError` to a new `ObligationCauseCode`.
2021-09-15Reuse existing shared Lrc for MatchImpl parentMark Rousskov-2/+2
This is hopefully a small performance win for the hot path.
2021-09-15Remove ToPredicate impls that use Binder::dummyjackh726-7/+11
2021-09-15Move object safety suggestions to the end of the errorEsteban Kuber-4/+8
2021-09-14Remove concept of 'completion' from the projection cacheAaron Hill-41/+0
Fixes #88910 When we initially store a `NormalizedTy` in the projection cache, we discard all obligations that we can (while ensuring that we don't cause any issues with incremental compilation). Marking a projection cache entry as 'completed' discards all obligations associated with it. This can only cause problems, since any obligations stored in the cache are there for a reason (e.g. they evaluate to `EvaluatedToOkModuloRegions`). This commit removes `complete` and `complete_normalized` entirely.
2021-09-12Rollup merge of #88336 - jackh726:gats-where-constraints, r=estebankManish Goregaokar-30/+97
Detect stricter constraints on gats where clauses in impls vs trait I might try to see if I can do a bit more to improve these diagnostics, but any initial feedback is appreciated. I can also do any additional work in a followup PR. r? `@estebank`
2021-09-11Rollup merge of #88850 - matthiaskrgr:identical_conv, r=jackh726Jubilee-1/+1
don't convert types into identical types example: let x: String = String::new().into();
2021-09-11don't convert types into identical typesMatthias Krüger-1/+1
example: let x: String = String::new().into();
2021-09-11don't clone types that are Copy (clippy::clone_on_copy)Matthias Krüger-3/+3
2021-09-07Fix duplicate errorjackh726-0/+1
2021-09-07Detect stricter constraints on gats where clauses in impls vs traitjackh726-30/+96
2021-09-06Use index newtyping for TyVidMark Rousskov-10/+10
2021-09-03Auto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebankbors-6/+3
Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix. This PR fixes a regression (#87745) with `--remap-path-prefix` where the flag stopped causing diagnostic messages to be remapped as well. The regression was introduced in https://github.com/rust-lang/rust/pull/83813 where we erroneously assumed that remapping of diagnostic messages was not desired anymore (because #70642 partially undid that functionality with nobody objecting). The issue is fixed by making `--remap-path-prefix` remap diagnostic messages again, including for paths that have been remapped in upstream crates (e.g. the standard library). This means that "sysroot-localization" (implemented in #70642) is also disabled if `rustc` is invoked with `--remap-path-prefix`. The assumption is that once someone starts explicitly remapping paths they also don't want paths to their local Rust installation in their build output. In the future we might want to give more fine-grained control over this behavior via compiler flags (see https://github.com/rust-lang/rfcs/pull/3127 for a related RFC). For now this PR is intended as a regression fix. This PR is an alternative to https://github.com/rust-lang/rust/pull/88191, which makes diagnostic messages be remapped unconditionally. That approach, however, would effectively revert #70642. Fixes https://github.com/rust-lang/rust/issues/87745. cc `@cbeuw` r? `@ghost`
2021-08-30Enforce diverging let...elseCameron Steffen-0/+5
2021-08-30`feature(const_generics)` -> `feature(const_param_types)`lcnr-1/+1
2021-08-30remove lazy_normalization_constsEllen-1/+1
2021-08-27Path remapping: Make behavior of diagnostics output dependent on presence of ↵Michael Woerister-6/+3
--remap-path-prefix.
2021-08-26reviewlcnr-1/+1
2021-08-26shrink `ty::PredicateKind` againlcnr-2/+2
2021-08-26use `ty::Unevaluated` instead of def substs pairlcnr-4/+1
2021-08-26don't just compare `ty::Const`lcnr-0/+2
2021-08-26update `TypeFlags` to deal with missing ct substslcnr-2/+2
2021-08-26add `tcx` to `fn walk`lcnr-2/+2
2021-08-26make unevaluated const substs optionallcnr-23/+23
2021-08-26require a `tcx` for `TypeVisitor`lcnr-3/+24
2021-08-25Rollup merge of #88218 - Aaron1011:missing-method-dyn, r=nagisaLéo Lanteri Thauvin-6/+0
Remove `Session.trait_methods_not_found` Instead, avoid registering the problematic well-formed obligation to begin with. This removes global untracked mutable state, and avoids potential issues with incremental compilation.
2021-08-23Rollup merge of #88230 - steffahn:a_an, r=oli-obkMara Bos-6/+6
Fix typos “a”→“an” Fix typos in comments; found using a regex to find some easy instance of incorrect usage of a vs. an. While automation was used to find these, every change was checked manually. Changes in submodules get separate PRs: * https://github.com/rust-lang/stdarch/pull/1201 * https://github.com/rust-lang/cargo/pull/9821 * https://github.com/rust-lang/miri/pull/1874 * https://github.com/rust-lang/rls/pull/1746 * https://github.com/rust-analyzer/rust-analyzer/pull/9984 _folks @ rust-analyzer are fast at merging…_ * https://github.com/rust-analyzer/rust-analyzer/pull/9985 * https://github.com/rust-analyzer/rust-analyzer/pull/9987 * https://github.com/rust-analyzer/rust-analyzer/pull/9989 _For `clippy`, I don’t know if the changes should better better be moved to a PR to the original repo._ <hr> This has some overlap with #88226, but neither is a strict superset of the other. If you want multiple commits, I can split it up; in that case, make sure to suggest a criterion for splitting.
2021-08-22Auto merge of #88166 - BoxyUwU:const-equate-canon, r=lcnrbors-0/+16
canonicalize consts before calling try_unify_abstract_consts query Fixes #88022 Fixes #86953 Fixes #77708 Fixes #82034 Fixes #85031 these ICEs were all caused by calling the `try_unify_abstract_consts` query with inference vars in substs r? `@lcnr`
2021-08-22Fix more “a”/“an” typosFrank Steffahn-2/+2
2021-08-22Fix typos “a”→“an”Frank Steffahn-4/+4
2021-08-21Remove `Session.trait_methods_not_found`Aaron Hill-6/+0
Instead, avoid registering the problematic well-formed obligation to begin with. This removes global untracked mutable state, and avoids potential issues with incremental compilation.
2021-08-20move `fallback_if_possible` and friends to fallback.rsNiko Matsakis-23/+18
Along the way, simplify and document the logic more clearly.
2021-08-20move the `sub-unify` check and extend the documentation a bitNiko Matsakis-25/+46
I didn't like the sub-unify code executing when a predicate was ENQUEUED, that felt fragile. I would have preferred to move the sub-unify code so that it only occurred during generalization, but that impacted diagnostics, so having it also occur when we process subtype predicates felt pretty reasonable. (I guess we only need one or the other, but I kind of prefer both, since the generalizer ultimately feels like the *right* place to guarantee the properties we want.)
2021-08-19introduce a Coerce predicateNiko Matsakis-0/+34
2021-08-19introduce a `Diverging` enum instead of a boolNiko Matsakis-15/+27
2021-08-19move code to `InferCtxt` methodEllen-0/+16