From b43716d687859191769509876ddec85b98cea39c Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Sat, 17 Nov 2018 22:10:10 +0000 Subject: [PATCH] Added `Captures` marker trait. --- src/libcore/marker.rs | 12 +++++++++++- src/libsyntax/feature_gate.rs | 8 ++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 3bcdfabbb245e..5b71e1d29b6b7 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -605,7 +605,7 @@ unsafe impl Freeze for *mut T {} unsafe impl Freeze for &T {} unsafe impl Freeze for &mut T {} -/// Types which can be safely moved after being pinned. +/// Types that can be safely moved after being pinned. /// /// Since Rust itself has no notion of immovable types, and will consider moves to always be safe, /// this trait cannot prevent types from moving by itself. @@ -694,3 +694,13 @@ mod copy_impls { impl Copy for &T {} } + +/// Captures a lifetime without doing anything with it. +/// +/// This is useful in particular for functions returning opaque types +/// (i.e. `impl Trait`) that do not mention lifetimes otherwise mentioned in +/// the corresponding concrete type. +#[unstable(feature = "captures_trait", issue = "56046")] +trait Captures<'a> {} + +impl Captures<'a> for T {} diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 55652c481bd3f..f3b6538c9ccc8 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -617,7 +617,7 @@ declare_features! ( (accepted, match_beginning_vert, "1.25.0", Some(44101), None), // Nested groups in `use` (RFC 2128) (accepted, use_nested_groups, "1.25.0", Some(44494), None), - // a..=b and ..=b + // `a..=b` and `..=b` (accepted, inclusive_range_syntax, "1.26.0", Some(28237), None), // allow `..=` in patterns (RFC 1192) (accepted, dotdoteq_in_patterns, "1.26.0", Some(28237), None), @@ -688,8 +688,8 @@ declare_features! ( (accepted, min_const_fn, "1.31.0", Some(53555), None), // Scoped lints (accepted, tool_lints, "1.31.0", Some(44690), None), - // impl Iterator for &mut Iterator - // impl Debug for Foo<'_> + // `impl Iterator for &mut Iterator` + // `impl Debug for Foo<'_>` (accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None), ); @@ -1183,7 +1183,7 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG cfg_fn!(custom_test_frameworks))), ]; -// cfg(...)'s that are feature gated +// cfg's that are feature gated const GATED_CFGS: &[(&str, &str, fn(&Features) -> bool)] = &[ // (name in cfg, feature, function to check if the feature is enabled) ("target_vendor", "cfg_target_vendor", cfg_fn!(cfg_target_vendor)),