summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2021-06-07Differentiate different defining uses of taits when they reference distinct ↵Santiago Pastorino-10/+7
generic parameters
2021-06-07Remove substs from OpaqueTypeDecl, use the one in OpaqueTypeKeySantiago Pastorino-27/+25
2021-06-07Use substs from opaque type key instead of using it from opaque_declSantiago Pastorino-2/+1
2021-06-07Make opaque type map key be of type OpaqueTypeKeySantiago Pastorino-4/+10
2021-06-07Make OpaqueTypeKey the key of opaque types mapSantiago Pastorino-5/+5
2021-06-07Change opaque type map to be a `VecMap`Santiago Pastorino-4/+5
2021-06-03don't suggest unsized indirection in where-clausesTaylor Yu-0/+4
Skip where-clauses when suggesting using indirection in combination with `?Sized` bounds on type parameters.
2021-06-02Restrict access to crate_name.Camille GILLOT-2/+6
Also remove original_crate_name, which had the exact same implementation
2021-06-01Revert "Reduce the amount of untracked state in TyCtxt"Camille Gillot-6/+2
2021-05-30Restrict access to crate_name.Camille GILLOT-2/+6
Also remove original_crate_name, which had the exact same implementation
2021-05-26stabilize member constraintsNiko Matsakis-66/+0
2021-05-25Auto merge of #85481 - lcnr:const-equate, r=matthewjasperbors-3/+34
deal with `const_evaluatable_checked` in `ConstEquate` Failing to evaluate two constants which do not contain inference variables should not result in ambiguity.
2021-05-25Auto merge of #84985 - pietroalbini:bootstrap-1.54, r=Mark-Simulacrumbors-1/+0
Bump bootstrap compiler to beta 1.53.0 This PR bumps the bootstrap compiler to version 1.53.0 beta, as part of our usual release process (this was supposed to be Wednesday's step, but creating the beta release took longer than expected). The PR also includes the "Bootstrap: skip rustdoc fingerprint for building docs" commit, see the reasoning [on Zulip](https://zulip-archive.rust-lang.org/241545trelease/88450153betabootstrap.html). r? `@Mark-Simulacrum`
2021-05-24Auto merge of #85596 - scottmcm:more-on-unimplemented, r=estebankbors-0/+9
Extend `rustc_on_implemented` to improve more `?` error messages `_Self` could match the generic definition; this adds that functionality for matching the generic definition of type parameters too. Your advice welcome on the wording of all these messages, and which things belong in the message/label/note. r? `@estebank`
2021-05-24remove cfg(bootstrap)Pietro Albini-1/+0
2021-05-23Extend rustc_on_implemented to improve a ?-on-ControlFlow error messageScott McMurray-0/+9
2021-05-21Auto merge of #85382 - Aaron1011:project-eval, r=nikomatsakisbors-9/+1
Always produce sub-obligations when using cached projection result See https://github.com/rust-lang/rust/issues/85360 When we skip adding the sub-obligations to the `obligation` list, we can affect whether or not the final result is `EvaluatedToOk` or `EvaluatedToOkModuloObligations`. This creates problems for incremental compilation, since the projection cache is untracked shared state. To solve this issue, we unconditionally process the sub-obligations. Surprisingly, this is a slight performance *win* in many cases.
2021-05-19deal with `const_evaluatable_checked` in `ConstEquate`lcnr-3/+34
2021-05-18Rollup merge of #85369 - FabianWolff:issue-84973, r=jackh726Guillaume Gomez-13/+68
Suggest borrowing if a trait implementation is found for &/&mut <type> This pull request fixes #84973 by suggesting to borrow if a trait is not implemented for some type `T`, but it is for `&T` or `&mut T`. For instance: ```rust trait Ti {} impl<T> Ti for &T {} fn foo<T: Ti>(_: T) {} trait Tm {} impl<T> Tm for &mut T {} fn bar<T: Tm>(_: T) {} fn main() { let a: i32 = 5; foo(a); let b: Box<i32> = Box::new(42); bar(b); } ``` gives, on current nightly: ``` error[E0277]: the trait bound `i32: Ti` is not satisfied --> t2.rs:11:9 | 3 | fn foo<T: Ti>(_: T) {} | -- required by this bound in `foo` ... 11 | foo(a); | ^ the trait `Ti` is not implemented for `i32` error[E0277]: the trait bound `Box<i32>: Tm` is not satisfied --> t2.rs:14:9 | 7 | fn bar<T: Tm>(_: T) {} | -- required by this bound in `bar` ... 14 | bar(b); | ^ the trait `Tm` is not implemented for `Box<i32>` error: aborting due to 2 previous errors ``` whereas with my changes, I get: ``` error[E0277]: the trait bound `i32: Ti` is not satisfied --> t2.rs:11:9 | 3 | fn foo<T: Ti>(_: T) {} | -- required by this bound in `foo` ... 11 | foo(a); | ^ | | | expected an implementor of trait `Ti` | help: consider borrowing here: `&a` error[E0277]: the trait bound `Box<i32>: Tm` is not satisfied --> t2.rs:14:9 | 7 | fn bar<T: Tm>(_: T) {} | -- required by this bound in `bar` ... 14 | bar(b); | ^ | | | expected an implementor of trait `Tm` | help: consider borrowing mutably here: `&mut b` error: aborting due to 2 previous errors ``` In my implementation, I have added a "blacklist" to make these suggestions flexible. In particular, suggesting to borrow can interfere with other suggestions, such as to add another trait bound to a generic argument. I have tried to configure this blacklist to cause the least amount of test case failures, i.e. to model the current behavior as closely as possible (I only had to change one existing test case, and this change was quite clearly an improvement).
2021-05-17New rustdoc lint to respect -Dwarnings correctlyAlexis Bourget-0/+1
This adds a new lint to `rustc` that is used in rustdoc when a code block is empty or cannot be parsed as valid Rust code. Previously this was unconditionally a warning. As such some documentation comments were (unknowingly) abusing this to pass despite the `-Dwarnings` used when compiling `rustc`, this should not be the case anymore.
2021-05-17Implement jackh726's suggestionsFabian Wolff-12/+6
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-2/+2
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-16Always produce sub-obligations when using cached projection resultAaron Hill-9/+1
2021-05-16Suggest borrowing if a trait implementation is found for &/&mut <type>Fabian Wolff-13/+74
2021-05-13have on_completion record subcyclesNiko Matsakis-48/+61
Rework `on_completion` method so that it removes all provisional cache entries that are "below" a completed node (while leaving those entries that are not below the node). This corrects an imprecise result that could in turn lead to an incremental compilation failure. Under the old scheme, if you had: * A depends on... * B depends on A * C depends on... * D depends on C * T: 'static then the provisional results for A, B, C, and D would all be entangled. Thus, if A was `EvaluatedToOkModuloRegions` (because of that final condition), then the result for C and D would also be demoted to "ok modulo regions". In reality, though, the result for C depends only on C and itself, and is not dependent on regions. If we happen to evaluate the cycle starting from C, we would never reach A, and hence the result would be "ok". Under the new scheme, the provisional results for C and D are moved to the permanent cache immediately and are not affected by the result of A.
2021-05-12Use () for all_traits.Camille GILLOT-2/+2
2021-05-07Rollup merge of #84987 - lcnr:nits, r=Mark-SimulacrumDylan DPC-2/+0
small nits
2021-05-06Auto merge of #84559 - jackh726:issue-84398, r=nikomatsakisbors-1/+11
Deduplicate ParamCandidates with the same value except for bound vars Fixes #84398 This is kind of a hack. I wonder if we can get other types of candidates that are the same except for bound vars. This won't be a problem with Chalk, since we don't really need to know that there are two different "candidates" if they both give the same final substitution. r? `@nikomatsakis`
2021-05-06outdated commentlcnr-2/+0
2021-05-06Pick candidate with fewer bound varsJack Huey-5/+5
2021-04-27Make traits with GATs not object safeJack Huey-4/+11
2021-04-25Deduplicate ParamCandidates with the same value except for bound varsJack Huey-1/+11
2021-04-22Rollup merge of #84343 - camsteffen:closure-tree, r=varkorDylan DPC-2/+1
Remove `ScopeTree::closure_tree` Seems to be dead code since #50649.
2021-04-19Small refactorCameron Steffen-2/+1
2021-04-19fix few typosklensy-2/+2
2021-04-18Improve an error message.teymour-aldridge-6/+6
2021-04-08Rollup merge of #83980 - pierwill:fix-compiler-librustc-names, r=davidtwcoDylan DPC-1/+1
Fix outdated crate names in compiler docs Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged.
2021-04-08Fix outdated crate names in compiler docspierwill-1/+1
Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged. Also fix incorrect file paths.
2021-04-08Rollup merge of #83689 - estebank:cool-bears-hot-tip, r=davidtwcoDylan DPC-14/+87
Add more info for common trait resolution and async/await errors * Suggest `Pin::new`/`Box::new`/`Arc::new`/`Box::pin` in more cases * Point at `impl` and type defs introducing requirements on E0277
2021-04-06Add spans to E0277 for impl/trait type/fn obligation disparityEsteban Küber-11/+52
2021-04-06review commentsEsteban Küber-1/+1
2021-04-06Point at `impl` and type defs introducing requirements on E0277Esteban Küber-3/+35
2021-04-06Do not ICE when closure is involved in TAITEsteban Küber-1/+6
Fix #83613.
2021-04-06Remove trailing `:` from E0119 messageEsteban Küber-2/+2
2021-04-02Rollup merge of #83673 - hi-rustin:rustin-patch-suggestion, r=estebankDylan DPC-1/+3
give full path of constraint in suggest_constraining_type_param close https://github.com/rust-lang/rust/issues/83513
2021-04-02Auto merge of #83207 - oli-obk:valtree2, r=lcnrbors-0/+5
normalize mir::Constant differently from ty::Const in preparation for valtrees Valtrees are unable to represent many kind of constant values (this is on purpose). For constants that are used at runtime, we do not need a valtree representation and can thus use a different form of evaluation. In order to make this explicit and less fragile, I added a `fold_constant` method to `TypeFolder` and implemented it for normalization. Normalization can now, when it wants to eagerly evaluate a constant, normalize `mir::Constant` directly into a `mir::ConstantKind::Val` instead of relying on the `ty::Const` evaluation. In the future we can get rid of the `ty::Const` in there entirely and add our own `Unevaluated` variant to `mir::ConstantKind`. This would allow us to remove the `promoted` field from `ty::ConstKind::Unevaluated`, as promoteds can never occur in the type system. cc `@rust-lang/wg-const-eval` r? `@lcnr`
2021-04-02Auto merge of #80828 - SNCPlay42:opaque-projections, r=estebankbors-2/+4
Fix expected/found order on impl trait projection mismatch error fixes #68561 This PR adds a new `ObligationCauseCode` used when checking the concrete type of an impl trait satisfies its bounds, and checks for that cause code in the existing test to see if a projection's normalized type should be the "expected" or "found" type. The second commit adds a `peel_derives` to that test, which appears to be necessary in some cases (see projection-mismatch-in-impl-where-clause.rs, which would still give expected/found in the wrong order otherwise). This caused some other changes in diagnostics not involving impl trait, but they look correct to me.
2021-04-01Auto merge of #82780 - cjgillot:dep-stream, r=michaelwoeristerbors-1/+1
Stream the dep-graph to a file instead of storing it in-memory. This is a reimplementation of #60035. Instead of storing the dep-graph in-memory, the nodes are encoded as they come into the a temporary file as they come. At the end of a successful the compilation, this file is renamed to be the persistent dep-graph, to be decoded during the next compilation session. This two-files scheme avoids overwriting the dep-graph on unsuccessful or crashing compilations. The structure of the file is modified to be the sequence of `(DepNode, Fingerprint, EdgesVec)`. The deserialization is responsible for going to the more compressed representation. The `node_count` and `edge_count` are stored in the last 16 bytes of the file, in order to accurately reserve capacity for the vectors. At the end of the compilation, the encoder is flushed and dropped. The graph is not usable after this point: any creation of a node will ICE. I had to retrofit the debugging options, which is not really pretty.
2021-03-31Cleanups and commentsJack Huey-1/+0
2021-03-31Track bound varsJack Huey-2/+5