about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
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-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-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-73/+27
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-73/+27
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-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-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-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/+145
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).
2022-08-23Rollup merge of #100368 - chenyukang:fix-100321, r=lcnrDylan DPC-3/+0
InferCtxt tainted_by_errors_flag should be Option<ErrorGuaranteed> Fixes #100321. Use Cell<Option<ErrorGuaranteed>> to guarantee that we emit an error when that flag is set.
2022-08-23Use CRATE_HIR_ID and CRATE_DEF_ID for obligations from foreign cratesSantiago Pastorino-11/+13
2022-08-23Do not use unneeded extra errors variableSantiago Pastorino-2/+1
2022-08-23Permit negative impls coherence to take advantage of implied boundsSantiago Pastorino-8/+26
2022-08-23Move InferCtxtExt to rustc_trait_selectionSantiago Pastorino-0/+115
2022-08-23Rollup merge of #100789 - compiler-errors:issue-99662, r=spastorinoMatthias Krüger-13/+8
Use separate infcx to solve obligations during negative coherence I feel like I fixed this already but I may have fixed it then forgot to push the branch... Also fixes up some redundant param-envs being passed around (since they're already passed around in the `Obligation`) Fixes #99662 r? ``@spastorino``
2022-08-22safe transmute: use `Assume` struct to provide analysis optionsJack Wrenn-16/+4
This was left as a TODO in #92268, and brings the trait more in line with what was defined in MCP411. `Assume::visibility` has been renamed to `Assume::safety`, as library safety is what's actually being assumed; visibility is just the mechanism by which it is currently checked (this may change). ref: https://github.com/rust-lang/compiler-team/issues/411 ref: https://github.com/rust-lang/rust/issues/99571
2022-08-22remove hack fix since we don't have no overflow diagnosticyukang-3/+0
2022-08-22Auto merge of #100868 - Dylan-DPC:rollup-a1hfi1r, r=Dylan-DPCbors-0/+12
Rollup of 5 pull requests Successful merges: - #93162 (Std module docs improvements) - #99386 (Add tests that check `Vec::retain` predicate execution order.) - #99915 (Recover keywords in trait bounds) - #100694 (Migrate rustc_ast_passes diagnostics to `SessionDiagnostic` and translatable messages (first part)) - #100757 (Catch overflow early) Failed merges: - #99917 (Move Error trait into core) r? `@ghost` `@rustbot` modify labels: rollup
2022-08-22Rollup merge of #100757 - ouz-a:issue-95134, r=jackh726Dylan DPC-0/+12
Catch overflow early Although this code should raise an overflow error, it didn't because [check_recursion_limit](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/select/struct.SelectionContext.html#method.check_recursion_limit) it checks for `depth = 128` but not for `129` which should have triggered the overflow error. Anyways this catches that error early. Fixes #95134
2022-08-22Auto merge of #100676 - lcnr:implied-bounds-yay, r=nikomatsakisbors-1/+22
implied bounds: explicitly state which types are assumed to be wf Adds a new query which maps each definition to the types which that definition assumes to be well formed. The intent is to make it easier to reason about implied bounds. This change should not influence the user-facing behavior of rustc. Notably, `borrowck` still only assumes that the function signature of associated functions is well formed while `wfcheck` assumes that the both the function signature and the impl trait ref is well formed. Not sure if that by itself can trigger UB or whether it's just annoying. As a next step, we can add `WellFormed` predicates to `predicates_of` of these items and can stop adding the wf bounds at each place which uses them. I also intend to move the computation from `assumed_wf_types` to `implied_bounds` into the `param_env` computation. This requires me to take a deeper look at `compare_predicate_entailment` which is currently somewhat weird wrt implied bounds so I am not touching this here. r? `@nikomatsakis`
2022-08-21Bless tests after #100769Michael Goulet-92/+95
2022-08-21Adjust messages, address some nitsMichael Goulet-38/+38
2022-08-21Targeted fixes addressing erroneous suggestionsMichael Goulet-9/+27
2022-08-21Note closure kind mismatch causeMichael Goulet-2/+1
2022-08-21Rework point-at-argMichael Goulet-46/+34
2022-08-20Rollup merge of #100796 - TaKO8Ki:remove-unnecessary-string-searching, ↵Matthias Krüger-14/+17
r=compiler-errors Refactor: remove unnecessary string searchings This patch removes unnecessary string searchings for checking if function arguments have `&` and `&mut`.