Skip to content

Commit 7218e5d

Browse files
BillWagnerjskeet
authored andcommitted
Item 45: §16.2.3 Restructure ref struct restriction list
Restructure the bullet list so all items grammatically complete the lead-in "It is a compile-time error if a ref struct type is used in any of the following contexts:". Several items are currently standalone statements (e.g., "There is no conversion from...") that don't fit the lead-in.
1 parent ed81fd3 commit 7218e5d

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

standard/structs.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,18 @@ It is a compile-time error if a ref struct type is used in any of the following
6969

7070
- As the element type of an array.
7171
- As the declared type of a field of a class or a struct that does not have the `ref` modifier.
72-
- Being boxed to `System.ValueType` or `System.Object`.
7372
- As a type argument.
7473
- As the type of a tuple element.
75-
- An async method.
76-
- An iterator.
77-
- There is no conversion from a `ref struct` type to the type `object` or the type `System.ValueType`.
74+
- In an async method.
75+
- In an iterator.
76+
- As the receiver type for a method group conversion to a delegate type.
77+
- As a captured variable in a lambda expression or a local function.
78+
79+
In addition, the following restrictions apply to a `ref struct` type:
80+
81+
- A `ref struct` type shall not be boxed to `System.ValueType` or `System.Object`.
7882
- A `ref struct` type shall not be declared to implement any interface.
7983
- An instance method declared in `object` or in `System.ValueType` but not overridden in a `ref struct` type shall not be called with a receiver of that `ref struct` type.
80-
- An instance method of a `ref struct` type shall not be captured by method group conversion to a delegate type.
81-
- A ref struct shall not be captured by a lambda expression or a local function.
8284

8385
> *Note*: A `ref struct` shall not declare `async` instance methods nor use a `yield return` or `yield break` statement within an instance method, because the implicit `this` parameter cannot be used in those contexts. *end note*
8486

0 commit comments

Comments
 (0)