about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
2021-08-26use `ty::Unevaluated` instead of def substs pairlcnr-47/+39
2021-08-26update `TypeFlags` to deal with missing ct substslcnr-11/+15
2021-08-26add `tcx` to `fn walk`lcnr-8/+9
2021-08-26make unevaluated const substs optionallcnr-18/+15
2021-08-26require a `tcx` for `TypeVisitor`lcnr-0/+6
2021-08-24Review commentsjackh726-39/+66
2021-08-24Normalize associated types with bound varsJack Huey-70/+115
2021-08-23Rollup merge of #88230 - steffahn:a_an, r=oli-obkMara Bos-8/+8
Fix typos “a”→“an” Fix typos in comments; found using a regex to find some easy instance of incorrect usage of a vs. an. While automation was used to find these, every change was checked manually. Changes in submodules get separate PRs: * https://github.com/rust-lang/stdarch/pull/1201 * https://github.com/rust-lang/cargo/pull/9821 * https://github.com/rust-lang/miri/pull/1874 * https://github.com/rust-lang/rls/pull/1746 * https://github.com/rust-analyzer/rust-analyzer/pull/9984 _folks @ rust-analyzer are fast at merging…_ * https://github.com/rust-analyzer/rust-analyzer/pull/9985 * https://github.com/rust-analyzer/rust-analyzer/pull/9987 * https://github.com/rust-analyzer/rust-analyzer/pull/9989 _For `clippy`, I don’t know if the changes should better better be moved to a PR to the original repo._ <hr> This has some overlap with #88226, but neither is a strict superset of the other. If you want multiple commits, I can split it up; in that case, make sure to suggest a criterion for splitting.
2021-08-22Auto merge of #88166 - BoxyUwU:const-equate-canon, r=lcnrbors-9/+2
canonicalize consts before calling try_unify_abstract_consts query Fixes #88022 Fixes #86953 Fixes #77708 Fixes #82034 Fixes #85031 these ICEs were all caused by calling the `try_unify_abstract_consts` query with inference vars in substs r? `@lcnr`
2021-08-22Fix typos “a”→“an”Frank Steffahn-8/+8
2021-08-22Auto merge of #88139 - lcnr:marker-trait-attr, r=nikomatsakisbors-3/+10
marker_traits: require `EvaluatedToOk` during winnowing closes #84955, while it doesn't really fix it in a way that makes me happy it should prevent the issue for now and this test can't be reproduced anyways, so it doesn't make much sense to keep it open. fixes #84917 as only one of the impls depends on regions, so we now drop the ambiguous one instead of the correct one. cc https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/winnowing.20soundly/near/247899832 r? `@nikomatsakis`
2021-08-21Auto merge of #88135 - crlf0710:trait_upcasting_part_3, r=nikomatsakisbors-101/+205
Trait upcasting coercion (part 3) By using separate candidates for each possible choice, this fixes type-checking issues in previous commits. r? `@nikomatsakis`
2021-08-21Auto merge of #88149 - Mark-Simulacrum:prep-never-type, r=jackh726bors-0/+55
Refactor fallback code to prepare for never type This PR contains cherry-picks of some of `@nikomatsakis's` work from #79366, and shouldn't (AFAICT) represent any change in behavior. However, the refactoring is good regardless of the never type work being landed, and will reduce the size of those eventual PR(s) (and rebase pain). I am not personally an expert on this code, and the commits are essentially 100% `@nikomatsakis's,` but they do seem reasonable to me by my understanding. Happy to edit with review, of course. Commits are best reviewed in sequence rather than all together. r? `@jackh726` perhaps?
2021-08-20Require a box expression's type to be SizedAnton Golov-0/+3
2021-08-19introduce a Coerce predicateNiko Matsakis-0/+55
2021-08-19move code to `InferCtxt` methodEllen-16/+2
2021-08-19canonicalize const equate predicatesEllen-9/+16
2021-08-20Add assertion to ensure the query doesn't get called before type infererence ↵Charles Lew-2/+2
is done.
2021-08-18Auto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakisbors-30/+38
Matthew's work on improving NLL's "higher-ranked subtype error"s This PR rebases `@matthewjasper's` [branch](https://github.com/matthewjasper/rust/tree/nll-hrtb-errors) which has great work to fix the obscure higher-ranked subtype errors that are tracked in #57374. These are a blocker to turning full NLLs on, and doing some internal cleanups to remove some of the old region code. The goal is so `@nikomatsakis` can take a look at this early, and I'll then do my best to help do the changes and followup work to land this work, and move closer to turning off the migration mode. I've only updated the branch and made it compile, removed a warning or two. r? `@nikomatsakis` (Here's the [zulip topic to discuss this](https://rust-lang.zulipchat.com/#narrow/stream/122657-t-compiler.2Fwg-nll/topic/.2357374.3A.20improving.20higher-ranked.20subtype.20errors.20via.20.2386700) that Niko wanted)
2021-08-18marker_traits: require `EvaluatedToOk`lcnr-3/+10
2021-08-18Fold `vtable_trait_upcasting_coercion_new_vptr_slot` logic into obligation ↵Charles Lew-45/+74
processing.
2021-08-18Properly generate multiple candidates for trait upcasting coercion.Charles Lew-63/+138
2021-08-17Auto merge of #87668 - estebank:tweak-bound-output, r=oli-obkbors-7/+8
Use note for pointing at bound introducing requirement Modify output for pointing where a trait bound obligation is introduced in an E0277 from using a span label to using a note in order to always preserve order of the output: Before: ``` error[E0277]: `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug` --> $DIR/bounds-on-assoc-in-trait.rs:18:28 | LL | type A: Iterator<Item: Debug>; | ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug` | ::: $SRC_DIR/core/src/fmt/mod.rs:LL:COL | LL | pub trait Debug { | --------------- required by this bound in `Debug` | = help: the trait `Debug` is not implemented for `<<Self as Case1>::A as Iterator>::Item` ``` After: ``` error[E0277]: `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug` --> $DIR/bounds-on-assoc-in-trait.rs:18:28 | LL | type A: Iterator<Item: Debug>; | ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for `<<Self as Case1>::A as Iterator>::Item` note: required by a bound in `Debug` --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL | LL | pub trait Debug { | ^^^^^^^^^^^^^^^ required by this bound in `Debug` ```
2021-08-16Use note to point at bound introducing requirementEsteban Küber-7/+8
2021-08-15Return the canonicalized query from type opsMatthew Jasper-30/+38
2021-08-14Assign FIXMEs to me and remove obsolete onesDeadbeef-1/+1
Also fixed capitalization of documentation
2021-08-13make check less conservative and add explanationDeadbeef-11/+24
2021-08-13Fix testsDeadbeef-2/+3
2021-08-13Fix assoc-type testDeadbeef-0/+9
2021-08-13Pass constness to SelectionContextDeadbeef-20/+71
2021-08-13Make selection and evaluation caches use constnessDeadbeef-30/+57
2021-08-13fmtDeadbeef-1/+2
2021-08-13fmtDeadbeef-2/+3
2021-08-13Filter non-const impls when we expect a const oneDeadbeef-6/+23
2021-08-13move Constness into TraitPredicateDeadbeef-30/+24
2021-08-09Do not ICE on HIR based WF check when involving lifetimesEsteban Küber-3/+4
Fix #87549.
2021-08-03Auto merge of #86400 - FabianWolff:issue-85735, r=estebankbors-0/+1
Remove invalid suggestion involving `Fn` trait bound This pull request closes #85735. The actual issue is a duplicate of #21974, but #85735 contains a further problem, which is an invalid suggestion if `Fn`/`FnMut`/`FnOnce` trait bounds are involved: The suggestion code checks whether the trait bound ends with `>` to determine whether it has any generic arguments, but the `Fn*` traits have a special syntax for generic arguments that doesn't involve angle brackets. The example given in #85735: ```rust trait Foo {} impl<'a, 'b, T> Foo for T where T: FnMut(&'a ()), T: FnMut(&'b ()), { } ``` currently produces: ``` error[E0283]: type annotations needed --> src/lib.rs:4:8 | 4 | T: FnMut(&'a ()), | ^^^^^^^^^^^^^ cannot infer type for type parameter `T` | = note: cannot satisfy `T: FnMut<(&'a (),)>` help: consider specifying the type arguments in the function call | 4 | T: FnMut(&'a ())::<Self, Args>, | ^^^^^^^^^^^^^^ error: aborting due to previous error ``` which is incorrect, because there is no function call, and applying the suggestion would lead to a parse error. With my changes, I get: ``` error[E0283]: type annotations needed --> test.rs:4:8 | 4 | T: FnMut(&'a ()), | ^^^^^^^^^^^^^ cannot infer type for type parameter `T` | ::: [...]/library/core/src/ops/function.rs:147:1 | 147 | pub trait FnMut<Args>: FnOnce<Args> { | ----------------------------------- required by this bound in `FnMut` | = note: cannot satisfy `T: FnMut<(&'a (),)>` error: aborting due to previous error ``` i.e. I have added a check to prevent the invalid suggestion from being issued for `Fn*` bounds, while the underlying issue #21974 remains for now.
2021-08-03Remove invalid suggestion involving Fn trait boundFabian Wolff-0/+1
2021-08-03Auto merge of #87515 - crlf0710:trait_upcasting_part2, r=bjorn3bors-7/+9
Trait upcasting coercion (part2) This is the second part of trait upcasting coercion implementation. Currently this is blocked on #86264 . The third part might be implemented using unsafety checking r? `@bjorn3`
2021-08-03Do not suggest impl traits as type argumentsYuki Okushi-0/+1
2021-08-03Implement pointer casting.Charles Lew-7/+9
2021-08-01Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisabors-10/+5
more clippy::complexity fixes (also a couple of clippy::perf fixes)
2021-07-31Auto merge of #86264 - crlf0710:trait_upcasting_part1, r=nikomatsakisbors-20/+56
Trait upcasting coercion (part1) This revives the first part of earlier PR #60900 . It's not very clear to me which parts of that pr was design decisions, so i decide to cut it into pieces and land them incrementally. This allows more eyes on the details. This is the first part, it adds feature gates, adds feature gates tests, and implemented the unsize conversion part. (I hope i have dealt with the `ExistentialTraitRef` values correctly...) The next part will be implementing the pointer casting.
2021-07-31Implement trait upcasting coercion type-checking.Charles Lew-20/+56
2021-07-30Use multispan suggestions more oftenEsteban Küber-6/+9
* Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often
2021-07-28Fix ICE in `diagnostic_hir_wf_check`Fabian Wolff-2/+2
2021-07-25clippy::filter_nextMatthias Krüger-7/+3
2021-07-25use vec![] macro to create Vector with first item inside instead of pushing ↵Matthias Krüger-3/+2
to an empty vec![] slightly reduces code bloat
2021-07-24Auto merge of #86461 - crlf0710:rich_vtable, r=nikomatsakisbors-58/+319
Refactor vtable format for upcoming trait_upcasting feature. This modifies vtable format: 1. reordering occurrence order of methods coming from different traits 2. include `VPtr`s for supertraits where this vtable cannot be directly reused during trait upcasting. Also, during codegen, the vtables corresponding to these newly included `VPtr` will be requested and generated. For the cases where this vtable can directly used, now the super trait vtable has exactly the same content to some prefix of this one. r? `@bjorn3` cc `@RalfJung` cc `@rust-lang/wg-traits`
2021-07-24Rollup merge of #87322 - chazkiker2:fix/suggestion-ref-sync-send, r=estebankYuki Okushi-5/+30
fix: clarify suggestion that `&T` must refer to `T: Sync` for `&T: Send` ### Description - [x] fix #86507 - [x] add UI test for relevant code from issue - [x] change `rustc_trait_selection/src/traits/error_reporting/suggestions.rs` to include a more clear suggestion when `&T` fails to satisfy `Send` bounds due to the fact that `T` fails to implement `Sync` - [x] update UI test in Clippy: `src/tools/tests/ui/future_not_send.stderr`