From 347a257a474c0ee2d24f9fe780df16fdd7fb4972 Mon Sep 17 00:00:00 2001 From: Ivan Kozik Date: Mon, 15 Feb 2016 15:49:24 +0000 Subject: [PATCH 1/2] reference: vtable entries are resolved at runtime --- src/doc/reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 19c9b571a33c2..13288fbdbce21 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -3565,7 +3565,7 @@ Each instance of a trait object includes: implementation (i.e. a function pointer). The purpose of trait objects is to permit "late binding" of methods. A call to -a method on a trait object is only resolved to a vtable entry at compile time. +a method on a trait object is only resolved to a vtable entry at runtime. The actual implementation for each vtable entry can vary on an object-by-object basis. From 58f0d72d90bd38171e633705482c2043e2ef36bf Mon Sep 17 00:00:00 2001 From: Ivan Kozik Date: Thu, 18 Feb 2016 19:16:56 +0000 Subject: [PATCH 2/2] reference: vtable entries: copy @nikomatsakis's wording --- src/doc/reference.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 13288fbdbce21..2fdc1be3e77ce 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -3564,8 +3564,9 @@ Each instance of a trait object includes: each method of `SomeTrait` that `T` implements, a pointer to `T`'s implementation (i.e. a function pointer). -The purpose of trait objects is to permit "late binding" of methods. A call to -a method on a trait object is only resolved to a vtable entry at runtime. +The purpose of trait objects is to permit "late binding" of methods. Calling a +method on a trait object results in virtual dispatch at runtime: that is, a +function pointer is loaded from the trait object vtable and invoked indirectly. The actual implementation for each vtable entry can vary on an object-by-object basis.