about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2024-03-02Rollup merge of #121875 - estebank:e0277-drive-by, r=compiler-errorsMatthias Krüger-12/+13
Account for unmet T: !Copy in E0277 message ``` error[E0277]: the trait bound `T: !Copy` is not satisfied --> $DIR/simple.rs:10:16 | LL | not_copy::<T>(); | ^ the trait bound `T: !Copy` is not satisfied ``` instead of the current ``` error[E0277]: the trait bound `T: !Copy` is not satisfied --> $DIR/simple.rs:10:16 | LL | not_copy::<T>(); | ^ the trait `!Copy` is not implemented for `T` ```
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-172/+305
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-01normalizes-to: handle negative implslcnr-3/+16
2024-03-01Auto merge of #121462 - compiler-errors:eq-and-sub, r=lcnrbors-26/+9
Combine `Sub` and `Equate` Combine `Sub` and `Equate` into a new relation called `TypeRelating` (that name sounds familiar...) Tracks the difference between `Sub` and `Equate` via `ambient_variance: ty::Variance` much like the `NllTypeRelating` relation, but implemented slightly jankier because it's a more general purpose relation. r? lcnr
2024-03-01Auto merge of #121728 - tgross35:f16-f128-step1-ty-updates, r=compiler-errorsbors-1/+3
Add stubs in IR and ABI for `f16` and `f128` This is the very first step toward the changes in https://github.com/rust-lang/rust/pull/114607 and the [`f16` and `f128` RFC](https://rust-lang.github.io/rfcs/3453-f16-and-f128.html). It adds the types to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`, and just propagates those out as `unimplemented!` stubs where necessary. These types do not parse yet so there is no feature gate, and it should be okay to use `unimplemented!`. The next steps will probably be AST support with parsing and the feature gate. r? `@compiler-errors` cc `@Nilstrieb` suggested breaking the PR up in https://github.com/rust-lang/rust/pull/120645#issuecomment-1925900572
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-23/+9
2024-02-29Rollup merge of #121681 - jswrenn:nix-visibility-analysis, r=compiler-errorsMatthias Krüger-18/+8
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-92/+230
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-29stash overflowing obligations in fulfilllcnr-12/+75
2024-02-29extract fulfillment err creationlcnr-82/+73
2024-02-29distinguish recursion limit based overflow for diagnosticslcnr-41/+57
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-28Add `f16` and `f128` to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`Trevor Gross-1/+3
Make changes necessary to support these types in the compiler.
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-110/+92
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-27Add a couple helpers, make return types less confusingMichael Goulet-116/+172
2024-02-27Support `{async closure}: Fn` in new solverMichael Goulet-1/+73
2024-02-27safe transmute: revise safety analysisJack Wrenn-18/+8
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-26consider placeholders in `fn term_is_fully_unconstrained`lcnr-37/+49
2024-02-26always emit `AliasRelate` goals when relating aliaseslcnr-219/+232
Add `StructurallyRelateAliases` to allow instantiating infer vars with rigid aliases. Change `instantiate_query_response` to be infallible in the new solver. This requires canonicalization to not hide any information used by the query, so weaken universe compression. It also modifies `term_is_fully_unconstrained` to allow region inference variables in a higher universe.
2024-02-26add additional logginglcnr-1/+7
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-72/+97
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-22Rollup merge of #120598 - compiler-errors:no-rigid-check, r=lcnrMatthias Krüger-115/+1
No need to `validate_alias_bound_self_from_param_env` in `assemble_alias_bound_candidates` We already fully normalize the self type before we reach `assemble_alias_bound_candidates`, so there's no reason to double check that a projection is truly rigid by checking param-env bounds. I think this is also blocked on us making sure to always normalize opaques: #120549. r? lcnr
2024-02-22do not use <: in subtyping overflow msglcnr-7/+20
2024-02-22overflow errors: change source to a concrete enumlcnr-49/+78
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.