Skip to content

Commit aa1b003

Browse files
committed
---
yaml --- r: 234905 b: refs/heads/stable c: 8cf22b5 h: refs/heads/master i: 234903: 610d11d v: v3
1 parent d16d8c5 commit aa1b003

File tree

4 files changed

+91
-7
lines changed

4 files changed

+91
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 0716da555f5da1d0039167c567853ac5b7cbb1a6
32+
refs/heads/stable: 8cf22b5eaf2b442fb2461a69c89d6c6011350f49
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/doc/trpl/ffi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ and invokes callbacks from there.
309309
In these cases access to Rust data structures inside the callbacks is
310310
especially unsafe and proper synchronization mechanisms must be used.
311311
Besides classical synchronization mechanisms like mutexes, one possibility in
312-
Rust is to use channels (in `std::comm`) to forward data from the C thread
313-
that invoked the callback into a Rust thread.
312+
Rust is to use channels (in `std::sync::mpsc`) to forward data from the C
313+
thread that invoked the callback into a Rust thread.
314314
315315
If an asynchronous callback targets a special object in the Rust address space
316316
it is also absolutely necessary that no more callbacks are performed by the

branches/stable/src/librustc/diagnostics.rs

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,57 @@ From [RFC 246]:
984984
[RFC 246]: https://github.com/rust-lang/rfcs/pull/246
985985
"##,
986986

987+
E0395: r##"
988+
The value assigned to a constant expression must be known at compile time,
989+
which is not the case when comparing raw pointers. Erroneous code example:
990+
991+
```
992+
static foo: i32 = 42;
993+
static bar: i32 = 43;
994+
995+
static baz: bool = { (&foo as *const i32) == (&bar as *const i32) };
996+
// error: raw pointers cannot be compared in statics!
997+
```
998+
999+
Please check that the result of the comparison can be determined at compile time
1000+
or isn't assigned to a constant expression. Example:
1001+
1002+
```
1003+
static foo: i32 = 42;
1004+
static bar: i32 = 43;
1005+
1006+
let baz: bool = { (&foo as *const i32) == (&bar as *const i32) };
1007+
// baz isn't a constant expression so it's ok
1008+
```
1009+
"##,
1010+
1011+
E0396: r##"
1012+
The value assigned to a constant expression must be known at compile time,
1013+
which is not the case when dereferencing raw pointers. Erroneous code
1014+
example:
1015+
1016+
```
1017+
const foo: i32 = 42;
1018+
const baz: *const i32 = (&foo as *const i32);
1019+
1020+
const deref: i32 = *baz;
1021+
// error: raw pointers cannot be dereferenced in constants
1022+
```
1023+
1024+
To fix this error, please do not assign this value to a constant expression.
1025+
Example:
1026+
1027+
```
1028+
const foo: i32 = 42;
1029+
const baz: *const i32 = (&foo as *const i32);
1030+
1031+
unsafe { let deref: i32 = *baz; }
1032+
// baz isn't a constant expression so it's ok
1033+
```
1034+
1035+
You'll also note that this assignment must be done in an unsafe block!
1036+
"##,
1037+
9871038
E0397: r##"
9881039
It is not allowed for a mutable static to allocate or have destructors. For
9891040
example:
@@ -1039,7 +1090,5 @@ register_diagnostics! {
10391090
E0314, // closure outlives stack frame
10401091
E0315, // cannot invoke closure outside of its lifetime
10411092
E0316, // nested quantification of lifetimes
1042-
E0370, // discriminant overflow
1043-
E0395, // pointer comparison in const-expr
1044-
E0396 // pointer dereference in const-expr
1093+
E0370 // discriminant overflow
10451094
}

branches/stable/src/librustc_typeck/diagnostics.rs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,42 @@ impl Foo for Bar {
14581458
```
14591459
"##,
14601460

1461+
E0327: r##"
1462+
You cannot use associated items other than constant items as patterns. This
1463+
includes method items. Example of erroneous code:
1464+
1465+
```
1466+
enum B {}
1467+
1468+
impl B {
1469+
fn bb() -> i32 { 0 }
1470+
}
1471+
1472+
fn main() {
1473+
match 0 {
1474+
B::bb => {} // error: associated items in match patterns must
1475+
// be constants
1476+
}
1477+
}
1478+
```
1479+
1480+
Please check that you're not using a method as a pattern. Example:
1481+
1482+
```
1483+
enum B {
1484+
ba,
1485+
bb
1486+
}
1487+
1488+
fn main() {
1489+
match B::ba {
1490+
B::bb => {} // ok!
1491+
_ => {}
1492+
}
1493+
}
1494+
```
1495+
"##,
1496+
14611497
E0368: r##"
14621498
This error indicates that a binary assignment operator like `+=` or `^=` was
14631499
applied to the wrong types. For example:
@@ -1640,7 +1676,6 @@ register_diagnostics! {
16401676
E0323, // implemented an associated const when another trait item expected
16411677
E0324, // implemented a method when another trait item expected
16421678
E0325, // implemented an associated type when another trait item expected
1643-
E0327, // referred to method instead of constant in match pattern
16441679
E0328, // cannot implement Unsize explicitly
16451680
E0329, // associated const depends on type parameter or Self.
16461681
E0366, // dropck forbid specialization to concrete type or region

0 commit comments

Comments
 (0)