about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
2023-10-16address review commentEsteban Küber-90/+125
2023-10-16Make `rustc_onunimplemented` export path agnosticNilstrieb-4/+7
This makes it so that all the matchers that match against paths use the definition path instead of the export path. This removes all duplication around `std`/`alloc`/`core`. This is not necessarily optimal because we now depend on internal implementation details like `core::ops::control_flow::ControlFlow`, which is not very nice and probably not acceptable for a stable `on_unimplemented`. An alternative would be to just string-replace normalize away `alloc`/`core` to `std` as a special case, keeping the export paths but making it so that we're still fully standard library flavor agnostic.
2023-10-16Rollup merge of #116257 - estebank:issue-101351, r=b-naberMatthias Krüger-1/+1
Suggest trait bounds for used associated type on type param Fix #101351. When an associated type on a type parameter is used, and the type parameter isn't constrained by the correct trait, suggest the appropriate trait bound: ``` error[E0220]: associated type `Associated` not found for `T` --> file.rs:6:15 | 6 | field: T::Associated, | ^^^^^^^^^^ there is a similarly named associated type `Associated` in the trait `Foo` | help: consider restricting type parameter `T` | 5 | struct Generic<T: Foo> { | +++++ ``` When an associated type on a type parameter has a typo, suggest fixing it: ``` error[E0220]: associated type `Baa` not found for `T` --> $DIR/issue-55673.rs:9:8 | LL | T::Baa: std::fmt::Debug, | ^^^ there is a similarly named associated type `Bar` in the trait `Foo` | help: change the associated type name to use `Bar` from `Foo` | LL | T::Bar: std::fmt::Debug, | ~~~ ```
2023-10-16Rollup merge of #115196 - chenyukang:yukang-fix-86094, r=estebankMatthias Krüger-4/+4
Suggest adding `return` if the for semi which can coerce to the fn return type Fixes #86094 r? `@estebank`
2023-10-15Suggest adding `return` if the type of unused semi return value can coerce ↵yukang-4/+4
to the fn return type
2023-10-15Auto merge of #116688 - compiler-errors:rustfmt-up, r=WaffleLapkin,Nilstriebbors-139/+182
Format all the let-chains in compiler crates Since rust-lang/rustfmt#5910 has landed, soon we will have support for formatting let-chains (as soon as rustfmt syncs and beta gets bumped). This PR applies the changes [from master rustfmt to rust-lang/rust eagerly](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/out.20formatting.20of.20prs/near/374997516), so that the next beta bump does not have to deal with a 200+ file diff and can remain concerned with other things like `cfg(bootstrap)` -- #113637 was a pain to land, for example, because of let-else. I will also add this commit to the ignore list after it has landed. The commands that were run -- I'm not great at bash-foo, but this applies rustfmt to every compiler crate, and then reverts the two crates that should probably be formatted out-of-tree. ``` ~/rustfmt $ ls -1d ~/rust/compiler/* | xargs -I@ cargo run --bin rustfmt -- `@/src/lib.rs` --config-path ~/rust --edition=2021 # format all of the compiler crates ~/rust $ git checkout HEAD -- compiler/rustc_codegen_{gcc,cranelift} # revert changes to cg-gcc and cg-clif ``` cc `@rust-lang/rustfmt` r? `@WaffleLapkin` or `@Nilstrieb` who said they may be able to review this purely mechanical PR :> cc `@Mark-Simulacrum` and `@petrochenkov,` who had some thoughts on the order of operations with big formatting changes in https://github.com/rust-lang/rust/pull/95262#issue-1178993801. I think the situation has changed since then, given that let-chains support exists on master rustfmt now, and I'm fairly confident that this formatting PR should land even if *bootstrap* rustfmt doesn't yet format let-chains in order to lessen the burden of the next beta bump.
2023-10-14Special case iterator chain checks for suggestionEsteban Küber-1/+91
When encountering method call chains of `Iterator`, check for trailing `;` in the body of closures passed into `Iterator::map`, as well as calls to `<T as Clone>::clone` when `T` is a type param and `T: !Clone`. Fix #9082.
2023-10-13Suggest trait bounds for used associated type on type paramEsteban Küber-1/+1
Fix #101351. When an associated type on a type parameter is used, and the type parameter isn't constrained by the correct trait, suggest the appropriate trait bound: ``` error[E0220]: associated type `Associated` not found for `T` --> file.rs:6:15 | 6 | field: T::Associated, | ^^^^^^^^^^ there is a similarly named associated type `Associated` in the trait `Foo` | help: consider restricting type parameter `T` | 5 | struct Generic<T: Foo> { | +++++ ``` When an associated type on a type parameter has a typo, suggest fixing it: ``` error[E0220]: associated type `Baa` not found for `T` --> $DIR/issue-55673.rs:9:8 | LL | T::Baa: std::fmt::Debug, | ^^^ there is a similarly named associated type `Bar` in the trait `Foo` | help: change the associated type name to use `Bar` from `Foo` | LL | T::Bar: std::fmt::Debug, | ~~~ ```
2023-10-13explicitly handle auto trait leakage in coherencelcnr-14/+19
2023-10-13Format all the let chains in compilerMichael Goulet-139/+182
2023-10-11Handle several `#[diagnostic::on_unimplemented]` attributes correctlyGeorg Semmler-12/+34
This PR fixes an issues where rustc would ignore subsequent `#[diagnostic::on_unimplemented]` attributes. The [corresponding RFC](https://rust-lang.github.io/rfcs/3368-diagnostic-attribute-namespace.html) specifies that the first matching instance of each option is used. Invalid attributes are linted and otherwise ignored.
2023-10-09Move predicate error early check to its own methodEsteban Küber-14/+23
2023-10-09Remove need for `has_errors()` checkEsteban Küber-7/+12
2023-10-09Only emit one error per unsized binding, instead of one per usageEsteban Küber-0/+19
Fix #56607.
2023-10-08delay a bug when encountering an ambiguity in MIR typeckAli MJ Al-Nasrawy-4/+12
2023-10-06Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiserbors-3476/+3562
Show more information when multiple `impl`s apply - When there are `impl`s without type params, show only those (to avoid showing overly generic `impl`s). ``` error[E0283]: type annotations needed --> $DIR/multiple-impl-apply.rs:34:9 | LL | let y = x.into(); | ^ ---- type must be known at this point | note: multiple `impl`s satisfying `_: From<Baz>` found --> $DIR/multiple-impl-apply.rs:14:1 | LL | impl From<Baz> for Bar { | ^^^^^^^^^^^^^^^^^^^^^^ ... LL | impl From<Baz> for Foo { | ^^^^^^^^^^^^^^^^^^^^^^ = note: required for `Baz` to implement `Into<_>` help: consider giving `y` an explicit type | LL | let y: /* Type */ = x.into(); | ++++++++++++ ``` - Lower the importance of `T: Sized`, `T: WellFormed` and coercion errors, to prioritize more relevant errors. The pre-existing deduplication logic deals with hiding redundant errors better that way, and we show errors with more metadata that is useful to the user. - Show `<SelfTy as Trait>::assoc_fn` suggestion in more cases. ``` error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> $DIR/cross-return-site-inference.rs:38:16 | LL | return Err(From::from("foo")); | ^^^^^^^^^^ cannot call associated function of trait | help: use a fully-qualified path to a specific available implementation | LL | return Err(</* self type */ as From>::from("foo")); | +++++++++++++++++++ + ``` Fix #88284.
2023-10-05Rollup merge of #116452 - cjgillot:noassert-erased, r=oli-obkMatthias Krüger-3/+0
Do not assert that hidden types don't have erased regions. cc https://github.com/rust-lang/rust/issues/116306 `args` can have erased regions. In the linked issue, this is reached by computing whether a large type is `Freeze` to compute its ABI. I do not have a minimized test to include.
2023-10-05Do not assert that hidden types don't have erased regions.Camille GILLOT-3/+0
2023-10-05Auto merge of #116184 - compiler-errors:afit-lint, r=tmandrybors-53/+69
Add `async_fn_in_trait` lint cc https://github.com/rust-lang/rust/pull/115822#issuecomment-1731168465 Mostly unsure what the messaging should be. Feedback required. r? `@tmandry`
2023-10-04Auto merge of #116370 - nnethercote:more-arena-stuff, r=cjgillotbors-1/+1
Remove the `TypedArena::alloc_from_iter` specialization. It was added in #78569. It's complicated and doesn't actually help performance. r? `@cjgillot`
2023-10-04Fix test on WASM target by making ambiguity pruning more agressiveEsteban Küber-1/+1
2023-10-04Split `traits::error_reporting` to keep files smallerEsteban Küber-3528/+3560
2023-10-04Show suggestion for `<SelfTy as Trait>::assoc_fn` in more cases and fmt codeEsteban Küber-19/+42
2023-10-04Reorder fullfillment errors to keep more interesting ones firstEsteban Küber-5/+21
In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed` and coercion errors to the end of the list. The pre-existing deduplication logic eliminates redundant errors better that way, keeping the resulting output with fewer errors than before, while also having more detail.
2023-10-04Show more information when multiple `impl` applyEsteban Küber-4/+19
2023-10-03Make non-zero check more obviousMaybe Waffle-1/+1
2023-10-03Rollup merge of #116261 - lcnr:wf-only-clause, r=davidtwcoMatthias Krüger-31/+23
a small wf and clause cleanup - remove `Clause::from_projection_clause`, instead use `ToPredicate` - change `predicate_obligations` to directly take a `Clause` - remove some unnecessary `&` - use clause in `min_specialization` checks where easily applicable
2023-10-03Auto merge of #116376 - matthiaskrgr:rollup-b3d14gq, r=matthiaskrgrbors-1/+2
Rollup of 5 pull requests Successful merges: - #115863 (Add check_unused_messages in tidy) - #116210 (Ensure that `~const` trait bounds on associated functions are in const traits or impls) - #116358 (Rename both of the `Match` relations) - #116371 (Remove unused features from `rustc_llvm`.) - #116374 (Print normalized ty) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-03Rollup merge of #116358 - compiler-errors:match, r=lcnrMatthias Krüger-1/+2
Rename both of the `Match` relations Both of these names kinda were ambiguous. r? lcnr
2023-10-03Auto merge of #115025 - ouz-a:ouz_testing, r=lcnrbors-0/+15
Make subtyping explicit in MIR This adds new mir-opt that pushes new `ProjectionElem` called `ProjectionElem::Subtype(T)` to `Rvalue` of a subtyped assignment so we can unsoundness issues like https://github.com/rust-lang/rust/issues/107205 Addresses https://github.com/rust-lang/rust/issues/112651 r? `@lcnr`
2023-10-03Optimize some `alloc_from_iter` call sites.Nicholas Nethercote-1/+1
There's no need to collect an iterator into a `Vec`, or to call `into_iter` at the call sites.
2023-10-03Add async_fn_in_trait lintMichael Goulet-53/+69
2023-10-02Point out the actual mismatch errorMichael Goulet-1/+14
2023-10-02For a single impl candidate, try to unify it with error trait refMichael Goulet-3/+75
2023-10-02Rename both of the Match relationsMichael Goulet-1/+2
2023-10-02change is_subtype to relate_typesouz-a-0/+15
2023-09-29a small wf and clause cleanuplcnr-31/+23
2023-09-27fix clippy::{redundant_guards, useless_format}Matthias Krüger-1/+1
2023-09-24Remove span from BrAnon.Camille GILLOT-4/+5
2023-09-24Remove dead code.Camille GILLOT-66/+8
2023-09-23Remove GeneratorWitness and rename GeneratorWitnessMIR.Camille GILLOT-65/+13
2023-09-23Enable drop_tracking_mir by default.Camille GILLOT-147/+44
2023-09-23Fold lifetimes before substitution.Camille GILLOT-14/+14
2023-09-23Check types live across yields in generators tooMichael Goulet-0/+7
2023-09-23Check that closure's by-value captures are sizedMichael Goulet-0/+11
2023-09-22Auto merge of #115920 - Zoxc:depkind-u16, r=cjgillotbors-2/+3
Move `DepKind` to `rustc_query_system` and define it as `u16` This moves the `DepKind` type to `rustc_query_system` where it's defined with an inner `u16` field. This decouples it from `rustc_middle` and is a step towards letting other crates define dep kinds. It also allows some type parameters to be removed. The `DepKind` trait is replaced with a `Deps` trait. That's used when some operations or information about dep kinds which is unavailable in `rustc_query_system` are still needed. r? `@cjgillot`
2023-09-21Auto merge of #115897 - eduardosm:check-fn-sig, r=compiler-errorsbors-0/+1
rustc_hir_analysis: add a helper to check function the signature mismatches This function is now used to check `#[panic_handler]`, `start` lang item, `main`, `#[start]` and intrinsic functions. The diagnosis produced are now closer to the ones produced by trait/impl method signature mismatch. This is the first time I do anything with rustc_hir_analysis/rustc_hir_typeck, so comments and suggestions about things I did wrong or that could be improved will be appreciated.
2023-09-21Suggest desugaring to RPITIT when AFIT is required to be an auto traitMichael Goulet-0/+137
2023-09-21Record asyncness span in HIRMichael Goulet-2/+4
2023-09-21Move `DepKind` to `rustc_query_system` and define it as `u16`John Kåre Alsaker-2/+3