about summary refs log tree commit diff
path: root/src/libsyntax/ast.rs
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2019-11-23 14:15:49 +0000
committerMatthew Jasper <mjjasper1@gmail.com>2019-11-24 18:06:13 +0000
commita8efd31f2b97a043d73db2131dddfedd65485d50 (patch)
treed5eef5952391f5bf162f3ce4a4470255157843f0 /src/libsyntax/ast.rs
parent9420ff4c0ebea44b167d530bb59f9d5721d8ff0b (diff)
downloadrust-a8efd31f2b97a043d73db2131dddfedd65485d50.tar.gz
rust-a8efd31f2b97a043d73db2131dddfedd65485d50.zip
Add raw address of expressions to the AST and HIR
Diffstat (limited to 'src/libsyntax/ast.rs')
-rw-r--r--src/libsyntax/ast.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 14243076941..dc26929100a 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -754,6 +754,21 @@ impl Mutability {
     }
 }
 
+/// The kind of borrow in an `AddrOf` expression,
+/// e.g., `&place` or `&raw const place`.
+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
+#[derive(RustcEncodable, RustcDecodable, HashStable_Generic)]
+pub enum BorrowKind {
+    /// A raw borrow, `&raw const $expr` or `&raw mut $expr`.
+    /// The resulting type is either `*const T` or `*mut T`
+    /// where `T = typeof($expr)`.
+    Ref,
+    /// A normal borrow, `&$expr` or `&mut $expr`.
+    /// The resulting type is either `&'a T` or `&'a mut T`
+    /// where `T = typeof($expr)` and `'a` is some lifetime.
+    Raw,
+}
+
 #[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
 pub enum BinOpKind {
     /// The `+` operator (addition)
@@ -1071,7 +1086,7 @@ impl Expr {
 
             ExprKind::Paren(expr) => expr.to_ty().map(TyKind::Paren)?,
 
-            ExprKind::AddrOf(mutbl, expr) => expr
+            ExprKind::AddrOf(BorrowKind::Ref, mutbl, expr) => expr
                 .to_ty()
                 .map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?,
 
@@ -1262,8 +1277,8 @@ pub enum ExprKind {
     /// Optionally "qualified" (e.g., `<Vec<T> as SomeTrait>::SomeType`).
     Path(Option<QSelf>, Path),
 
-    /// A referencing operation (`&a` or `&mut a`).
-    AddrOf(Mutability, P<Expr>),
+    /// A referencing operation (`&a`, `&mut a`, `&raw const a` or `&raw mut a`).
+    AddrOf(BorrowKind, Mutability, P<Expr>),
     /// A `break`, with an optional label to break, and an optional expression.
     Break(Option<Label>, Option<P<Expr>>),
     /// A `continue`, with an optional label.