Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when generator trait is not found #63917

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
19 changes: 19 additions & 0 deletions src/test/ui/lang-item-missing-generator.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions src/test/ui/lang-item-missing-generator.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
error: requires `generator` lang_item

error: aborting due to previous error