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

Add Captures marker trait #56047

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 11 additions & 1 deletion src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ unsafe impl<T: ?Sized> Freeze for *mut T {}
unsafe impl<T: ?Sized> Freeze for &T {}
unsafe impl<T: ?Sized> 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.
Expand Down Expand Up @@ -694,3 +694,13 @@ mod copy_impls {
impl<T: ?Sized> 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<T: ?Sized> Captures<'a> for T {}
8 changes: 4 additions & 4 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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<I:Iterator> Iterator for &mut Iterator
// impl Debug for Foo<'_>
// `impl<I: Iterator> Iterator for &mut Iterator`
// `impl Debug for Foo<'_>`
(accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None),
);

Expand Down Expand Up @@ -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)),
Expand Down