mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 13:05:18 +03:00
Error when generator trait is not found
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
use super::{check_fn, Expectation, FnCtxt, GeneratorTypes};
|
||||
|
||||
use crate::astconv::AstConv;
|
||||
use crate::middle::region;
|
||||
use crate::middle::{lang_items, region};
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::infer::{InferOk, InferResult};
|
||||
use rustc::infer::LateBoundRegionConversionTime;
|
||||
@@ -266,7 +266,7 @@ fn deduce_sig_from_projection(
|
||||
let trait_ref = projection.to_poly_trait_ref(tcx);
|
||||
|
||||
let is_fn = tcx.lang_items().fn_trait_kind(trait_ref.def_id()).is_some();
|
||||
let gen_trait = tcx.lang_items().gen_trait().unwrap();
|
||||
let gen_trait = tcx.require_lang_item(lang_items::GeneratorTraitLangItem);
|
||||
let is_gen = gen_trait == trait_ref.def_id();
|
||||
if !is_fn && !is_gen {
|
||||
debug!("deduce_sig_from_projection: not fn or generator");
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// error-pattern: requires `generator` lang_item
|
||||
#![feature(no_core, lang_items, unboxed_closures)]
|
||||
#![no_core]
|
||||
|
||||
#[lang = "sized"] pub trait Sized { }
|
||||
|
||||
#[lang = "fn_once"]
|
||||
#[rustc_paren_sugar]
|
||||
pub trait FnOnce<Args> {
|
||||
type Output;
|
||||
|
||||
extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
|
||||
}
|
||||
|
||||
pub fn abc() -> impl FnOnce(f32) {
|
||||
|_| {}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,4 @@
|
||||
error: requires `generator` lang_item
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Reference in New Issue
Block a user