Error when generator trait is not found
This commit is contained in:
parent
9fa8f14023
commit
fa7ea104b2
3 changed files with 25 additions and 2 deletions
|
@ -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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
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");
|
||||
|
|
19
src/test/ui/lang-item-missing-generator.rs
Normal file
19
src/test/ui/lang-item-missing-generator.rs
Normal file
|
@ -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() {}
|
4
src/test/ui/lang-item-missing-generator.stderr
Normal file
4
src/test/ui/lang-item-missing-generator.stderr
Normal file
|
@ -0,0 +1,4 @@
|
|||
error: requires `generator` lang_item
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue