Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c4b1054
Move PointIndex to mir_dataflow.
cjgillot Dec 3, 2023
da235ce
Do not recompute liveness for DestinationPropagation.
cjgillot Dec 3, 2023
3082028
Fix comment.
cjgillot Dec 3, 2023
1d6723a
Use for_each instead of fold.
cjgillot Jan 7, 2024
adce3fd
Enable Static Builds for FreeBSD
rellerreller Jan 11, 2024
9a8f117
Don't create the array type twice
oli-obk Jan 15, 2024
ee370a1
Consistently unset RUSTC_BOOTSTRAP when compiling bootstrap
dtolnay Jan 15, 2024
3599c18
Skip dead code checks on items that failed typeck
oli-obk Jan 16, 2024
450cb5e
Don't ICE if TAIT-defining fn contains a closure with `_` in return type
Jan 14, 2024
22833c1
add test for non-defining use of TAIT in foreign function item
Jan 15, 2024
e12101c
Fix `rustc_abi` build on stable
Nadrieril Jan 16, 2024
37a5464
Eagerly instantiate closure ty
compiler-errors Jan 14, 2024
19d6f06
Don't rely on contiguous `VariantId`s outside of rustc
Nadrieril Jan 17, 2024
db7125f
Fix typo in comments (in_place_collect)
Storyyeller Jan 17, 2024
d6b99b9
Use FnOnceOutput instead of FnOnce where expected
oli-obk Jan 17, 2024
3ae7ab6
Rollup merge of #115291 - cjgillot:dest-prop-save, r=JakobDegen
matthiaskrgr Jan 17, 2024
c9779af
Rollup merge of #119855 - rellerreller:freebsd-static, r=wesleywiser
matthiaskrgr Jan 17, 2024
22f1913
Rollup merge of #119975 - lukas-code:inferring-return-types-and-opaqu…
matthiaskrgr Jan 17, 2024
cc9a4a2
Rollup merge of #120001 - dtolnay:bootstrapbootstrap, r=onur-ozkan
matthiaskrgr Jan 17, 2024
6ca77ff
Rollup merge of #120020 - oli-obk:long_const_eval_err_taint, r=compil…
matthiaskrgr Jan 17, 2024
cd5eb6a
Rollup merge of #120031 - compiler-errors:construct-closure-ty-eagerl…
matthiaskrgr Jan 17, 2024
e0aa4df
Rollup merge of #120032 - Nadrieril:fix-rustc_abi, r=Nilstrieb
matthiaskrgr Jan 17, 2024
3a3242a
Rollup merge of #120039 - Nadrieril:remove-idx, r=compiler-errors
matthiaskrgr Jan 17, 2024
a2eefd2
Rollup merge of #120044 - Storyyeller:patch-2, r=lqd
matthiaskrgr Jan 17, 2024
99a8b6a
Rollup merge of #120056 - oli-obk:arg_mismatch_ice, r=compiler-errors
matthiaskrgr Jan 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't ICE if TAIT-defining fn contains a closure with _ in return type
  • Loading branch information
Lukas Markeffsky committed Jan 16, 2024
commit 450cb5eda6d1db8b5b45a3775cb5316bb623dc63
31 changes: 19 additions & 12 deletions compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,25 @@ impl TaitConstraintLocator<'_> {
return;
}

if let Some(hir_sig) = self.tcx.hir_node_by_def_id(item_def_id).fn_decl() {
if hir_sig.output.get_infer_ret_ty().is_some() {
let guar = self.tcx.dcx().span_delayed_bug(
hir_sig.output.span(),
"inferring return types and opaque types do not mix well",
);
self.found = Some(ty::OpaqueHiddenType {
span: DUMMY_SP,
ty: Ty::new_error(self.tcx, guar),
});
return;
}
// Function items with `_` in their return type already emit an error, skip any
// "non-defining use" errors for them.
// Note that we use `Node::fn_sig` instead of `Node::fn_decl` here, because the former
// excludes closures, which are allowed to have `_` in their return type.
let hir_node = self.tcx.hir_node_by_def_id(item_def_id);
debug_assert!(
!matches!(hir_node, Node::ForeignItem(..)),
"foreign items cannot constrain opaque types",
);
if let Some(hir_sig) = hir_node.fn_sig()
&& hir_sig.decl.output.get_infer_ret_ty().is_some()
{
let guar = self.tcx.dcx().span_delayed_bug(
hir_sig.decl.output.span(),
"inferring return types and opaque types do not mix well",
);
self.found =
Some(ty::OpaqueHiddenType { span: DUMMY_SP, ty: Ty::new_error(self.tcx, guar) });
return;
}

// Calling `mir_borrowck` can lead to cycle errors through
Expand Down
35 changes: 35 additions & 0 deletions tests/ui/type-alias-impl-trait/closure_infer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// check-pass

// Regression test for an ICE: https://github.com/rust-lang/rust/issues/119916

#![feature(impl_trait_in_assoc_type)]
#![feature(type_alias_impl_trait)]

// `impl_trait_in_assoc_type` example from the bug report.
pub trait StreamConsumer {
type BarrierStream;
fn execute() -> Self::BarrierStream;
}

pub struct DispatchExecutor;

impl StreamConsumer for DispatchExecutor {
type BarrierStream = impl Sized;
fn execute() -> Self::BarrierStream {
|| -> _ {}
}
}

// Functions that constrain TAITs can contain closures with an `_` in the return type.
type Foo = impl Sized;
fn foo() -> Foo {
|| -> _ {}
}

// The `_` in the closure return type can also be the TAIT itself.
type Bar = impl Sized;
fn bar() -> impl FnOnce() -> Bar {
|| -> _ {}
}

fn main() {}