rust/tests/ui/typeck
Matthias Krüger 2128efd87f
Rollup merge of #115313 - gurry:issue-114918-cycle-detected, r=compiler-errors
Make `get_return_block()` return `Some` only for HIR nodes in body

Fixes #114918

The issue occurred while compiling the following input:

```rust
fn uwu() -> [(); { () }] {
    loop {}
}
```

It was caused by the code below trying to suggest a missing return type which resulted in a const eval cycle: 1bd043098e/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs (L68-L75)

The root cause was `get_return_block()` returning an `Fn` node for a node in the return type (i.e. the second `()` in the return type `[(); { () }]` of the input) although it is supposed to do so only for nodes that lie in the body of the function and return `None` otherwise (at least as per my understanding).

The PR fixes the issue by fixing this behaviour of `get_return_block()`.
2023-08-30 07:18:11 +02:00
..
auxiliary Move issue 29181, 2804, 17431, 66768 2023-08-24 20:44:08 +03:00
issue-87181
issue-114918 Make get_return_block() return Some only for HIR nodes in body 2023-08-30 07:40:08 +05:30
apit-with-error-type-in-sig.rs Don't call a type uncallable if its signature has errors in it 2023-07-22 15:27:21 +00:00
apit-with-error-type-in-sig.stderr Don't call a type uncallable if its signature has errors in it 2023-07-22 15:27:21 +00:00
assign-non-lval-derefmut.fixed
assign-non-lval-derefmut.rs
assign-non-lval-derefmut.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
assign-non-lval-mut-ref.fixed
assign-non-lval-mut-ref.rs
assign-non-lval-mut-ref.stderr
assign-non-lval-needs-deref.rs
assign-non-lval-needs-deref.stderr
autoderef-with-param-env-error.rs
autoderef-with-param-env-error.stderr Render missing generics suggestion verbosely 2023-01-12 22:04:30 +00:00
bad-index-due-to-nested.rs Test downstream errors from bad index expr 2023-04-18 19:25:57 +00:00
bad-index-due-to-nested.stderr Tweak borrow suggestion 2023-05-08 03:36:30 +00:00
bad-recursive-type-sig-infer.rs Don't infer fn return type to return itself 2023-04-22 19:30:47 +00:00
bad-recursive-type-sig-infer.stderr Don't infer fn return type to return itself 2023-04-22 19:30:47 +00:00
bad-type-in-vec-contains.rs Fix another ICE in point_at_expr_source_of_inferred_type 2023-03-02 18:27:06 +00:00
bad-type-in-vec-contains.stderr Tweak borrow suggestion 2023-05-08 03:36:30 +00:00
bad-type-in-vec-push.rs Hack to suppress bad labels in type mismatch inference deduction code 2023-01-23 17:02:50 +00:00
bad-type-in-vec-push.stderr Make note_source_of_type_mismatch_constraint simpler 2023-04-12 23:05:55 +00:00
call-block.rs
call-block.stderr
check-args-on-fn-err-2.rs
check-args-on-fn-err-2.stderr
check-args-on-fn-err.rs
check-args-on-fn-err.stderr
conversion-methods.rs
conversion-methods.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
deref-multi.rs
deref-multi.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
derive-sugg-arg-arity.rs Don't use can_eq in derive suggestion for missing method 2023-05-12 20:34:51 +00:00
derive-sugg-arg-arity.stderr Don't use can_eq in derive suggestion for missing method 2023-05-12 20:34:51 +00:00
do-not-suggest-adding-missing-zero-to-floating-point-number.rs
do-not-suggest-adding-missing-zero-to-floating-point-number.stderr
do-not-suggest-placeholder-to-const-static-without-type.rs
do-not-suggest-placeholder-to-const-static-without-type.stderr
dont-record-adjustments-when-pointing-at-arg.rs Don't record adjustments twice in note_source_of_type_mismatch_constraint 2023-06-12 00:35:30 +00:00
dont-record-adjustments-when-pointing-at-arg.stderr Don't record adjustments twice in note_source_of_type_mismatch_constraint 2023-06-12 00:35:30 +00:00
explain_clone_autoref.rs Added recursive checking back up to see if a Clone suggestion would be helpful. 2023-07-25 10:09:26 +01:00
explain_clone_autoref.stderr Added recursive checking back up to see if a Clone suggestion would be helpful. 2023-07-25 10:09:26 +01:00
issue-1871.rs Move tests 2023-05-24 19:35:59 -03:00
issue-1871.stderr Move tests 2023-05-24 19:35:59 -03:00
issue-2063-resource.rs Move tests 2023-05-24 19:35:59 -03:00
issue-2063.rs Move tests 2023-05-24 19:35:59 -03:00
issue-7813.rs Move tests 2023-02-16 11:42:35 -03:00
issue-7813.stderr Move tests 2023-02-16 11:42:35 -03:00
issue-10401.rs
issue-10401.stderr
issue-10969.rs
issue-10969.stderr
issue-13853-2.rs
issue-13853-2.stderr
issue-13853-5.rs
issue-13853-5.stderr
issue-13853.rs
issue-13853.stderr Tweak borrow suggestion 2023-05-08 03:36:30 +00:00
issue-18937-1.rs
issue-18937.rs
issue-18937.stderr
issue-22375.rs
issue-29124.rs
issue-29124.stderr
issue-29181.rs Move issue 29181, 2804, 17431, 66768 2023-08-24 20:44:08 +03:00
issue-29181.stderr Move issue 29181, 2804, 17431, 66768 2023-08-24 20:44:08 +03:00
issue-31173.rs
issue-31173.stderr Highlight whole expression for E0599 2023-03-01 16:57:11 +00:00
issue-33575.rs
issue-33575.stderr
issue-36708.rs
issue-36708.stderr
issue-43189.rs
issue-43189.stderr Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
issue-46112.rs
issue-46112.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
issue-50687-ice-on-borrow.rs
issue-50687-ice-on-borrow.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
issue-52082-type-param-shadows-existing-type.rs
issue-52082-type-param-shadows-existing-type.stderr
issue-53712.rs Move tests 2023-02-16 11:42:35 -03:00
issue-53712.stderr Move tests 2023-02-16 11:42:35 -03:00
issue-55810-must-typeck-match-pats-before-guards.rs
issue-57404.rs
issue-57404.stderr Make &-removal suggestion verbose 2023-01-11 21:38:54 +00:00
issue-57673-ice-on-deref-of-boxed-trait.rs
issue-57673-ice-on-deref-of-boxed-trait.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
issue-61711-once-caused-rustc-inf-loop.rs
issue-65611.rs
issue-65611.stderr
issue-67971.rs
issue-67971.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
issue-68590-reborrow-through-derefmut.rs
issue-69378-ice-on-invalid-type-node-after-recovery.rs
issue-69378-ice-on-invalid-type-node-after-recovery.stderr
issue-72225-call-fnmut-through-derefmut.rs
issue-73592-borrow_mut-through-deref.fixed
issue-73592-borrow_mut-through-deref.rs
issue-73592-borrow_mut-through-deref.stderr
issue-74086.rs
issue-74086.stderr
issue-74933.rs
issue-75883.rs diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07:00
issue-75883.stderr diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07:00
issue-75889.rs
issue-75889.stderr
issue-79040.rs
issue-79040.stderr
issue-80207-unsized-return.rs
issue-80779.rs
issue-80779.stderr
issue-81293.rs
issue-81293.stderr Don't sort strings right after we just sorted by types 2023-06-27 23:31:06 +00:00
issue-81885.rs
issue-81885.stderr
issue-81943.rs
issue-81943.stderr
issue-82772.rs
issue-82772.stderr
issue-83621-placeholder-static-in-extern.rs
issue-83621-placeholder-static-in-extern.stderr
issue-83693.rs
issue-83693.stderr
issue-84160.rs
issue-84160.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
issue-84768.rs
issue-84768.stderr diagnostics: update test cases to refer to assoc fn with self as method 2023-02-22 08:40:47 -07:00
issue-84831.rs
issue-84831.stderr
issue-86721-return-expr-ice.rev1.stderr
issue-86721-return-expr-ice.rev2.stderr
issue-86721-return-expr-ice.rs hir: Add Become expression kind 2023-06-26 08:56:32 +00:00
issue-87771-ice-assign-assign-to-bool.rs
issue-87771-ice-assign-assign-to-bool.stderr
issue-87872-missing-inaccessible-field-literal.rs
issue-87872-missing-inaccessible-field-literal.stderr
issue-87872-missing-inaccessible-field-pattern.rs
issue-87872-missing-inaccessible-field-pattern.stderr
issue-88609.rs
issue-88643.rs
issue-88643.stderr
issue-88803-call-expr-method.fixed
issue-88803-call-expr-method.rs
issue-88803-call-expr-method.stderr
issue-88844.rs
issue-88844.stderr
issue-89044-wrapped-expr-method.fixed
issue-89044-wrapped-expr-method.rs
issue-89044-wrapped-expr-method.stderr
issue-89275.rs
issue-89275.stderr
issue-89806.rs
issue-89806.stderr
issue-89856.fixed Fix suggestion for coercing Option<&String> to Option<&str> 2023-02-03 11:44:23 +00:00
issue-89856.rs Fix suggestion for coercing Option<&String> to Option<&str> 2023-02-03 11:44:23 +00:00
issue-89856.stderr More robust as_ref/as_deref suggestions 2023-06-08 16:30:05 +00:00
issue-89935.rs
issue-90027-async-fn-return-suggestion.rs Suggest return type for async function without return type 2023-02-06 13:02:04 +08:00
issue-90027-async-fn-return-suggestion.stderr fix: improve the suggestion on future not awaited 2023-02-13 16:23:23 +01:00
issue-90101.rs
issue-90101.stderr Don't sort strings right after we just sorted by types 2023-06-27 23:31:06 +00:00
issue-90164.rs
issue-90164.stderr Added diagnostic for pin! macro in addition to Box::pin if Unpin isn't implemented 2023-04-12 18:03:11 -04:00
issue-90319.rs
issue-90319.stderr
issue-90483-inaccessible-field-adjustment.rs
issue-90483-inaccessible-field-adjustment.stderr
issue-90804-incorrect-reference-suggestion.rs
issue-90804-incorrect-reference-suggestion.stderr Point at appropriate type parameter in more trait bound errors 2023-08-26 01:07:05 +00:00
issue-91210-ptr-method.fixed
issue-91210-ptr-method.rs
issue-91210-ptr-method.stderr
issue-91267.rs
issue-91267.stderr
issue-91328.fixed
issue-91328.rs
issue-91328.stderr
issue-91334.rs Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
issue-91334.stderr remove duplicated diagnostic for unclosed delimiter 2023-02-28 07:57:17 +00:00
issue-91450-inner-ty-error.rs
issue-91450-inner-ty-error.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
issue-91633.rs
issue-92481.rs Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
issue-92481.stderr Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
issue-93486.rs
issue-93486.stderr
issue-96530.rs
issue-96530.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
issue-96738.rs
issue-96738.stderr
issue-98260.rs
issue-98260.stderr
issue-98982.rs
issue-98982.stderr
issue-100164.fixed
issue-100164.rs
issue-100164.stderr
issue-100246.rs
issue-100246.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
issue-100285.rs
issue-100285.stderr
issue-103899.rs
issue-104510-ice.rs
issue-104510-ice.stderr
issue-104513-ice.rs
issue-104513-ice.stderr pluralize stuff 2023-02-22 21:52:26 +00:00
issue-104582.rs
issue-104582.stderr
issue-105946.rs Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
issue-105946.stderr Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
issue-106929.rs Don't typecheck suggested method call 2023-05-30 17:57:37 +08:00
issue-106929.stderr Don't typecheck suggested method call 2023-05-30 17:57:37 +08:00
issue-107087.rs Use proper InferCtxt when probing for associated types in astconv 2023-01-23 16:53:23 +00:00
issue-107087.stderr Use proper InferCtxt when probing for associated types in astconv 2023-01-23 16:53:23 +00:00
issue-107775.rs Remove astconv usage in diagnostic 2023-02-07 23:08:25 +00:00
issue-107775.stderr Point at which arg causes a binding to be constrained 2023-04-12 23:20:11 +00:00
issue-110017-format-into-help-deletes-macro.fixed Fix suggestions span for when expr is from macro expansions 2023-06-28 17:54:20 +08:00
issue-110017-format-into-help-deletes-macro.rs Fix suggestions span for when expr is from macro expansions 2023-06-28 17:54:20 +08:00
issue-110017-format-into-help-deletes-macro.stderr Fix suggestions span for when expr is from macro expansions 2023-06-28 17:54:20 +08:00
issue-110052.rs Erase lifetimes above ty::INNERMOST when probing ambiguous types 2023-04-11 17:17:32 +00:00
issue-110052.stderr Erase lifetimes above ty::INNERMOST when probing ambiguous types 2023-04-11 17:17:32 +00:00
issue-112007-leaked-writeln-macro-internals.fixed Fix suggestions span for when expr is from macro expansions 2023-06-28 17:54:20 +08:00
issue-112007-leaked-writeln-macro-internals.rs Fix suggestions span for when expr is from macro expansions 2023-06-28 17:54:20 +08:00
issue-112007-leaked-writeln-macro-internals.stderr Fix suggestions span for when expr is from macro expansions 2023-06-28 17:54:20 +08:00
issue-112252-ptr-arithmetics-help.fixed Add help for trying to do C-like pointer arithmetics 2023-06-09 10:01:16 +08:00
issue-112252-ptr-arithmetics-help.rs Add help for trying to do C-like pointer arithmetics 2023-06-09 10:01:16 +08:00
issue-112252-ptr-arithmetics-help.stderr Improve spans for indexing expressions 2023-08-04 13:17:39 +02:00
issue-112385-while-assign-lhs-place-expr-ice.rs Fix ICE for while loop with assignment condition with LHS place expr 2023-06-08 02:38:12 +08:00
issue-112385-while-assign-lhs-place-expr-ice.stderr Fix ICE for while loop with assignment condition with LHS place expr 2023-06-08 02:38:12 +08:00
issue-114423-ice-regression-in-suggestion.rs Rename issue #114423 test files to include context 2023-08-05 09:04:47 +08:00
issue-114423-ice-regression-in-suggestion.stderr Rename issue #114423 test files to include context 2023-08-05 09:04:47 +08:00
mismatched-map-under-self.rs Adjust inner span of implicit self ref argument 2023-06-28 17:51:01 +00:00
mismatched-map-under-self.stderr Do not suggest adjusting trait signature on type mismatch 2023-06-28 17:51:01 +00:00
missing-private-fields-in-struct-literal.rs
missing-private-fields-in-struct-literal.stderr
no-type-for-node-ice.rs
no-type-for-node-ice.stderr
nonexistent-field-not-ambiguous.rs
nonexistent-field-not-ambiguous.stderr
output-type-mismatch.rs Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
output-type-mismatch.stderr Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
path-to-method-sugg-unresolved-expr.rs
path-to-method-sugg-unresolved-expr.stderr
pin-unsound-issue-85099-derefmut.rs add known-bug test for unsound issue 85099 2023-04-22 00:51:49 -04:00
point-at-type-param-in-path-expr.rs
point-at-type-param-in-path-expr.stderr
point-at-type-parameter-definition.rs
point-at-type-parameter-definition.stderr
prim-with-args.fixed
prim-with-args.rs
prim-with-args.stderr
project-cache-issue-37154.rs
ptr-null-mutability-suggestions.fixed Suggest using ptr::null_mut when user supplied ptr::null to a function expecting ptr::null_mut 2023-06-09 20:05:46 +08:00
ptr-null-mutability-suggestions.rs Suggest using ptr::null_mut when user supplied ptr::null to a function expecting ptr::null_mut 2023-06-09 20:05:46 +08:00
ptr-null-mutability-suggestions.stderr Suggest using ptr::null_mut when user supplied ptr::null to a function expecting ptr::null_mut 2023-06-09 20:05:46 +08:00
quiet-type-err-let-binding.rs
quiet-type-err-let-binding.stderr
remove-extra-argument.fixed
remove-extra-argument.rs
remove-extra-argument.stderr Make removal suggestion not verbose 2023-02-14 20:22:10 +00:00
repeat-expr-checks-wf.rs check array type of repeat exprs is wf 2023-05-04 11:22:40 +01:00
repeat-expr-checks-wf.stderr check array type of repeat exprs is wf 2023-05-04 11:22:40 +01:00
return_type_containing_closure.rs Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
return_type_containing_closure.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
return-dyn-type-mismatch-2.rs only suppress coercion error if type is definitely unsized 2023-06-02 16:38:08 +00:00
return-dyn-type-mismatch-2.stderr only suppress coercion error if type is definitely unsized 2023-06-02 16:38:08 +00:00
return-dyn-type-mismatch.rs only suppress coercion error if type is definitely unsized 2023-06-02 16:38:08 +00:00
return-dyn-type-mismatch.stderr only suppress coercion error if type is definitely unsized 2023-06-02 16:38:08 +00:00
slow-lhs-suggestion.rs
slow-lhs-suggestion.stderr
struct-enum-wrong-args.rs
struct-enum-wrong-args.stderr Make removal suggestion not verbose 2023-02-14 20:22:10 +00:00
suggest-adding-missing-zero-to-floating-point-number.fixed
suggest-adding-missing-zero-to-floating-point-number.rs
suggest-adding-missing-zero-to-floating-point-number.stderr
suppressed-error.rs Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
suppressed-error.stderr Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
tag-that-dare-not-speak-its-name.rs Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
tag-that-dare-not-speak-its-name.stderr Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
terr-in-field.rs Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
terr-in-field.stderr Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
terr-sorts.rs Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
terr-sorts.stderr Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
type-placeholder-fn-in-const.rs properly check associated consts for infer placeholders 2023-06-11 00:27:03 +00:00
type-placeholder-fn-in-const.stderr properly check associated consts for infer placeholders 2023-06-11 00:27:03 +00:00
typeck_type_placeholder_1.rs
typeck_type_placeholder_item_help.rs properly check associated consts for infer placeholders 2023-06-11 00:27:03 +00:00
typeck_type_placeholder_item_help.stderr properly check associated consts for infer placeholders 2023-06-11 00:27:03 +00:00
typeck_type_placeholder_item.rs properly check associated consts for infer placeholders 2023-06-11 00:27:03 +00:00
typeck_type_placeholder_item.stderr properly check associated consts for infer placeholders 2023-06-11 00:27:03 +00:00
typeck_type_placeholder_lifetime_1.rs diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07:00
typeck_type_placeholder_lifetime_1.stderr diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07:00
typeck_type_placeholder_lifetime_2.rs diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07:00
typeck_type_placeholder_lifetime_2.stderr diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07:00
typeck_type_placeholder_mismatch.rs Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
typeck_type_placeholder_mismatch.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
typeck-builtin-bound-type-parameters.rs Don't use implied trait predicates in gather_explicit_predicates_of 2023-05-01 15:45:28 +00:00
typeck-builtin-bound-type-parameters.stderr Don't use implied trait predicates in gather_explicit_predicates_of 2023-05-01 15:45:28 +00:00
typeck-cast-pointer-to-float.rs
typeck-cast-pointer-to-float.stderr
typeck-closure-to-unsafe-fn-ptr.rs
typeck-default-trait-impl-assoc-type.fixed
typeck-default-trait-impl-assoc-type.rs
typeck-default-trait-impl-assoc-type.stderr Revert "Suggest using Arc on !Send/!Sync types" 2023-08-28 03:16:48 -07:00
typeck-default-trait-impl-cross-crate-coherence.rs
typeck-default-trait-impl-cross-crate-coherence.stderr
typeck-default-trait-impl-negation-send.rs
typeck-default-trait-impl-negation-send.stderr Revert "Suggest using Arc on !Send/!Sync types" 2023-08-28 03:16:48 -07:00
typeck-default-trait-impl-negation-sync.rs
typeck-default-trait-impl-negation-sync.stderr Revert "Suggest using Arc on !Send/!Sync types" 2023-08-28 03:16:48 -07:00
typeck-default-trait-impl-send-param.rs
typeck-default-trait-impl-send-param.stderr Revert "Suggest using Arc on !Send/!Sync types" 2023-08-28 03:16:48 -07:00
typeck-fn-to-unsafe-fn-ptr.rs
typeck-unsafe-always-share.rs
typeck-unsafe-always-share.stderr Revert "Suggest using Arc on !Send/!Sync types" 2023-08-28 03:16:48 -07:00
ufcs-type-params.rs
unify-return-ty.rs
while-loop-block-cond.rs
while-loop-block-cond.stderr
while-type-error.rs Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
while-type-error.stderr Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
wrong-ret-type.rs Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00
wrong-ret-type.stderr Move some UI tests into subdirectories 2023-04-02 19:42:30 -04:00