about summary refs log tree commit diff
path: root/library/alloc/src
diff options
context:
space:
mode:
authorThe Miri Conjob Bot <miri@cron.bot>2023-07-22 06:34:13 +0000
committerThe Miri Conjob Bot <miri@cron.bot>2023-07-22 06:34:13 +0000
commitbd1e4eeaeaba6bfb67c07af3ccb5241cf80bc431 (patch)
tree2be01ed59bba85f4bdfe6c2f9d49856e7cf0b039 /library/alloc/src
parent6e3932e10d02c68d2013e3f6c889a95ec588f28f (diff)
parent7ac0ef9d1164fdb744f3f3c2f4a6893ed06cbe73 (diff)
downloadrust-bd1e4eeaeaba6bfb67c07af3ccb5241cf80bc431.tar.gz
rust-bd1e4eeaeaba6bfb67c07af3ccb5241cf80bc431.zip
Merge from rustc
Diffstat (limited to 'library/alloc/src')
-rw-r--r--library/alloc/src/rc.rs8
-rw-r--r--library/alloc/src/sync.rs8
2 files changed, 12 insertions, 4 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs
index b3ec830a7d7..bf01b2082ed 100644
--- a/library/alloc/src/rc.rs
+++ b/library/alloc/src/rc.rs
@@ -661,10 +661,14 @@ impl<T> Rc<T> {
 
 impl<T, A: Allocator> Rc<T, A> {
     /// Returns a reference to the underlying allocator.
+    ///
+    /// Note: this is an associated function, which means that you have
+    /// to call it as `Rc::allocator(&r)` instead of `r.allocator()`. This
+    /// is so that there is no conflict with a method on the inner type.
     #[inline]
     #[unstable(feature = "allocator_api", issue = "32838")]
-    pub fn allocator(&self) -> &A {
-        &self.alloc
+    pub fn allocator(this: &Self) -> &A {
+        &this.alloc
     }
     /// Constructs a new `Rc` in the provided allocator.
     ///
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs
index e00850eb5d8..c2202f2fce5 100644
--- a/library/alloc/src/sync.rs
+++ b/library/alloc/src/sync.rs
@@ -678,10 +678,14 @@ impl<T> Arc<T> {
 
 impl<T, A: Allocator> Arc<T, A> {
     /// Returns a reference to the underlying allocator.
+    ///
+    /// Note: this is an associated function, which means that you have
+    /// to call it as `Arc::allocator(&a)` instead of `a.allocator()`. This
+    /// is so that there is no conflict with a method on the inner type.
     #[inline]
     #[unstable(feature = "allocator_api", issue = "32838")]
-    pub fn allocator(&self) -> &A {
-        &self.alloc
+    pub fn allocator(this: &Self) -> &A {
+        &this.alloc
     }
     /// Constructs a new `Arc<T>` in the provided allocator.
     ///