Skip to content

Commit 6e3bc59

Browse files
committed
Merge remote-tracking branch 'origin/trunk' into test-call-returning-facet-value
2 parents 5583449 + 7c13bdd commit 6e3bc59

File tree

649 files changed

+25894
-37670
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

649 files changed

+25894
-37670
lines changed

.codespell_ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Exceptions. See /LICENSE for license information.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

5+
AggregateT
56
ArchType
67
atleast
78
circularly

.github/workflows/auto_assign_prs.yaml

Lines changed: 0 additions & 63 deletions
This file was deleted.

CODEOWNERS

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
2+
# Exceptions. See /LICENSE for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
# This file is only used for PR autoassignment. Branch protections don't enforce
6+
# it.
7+
#
8+
# Syntax:
9+
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax
10+
11+
# Toolchain reviewers are used as a fallback.
12+
* @carbon-language/toolchain-reviewers
13+
14+
# Key project documents should be reviewed by leads.
15+
/*.md @carbon-language/leads
16+
/LICENSE @carbon-language/leads
17+
/docs/project/evolution.md @carbon-language/leads
18+
/docs/project/goals.md @carbon-language/leads
19+
/docs/project/principles/* @carbon-language/leads
20+
/docs/project/roadmap.md @carbon-language/leads
21+
/proposals/*.md @carbon-language/leads
22+
23+
# Toolchain code.
24+
/toolchain @carbon-language/toolchain-reviewers

common/filesystem.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ auto PathError::Print(llvm::raw_ostream& out) const -> void {
6262
// The `format_` member is a `StringLiteral` that is null terminated, so
6363
// `.data()` is safe here.
6464
// NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
65-
out << llvm::formatv(format_.data(), path_, dir_fd_) << " failed: ";
65+
out << llvm::formatv(format_.data(), path_,
66+
dir_fd_ == AT_FDCWD ? std::string("AT_FDCWD")
67+
: std::to_string(dir_fd_))
68+
<< " failed: ";
6669
PrintErrorNumber(out, unix_errnum());
6770
}
6871

core/prelude/destroy.carbon

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@
44

55
package Core library "prelude/destroy";
66

7-
// Object destruction, including running `fn destroy()`. Note this is distinct
8-
// from memory deallocation.
7+
// TODO: Add `Destructor`, as in:
8+
// interface Destructor {
9+
// private fn Op[ref self: Self]();
10+
// }
11+
12+
// Destroys objects. This will invoke `Destructor` impls recursively on members;
13+
// it does not deallocate memory.
914
interface Destroy {
15+
// TODO: This should be `final fn Op[ref self: Self]() = "type.destroy"`.
1016
fn Op[addr self: Self*]();
1117
}
1218

13-
// Provide a default blanket impl for trivial destruction.
14-
impl forall [T:! type] T as Destroy {
15-
fn Op[addr self: Self*]() = "no_op";
19+
// Returns a constraint that matches all types that should have a `Destroy` impl.
20+
private fn CanDestroy() -> type = "type.can_destroy";
21+
22+
// Destroys an instance of `DestroyT`. This is also used for trivial types.
23+
final impl forall [DestroyT:! CanDestroy()] DestroyT as Destroy {
24+
fn Op[addr self: Self*]() = "type.destroy";
1625
}

core/prelude/operators/index.carbon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package Core library "prelude/operators/index";
66

7-
interface IndexWith(SubscriptType:! type, ElementType:! type) {
7+
interface IndexWith(SubscriptType:! type) {
8+
let ElementType:! type;
89
fn At[self: Self](subscript: SubscriptType) -> ElementType;
910
}

docs/design/README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,9 @@ or restrictions on casts between pointers and integers.
862862
863863
### Arrays and slices
864864

865+
> **TODO:** The provisional array syntax documented here has been superseded by
866+
> [p4682: The Core.Array type for direct-storage immutably-sized buffers](/proposals/p4682.md).
867+
865868
The type of an array of holding 4 `i32` values is written `[i32; 4]`. There is
866869
an [implicit conversion](expressions/implicit_conversions.md) from tuples to
867870
arrays of the same length as long as every component of the tuple may be
@@ -1764,16 +1767,16 @@ class Point {
17641767
return Math.Sqrt(dx * dx + dy * dy);
17651768
}
17661769
// Mutating method declaration
1767-
fn Offset[addr self: Self*](dx: i32, dy: i32);
1770+
fn Offset[ref self: Self](dx: i32, dy: i32);
17681771
17691772
var x: i32;
17701773
var y: i32;
17711774
}
17721775
17731776
// Out-of-line definition of method declared inline
1774-
fn Point.Offset[addr self: Self*](dx: i32, dy: i32) {
1775-
self->x += dx;
1776-
self->y += dy;
1777+
fn Point.Offset[ref self: Self](dx: i32, dy: i32) {
1778+
self.x += dx;
1779+
self.y += dy;
17771780
}
17781781
17791782
var origin: Point = {.x = 0, .y = 0};
@@ -1793,10 +1796,9 @@ two methods `Distance` and `Offset`:
17931796
- `Distance` computes and returns the distance to another point, without
17941797
modifying the `Point`. This is signified using `[self: Self]` in the method
17951798
declaration.
1796-
- `origin.Offset(`...`)` does modify the value of `origin`. This is signified
1797-
using `[addr self: Self*]` in the method declaration. Since calling this
1798-
method requires taking the [non-`const`](#const) address of `origin`, it may
1799-
only be called on [reference expressions](#expression-categories).
1799+
- `origin.Offset(`...`)` _does_ modify the value of `origin`. This is
1800+
signified using `[ref self: Self]` in the method declaration. It may only be
1801+
called on [reference expressions](#expression-categories).
18001802
- Methods may be declared lexically inline like `Distance`, or lexically out
18011803
of line like `Offset`.
18021804

@@ -1952,7 +1954,7 @@ names resolvable by the compiler, and don't act like forward declarations.
19521954

19531955
A destructor for a class is custom code executed when the lifetime of a value of
19541956
that type ends. They are defined with `fn destroy` followed by either
1955-
`[self: Self]` or `[addr self: Self*]` (as is done with [methods](#methods)) and
1957+
`[self: Self]` or `[ref self: Self]` (as is done with [methods](#methods)) and
19561958
the block of code in the class definition, as in:
19571959

19581960
```carbon
@@ -1966,7 +1968,7 @@ or:
19661968
```carbon
19671969
class MyClass {
19681970
// Can modify `self` in the body.
1969-
fn destroy[addr self: Self*]() { ... }
1971+
fn destroy[ref self: Self]() { ... }
19701972
}
19711973
```
19721974

@@ -2001,8 +2003,8 @@ For every type `MyClass`, there is the type `const MyClass` such that:
20012003
has type `const T`.
20022004
- While all of the member names in `MyClass` are also member names in
20032005
`const MyClass`, the effective API of a `const MyClass` reference expression
2004-
is a subset of `MyClass`, because only `addr` methods accepting a
2005-
`const Self*` will be valid.
2006+
is a subset of `MyClass`, because only `ref` methods accepting a
2007+
`const Self` will be valid.
20062008

20072009
Note that `const` binds more tightly than postfix-`*` for forming a pointer
20082010
type, so `const MyClass*` is equal to `(const MyClass)*`.
@@ -2993,8 +2995,8 @@ associated constant to represent the type of elements stored in the stack.
29932995
```
29942996
interface StackInterface {
29952997
let ElementType:! Movable;
2996-
fn Push[addr self: Self*](value: ElementType);
2997-
fn Pop[addr self: Self*]() -> ElementType;
2998+
fn Push[ref self: Self](value: ElementType);
2999+
fn Pop[ref self: Self]() -> ElementType;
29983000
fn IsEmpty[self: Self]() -> bool;
29993001
}
30003002
```
@@ -3005,14 +3007,14 @@ for the `ElementType` member of the interface using a `where` clause:
30053007
```carbon
30063008
class IntStack {
30073009
extend impl as StackInterface where .ElementType = i32 {
3008-
fn Push[addr self: Self*](value: i32);
3010+
fn Push[ref self: Self](value: i32);
30093011
// ...
30103012
}
30113013
}
30123014
30133015
class FruitStack {
30143016
extend impl as StackInterface where .ElementType = Fruit {
3015-
fn Push[addr self: Self*](value: Fruit);
3017+
fn Push[ref self: Self](value: Fruit);
30163018
// ...
30173019
}
30183020
}
@@ -3040,8 +3042,8 @@ values of any type `T`:
30403042

30413043
```carbon
30423044
class Stack(T:! type) {
3043-
fn Push[addr self: Self*](value: T);
3044-
fn Pop[addr self: Self*]() -> T;
3045+
fn Push[ref self: Self](value: T);
3046+
fn Pop[ref self: Self]() -> T;
30453047
30463048
var storage: Array(T);
30473049
}

docs/design/assignment.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ standard library.
7373
## Syntax
7474

7575
The operands of these operators can be any [expression](expressions/README.md).
76-
However, the first operand must be modifiable because it is passed to an
77-
`[addr self: Self*]` parameter, which disallows most expression forms other
78-
than:
76+
However, the first operand must be modifiable because it is passed to a
77+
`[ref self: Self]` parameter, which disallows most expression forms other than:
7978

8079
- The name of a `var` binding.
8180
- A dereference of a pointer.
@@ -175,7 +174,7 @@ provided for built-in types as necessary to give the semantics described above.
175174
```
176175
// Simple `=`.
177176
interface AssignWith(U:! type) {
178-
fn Op[addr self: Self*](other: U);
177+
fn Op[ref self: Self](other: U);
179178
}
180179
constraint Assign { extend AssignWith(Self); }
181180
```
@@ -189,48 +188,48 @@ Given `var x: T` and `y: U`:
189188
```
190189
// Compound `+=`.
191190
interface AddAssignWith(U:! type) {
192-
fn Op[addr self: Self*](other: U);
191+
fn Op[ref self: Self](other: U);
193192
}
194193
constraint AddAssign { extend AddAssignWith(Self); }
195194
```
196195

197196
```
198197
// Compound `-=`.
199198
interface SubAssignWith(U:! type) {
200-
fn Op[addr self: Self*](other: U);
199+
fn Op[ref self: Self](other: U);
201200
}
202201
constraint SubAssign { extend SubAssignWith(Self); }
203202
```
204203

205204
```
206205
// Compound `*=`.
207206
interface MulAssignWith(U:! type) {
208-
fn Op[addr self: Self*](other: U);
207+
fn Op[ref self: Self](other: U);
209208
}
210209
constraint MulAssign { extend MulAssignWith(Self); }
211210
```
212211

213212
```
214213
// Compound `/=`.
215214
interface DivAssignWith(U:! type) {
216-
fn Op[addr self: Self*](other: U);
215+
fn Op[ref self: Self](other: U);
217216
}
218217
constraint DivAssign { extend DivAssignWith(Self); }
219218
```
220219

221220
```
222221
// Compound `%=`.
223222
interface ModAssignWith(U:! type) {
224-
fn Op[addr self: Self*](other: U);
223+
fn Op[ref self: Self](other: U);
225224
}
226225
constraint ModAssign { extend ModAssignWith(Self); }
227226
```
228227

229228
```
230229
// Increment `++`.
231-
interface Inc { fn Op[addr self: Self*](); }
230+
interface Inc { fn Op[ref self: Self](); }
232231
// Decrement `++`.
233-
interface Dec { fn Op[addr self: Self*](); }
232+
interface Dec { fn Op[ref self: Self](); }
234233
```
235234

236235
Given `var x: T` and `y: U`:
@@ -248,39 +247,39 @@ Given `var x: T` and `y: U`:
248247
```
249248
// Compound `&=`.
250249
interface BitAndAssignWith(U:! type) {
251-
fn Op[addr self: Self*](other: U);
250+
fn Op[ref self: Self](other: U);
252251
}
253252
constraint BitAndAssign { extend BitAndAssignWith(Self); }
254253
```
255254

256255
```
257256
// Compound `|=`.
258257
interface BitOrAssignWith(U:! type) {
259-
fn Op[addr self: Self*](other: U);
258+
fn Op[ref self: Self](other: U);
260259
}
261260
constraint BitOrAssign { extend BitOrAssignWith(Self); }
262261
```
263262

264263
```
265264
// Compound `^=`.
266265
interface BitXorAssignWith(U:! type) {
267-
fn Op[addr self: Self*](other: U);
266+
fn Op[ref self: Self](other: U);
268267
}
269268
constraint BitXorAssign { extend BitXorAssignWith(Self); }
270269
```
271270

272271
```
273272
// Compound `<<=`.
274273
interface LeftShiftAssignWith(U:! type) {
275-
fn Op[addr self: Self*](other: U);
274+
fn Op[ref self: Self](other: U);
276275
}
277276
constraint LeftShiftAssign { extend LeftShiftAssignWith(Self); }
278277
```
279278

280279
```
281280
// Compound `>>=`.
282281
interface RightShiftAssignWith(U:! type) {
283-
fn Op[addr self: Self*](other: U);
282+
fn Op[ref self: Self](other: U);
284283
}
285284
constraint RightShiftAssign { extend RightShiftAssignWith(Self); }
286285
```
@@ -310,7 +309,7 @@ This defaulting is accomplished by a parameterized implementation of
310309
```
311310
impl forall [U:! type, T:! OpWith(U) where .Self impls AssignWith(.Self.Result)]
312311
T as OpAssignWith(U) {
313-
fn Op[addr self: Self*](other: U) {
312+
fn Op[ref self: Self](other: U) {
314313
// Here, `$` is the operator described by `OpWith`.
315314
*self = *self $ other;
316315
}

0 commit comments

Comments
 (0)