Skip to content

unconstrained type parameter #4883

Description

@philberty

Summary

test.rs:37:6: error: unconstrained type parameter
   37 | impl<B, I: Iterator2, F> Iterator2 for FilterMap<I, F>
      |      ^

Reproducer

I tried this code:

#![feature(no_core, lang_items, unboxed_closures)]
#![no_core]

#[lang = "sized"]
pub trait Sized {}

pub trait Iterator2 {
    type Item;
}

#[lang = "fn_once"]
#[rustc_paren_sugar]
pub trait FnOnce<Args> {
    #[lang = "fn_once_output"]
    type Output;

    extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
}

#[lang = "fn_mut"]
#[rustc_paren_sugar]
pub trait FnMut<Args>: FnOnce<Args> {
    extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
}

pub struct FilterMap<I, F> {
    iter: I,
    f: F,
}

impl<B, I: Iterator2, F> Iterator2 for FilterMap<I, F>
where
    F: FnMut(I::Item) -> Option<B>,
{
    type Item = B;
}

pub enum Option<T> {
    None,
    Some(T),
}

fn main() -> i32 {
    0
}

Does the code make use of any (1.49) nightly feature ?

  • Nightly

Godbolt link

No response

Actual behavior

The current behavior is...

Expected behavior

I expected to see...

GCC Version

HEAD

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreIssue related to the compilation of the `core` crate

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions