diff options
Diffstat (limited to 'src/libsyntax/ptr.rs')
| -rw-r--r-- | src/libsyntax/ptr.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index 1b3ebde2461..8b1aed483c3 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -10,16 +10,18 @@ //! The AST pointer //! -//! Provides `P<T>`, a frozen owned smart pointer, as a replacement for `@T` in the AST. +//! Provides `P<T>`, a frozen owned smart pointer, as a replacement for `@T` in +//! the AST. //! //! # Motivations and benefits //! -//! * **Identity**: sharing AST nodes is problematic for the various analysis passes -//! (e.g. one may be able to bypass the borrow checker with a shared `ExprAddrOf` -//! node taking a mutable borrow). The only reason `@T` in the AST hasn't caused -//! issues is because of inefficient folding passes which would always deduplicate -//! any such shared nodes. Even if the AST were to switch to an arena, this would -//! still hold, i.e. it couldn't use `&'a T`, but rather a wrapper like `P<'a, T>`. +//! * **Identity**: sharing AST nodes is problematic for the various analysis +//! passes (e.g. one may be able to bypass the borrow checker with a shared +//! `ExprAddrOf` node taking a mutable borrow). The only reason `@T` in the +//! AST hasn't caused issues is because of inefficient folding passes which +//! would always deduplicate any such shared nodes. Even if the AST were to +//! switch to an arena, this would still hold, i.e. it couldn't use `&'a T`, +//! but rather a wrapper like `P<'a, T>`. //! //! * **Immutability**: `P<T>` disallows mutating its inner `T`, unlike `Box<T>` //! (unless it contains an `Unsafe` interior, but that may be denied later). @@ -34,9 +36,9 @@ //! implementation changes (using a special thread-local heap, for example). //! Moreover, a switch to, e.g. `P<'a, T>` would be easy and mostly automated. -use std::fmt; -use std::fmt::Show; +use std::fmt::{mod, Show}; use std::hash::Hash; +use std::ops::Deref; use std::ptr; use serialize::{Encodable, Decodable, Encoder, Decoder}; |
