about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2022-09-08Rollup merge of #101424 - compiler-errors:operator-err-sugg, r=TaKO8KiDylan DPC-12/+14
Adjust and slightly generalize operator error suggestion (in no particular order) * Stop passing around a whole extra `ProjectionPredicate` * Add spaces around `=` in `Trait<..., Output = Ty>` suggestion * Some code clean-ups, including * add `lang_item_for_op` to turn a `Op` into a `DefId` * avoid `SourceMap` because we don't really need to render an expr * Remove `TypeParamVisitor` in favor of just checking `ty.has_param_types_or_consts` -- this acts a bit differently, but shouldn't cause erroneous suggestions (actually might generalize them a bit) * We now suggest `Output = Ty` in the `where` clause suggestion when we fail to add `Struct<T>` and `T`. I can split this out into more PRs if needed, but they're all just miscellaneous generalizations, changes, and nitpicks I saw when messing with this operator code.
2022-09-08Auto merge of #98900 - lcnr:region-stuff, r=jackh726bors-13/+54
const_generics: correctly deal with bound variables removes the hack in `resolve` which was needed because we evaluated constants without caring about their bound variables. Each commit should be fairly self-contained, even if they build on each other r? `@jackh726`
2022-09-08don't evaluate with escaping bound varslcnr-13/+54
2022-09-08stop evaluating constants in `Relate`lcnr-1/+1
2022-09-08Rollup merge of #101498 - petrochenkov:visparam, r=cjgillotDylan DPC-3/+1
rustc: Parameterize `ty::Visibility` over used ID It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-09-08Adjust spacing in suggestion, add a testMichael Goulet-2/+2
2022-09-08Add associated item binding to non-param-ty where clause suggestionsMichael Goulet-11/+13
2022-09-07Rollup merge of #101503 - spastorino:add-debug-calls, r=compiler-errorsMatthias Krüger-0/+3
Add debug calls `@oli-obk` requested this and other changes as a way of simplifying https://github.com/rust-lang/rust/pull/101345. This is just going to make the diff of https://github.com/rust-lang/rust/pull/101345 smaller. r? `@oli-obk` `@cjgillot`
2022-09-07Auto merge of #101432 - nnethercote:shrink-PredicateS, r=lcnrbors-6/+6
Shrink `PredicateS` r? `@ghost`
2022-09-07Add instrument and debug callsSantiago Pastorino-0/+3
2022-09-07rustc: Parameterize `ty::Visibility` over used IDVadim Petrochenkov-3/+1
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-09-06Rollup merge of #101434 - ↵Guillaume Gomez-4/+4
JhonnyBillM:replace-session-for-handler-in-into-diagnostic, r=davidtwco Update `SessionDiagnostic::into_diagnostic` to take `Handler` instead of `ParseSess` Suggested by the team in [this Zulip Topic](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20SessionDiagnostic.20on.20Handler). `Handler` already has almost all the capabilities of `ParseSess` when it comes to diagnostic emission, in this migration we only needed to add the ability to access `source_map` from the emitter in order to get a `Snippet` and the `start_point`. Not sure if adding these two methods [`span_to_snippet_from_emitter` and `span_start_point_from_emitter`] is the best way to address this gap. P.S. If this goes in the right direction, then we probably may want to move `SessionDiagnostic` to `rustc_errors` and rename it to `DiagnosticHandler` or something similar. r? `@davidtwco` r? `@compiler-errors`
2022-09-06Auto merge of #101359 - ↵bors-0/+17
compiler-errors:cannot-call-trait-object-with-unsized-return, r=lcnr Point out when a callable is not actually callable because its return is not sized Fixes #100755 I didn't add a UI test for that one because it's equivalent to the UI test that already exists in the suite.
2022-09-06Auto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillotbors-1/+1
`BindingAnnotation` refactor * `ast::BindingMode` is deleted and replaced with `hir::BindingAnnotation` (which is moved to `ast`) * `BindingAnnotation` is changed from an enum to a tuple struct e.g. `BindingAnnotation(ByRef::No, Mutability::Mut)` * Associated constants added for convenience `BindingAnnotation::{NONE, REF, MUT, REF_MUT}` One goal is to make it more clear that `BindingAnnotation` merely represents syntax `ref mut` and not the actual binding mode. This was especially confusing since we had `ast::BindingMode`->`hir::BindingAnnotation`->`thir::BindingMode`. I wish there were more symmetry between `ByRef` and `Mutability` (variant) naming (maybe `Mutable::Yes`?), and I also don't love how long the name `BindingAnnotation` is, but this seems like the best compromise. Ideas welcome.
2022-09-05Point out when a callable is not actually callable because its return is not ↵Michael Goulet-0/+17
sized
2022-09-05UPDATE - into_diagnostic to take a Handler instead of a ParseSessJhonny Bill Mena-4/+4
Suggested by the team in this Zulip Topic https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20SessionDiagnostic.20on.20Handler Handler already has almost all the capabilities of ParseSess when it comes to diagnostic emission, in this migration we only needed to add the ability to access source_map from the emitter in order to get a Snippet and the start_point. Not sure if this is the best way to address this gap
2022-09-05Pack `Term` in the same way as `GenericArg`.Nicholas Nethercote-6/+6
This shrinks the `PredicateS` type, which is instanted frequently.
2022-09-05Make `hir::PathSegment::res` non-optional.Nicholas Nethercote-2/+2
2022-09-04Auto merge of #101296 - compiler-errors:head-span-for-enclosing-scope, r=oli-obkbors-19/+15
Use head span for `rustc_on_unimplemented`'s `enclosing_scope` attr This may make #101281 slightly easier to understand
2022-09-04Auto merge of #100726 - jswrenn:transmute, r=oli-obkbors-16/+4
safe transmute: use `Assume` struct to provide analysis options This task was left as a TODO in #92268; resolving it brings [`BikeshedIntrinsicFrom`](https://doc.rust-lang.org/nightly/core/mem/trait.BikeshedIntrinsicFrom.html) more in line with the API defined in [MCP411](https://github.com/rust-lang/compiler-team/issues/411). **Before:** ```rust pub unsafe trait BikeshedIntrinsicFrom< Src, Context, const ASSUME_ALIGNMENT: bool, const ASSUME_LIFETIMES: bool, const ASSUME_VALIDITY: bool, const ASSUME_VISIBILITY: bool, > where Src: ?Sized, {} ``` **After:** ```rust pub unsafe trait BikeshedIntrinsicFrom<Src, Context, const ASSUME: Assume = { Assume::NOTHING }> where Src: ?Sized, {} ``` `Assume::visibility` has also been renamed to `Assume::safety`, as library safety invariants are what's actually being assumed; visibility is just the mechanism by which it is currently checked (and that may change). r? `@oli-obk` --- Related: - https://github.com/rust-lang/compiler-team/issues/411 - https://github.com/rust-lang/rust/issues/99571
2022-09-04Address nits, rename enclosing_scope => parent_labelMichael Goulet-19/+15
2022-09-04Use head span for rustc_on_unimplemented's enclosing_scope attrMichael Goulet-1/+1
2022-09-04Rollup merge of #100647 - obeis:issue-99875, r=nagisaMatthias Krüger-7/+30
Make trait bound not satisfied specify kind Closes #99875
2022-09-02Refactor and re-use BindingAnnotationCameron Steffen-1/+1
2022-09-02Rollup merge of #100814 - gabrielBusta:port_trait_selection_diagnostics, ↵Matthias Krüger-87/+135
r=davidtwco Porting 'compiler/rustc_trait_selection' to translatable diagnostics - Part 1 ``@rustbot`` label +A-translation r? rust-lang/diagnostics cc #100717
2022-09-01Porting 'compiler/rustc_trait_selection' to translatable diagnostics - Part 1Gabriel Bustamante-87/+135
2022-09-01tracing::instrument cleanupOli Scherer-34/+22
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+1
by module
2022-09-01Directly use the `instrument` macro instead of its full pathOli Scherer-12/+12
2022-08-30Stabilize GATsJack Huey-2/+0
2022-08-30Rollup merge of #100473 - compiler-errors:normalize-the-fn-def-sig-plz, r=lcnrDylan DPC-12/+30
Attempt to normalize `FnDef` signature in `InferCtxt::cmp` Stashes a normalization callback in `InferCtxt` so that the signature we get from `tcx.fn_sig(..).subst(..)` in `InferCtxt::cmp` can be properly normalized, since we cannot expect for it to have normalized types since it comes straight from astconv. This is kind of a hack, but I will say that `@jyn514` found the fact that we present unnormalized types to be very confusing in real life code, and I agree with that feeling. Though altogether I am still a bit unsure about whether this PR is worth the effort, so I'm open to alternatives and/or just closing it outright. On the other hand, this isn't a ridiculously heavy implementation anyways -- it's less than a hundred lines of changes, and half of that is just miscellaneous cleanup. This is stacked onto #100471 which is basically unrelated, and it can be rebased off of that when that lands or if needed. --- The code: ```rust trait Foo { type Bar; } impl<T> Foo for T { type Bar = i32; } fn foo<T>(_: <T as Foo>::Bar) {} fn needs_i32_ref_fn(f: fn(&'static i32)) {} fn main() { needs_i32_ref_fn(foo::<()>); } ``` Before: ``` = note: expected fn pointer `fn(&'static i32)` found fn item `fn(<() as Foo>::Bar) {foo::<()>}` ``` After: ``` = note: expected fn pointer `fn(&'static i32)` found fn item `fn(i32) {foo::<()>}` ```
2022-08-30Auto merge of #101183 - Dylan-DPC:rollup-6kewixv, r=Dylan-DPCbors-4/+8
Rollup of 9 pull requests Successful merges: - #95376 (Add `vec::Drain{,Filter}::keep_rest`) - #100092 (Fall back when relating two opaques by substs in MIR typeck) - #101019 (Suggest returning closure as `impl Fn`) - #101022 (Erase late bound regions before comparing types in `suggest_dereferences`) - #101101 (interpret: make read-pointer-as-bytes a CTFE-only error with extra information) - #101123 (Remove `register_attr` feature) - #101175 (Don't --bless in pre-push hook) - #101176 (rustdoc: remove unused CSS selectors for `.table-display`) - #101180 (Add another MaybeUninit array test with const) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-30Rollup merge of #101022 - compiler-errors:issue-101020, r=jackh726Dylan DPC-4/+8
Erase late bound regions before comparing types in `suggest_dereferences` Fixes #101020
2022-08-29Revert let_chains stabilizationNilstrieb-0/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. This is the revert against master, the beta revert was already done in #100538.
2022-08-29Make the trait bound is not satisfied specify kindObei Sideg-7/+30
2022-08-29Auto merge of #98626 - oli-obk:tracing, r=lcnrbors-0/+1
bump tracing version Bump tracing dependency to 0.1.35 to give us features like printing the return value of functions
2022-08-29Rollup merge of #100437 - compiler-errors:better-const-mismatch-err, r=oli-obkMatthias Krüger-3/+18
Improve const mismatch `FulfillmentError` Fixes #100414
2022-08-28Auto merge of #100497 - kadiwa4:remove_clone_into_iter, r=cjgillotbors-1/+1
Avoid cloning a collection only to iterate over it `@rustbot` label: +C-cleanup
2022-08-27Auto merge of #100989 - lcnr:implied-bounds-uwu, r=spastorinobors-1/+12
no unnormalized types for implied bounds outside borrowck fixes #100910 - introduced in https://github.com/rust-lang/rust/pull/100676 - by only considering normalized types for wf. r? types
2022-08-26Don't catch overflow when running with cargo docouz-a-1/+4
2022-08-26Auto merge of #100705 - compiler-errors:issue-100620, r=oli-obkbors-3/+10
Avoid reporting overflow in `is_impossible_method` Fixes #100620 We're evaluating a new predicate in a different param-env than it was checked during typeck, so be more careful about handling overflow errors. Instead of using `FulfillmentCtxt`, using `InferCtxt::evaluate_obligation` by itself will give us back the overflow error, so we can throw it away properly. This may give us more false-positives, but it doesn't regress the `<HashMap as Iterator>::rev` example that originally motivated adding `is_impossible_method` in the first place.
2022-08-26Erase late bound regions before comparing types in suggest_dereferencesMichael Goulet-4/+8
2022-08-26Add and use ObligationCtxt::new_in_snapshotMichael Goulet-0/+13
2022-08-25Use real inference variable in build_fn_sig_tyMichael Goulet-9/+16
2022-08-25Don't create an extra infcx in report_closure_arg_mismatchMichael Goulet-3/+1
2022-08-25no unnormalized types for implied boundslcnr-1/+12
2022-08-25Rollup merge of #99332 - jyn514:stabilize-label-break-value, r=petrochenkovYuki Okushi-1/+1
Stabilize `#![feature(label_break_value)]` See the stabilization report in https://github.com/rust-lang/rust/issues/48594#issuecomment-1186213313.
2022-08-24Use ExprItemObligation and ExprBindingObligation tooMichael Goulet-1/+3
2022-08-24Note binding obligation causes for const equate errorsMichael Goulet-3/+16
2022-08-24Rollup merge of #100888 - ↵Matthias Krüger-11/+146
spastorino:coherence-negative-impls-implied-bounds, r=lcnr Coherence negative impls implied bounds Fixes #93875 This PR is rebased on top of #100789 and it would need to include that one which is already r+ed. r? ``@nikomatsakis`` cc ``@lcnr`` (which I've talked about https://github.com/rust-lang/rust/commit/3222f420d9d2312efe0735eb48160c7b070adc54, I guess after you finish your reordering of modules and work with OutlivesEnvironmentEnv this commit can just be reverted).