about summary refs log tree commit diff
path: root/tests/ui/traits
AgeCommit message (Collapse)AuthorLines
2023-12-21Rollup merge of #119154 - surechen:fix_119067, r=fmeaseMatthias Krüger-0/+22
Simple modification of `non_lifetime_binders`'s diagnostic information to adapt to type binders fixes #119067 Replace diagnostic information "lifetime bounds cannot be used in this context" to "bounds cannot be used in this context". ```rust #![allow(incomplete_features)] #![feature(non_lifetime_binders)] trait Trait {} trait Trait2 where for <T: Trait> ():{} //~^ ERROR bounds cannot be used in this context ```
2023-12-21Simple modification of diagnostic informationsurechen-0/+22
fixes #119067
2023-12-20Rollup merge of #119071 - lcnr:overflowo, r=compiler-errorsMatthias Krüger-1/+34
-Znext-solver: adapt overflow rules to avoid breakage Do not erase overflow constraints if they are from equating the impl header when normalizing[^1]. This should be the minimal change to not break crates depending on the old project behavior of "apply impl constraints while only lazily evaluating any nested goals". Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/70, see https://hackmd.io/ATf4hN0NRY-w2LIVgeFsVg for the reasoning behind this. Only keeping constraints on overflow for `normalize-to` goals as that's the only thing needed for backcompat. It also allows us to not track the origin of root obligations. The issue with root goals would be something like the following: ```rust trait Foo {} trait Bar {} trait FooBar {} impl<T: Foo + Bar> FooBar for T {} // These two should behave the same, rn we can drop constraints for both, // but if we don't drop `Misc` goals we would only drop the constraints for // `FooBar` unless we track origins of root obligations. fn func1<T: Foo + Bar>() {} fn func2<T: FooBaz>() {} ``` [^1]: mostly, the actual rules are slightly different r? ``@compiler-errors``
2023-12-18Use alias-eq in structural normalizationMichael Goulet-19/+18
2023-12-18dont discard overflow from normalizes-to goalslcnr-1/+34
2023-12-17skip rpit constraint check if borrowck return type errorbohan-0/+19
2023-12-15Rollup merge of #118396 - compiler-errors:ast-lang-items, r=cjgillotJubilee-4/+19
Collect lang items from AST, get rid of `GenericBound::LangItemTrait` r? `@cjgillot` cc #115178 Looking forward, the work to remove `QPath::LangItem` will also be significantly more difficult, but I plan on doing it as well. Specifically, we have to change: 1. A lot of `rustc_ast_lowering` for things like expr `..` 2. A lot of astconv, since we actually instantiate lang and non-lang paths quite differently. 3. A ton of diagnostics and clippy lints that are special-cased via `QPath::LangItem` Meanwhile, it was pretty easy to remove `GenericBound::LangItemTrait`, so I just did that here.
2023-12-15Move type relations into submodule in rustc_inferMichael Goulet-8/+8
2023-12-15Collect lang items from ASTMichael Goulet-4/+19
2023-12-15Opportunistically resolve region var in canonicalizerMichael Goulet-0/+58
2023-12-14Unconditionally register alias-relate in projection goalMichael Goulet-2/+48
2023-12-14consistently use "next solver" instead of "new solver"lcnr-1/+1
2023-12-14update use of feature flagslcnr-132/+132
2023-12-13Tweak `short_ty_string` to reduce number of filesEsteban Küber-4/+4
When shortening types and writing them to disk, make `short_ty_string` capable of reusing the same file, instead of writing a file per shortened type.
2023-12-12refactor writeback: emit normalization errors with new solverlcnr-20/+27
2023-12-10Auto merge of #118692 - surechen:remove_unused_imports, r=petrochenkovbors-11/+0
remove redundant imports detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR. r? `@petrochenkov`
2023-12-10remove redundant importssurechen-11/+0
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-09add test for inductive cycle hangslcnr-4/+57
2023-12-08Rollup merge of #118730 - jyn514:cmp_refs, r=estebank,compiler-errorsMatthias Krüger-4/+4
recurse into refs when comparing tys for diagnostics before: ![image](https://github.com/rust-lang/rust/assets/23638587/bf6abd62-c7f3-4c09-a47e-31b6e129de19) after: ![image](https://github.com/rust-lang/rust/assets/23638587/b704d728-ddba-4204-aebe-c07dcbbcb55c) this diff from the test suite is also quite nice imo: ```diff `@@` -4,8 +4,8 `@@` error[E0308]: mismatched types LL | debug_assert_eq!(iter.next(), Some(value)); | ^^^^^^^^^^^ expected `Option<<I as Iterator>::Item>`, found `Option<&<I as Iterator>::Item>` | - = note: expected enum `Option<<I as Iterator>::Item>` - found enum `Option<&<I as Iterator>::Item>` + = note: expected enum `Option<_>` + found enum `Option<&_>` ```
2023-12-07recurse into refs when comparing tys for diagnosticsjyn-4/+4
2023-12-08add regression testslcnr-0/+43
2023-12-08implement and use `NormalizesTo`lcnr-11/+14
2023-12-06Rollup merge of #116496 - estebank:question-method-chain-context, ↵Matthias Krüger-0/+121
r=compiler-errors Provide context when `?` can't be called because of `Result<_, E>` When a method chain ending in `?` causes an E0277 because the expression's `Result::Err` variant doesn't have a type that can be converted to the `Result<_, E>` type parameter in the return type, provide additional context of which parts of the chain can and can't support the `?` operator. ``` error[E0277]: `?` couldn't convert the error to `String` --> $DIR/question-mark-result-err-mismatch.rs:27:25 | LL | fn bar() -> Result<(), String> { | ------------------ expected `String` because of this LL | let x = foo(); | ----- this has type `Result<_, String>` ... LL | .map_err(|_| ())?; | ---------------^ the trait `From<()>` is not implemented for `String` | | | this can't be annotated with `?` because it has type `Result<_, ()>` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: <String as From<char>> <String as From<Box<str>>> <String as From<Cow<'a, str>>> <String as From<&str>> <String as From<&mut str>> <String as From<&String>> = note: required for `Result<(), String>` to implement `FromResidual<Result<Infallible, ()>>` ``` Fix #72124.
2023-12-05Reduce verbosity of errorEsteban Küber-27/+3
2023-12-05Detect incorrect `;` in `Option::ok_or_else` and `Result::map_err`Esteban Küber-7/+17
Fix #72124.
2023-12-05Point at fewer methods in the chain, only those that change the E typeEsteban Küber-24/+17
2023-12-05Provide context when `?` can't be called because of `Result<_, E>`Esteban Küber-0/+142
When a method chain ending in `?` causes an E0277 because the expression's `Result::Err` variant doesn't have a type that can be converted to the `Result<_, E>` type parameter in the return type, provide additional context of which parts of the chain can and can't support the `?` operator. ``` error[E0277]: `?` couldn't convert the error to `String` --> $DIR/question-mark-result-err-mismatch.rs:28:25 | LL | fn bar() -> Result<(), String> { | ------------------ expected `String` because of this LL | let x = foo(); | ----- this can be annotated with `?` because it has type `Result<String, String>` LL | let one = x LL | .map(|s| ()) | ----------- this can be annotated with `?` because it has type `Result<(), String>` LL | .map_err(|_| ())?; | ---------------^ the trait `From<()>` is not implemented for `String` | | | this can't be annotated with `?` because it has type `Result<(), ()>` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: <String as From<char>> <String as From<Box<str>>> <String as From<Cow<'a, str>>> <String as From<&str>> <String as From<&mut str>> <String as From<&String>> = note: required for `Result<(), String>` to implement `FromResidual<Result<Infallible, ()>>` ``` Fix #72124.
2023-12-05Add print_trait_sugaredMichael Goulet-2/+2
2023-12-04rebaselcnr-2/+2
2023-12-04cleanup and commentslcnr-0/+46
2023-12-04generalize: handle occurs check failure in aliaseslcnr-10/+4
2023-12-01Handle recursion limit for subtype and well-formed predicatesMatthew Jasper-0/+75
2023-11-24Show number in error message even for one errorNilstrieb-180/+180
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-22Rework supertrait lint once againMichael Goulet-3/+88
2023-11-22Stabilize RFC3324 dyn upcasting coercionUrgau-183/+78
Aka trait_upcasting feature. And also adjust the `deref_into_dyn_supertrait` lint.
2023-11-20Rollup merge of #118089 - lcnr:intercrate-ambig-msg, r=compiler-errorsMatthias Krüger-3/+2
intercrate_ambiguity_causes: handle self ty infer + reservation impls r? `@compiler-errors`
2023-11-20Rollup merge of #118026 - compiler-errors:deref-into-dyn-regions, r=lcnrMatthias Krüger-8/+95
Don't consider regions in `deref_into_dyn_supertrait` lint I actually wonder if we should just warn on *any* deref impl with a target type that matches a supertrait by *def-id*. cc #89460 r? types
2023-11-20Rollup merge of #117835 - Nilstrieb:note-object-lifetime-defaults, ↵Matthias Krüger-0/+35
r=compiler-errors Note about object lifetime defaults in does not live long enough error This is a aspect of Rust that frequently trips up people who are not aware of it yet. This diagnostic attempts to explain what's happening and why the lifetime constraint, that was never mentioned in the source, arose. The implementation feels a bit questionable, I'm not sure whether there are better ways to do this. There probably are. fixes #117835 r? types
2023-11-20Bump future release warning modeMichael Goulet-4/+4
2023-11-20Don't consider regions in deref_into_dyn_supertrait lintMichael Goulet-6/+93
2023-11-20handle reservation impls, track impl sourcelcnr-0/+2
2023-11-20self ty infer ambiguity: add proof tree candlcnr-3/+0
2023-11-19Make regionck care about placeholders in outlives componentsMichael Goulet-3/+91
2023-11-17Auto merge of #117278 - lcnr:try-normalize-ty, r=compiler-errorsbors-5/+32
new solver normalization improvements cool beans At the core of this PR is a `try_normalize_ty` which stops for rigid aliases by using `commit_if_ok`. Reworks alias-relate to fully normalize both the lhs and rhs and then equate the resulting rigid (or inference) types. This fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/68 by avoiding the exponential blowup. Also supersedes #116369 by only defining opaque types if the hidden type is rigid. I removed the stability check in `EvalCtxt::evaluate_goal` due to https://github.com/rust-lang/trait-system-refactor-initiative/issues/75. While I personally have opinions on how to fix it, that still requires further t-types/`@nikomatsakis` buy-in, so I removed that for now. Once we've decided on our approach there, we can revert this commit. r? `@compiler-errors`
2023-11-12Note about object lifetime defaults in does not live long enough errorNilstrieb-0/+35
This is a aspect of Rust that frequently trips up people who are not aware of it yet. This diagnostic attempts to explain what's happening and why the lifetime constraint, that was never mentioned in the source, arose.
2023-11-09update overflow handling for norm, add testlcnr-0/+22
2023-11-09update testslcnr-5/+10
2023-11-08Only use normalize_param_env when normalizing predicate in check_item_boundsMichael Goulet-6/+20
2023-11-06Don't instantiate the binder twice when assembling object candidateMichael Goulet-0/+38
2023-11-06Only check predicates for late-bound non-lifetime vars in object candidate ↵Michael Goulet-0/+19
assembly