about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2022-07-27Initial (incomplete) implementation of transmutability trait.Jack Wrenn-0/+79
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?
2022-07-22Don't suggest unnameable generic argumentsLeón Orell Valerian Liehr-3/+3
2022-07-21Auto merge of #99501 - lcnr:check-regions-infcx, r=oli-obkbors-98/+32
move `considering_regions` to the infcx it seems weird to prove some obligations which constrain inference vars while ignoring regions in a context which considers regions. This is especially weird because even for a fulfillment context with ignored regions, we still added region outlives bounds when directly relating regions. tbh our handling of regions is still very weird, but at least this is a step in the right direction imo. r? rust-lang/types
2022-07-21Rollup merge of #99558 - fee1-dead-contrib:remap_constness_fix, r=oli-obkMatthias Krüger-3/+3
Fix `remap_constness` `~const Drop` was renamed to `~const Destruct` and this special case should be removed
2022-07-21Rollup merge of #99552 - lcnr:orphan_check-rework, r=oli-obkMatthias Krüger-196/+123
Rewrite `orphan_check_trait_ref` to use a `TypeVisitor` The current impl is far more confusing than it has any right to be :sparkles: r? rust-lang/types
2022-07-21Rollup merge of #99528 - matthiaskrgr:2022_07_perf, r=estebankMatthias Krüger-2/+2
couple of clippy::perf fixes
2022-07-21Fix `remap_constness`Deadbeef-3/+3
`~const Drop` was renamed to `~const Destruct` and this special case should be removed
2022-07-21`region_outlives_predicate` no snapshotlcnr-29/+7
2022-07-21move `considering_regions` to the infcxlcnr-77/+33
2022-07-21rewrite the orphan check to use a type visitorlcnr-169/+124
2022-07-21orphan check: opaque types are an errorlcnr-29/+1
2022-07-21change `map_bound(|_| x` to `rebind(x`Deadbeef-2/+2
2022-07-21Resolve vars in same_type_modulo_inferMichael Goulet-2/+1
2022-07-20Fix hack that remaps env constness.Deadbeef-46/+27
WARNING: might have perf implications. Are there any more problems with having a constness in the `ParamEnv` now? :)
2022-07-20no leak_check -> commit_unconditionally is nooplcnr-186/+167
2022-07-20clippy::perf fixesMatthias Krüger-2/+2
2022-07-20take opaq typesouz-a-3/+6
2022-07-19Rollup merge of #99401 - TaKO8Ki:avoid-symbol-to-&str-conversions, r=nnethercoteMatthias Krüger-2/+2
Avoid `Symbol` to `&str` conversions `Symbol::as_str` is a slowish operation, so this patch removes some usages of it.
2022-07-19Rollup merge of #98028 - aticu:master, r=estebankMatthias Krüger-0/+92
Add E0790 as more specific variant of E0283 Fixes #81701 I think this should be good to go, there are only two things where I am somewhat unsure: - Is there a better way to get the fully-qualified path for the suggestion? I tried `self.tcx.def_path_str`, but that didn't seem to always give a correct path for the context. - Should all this be extracted into it's own method or is it fine where it is? r? `@estebank`
2022-07-19Add E0790 as more specific variant of E0283aticu-0/+92
2022-07-18Check generators for well formednessOli Scherer-9/+10
2022-07-18Auto merge of #99232 - lcnr:no-bound-vars-check, r=jackh726bors-2/+5
`replace_bound_vars` fast path: check predicates, don't check consts split out from #98900 `ty::Const` doesn't have precomputed type flags, so computing `has_vars_bound_at_or_above` for constants requires us to visit the const and its contained types and constants. A noop fold should be pretty much equally as fast so removing it prevents us from walking the constant twice in case it contains bound vars. r? `@jackh726`
2022-07-18Auto merge of #99181 - lcnr:arenaGTrc, r=wesleywiserbors-10/+11
`arena > Rc` for query results The `Rc`s have to live for the whole duration as their count cannot go below 1 while stored as part of the query results. By storing them in an arena we should save a bit of memory because we don't have as many independent allocations and also don't have to clone the `Rc` anymore.
2022-07-18avoid `Symbol` to `&str` conversionsTakayuki Maeda-2/+2
2022-07-18Auto merge of #99137 - jackh726:wf-no-infcx, r=estebankbors-58/+46
Don't pass InferCtxt to WfPredicates Simple cleanup. Infer vars will get passed up as obligations and shallowed resolved later. This actually improves one test output.
2022-07-16Stabilize `let_chains`Caio-1/+1
2022-07-16Rollup merge of #99290 - compiler-errors:revert-98794, r=lcnrMatthias Krüger-71/+13
Revert "Highlight conflicting param-env candidates" This reverts #98794, commit 08135254dcf22be0d5661ea8f75e703b29a83514. Seems to have caused an incremental compilation bug. The root cause of the incr comp bug is somewhat unrelated but is triggered by this PR, so I don't feel comfortable with having this PR in the codebase until it can be investigated further. Fixes #99233.
2022-07-15Fix suggestion regression with incorrect syntactic combination of trait boundsWill Crichton-1/+13