about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2021-06-23Auto merge of #86386 - ↵bors-0/+24
inquisitivecrystal:better-errors-for-display-traits-v3, r=estebank Better errors for Debug and Display traits Currently, if someone tries to pass value that does not implement `Debug` or `Display` to a formatting macro, they get a very verbose and confusing error message. This PR changes the error messages for missing `Debug` and `Display` impls to be less overwhelming in this case, as suggested by #85844. I was a little less aggressive in changing the error message than that issue proposed. Still, this implementation would be enough to reduce the number of messages to be much more manageable. After this PR, information on the cause of an error involving a `Debug` or `Display` implementation would suppressed if the requirement originated within a standard library macro. My reasoning was that errors originating from within a macro are confusing when they mention details that the programmer can't see, and this is particularly problematic for `Debug` and `Display`, which are most often used via macros. It is possible that either a broader or a narrower criterion would be better. I'm quite open to any feedback. Fixes #85844.
2021-06-18improve comments for unsized suggestionsTaylor Yu-1/+5
2021-06-18deindent unsized suggestionsTaylor Yu-63/+63
Move stuff out of loops. Use early returns.
2021-06-18factor out maybe_indirection_for_unsizedTaylor Yu-32/+47
2021-06-18factor out maybe_suggest_unsized_genericsTaylor Yu-1/+17
2021-06-18debug for suggest_unsized_bound_if_applicableTaylor Yu-1/+11
2021-06-18add various coments to explain how the code worksNiko Matsakis-9/+3
2021-06-16Improve errors for missing Debug and Display implsAris Merchant-0/+24
2021-06-15Refactor to make interpreter and codegen backend neutral to vtable internal ↵Charles Lew-63/+89
representation.
2021-06-12Auto merge of #86130 - BoxyUwU:abstract_const_as_cast, r=oli-obkbors-1/+30
const_eval_checked: Support as casts in abstract consts
2021-06-10support `as _` and add testsEllen-1/+3
2021-06-09Add more tests + visit_ty in some placesEllen-12/+21
2021-06-08Support as casts in abstract constsEllen-9/+27
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.