summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2022-08-30Auto merge of #99860 - oli-obk:revert_97346, r=pnkfelixbors-4/+14
Revert "Rollup merge of #97346 - JohnTitor:remove-back-compat-hacks, … …r=oli-obk" This reverts commit c703d11dccb4a895c7aead3b2fcd8cea8c483184, reversing changes made to 64eb9ab869bc3f9ef3645302fbf22e706eea16cf. it didn't apply cleanly, so now it works the same for RPIT and for TAIT instead of just working for RPIT, but we should keep those in sync anyway. It also exposed a TAIT bug (see the feature gated test that now ICEs). r? `@pnkfelix` fixes #99536
2022-08-15Revert let_chains stabilizationNilstrieb-1/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. It was discovered that they are not implemented correctly, which does not make them ready for stabilization.
2022-08-04Rollup merge of #100095 - jackh726:early-binder, r=lcnrMatthias Krüger-15/+19
More EarlyBinder cleanups Each commit is independent r? types
2022-08-03Rollup merge of #99795 - ↵Matthias Krüger-4/+6
compiler-errors:delay-specialization-normalize-error, r=spastorino Delay a bug when failed to normalize trait ref during specialization The error messages still kinda suck here but they don't ICE anymore... Fixes #45814 Fixes #43037 r? types
2022-08-03Rollup merge of #99746 - compiler-errors:more-trait-engine, r=jackh726Matthias Krüger-12/+14
Use `TraitEngine` in more places that don't specifically need `FulfillmentContext::new_in_snapshot` Not sure if this change is worthwhile, but couldn't hurt re: chalkification r? types
2022-08-03Add bound_impl_subject and bound_return_tyJack Huey-9/+9
2022-08-03Change sized_constraints to return EarlyBinderJack Huey-1/+5
2022-08-02Add bound_predicates_of and bound_explicit_predicates_ofJack Huey-5/+5
2022-08-03Auto merge of #99509 - lcnr:commit_unconditionally, r=jackh726bors-186/+167
remove `commit_unconditionally` `commit_unconditionally` is a noop unless we somehow inspect the current state of our snapshot. The only thing which does that is the leak check which was only used in one place where `commit_if_ok` is probably at least as, or even more, correct. r? rust-lang/types
2022-08-03Delay a bug when failed to normalize trait ref during specializationMichael Goulet-4/+6
2022-08-02Auto merge of #92268 - jswrenn:transmute, r=oli-obkbors-0/+77
Initial implementation of transmutability trait. *T'was the night before Christmas and all through the codebase, not a miri was stirring — no hint of `unsafe`!* This PR provides an initial, **incomplete** implementation of *[MCP 411: Lang Item for Transmutability](https://github.com/rust-lang/compiler-team/issues/411)*. The `core::mem::BikeshedIntrinsicFrom` trait provided by this PR is implemented on-the-fly by the compiler for types `Src` and `Dst` when the bits of all possible values of type `Src` are safely reinterpretable as a value of type `Dst`. What this PR provides is: - [x] [support for transmutations involving primitives](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/primitives) - [x] [support for transmutations involving arrays](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/arrays) - [x] [support for transmutations involving structs](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/structs) - [x] [support for transmutations involving enums](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/enums) - [x] [support for transmutations involving unions](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/unions) - [x] [support for weaker validity checks](https://github.com/jswrenn/rust/blob/transmute/src/test/ui/transmutability/unions/should_permit_intersecting_if_validity_is_assumed.rs) (i.e., `Assume::VALIDITY`) - [x] visibility checking What isn't yet implemented: - [ ] transmutability options passed using the `Assume` struct - [ ] [support for references](https://github.com/jswrenn/rust/blob/transmute/src/test/ui/transmutability/references.rs) - [ ] smarter error messages These features will be implemented in future PRs.
2022-08-02Auto merge of #100063 - matthiaskrgr:rollup-lznouys, r=matthiaskrgrbors-2/+2
Rollup of 7 pull requests Successful merges: - #99987 (Always include a position span in `rustc_parse_format::Argument`) - #100005 (Remove Clean trait for ast::Attribute and improve Attributes::from_ast) - #100025 (Remove redundant `TransferWrapper` struct) - #100045 (Properly reject the `may_unwind` option in `global_asm!`) - #100052 (RISC-V ASM test: relax label name constraint.) - #100053 (move [`assertions_on_result_states`] to restriction) - #100057 (Remove more Clean trait implementations) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-02Rollup merge of #99987 - Alexendoo:parse-format-position-span, r=fee1-deadMatthias Krüger-2/+2
Always include a position span in `rustc_parse_format::Argument` Moves the spans from the `Position` enum to always be included in the `Argument` struct. Doesn't make any changes to use it in rustc, but it will be useful for some upcoming Clippy lints
2022-08-02Auto merge of #100032 - BoxyUwU:no_ty_in_placeholder_const, r=compiler-errorsbors-4/+1
make `PlaceholderConst` not store the type of the const Currently the `Placeholder` variant on `ConstKind` is 28 bytes when with this PR its 8 bytes, i am not sure this is really useful at all rn since `Unevaluated` and `Value` variants are huge still but eventually it should be possible to get both down to 16 bytes :thinking:. Mostly opening this to see if this change has any perf impact when done before it can make `ConstKind`/`ConstS` smaller
2022-08-02Rollup merge of #99156 - lcnr:omoe-wa, r=wesleywiserMatthias Krüger-2/+0
`codegen_fulfill_obligation` expect erased regions it's a query, so by erasing regions before calling it, we get better caching. This doesn't actually change anything as its already the status quo.
2022-08-01Remove trait_of_item query.Camille GILLOT-1/+1
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-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-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