Rust: Невозможно применить Drop для универсального типа с привязкой свойства более высокого ранга

Созданный на 17 авг. 2015  ·  3Комментарии  ·  Источник: rust-lang/rust

Если я попытаюсь скомпилировать эту программу:

pub trait Foo<'a> {}

pub struct Bar<T> where T: for<'a> Foo<'a> {
    _phantom: ::std::marker::PhantomData<T>,
}

impl <T> Drop for Bar<T> where T: for<'a> Foo<'a> {
    fn drop(&mut self) {}
}

fn main() {}

Я получаю это явно поддельное сообщение об ошибке:

$ rustc test.rs
test.rs:7:1: 9:2 error: The requirement `for<'a> T : Foo<'a>` is added only by the Drop impl. [E0367]
test.rs:7 impl <T> Drop for Bar<T> where T: for<'a> Foo<'a> {
test.rs:8     fn drop(&mut self) {}
test.rs:9 }
test.rs:7:1: 9:2 help: run `rustc --explain E0367` to see a detailed explanation
test.rs:3:1: 5:2 note: The same requirement must be part of the struct/enum definition
test.rs:3 pub struct Bar<T> where T: for<'a> Foo<'a> {
test.rs:4     _phantom: ::std::marker::PhantomData<T>,
test.rs:5 }

Я попытался повозиться с ним, чтобы заставить его проверить тип, но ничего не помогло.

$ rustc --version --verbose
rustc 1.4.0-nightly (e822a18ae 2015-08-16)
binary: rustc
commit-hash: e822a18ae7d55cefc332c6598a607cef0554ec77
commit-date: 2015-08-16
host: x86_64-apple-darwin
release: 1.4.0-nightly
A-destructors A-traits A-typesystem C-bug T-compiler

Самый полезный комментарий

То же самое, я только что наткнулся на эту проблему. Как дела? Вопрос стоит 3 года.

Все 3 Комментарий

cc @pnkfelix

То же самое, я только что наткнулся на эту проблему. Как дела? Вопрос стоит 3 года.

Влияет и на меня. Удар?

Была ли эта страница полезной?
0 / 5 - 0 рейтинги