Skip to content

Commit 80d730b

Browse files
committed
Add MCP 563 syntax
1 parent 5bef91c commit 80d730b

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
540540

541541
gated!(fundamental, Normal, template!(Word), WarnFollowing, experimental!(fundamental)),
542542
gated!(
543-
may_dangle, Normal, template!(Word), WarnFollowing, dropck_eyepatch,
543+
may_dangle, Normal, template!(Word, List: "borrow"), WarnFollowing, dropck_eyepatch,
544544
"`may_dangle` has unstable semantics and may be removed in the future",
545545
),
546546

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ symbols! {
425425
black_box,
426426
block,
427427
bool,
428+
borrow,
428429
borrowck_graphviz_format,
429430
borrowck_graphviz_postflow,
430431
box_free,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#![feature(dropck_eyepatch)]
2+
3+
// This test checks the `#[may_dangle]` attribute syntax.
4+
5+
struct Foo<T>(*const T);
6+
7+
// No error: "drops" bound
8+
unsafe impl<#[may_dangle] T> Drop for Foo<T> {
9+
fn drop(&mut self) { }
10+
}
11+
12+
struct Bar<T>(*const T);
13+
14+
// No error: "borrows" bound
15+
unsafe impl<#[may_dangle(borrow)] T> Drop for Bar<T> {
16+
fn drop(&mut self) { }
17+
}
18+
19+
struct Baz<T>(*const T);
20+
21+
// Error: invalid syntax
22+
unsafe impl<#[may_dangle(invalid)] T> Drop for Baz<T> {
23+
fn drop(&mut self) { }
24+
}
25+
26+
pub fn main() { }

0 commit comments

Comments
 (0)