about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
2024-03-02Rollup merge of #121739 - jieyouxu:loooong-typename, r=estebankMatthias Krüger-48/+62
Display short types for unimplemented trait Shortens unimplemented trait diagnostics. Now shows: ``` error[E0277]: `Option<Option<Option<...>>>` doesn't implement `std::fmt::Display` --> $DIR/on_unimplemented_long_types.rs:4:17 | LL | pub fn foo() -> impl std::fmt::Display { | ^^^^^^^^^^^^^^^^^^^^^^ `Option<Option<Option<...>>>` cannot be formatted with the default formatter LL | LL | / Some(Some(Some(Some(Some(Some(Some(Some(Some(S... LL | | Some(Some(Some(Some(Some(Some(Some(Some(So... LL | | Some(Some(Some(Some(Some(Some(Some(Som... LL | | Some(Some(Some(Some(Some(Some(Some... ... | LL | | ))))))))))), LL | | ))))))))))) | |_______________- return type was inferred to be `Option<Option<Option<...>>>` here | = help: the trait `std::fmt::Display` is not implemented for `Option<Option<Option<...>>>` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. ``` I'm not 100% sure if this is desirable, or if we should just let the long types remain long. This is also kinda a short-term bandaid solution. The real long term solution is to properly migrate `rustc_trait_selection`'s error reporting to use translatable diagnostics and then properly handle type name printing. Fixes #121687.
2024-03-02Account for unmet `T: !Copy` in E0277 messageEsteban Küber-5/+12
2024-03-01Rollup merge of #121803 - estebank:dont-mention-type-error-e0277, ↵Matthias Krüger-1/+5
r=compiler-errors Never say "`Trait` is implemented for `{type error}`" When a trait bound error occurs, we look for alternative types that would have made the bound succeed. For some reason `{type error}` sometimes would appear as a type that would do so. We now remove `{type error}` from the list in every case to avoid nonsensical `note`s.
2024-03-01Rollup merge of #121497 - lcnr:coherence-suggest-increasing-recursion-limit, ↵Matthias Krüger-51/+118
r=compiler-errors `-Znext-solver=coherence`: suggest increasing recursion limit r? `@compiler-errors`
2024-03-01Avoid silently writing to a file when the involved ty is long许杰友 Jieyou Xu (Joe)-4/+15
2024-03-01Never say "`Trait` is implemented for `{type error}`"Esteban Küber-1/+5
When a trait bound error occurs, we look for alternative types that would have made the bound succeed. For some reason `{type error}` sometimes would appear as a type that would do so. We now remove `{type error}` from the list in every case to avoid nonsensical `note`s.
2024-03-01Remove a_is_expected from combine relationsMichael Goulet-6/+3
2024-03-01Get rid of some sub_exp and eq_expMichael Goulet-22/+9
2024-02-29Rollup merge of #121681 - jswrenn:nix-visibility-analysis, r=compiler-errorsMatthias Krüger-14/+7
Safe Transmute: Revise safety analysis This PR migrates `BikeshedIntrinsicFrom` to a simplified safety analysis (described [here](https://github.com/rust-lang/project-safe-transmute/issues/15)) that does not rely on analyzing the visibility of types and fields. The revised analysis treats primitive types as safe, and user-defined types as potentially carrying safety invariants. If Rust gains explicit (un)safe fields, this PR is structured so that it will be fairly easy to thread support for those annotations into the analysis. Notably, this PR removes the `Context` type parameter from `BikeshedIntrinsicFrom`. Most of the files changed by this PR are just UI tests tweaked to accommodate the removed parameter. r? `@compiler-errors`
2024-02-29Small clean up of E0277 message logicEsteban Küber-15/+9
2024-02-29Rollup merge of #121669 - nnethercote:count-stashed-errs-again, r=estebankGuillaume Gomez-11/+7
Count stashed errors again Stashed diagnostics are such a pain. Their "might be emitted, might not" semantics messes with lots of things. #120828 and #121206 made some big changes to how they work, improving some things, but still leaving some problems, as seen by the issues caused by #121206. This PR aims to fix all of them by restricting them in a way that eliminates the "might be emitted, might not" semantics while still allowing 98% of their benefit. Details in the individual commit logs. r? `@oli-obk`
2024-02-29Rollup merge of #121654 - compiler-errors:async-fn-for-fn-def, r=oli-obkGuillaume Gomez-6/+16
Fix `async Fn` confirmation for `FnDef`/`FnPtr`/`Closure` types Fixes three issues: 1. The code in `extract_tupled_inputs_and_output_from_async_callable` was accidentally getting the *future* type and the *output* type (returned by the future) messed up for fnptr/fndef/closure types. :/ 2. We have a (class of) bug(s) in the old solver where we don't really support higher ranked built-in `Future` goals for generators. This is not possible to hit on stable code, but [can be hit with `unboxed_closures`](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=e935de7181e37e13515ad01720bcb899) (#121653). * I'm opting not to fix that in this PR. Instead, I just instantiate placeholders when confirming `async Fn` goals. 4. Fixed a bug when generating `FnPtr` shims for `async Fn` trait goals. r? oli-obk
2024-02-29Rollup merge of #121745 - compiler-errors:refining-impl-trait-deeply-norm, ↵Jacob Pratt-0/+9
r=lcnr Deeply normalize obligations in `refining_impl_trait` We somewhat awkwardly use semantic comparison when checking the `refining_impl_trait` lint. This relies on us being able to normalize bounds eagerly to avoid cases where an unnormalized alias is not considered equal to a normalized alias. Since `normalize` in the new solver is a noop, let's use `deeply_normalize` instead. r? lcnr cc ``@tmandry,`` this should fix your bug lol
2024-02-29track overflowing goals for overfow errorslcnr-45/+108
2024-02-29distinguish recursion limit based overflow for diagnosticslcnr-6/+10
also change the number of allowed fixpoint steps to be fixed instead of using the `log` of the total recursion depth.
2024-02-29Overhaul how stashed diagnostics work, again.Nicholas Nethercote-11/+7
Stashed errors used to be counted as errors, but could then be cancelled, leading to `ErrorGuaranteed` soundness holes. #120828 changed that, closing the soundness hole. But it introduced other difficulties because you sometimes have to account for pending stashed errors when making decisions about whether errors have occured/will occur and it's easy to overlook these. This commit aims for a middle ground. - Stashed errors (not warnings) are counted immediately as emitted errors, avoiding the possibility of forgetting to consider them. - The ability to cancel (or downgrade) stashed errors is eliminated, by disallowing the use of `steal_diagnostic` with errors, and introducing the more restrictive methods `try_steal_{modify,replace}_and_emit_err` that can be used instead. Other things: - `DiagnosticBuilder::stash` and `DiagCtxt::stash_diagnostic` now both return `Option<ErrorGuaranteed>`, which enables the removal of two `delayed_bug` calls and one `Ty::new_error_with_message` call. This is possible because we store error guarantees in `DiagCtxt::stashed_diagnostics`. - Storing the guarantees also saves us having to maintain a counter. - Calls to the `stashed_err_count` method are no longer necessary alongside calls to `has_errors`, which is a nice simplification, and eliminates two more `span_delayed_bug` calls and one FIXME comment. - Tests are added for three of the four fixed PRs mentioned below. - `issue-121108.rs`'s output improved slightly, omitting a non-useful error message. Fixes #121451. Fixes #121477. Fixes #121504. Fixes #121508.
2024-02-28Unify long type name file and note in note_obligation_cause_code许杰友 Jieyou Xu (Joe)-48/+44
2024-02-28Deeply normalize obligations in refining_impl_traitMichael Goulet-0/+9
2024-02-28Display short types for unimplemented trait许杰友 Jieyou Xu (Joe)-2/+9
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-104/+87
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-27Don't emit higher-ranked Future obligations when confirm async Fn goalsMichael Goulet-6/+16
2024-02-27safe transmute: revise safety analysisJack Wrenn-14/+7
Migrate to a simplified safety analysis that does not use visibility. Closes https://github.com/rust-lang/project-safe-transmute/issues/15
2024-02-26Rollup merge of #121617 - compiler-errors:async-closure-kind-check, r=oli-obkMatthias Krüger-2/+3
Actually use the right closure kind when checking async Fn goals Dumb copy-paste mistake on my part from #120712. Sorry! r? oli-obk Fixes #121599
2024-02-26Actually use the right closure kind when checking async Fn goalsMichael Goulet-2/+3
2024-02-25Rollup merge of #121060 - clubby789:bool-newtypes, r=cjgillotMatthias Krüger-4/+19
Add newtypes for bool fields/params/return types Fixed all the cases of this found with some simple searches for `*/ bool` and `bool /*`; probably many more
2024-02-24Auto merge of #121549 - matthiaskrgr:rollup-1hvu3lb, r=matthiaskrgrbors-16/+19
Rollup of 7 pull requests Successful merges: - #121435 (Account for RPITIT in E0310 explicit lifetime constraint suggestion) - #121490 (Rustdoc: include crate name in links for local primitives) - #121520 (delay cloning of iterator items) - #121522 (check that simd_insert/extract indices are in-bounds) - #121531 (Ignore less tests in debug builds) - #121539 (compiler/rustc_target/src/spec/base/apple/tests.rs: Avoid unnecessary large move) - #121542 (update stdarch) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-23compiler: clippy::complexity fixesMatthias Krüger-17/+14
2024-02-23delay cloning of iterator itemsMatthias Krüger-16/+19
2024-02-23Rollup merge of #121434 - nnethercote:fix-121208-fallout, r=lcnrMatthias Krüger-3/+1
Fix #121208 fallout #121208 converted lots of delayed bugs to bugs. Unsurprisingly, there were a few invalid conversion found via fuzzing. r? `@lcnr`
2024-02-23Revert some `span_bug`s to `span_delayed_bug`.Nicholas Nethercote-3/+1
Fixes #121410. Fixes #121414. Fixes #121418. Fixes #121431.
2024-02-22Auto merge of #119989 - lcnr:sub_relations-bye-bye, r=compiler-errorsbors-69/+90
remove `sub_relations` from the `InferCtxt` While doing so, I tried to remove the `delay_span_bug` in `rematch_impl` again, which lead me to discover another `freshen` bug, fixing that one in the second commit. See commit descriptions for the reasoning behind each change. r? `@compiler-errors`
2024-02-22change error messages to be incorrect, but more helpfullcnr-1/+1
2024-02-22Rollup merge of #121386 - oli-obk:no_higher_ranked_opaques, r=lcnrMatthias Krüger-2/+4
test that we do not support higher-ranked regions in opaque type inference We already do all the right checks in `check_opaque_type_parameter_valid`, and we have done so since at least 2 years. I collected the tests from https://github.com/rust-lang/rust/pull/116935 and https://github.com/rust-lang/rust/pull/100503 and added some more cc https://github.com/rust-lang/rust/issues/96146 r? `@lcnr`
2024-02-22do not use <: in subtyping overflow msglcnr-7/+20
2024-02-22overflow errors: change source to a concrete enumlcnr-46/+71
2024-02-22freshen: resolve root varslcnr-23/+2
Without doing so we use the same candidate cache entry for `?0: Trait<?1>` and `?0: Trait<?0>`. These goals are different and we must not use the same entry for them.
2024-02-22remove `sub_relations` from infcx, recompute in diagnosticslcnr-0/+4
we don't track them when canonicalizing or when freshening, resulting in instable caching in the old solver, and issues when instantiating query responses in the new one.
2024-02-22Preserve the `Span` from `prove_predicate` all the way to registering opaque ↵Oli Scherer-2/+4
types
2024-02-22Replace unnecessary `abort_if_errors`.Nicholas Nethercote-9/+2
Replace `abort_if_errors` calls that are certain to abort -- because we emit an error immediately beforehand -- with `FatalErro.raise()`.
2024-02-21Rollup merge of #121328 - ffmancera:ff/verbose_long_type, r=compiler-errorsDylan DPC-0/+12
Make --verbose imply -Z write-long-types-to-disk=no When shortening the type it is necessary to take into account the `--verbose` flag, if it is activated, we must always show the entire type and not write it in a file. Fixes: https://github.com/rust-lang/rust/issues/119130
2024-02-21Rollup merge of #121208 - nnethercote:delayed_bug-to-bug, r=lcnrDylan DPC-20/+16
Convert `delayed_bug`s to `bug`s. I have a suspicion that quite a few delayed bug paths are impossible to reach, so I did an experiment. I converted every `delayed_bug` to a `bug`, ran the full test suite, then converted back every `bug` that was hit. A surprising number were never hit. This is too dangerous to merge. Increased coverage (fuzzing or a crater run) would likely hit more cases. But it might be useful for people to look at and think about which paths are genuinely unreachable. r? `@ghost`
2024-02-21Convert `bug`s back to `delayed_bug`s.Nicholas Nethercote-10/+10
This commit undoes some of the previous commit's mechanical changes, based on human judgment.
2024-02-21Convert `delayed_bug`s to `bug`s.Nicholas Nethercote-15/+11
I have a suspicion that quite a few delayed bug paths are impossible to reach, so I did an experiment. I converted every `delayed_bug` to a `bug`, ran the full test suite, then converted back every `bug` that was hit. A surprising number were never hit. The next commit will convert some more back, based on human judgment.
2024-02-20Suggest using --verbose when writing type to a fileFernando Fernandez Mancera-0/+12
2024-02-20Rollup merge of #121344 - fmease:lta-constr-by-input, r=oli-obkMatthias Krüger-21/+17
Expand weak alias types before collecting constrained/referenced late bound regions + refactorings Fixes #114220. Follow-up to #120780. r? `@oli-obk`
2024-02-20Introduce expand_weak_alias_tysLeón Orell Valerian Liehr-11/+9
2024-02-20Rename some normalization-related itemsLeón Orell Valerian Liehr-10/+8
2024-02-20Add newtype for first input typeclubby789-4/+19
2024-02-20Auto merge of #120576 - nnethercote:merge-Diagnostic-DiagnosticBuilder, ↵bors-81/+98
r=davidtwco Overhaul `Diagnostic` and `DiagnosticBuilder` Implements the first part of https://github.com/rust-lang/compiler-team/issues/722, which moves functionality and use away from `Diagnostic`, onto `DiagnosticBuilder`. Likely follow-ups: - Move things around, because this PR was written to minimize diff size, so some things end up in sub-optimal places. E.g. `DiagnosticBuilder` has impls in both `diagnostic.rs` and `diagnostic_builder.rs`. - Rename `Diagnostic` as `DiagInner` and `DiagnosticBuilder` as `Diag`. r? `@davidtwco`
2024-02-20Rollup merge of #121307 - estebank:drive-by, r=compiler-errorsNilstrieb-3/+2
Drive-by `DUMMY_SP` -> `Span` and fmt changes Noticed these while doing something else. There's no practical change, but it's preferable to use `DUMMY_SP` as little as possible, particularly when we have perfectlly useful `Span`s available.