Skip to content

Commit 83b70e0

Browse files
authored
Rollup merge of #63917 - lzutao:langitem_gen_63912, r=centril,cramert
Error when generator trait is not found Closes #63912
2 parents 572d46f + fa7ea10 commit 83b70e0

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/librustc_typeck/check/closure.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use super::{check_fn, Expectation, FnCtxt, GeneratorTypes};
44

55
use crate::astconv::AstConv;
6-
use crate::middle::region;
6+
use crate::middle::{lang_items, region};
77
use rustc::hir::def_id::DefId;
88
use rustc::infer::{InferOk, InferResult};
99
use rustc::infer::LateBoundRegionConversionTime;
@@ -266,7 +266,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
266266
let trait_ref = projection.to_poly_trait_ref(tcx);
267267

268268
let is_fn = tcx.lang_items().fn_trait_kind(trait_ref.def_id()).is_some();
269-
let gen_trait = tcx.lang_items().gen_trait().unwrap();
269+
let gen_trait = tcx.require_lang_item(lang_items::GeneratorTraitLangItem);
270270
let is_gen = gen_trait == trait_ref.def_id();
271271
if !is_fn && !is_gen {
272272
debug!("deduce_sig_from_projection: not fn or generator");
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// error-pattern: requires `generator` lang_item
2+
#![feature(no_core, lang_items, unboxed_closures)]
3+
#![no_core]
4+
5+
#[lang = "sized"] pub trait Sized { }
6+
7+
#[lang = "fn_once"]
8+
#[rustc_paren_sugar]
9+
pub trait FnOnce<Args> {
10+
type Output;
11+
12+
extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
13+
}
14+
15+
pub fn abc() -> impl FnOnce(f32) {
16+
|_| {}
17+
}
18+
19+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: requires `generator` lang_item
2+
3+
error: aborting due to previous error
4+

0 commit comments

Comments
 (0)