about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2022-08-01Remove DefId from AssocItemContainer.Camille GILLOT-3/+3
2022-08-01Store associated item defaultness in impl_defaultness.Camille GILLOT-3/+8
2022-08-01fmt...Ellen-4/+1
2022-08-01Rollup merge of #100012 - TaKO8Ki:avoid-ty-to-string-conversions, r=fee1-deadMatthias Krüger-5/+4
Avoid `Ty` to `String` conversions follow-up to #98668
2022-08-01Rollup merge of #99911 - cjgillot:no-guess, r=davidtwcoMatthias Krüger-1/+0
Remove some uses of `guess_head_span` That function cuts a span at the first occurrence of `{`. Using `def_span` is almost always more precise.
2022-08-01make `PlaceholderConst` not store the type of the constEllen-1/+1
2022-08-01avoid `Ty` to `String` conversionsTakayuki Maeda-5/+4
2022-07-31Always include a position span in rustc_parse_format::ArgumentAlex Macleod-2/+2
2022-07-30Rollup merge of #99862 - WaffleLapkin:type_mismatch_fix, r=compiler-errorsDylan DPC-13/+20
Improve type mismatch w/ function signatures This PR makes use of `note: expected/found` (instead of labeling types in labels) in type mismatch with function signatures. Pros: it's easier to compare the signatures, cons: the error is a little more verbose now. This is especially nice when - The signatures differ in a small subset of parameters (same parameters are elided) - The difference is in details, for example `isize` vs `usize` (there is a better chance that the types align) Also this PR fixes the inconsistency in variable names in the edited code (`expected` and `found`). A zulip thread from which this pr started: [[link]](https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/Type.20error.20regression.3F.2E.2E.2E/near/289756602). An example diagnostic: <table> <tr> <th>this pr</th> <th>nightly</th> </tr> <tr> <td> ```text error[E0631]: type mismatch in function arguments --> ./t.rs:4:12 | 4 | expect(&f); | ------ ^^ expected due to this | | | required by a bound introduced by this call ... 10 | fn f(_: isize, _: u8, _: Vec<u32>) {} | ---------------------------------- found signature defined here | = note: expected function signature `fn(usize, _, Vec<u64>) -> _` found function signature `fn(isize, _, Vec<u32>) -> _` note: required because of the requirements on the impl of `Trait` for `fn(isize, u8, Vec<u32>) {f}` --> ./t.rs:8:9 | 8 | impl<F> Trait for F where F: Fn(usize, u8, Vec<u64>) -> u8 {} | ^^^^^ ^ = note: required for the cast from `fn(isize, u8, Vec<u32>) {f}` to the object type `dyn Trait` ``` </td> <td> ```text error[E0631]: type mismatch in function arguments --> ./t.rs:4:12 | 4 | expect(&f); | ------ ^^ expected signature of `fn(usize, u8, Vec<u64>) -> _` | | | required by a bound introduced by this call ... 10 | fn f(_: isize, _: u8, _: Vec<u32>) {} | ---------------------------------- found signature of `fn(isize, u8, Vec<u32>) -> _` | note: required because of the requirements on the impl of `Trait` for `fn(isize, u8, Vec<u32>) {f}` --> ./t.rs:8:9 | 8 | impl<F> Trait for F where F: Fn(usize, u8, Vec<u64>) -> u8 {} | ^^^^^ ^ = note: required for the cast to the object type `dyn Trait` ``` </td> </tr> </table> <details><summary>code</summary> <p> ```rust fn main() { fn expect(_: &dyn Trait) {} expect(&f); } trait Trait {} impl<F> Trait for F where F: Fn(usize, u8, Vec<u64>) -> u8 {} fn f(_: isize, _: u8, _: Vec<u32>) {} ``` </p> </details> r? `@compiler-errors`
2022-07-30Rollup merge of #99311 - kckeiks:clean-up-body-owner-methods, r=cjgillotDylan DPC-3/+4
change maybe_body_owned_by to take local def id Issue https://github.com/rust-lang/rust/issues/96341 r? `@cjgillot`
2022-07-30Auto merge of #99796 - compiler-errors:issue-53475, r=oli-obkbors-7/+1
use `check_region_obligations_and_report_errors` to avoid ICEs If we don't call `process_registered_region_obligations` before `resolve_regions_and_report_errors` then we'll ICE if we have any region obligations, and `check_region_obligations_and_report_errors` just does both of these for us in a nice convenient function. Fixes #53475 r? types
2022-07-30Rollup merge of #99671 - TaKO8Ki:suggest-dereferencing-index, r=compiler-errorsYuki Okushi-0/+29
Suggest dereferencing index when trying to use a reference of usize as index fixes #96678
2022-07-29Rename local_did to def_idMiguel Guarniz-1/+1
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29Change maybe_body_owned_by to take local def idMiguel Guarniz-3/+4
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29never inline the only thing that calls a query, which could hit the ↵Oli Scherer-0/+1
instrument path
2022-07-29update commentlcnr-10/+15
2022-07-29Document check_region_obligations_and_report_errors, simplify a call to ↵Michael Goulet-7/+1
resolve_regions
2022-07-29check if T is sliceTakayuki Maeda-2/+3
fix msg
2022-07-29Auto merge of #99660 - PrestonFrom:issue_99265, r=compiler-errorsbors-1/+1
Generate correct suggestion with named arguments used positionally Address issue #99265 by checking each positionally used argument to see if the argument is named and adding a lint to use the name instead. This way, when named arguments are used positionally in a different order than their argument order, the suggested lint is correct. For example: ``` println!("{b} {}", a=1, b=2); ``` This will now generate the suggestion: ``` println!("{b} {a}", a=1, b=2); ``` Additionally, this check now also correctly replaces or inserts only where the positional argument is (or would be if implicit). Also, width and precision are replaced with their argument names when they exists. Since the issues were so closely related, this fix for issue #99265 also fixes issue #99266. Fixes #99265 Fixes #99266
2022-07-28Remove guess_head_span.Camille GILLOT-1/+0
2022-07-28orphan check: remove const generics fixmelcnr-1/+10
2022-07-28Revert "Rollup merge of #97346 - JohnTitor:remove-back-compat-hacks, r=oli-obk"Oli Scherer-4/+14
This reverts commit c703d11dccb4a895c7aead3b2fcd8cea8c483184, reversing changes made to 64eb9ab869bc3f9ef3645302fbf22e706eea16cf.
2022-07-28improve type mismatch error for functionsMaybe Waffle-13/+20
This also fixes the argument names in `report_closure_arg_mismatch` (confusing expected/found)
2022-07-28Rollup merge of #99837 - TaKO8Ki:avoid-symbol-to-string-conversions, r=fee1-deadDylan DPC-5/+5
Avoid `Symbol` to `String` conversions follow-up to #99508
2022-07-28avoid `Symbol` to `String` conversionsTakayuki Maeda-5/+5
2022-07-27safe transmute: don't mark user impls as unambiguousJack Wrenn-1/+0
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925243794
2022-07-27safe transmute: gracefully handle const params of wrong typesJack Wrenn-1/+1
ref: https://github.com/rust-lang/rust/pull/92268/files#r925244819
2022-07-27Initial (incomplete) implementation of transmutability trait.Jack Wrenn-0/+78
This initial implementation handles transmutations between types with specified layouts, except when references are involved. Co-authored-by: Igor null <m1el.2027@gmail.com>
2022-07-27Rollup merge of #99651 - compiler-errors:fn-and-raw-ptr-in-const-generics, ↵Guillaume Gomez-68/+68
r=oli-obk Deeply deny fn and raw ptrs in const generics I think this is right -- just because we wrap a fn ptr in a wrapper type does not mean we should allow it in a const parameter. We now reject both of these in the same way: ``` #![feature(adt_const_params)] #[derive(Eq, PartialEq)] struct Wrapper(); fn foo<const W: Wrapper>() {} fn foo2<const F: fn()>() {} ``` This does regress one test (`src/test/ui/consts/refs_check_const_eq-issue-88384.stderr`), but I'm not sure it should've passed in the first place. cc: ``@b-naber`` who introduced that test^ fixes #99641
2022-07-27Rollup merge of #99789 - TaKO8Ki:use-pluralize-macro, r=compiler-errorsYuki Okushi-2/+2
Refactor: use `pluralize!` Use `pluralize!` in more places
2022-07-27use `pluralize!`Takayuki Maeda-2/+2
2022-07-26Fix diagnostics for unfulfilled obligationsDeadbeef-7/+11
2022-07-26Rollup merge of #99666 - compiler-errors:issue-99663, r=lcnrDylan DPC-1/+30
Restore `Opaque` behavior to coherence check Fixes #99663. This broke in 84c3fcd2a0285c06a682c9b064640084e4c7271b. I'm not exactly certain that adding this behavior back is necessarily correct, but at least the UI test I provided may stimulate some thoughts. I think delaying a bug here is certainly not correct in the case of opaques -- if we want to change coherence behavior for opaques, then we should at least be emitting a new error. r? ``@lcnr``
2022-07-26Rollup merge of #99618 - compiler-errors:uhh-idk, r=lcnrDylan DPC-13/+4
handle consts with param/infer in `const_eval_resolve` better This PR addresses [this thread here](https://github.com/rust-lang/rust/pull/99449#discussion_r924141230). Was this the change you were looking for ``@lcnr?`` Interestingly, one test has begun to pass. Was that expected? r? ``@lcnr``
2022-07-26Use TraitEngine in more places that don't specifically need ↵Michael Goulet-12/+14
FulfillmentCtxt::new_in_snapshot
2022-07-25handle consts with param/infer in const_eval_resolve betterMichael Goulet-13/+4
2022-07-25Restore Opaque behavior to coherence checkMichael Goulet-1/+30
2022-07-25Generate correct suggestion with named arguments used positionallyPreston From-1/+1
Address issue #99265 by checking each positionally used argument to see if the argument is named and adding a lint to use the name instead. This way, when named arguments are used positionally in a different order than their argument order, the suggested lint is correct. For example: ``` println!("{b} {}", a=1, b=2); ``` This will now generate the suggestion: ``` println!("{b} {a}", a=1, b=2); ``` Additionally, this check now also correctly replaces or inserts only where the positional argument is (or would be if implicit). Also, width and precision are replaced with their argument names when they exists. Since the issues were so closely related, this fix for issue #99265 also fixes issue #99266. Fixes #99265 Fixes #99266
2022-07-25Remove non-descriptive boolean from search_for_structural_match_violationMichael Goulet-11/+26
2022-07-25Get rid of redundant NonStructuralMatchTyKindMichael Goulet-53/+14
2022-07-25Deeply deny fn and raw ptrs in const genericsMichael Goulet-23/+47
2022-07-24Combine redundant obligation cause codesMichael Goulet-41/+6
2022-07-24suggest dereferencing index when trying to use a reference of usize as indexTakayuki Maeda-0/+28
2022-07-24Auto merge of #93429 - fee1-dead-contrib:allow-super-trait-tilde-const, ↵bors-8/+35
r=oli-obk Allow `trait A: ~const B` What's included: a minimal working change set for `~const` supertraits to work. r? `@oli-obk`
2022-07-24Instantiate constness in wfcheckDeadbeef-8/+35
2022-07-23Rollup merge of #99449 - compiler-errors:assoc-const-missing-item, r=lcnrGuillaume Gomez-3/+12
Do not resolve associated const when there is no provided value Fixes #98629, since now we just delay a bug when we're not able to evaluate a const item due to the value not actually being provided by anything. This means compilation proceeds forward to where the "missing item in impl" error is emitted. ---- The root issue here is that when we're looking for the defining `LeafDef` in `resolve_associated_item`, we end up getting the trait's AssocItem instead of the impl's AssocItem (which does not exist). This resolution "succeeds" even if the trait's item has no default value, and then since this item has no value to evaluate, it turns into a const eval error. This root issue becomes problematic (as in #98629) when this const eval error happens in wfcheck (for example, due to normalizing the param-env of something that references this const). Since this happens sooner than the check that an impl actually provides all of the items that a trait requires (which happens during later typecheck), we end up aborting compilation early with only this un-informative message. I'm not exactly sure _why_ this bug arises due to #96591 -- perhaps valtrees are evaluated more eagerly than in the old system? r? ``@oli-obk`` or ``@lcnr`` since y'all are familiar with const eval and reviewed #96591, though feel free to reassign. This is a regression from stable to beta, so I would be open to considering this for beta backport. It seems correct to me, especially given the improvements in the other UI tests this PR touches, but may have some side-effects that I'm unaware of...?
2022-07-23Rollup merge of #99580 - fmease:fix-issue-99565, r=estebankMatthias Krüger-3/+3
Don't suggest unnameable generic arguments Fixes #99565. `@rustbot` label T-compiler A-diagnostics r? `@rust-lang/wg-diagnostics`
2022-07-22Do not resolve associated const when there is no provided valueMichael Goulet-3/+12
2022-07-22Auto merge of #99521 - fee1-dead-contrib:const_fix_hax, r=oli-obkbors-48/+29
Fix hack that remaps env constness. WARNING: might have perf implications. Are there any more problems with having a constness in the `ParamEnv` now? :) r? `@oli-obk`
2022-07-22Rollup merge of #99539 - compiler-errors:bidirectional-block-suggestions, ↵Dylan DPC-2/+1
r=fee1-dead Improve suggestions for returning binding Fixes #99525 Also reworks the cause codes for match and if a bit, I think cleaning them up in a positive way. We no longer need to call `could_remove_semicolon` in successful code, which might save a few cycles?