File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 140
140
#![ feature( type_alias_impl_trait) ]
141
141
#![ feature( associated_type_bounds) ]
142
142
#![ feature( slice_group_by) ]
143
+ #![ feature( decl_macro) ]
143
144
// Allow testing this library
144
145
145
146
#[ cfg( test) ]
@@ -193,4 +194,11 @@ mod std {
193
194
#[ unstable( feature = "liballoc_internals" , issue = "none" , reason = "implementation detail" ) ]
194
195
pub mod __export {
195
196
pub use core:: format_args;
197
+
198
+ /// Force AST node to an expression to improve diagnostics in pattern position.
199
+ #[ rustc_macro_transparency = "semitransparent" ]
200
+ #[ unstable( feature = "liballoc_internals" , issue = "none" , reason = "implementation detail" ) ]
201
+ pub macro force_expr( $e: expr) {
202
+ $e
203
+ }
196
204
}
Original file line number Diff line number Diff line change 37
37
#[ cfg( not( test) ) ]
38
38
#[ macro_export]
39
39
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
40
- #[ allow_internal_unstable( box_syntax) ]
40
+ #[ allow_internal_unstable( box_syntax, liballoc_internals ) ]
41
41
macro_rules! vec {
42
42
( ) => (
43
- $crate:: vec:: Vec :: new( )
43
+ $crate:: __export :: force_expr! ( $crate :: vec:: Vec :: new( ) )
44
44
) ;
45
45
( $elem: expr; $n: expr) => (
46
- $crate:: vec:: from_elem( $elem, $n)
46
+ $crate:: __export :: force_expr! ( $crate :: vec:: from_elem( $elem, $n) )
47
47
) ;
48
48
( $( $x: expr) ,+ $( , ) ?) => (
49
- <[ _] >:: into_vec( box [ $( $x) ,+] )
49
+ $crate :: __export :: force_expr! ( <[ _] >:: into_vec( box [ $( $x) ,+] ) )
50
50
) ;
51
51
}
52
52
You can’t perform that action at this time.
0 commit comments