Skip to content

Commit 0d739b5

Browse files
committed
Update/improve documentation of ExpliciSelf
1 parent 6fd2156 commit 0d739b5

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/librustc_typeck/astconv.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,23 +1413,26 @@ pub enum ExplicitSelf<'tcx> {
14131413
}
14141414

14151415
impl<'tcx> ExplicitSelf<'tcx> {
1416-
/// We wish to (for now) categorize an explicit self
1417-
/// declaration like `self: SomeType` into either `self`,
1418-
/// `&self`, `&mut self`, or `Box<self>`. We do this here
1419-
/// by some simple pattern matching. A more precise check
1420-
/// is done later in `check_method_receiver()`.
1416+
/// Categorizes an explicit self declaration like `self: SomeType`
1417+
/// into either `self`, `&self`, `&mut self`, `Box<self>`, or
1418+
/// `Other` (meaning the arbitrary_self_types feature is used).
1419+
/// We do this here via a combination of pattern matching and
1420+
/// `can_eq`. A more precise check is done in `check_method_receiver()`.
14211421
///
14221422
/// Examples:
14231423
///
14241424
/// ```
1425-
/// impl Foo for &T {
1425+
/// impl<'a> Foo for &'a T {
14261426
/// // Legal declarations:
1427-
/// fn method1(self: &&T); // ExplicitSelf::ByReference
1428-
/// fn method2(self: &T); // ExplicitSelf::ByValue
1429-
/// fn method3(self: Box<&T>); // ExplicitSelf::ByBox
1427+
/// fn method1(self: &&'a T); // ExplicitSelf::ByReference
1428+
/// fn method2(self: &'a T); // ExplicitSelf::ByValue
1429+
/// fn method3(self: Box<&'a T>); // ExplicitSelf::ByBox
1430+
/// fn method4(self: Rc<&'a T>); // ExplicitSelf::Other
14301431
///
1431-
/// // Invalid cases will be caught later by `check_method_receiver`:
1432-
/// fn method_err1(self: &mut T); // ExplicitSelf::ByReference
1432+
/// // Invalid cases will be caught by `check_method_receiver`:
1433+
/// fn method_err1(self: &'a mut T); // ExplicitSelf::Other
1434+
/// fn method_err2(self: &'static T) // ExplicitSelf::ByValue
1435+
/// fn method_err3(self: &&T) // ExplicitSelf::ByReference
14331436
/// }
14341437
/// ```
14351438
///

0 commit comments

Comments
 (0)