/// [`Pin`]: ../pin/struct.Pin.html
/// [`pin module`]: ../../std/pin/index.html
#[stable(feature = "pin", since = "1.33.0")]
+#[cfg_attr(not(stage0), lang = "unpin")]
pub auto trait Unpin {}
/// A marker type which does not implement `Unpin`.
GeneratorStateLangItem, "generator_state", gen_state, Target::Enum;
GeneratorTraitLangItem, "generator", gen_trait, Target::Trait;
+ UnpinTraitLangItem, "unpin", unpin_trait, Target::Trait;
EqTraitLangItem, "eq", eq_trait, Target::Trait;
PartialOrdTraitLangItem, "partial_ord", partial_ord_trait, Target::Trait;
// the auto impl might apply, we don't know
candidates.ambiguous = true;
}
+ ty::Generator(_, _, hir::GeneratorMovability::Static)
+ if self.tcx().lang_items().unpin_trait() == Some(def_id) =>
+ {
+ // Immovable generators are never `Unpin`, so suppress the
+ // normal auto-impl candidate for it.
+ }
_ => candidates.vec.push(AutoImplCandidate(def_id.clone())),
}
}
--- /dev/null
+#![feature(generators)]
+
+use std::marker::Unpin;
+
+fn assert_unpin<T: Unpin>(_: T) {
+}
+
+fn main() {
+ let mut generator = static || {
+ yield;
+ };
+ assert_unpin(generator); //~ ERROR std::marker::Unpin` is not satisfied
+}
--- /dev/null
+error[E0277]: the trait bound `[static generator@$DIR/static-not-unpin.rs:9:25: 11:6 _]: std::marker::Unpin` is not satisfied
+ --> $DIR/static-not-unpin.rs:12:5
+ |
+LL | assert_unpin(generator); //~ ERROR std::marker::Unpin` is not satisfied
+ | ^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:9:25: 11:6 _]`
+ |
+note: required by `assert_unpin`
+ --> $DIR/static-not-unpin.rs:5:1
+ |
+LL | fn assert_unpin<T: Unpin>(_: T) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.