about summary refs log tree commit diff
path: root/src/test/ui/nll
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-18827/+0
2023-01-09Auto merge of #101947 - aliemjay:astconv-normalize, r=lcnrbors-110/+770
Don't normalize in AstConv See individual commits. Fixes #101350 Fixes #54940
2023-01-08Improve spans of non-WF implied bound typesMichael Goulet-4/+4
2023-01-07don't eagerly normalize SelfCtor typeAli MJ Al-Nasrawy-0/+120
Delay until user annotations are registered. See the added test.
2023-01-07more testsAli MJ Al-Nasrawy-37/+188
2023-01-07make ascribe_user_type a TypeOpAli MJ Al-Nasrawy-8/+164
Projection types in user annotations may contain inference variables. This makes the normalization depend on the unification with the actual type and thus requires a separate TypeOp to track the obligations. Otherwise simply calling `TypeChecker::normalize` would ICE with "unexpected ambiguity"
2023-01-07fix method substsAli MJ Al-Nasrawy-2/+10
2023-01-07fix struct pathAli MJ Al-Nasrawy-33/+106
2023-01-07don't normalize in astconvAli MJ Al-Nasrawy-101/+253
We delay projection normalization to further stages in order to register user type annotations before normalization in HIR typeck. There are two consumers of astconv: ItemCtxt and FnCtxt. The former already expects unnormalized types from astconv, see its AstConv trait impl. The latter needs `RawTy` for a cleaner interface. Unfortunately astconv still needs the normalization machinery in order to resolve enum variants that have projections in the self type, e.g. `<<T as Trait>::Assoc>::StructVariant {}`. This is why `AstConv::normalize_ty_2` is necessary.
2023-01-04Move testsCaio-0/+15
2023-01-03Rollup merge of #106005 - LeSeulArtichaut:if-let-guard-borrowck-test, ↵Matthias Krüger-41/+482
r=Nilstrieb Test the borrowck behavior of if-let guards Add some tests to make sure that if-let guards behave the same as if guards with respect to borrow-checking. Most of them are a naive adaptation, replacing an `if` guard with `if let Some(())`. This includes regression tests for notable issues that arose for if guards (#24535, #27282, #29723, #31287) as suggested in https://github.com/rust-lang/rust/issues/51114#issuecomment-900470419. cc `@pnkfelix` are there any other tests that you would want to see? cc tracking issue #51114
2023-01-01Verbose suggestionsEsteban Küber-2/+5
2022-12-28Use verbose suggestions for mutability errorsEsteban Küber-7/+15
2022-12-21Test the borrowck behavior of if-let guardsLéo Lanteri Thauvin-41/+482
2022-12-13Account for dereference expressionsEsteban Küber-33/+44
2022-12-13Suggest `ref` for some patterns as a fallbackEsteban Küber-0/+28
2022-12-13Change pattern borrowing suggestions to be verboseEsteban Küber-48/+101
Synthesize a more accurate span and use verbose suggestion output to make the message clearer.
2022-12-02Rollup merge of #104614 - Nilstrieb:type-ascribe!, r=TaKO8KiMatthias Krüger-11/+11
Add `type_ascribe!` macro as placeholder syntax for type ascription This makes it still possible to test the internal semantics of type ascription even once the `:`-syntax is removed from the parser. The macro now gets used in a bunch of UI tests that test the semantics and not syntax of type ascription. I might have forgotten a few tests but this should hopefully be most of them. The remaining ones will certainly be found once type ascription is removed from the parser altogether. Part of #101728
2022-11-23Suggest `.clone()` or `ref binding` on E0382Esteban Küber-2/+56
2022-11-22Rollup merge of #104656 - c410-f3r:moar-errors, r=petrochenkovMatthias Krüger-0/+37
Move tests r? `@petrochenkov`
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-1/+1
Support using `Self` or projections inside an RPIT/async fn I reuse the same idea as https://github.com/rust-lang/rust/pull/103449 to use variances to encode whether a lifetime parameter is captured by impl-trait. The current implementation of async and RPIT replace all lifetimes from the parent generics by `'static`. This PR changes the scheme ```rust impl<'a> Foo<'a> { fn foo<'b, T>() -> impl Into<Self> + 'b { ... } } opaque Foo::<'_a>::foo::<'_b, T>::opaque<'b>: Into<Foo<'_a>> + 'b; impl<'a> Foo<'a> { // OLD fn foo<'b, T>() -> Foo::<'static>::foo::<'static, T>::opaque::<'b> { ... } ^^^^^^^ the `Self` becomes `Foo<'static>` // NEW fn foo<'b, T>() -> Foo::<'a>::foo::<'b, T>::opaque::<'b> { ... } ^^ the `Self` stays `Foo<'a>` } ``` There is the same issue with projections. In the example, substitute `Self` by `<T as Trait<'b>>::Assoc` in the sugared version, and `Foo<'_a>` by `<T as Trait<'_b>>::Assoc` in the desugared one. This allows to support `Self` in impl-trait, since we do not replace lifetimes by `'static` any more. The same trick allows to use projections like `T::Assoc` where `Self` is allowed. The feature is gated behind a `impl_trait_projections` feature gate. The implementation relies on 2 tweaking rules for opaques in 2 places: - we only relate substs that correspond to captured lifetimes during TypeRelation; - we only list captured lifetimes in choice region computation. For simplicity, I encoded the "capturedness" of lifetimes as a variance, `Bivariant` vs `Invariant` for unused vs captured lifetimes. The `variances_of` query used to ICE for opaques. Impl-trait that do not reference `Self` or projections will have their variances as: - `o` (invariant) for each parent type or const; - `*` (bivariant) for each parent lifetime --> will not participate in borrowck; - `o` (invariant) for each own lifetime. Impl-trait that does reference `Self` and/or projections will have some parent lifetimes marked as `o` (as the example above), and participate in type relation and borrowck. In the example above, `variances_of(opaque) = ['_a: o, '_b: *, T: o, 'b: o]`. r? types cc `@compiler-errors` , as you asked about the issue with `Self` and projections.
2022-11-20Move testsCaio-0/+37
2022-11-19Use `type_ascribe!` in many UI testsNilstrieb-11/+11
Use it in all UI tests that are about the semantics and not the syntax of type ascription.
2022-11-13Rollup merge of #104181 - jackh726:known-bug-tests, r=Mark-SimulacrumManish Goregaokar-0/+16
Add a few known-bug tests The labels of these tests should be changed from `S-bug-has-mcve` to `S-bug-has-test` once this is merged. cc: #101518 #99492 #90950 #89196 #104034 #101350 #103705 #103899 I couldn't reproduce the failures in #101962 and #100772 (so either these have started passing, or I didn't repro properly), so leaving those out for now. #102065 was a bit more complicated, since it uses `rustc_private` and I didn't want to mess with that.
2022-11-13Add a few known-bug testsJack Huey-0/+16
2022-11-13Auto merge of #104282 - cjgillot:intern-span, r=compiler-errorsbors-15/+15
Hash spans when interning types Ignoring hash for spans creates an inconsistency between the `Hash` impl for `WithStableHash`, which takes them into account, and the `HashStable` impl which does not. cc `@compiler-errors` Fixes https://github.com/rust-lang/rust/issues/104271 Fixes https://github.com/rust-lang/rust/issues/104255 Fixes https://github.com/rust-lang/rust/issues/104238
2022-11-12Bless ui tests.Camille GILLOT-1/+1
2022-11-11Do not rename bound variables when verbose-printing binders.Camille GILLOT-15/+15
2022-11-10Tweak span for `#[must_use]`Esteban Küber-1/+1
Do not point at whole statement, only at the expression (skip pointing at `;`)
2022-11-09Rollup merge of #103307 - b4den:master, r=estebankManish Goregaokar-5/+5
Add context to compiler error message Changed `creates a temporary which is freed while still in use` to `creates a temporary value which is freed while still in use`.
2022-11-07Rollup merge of #104003 - c410-f3r:moar-errors, r=petrochenkovDylan DPC-0/+21
Move some tests to more reasonable directories r? `@petrochenkov`
2022-11-05Move some tests to more reasonable directoriesCaio-0/+21
2022-11-05use spans in TypeTest rather than mir::LocationAli MJ Al-Nasrawy-68/+44
Spans are independent of the body being borrow-checked, so they don't need remapping when promoting type-tests and they yield more specific error spans inside bodies of closures/inline consts.
2022-11-05simplify applying closure requirementsAli MJ Al-Nasrawy-2/+5
Don't use `ConstraintCategory::ClosureBounds`! Set the category and the span for the promoted constraints to that of the original constraint earlier than before. This eliminates the need for `closure_bounds_mapping`.
2022-10-27Revert "Make ClosureOutlivesRequirement not rely on an unresolved type"Michael Goulet-15/+16
This reverts commit a6b5f95fb028f9feb4a2957c06b35035be2c6155.
2022-10-25Name impl trait in region bound suggestionMichael Goulet-1/+1
2022-10-20Update tests to match error message changesb4den-5/+5
2022-10-19Make ClosureOutlivesRequirement not rely on an unresolved typeMichael Goulet-16/+15
2022-10-16Auto merge of #102080 - yanchen4791:issue-99824-fix, r=cjgillotbors-6/+10
Fix missing explanation of where the borrowed reference is used when the same borrow occurs multiple times due to loop iterations Fix #99824. Problem of the issue: If a borrow occurs in a loop, the borrowed reference could be invalidated at the same place at next iteration of the loop. When this happens, the point where the borrow occurs is the same as the intervening point that might invalidate the reference in the loop. This causes a problem for the current code finding the point where the resulting reference is used, so that the explanation of the cause will be missing. As the second point of "explain all errors in terms of three points" (see [leveraging intuition framing errors in terms of points"](https://rust-lang.github.io/rfcs/2094-nll.html#leveraging-intuition-framing-errors-in-terms-of-points), this explanation is very helpful for user to understand the error. In the current implementation, the searching region for finding the location where the borrowed reference is used is limited to between the place where the borrow occurs and the place where the reference is invalidated. If those two places happen to be the same, which indicates that the borrow and invalidation occur at the same place in a loop, the search will fail. One solution to the problem is when these two places are the same, find the terminator of the loop, and then use the location of the loop terminator instead of the location of the borrow for the region to find the place where the borrowed reference is used.
2022-10-08Rollup merge of #99818 - aliemjay:fix-closure-normalize, r=jackh726Michael Howell-0/+135
don't ICE when normalizing closure input tys We were ICEing while rendering diagnostics because `universe_causes` is expected to track every universe created in the typeck's infcx. `normalize_and_add_constraints` doesn't update `universe_causes` when creating new universes, causing an ICE. Remove it! Add spans to better track normalization constraints. Fix couple places where `universe_causes` is not updated correctly to track newly added universes. Fixes #102800 ~Fixess #99665~ (UPDATE: no longer true; the issue has a different failure path than when this PR was created and should be fixed by #101708, but the changes in this PR are still correct and should prevent potential future ICEs)
2022-10-08don't ICE when normalizing closure input tysAli MJ Al-Nasrawy-0/+135
`normalize_and_add_constraints` doesn't add entries in `universe_causes` when creating new universes, causing an ICE. Remove it! Add spans to track normalization constraints. Fix couple places where `universe_causes` is not updated correctly to track newly added universes.
2022-10-06Rollup merge of #98496 - BoxyUwU:instancers_bad_equality, r=lcnrMatthias Krüger-1/+1
make `compare_const_impl` a query and use it in `instance.rs` Fixes #88365 the bug in #88365 was caused by some `instance.rs` code using the `PartialEq` impl on `Ty` to check that the type of the associated const in an impl is the same as the type of the associated const in the trait definition. This was wrong for two reasons: - the check typeck does is that the impl type is a subtype of the trait definition's type (see `mismatched_impl_ty_2.rs` which [was ICEing](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f6d60ebe6745011f0d52ab2bc712025d) before this PR on stable) - it assumes that if two types are equal then the `PartialEq` impl will reflect that which isnt true for higher ranked types or type level constants when `feature(generic_const_exprs)` is enabled (see `mismatched_impl_ty_3.rs` for higher ranked types which was [ICEing on stable](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d7af131a655ed515b035624626c62c71)) r? `@lcnr`
2022-10-01Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebankbors-2/+2
Move lint level source explanation to the bottom So, uhhhhh r? `@estebank` ## User-facing change "note: `#[warn(...)]` on by default" and such are moved to the bottom of the diagnostic: ```diff - = note: `#[warn(unsupported_calling_conventions)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678> + = note: `#[warn(unsupported_calling_conventions)]` on by default ``` Why warning is enabled is the least important thing, so it shouldn't be the first note the user reads, IMO. ## Developer-facing change `struct_span_lint` and similar methods have a different signature. Before: `..., impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>)` After: `..., impl Into<DiagnosticMessage>, impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` The reason for this is that `struct_span_lint` needs to edit the diagnostic _after_ `decorate` closure is called. This also makes lint code a little bit nicer in my opinion. Another option is to use `impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>) -> DiagnosticBuilder<'a, ()>` altough I don't _really_ see reasons to do `let lint = lint.build(message)` everywhere. ## Subtle problem By moving the message outside of the closure (that may not be called if the lint is disabled) `format!(...)` is executed earlier, possibly formatting `Ty` which may call a query that trims paths that crashes the compiler if there were no warnings... I don't think it's that big of a deal, considering that we move from `format!(...)` to `fluent` (which is lazy by-default) anyway, however this required adding a workaround which is unfortunate. ## P.S. I'm sorry, I do not how to make this PR smaller/easier to review. Changes to the lint API affect SO MUCH 😢
2022-10-01bless ui testsMaybe Waffle-2/+2
2022-09-30create def ids for impl traits during ast loweringSantiago Pastorino-4/+4
2022-09-30blessBoxy-1/+1
2022-09-28Fix missing explanation of where borrowed reference is used when the borrow ↵Yan Chen-6/+10
occurs in loop iteration
2022-09-26Rollup merge of #101996 - b-naber:binder-print, r=lcnrMatthias Krüger-26/+26
Don't duplicate region names for late-bound regions in print of Binder Fixes https://github.com/rust-lang/rust/issues/101280
2022-09-26address reviewb-naber-26/+26
2022-09-26bless testsb-naber-6/+6