diag: explain pointer-sized cast restrictions in source advice
This commit is contained in:
1 parent
8a714ba6de
commit
6a02659f31
23 files changed
+96
-8
No files matched your search
@@ -0,0 +1,13 @@
|
||||
// expect: run
|
||||
// result: 84
|
||||
// phase: 6
|
||||
// spec: docs/spec/02-types-and-values.md §2; docs/spec/15-source-language.md §5
|
||||
module cast.explicit
|
||||
fn same(x: isize) -> isize effects [] { return x as! isize; }
|
||||
fn main() -> u64 effects [] {
|
||||
let x: usize = 42u8 as! usize;
|
||||
let y: u64 = x as! u64;
|
||||
let z: isize = 42i8 as% isize;
|
||||
let q: i64 = same(z) as! i64;
|
||||
return y + (q as! u64);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/02-types-and-values.md §2; docs/spec/15-source-language.md §5
|
||||
module cast.rejection
|
||||
fn f(x: i8) -> isize effects [] { return x as isize; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1 @@
|
||||
[{"kind":"numeric_cast_modes","hint":"The target-independent `as` rule excludes `usize`/`isize`, even when the value fits. Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/02-types-and-values.md §2; docs/spec/15-source-language.md §5
|
||||
module cast.rejection
|
||||
fn f(x: isize) -> i64 effects [] { return x as i64; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1 @@
|
||||
[{"kind":"numeric_cast_modes","hint":"The target-independent `as` rule excludes `usize`/`isize`, even when the value fits. Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/02-types-and-values.md §2; docs/spec/15-source-language.md §5
|
||||
module cast.rejection
|
||||
fn f(x: isize) -> isize effects [] { return x as isize; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1 @@
|
||||
[{"kind":"numeric_cast_modes","hint":"The target-independent `as` rule excludes `usize`/`isize`, even when the value fits. Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/02-types-and-values.md §2; docs/spec/15-source-language.md §5
|
||||
module cast.rejection
|
||||
fn f(x: u8) -> usize effects [] { return x as usize; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1 @@
|
||||
[{"kind":"numeric_cast_modes","hint":"The target-independent `as` rule excludes `usize`/`isize`, even when the value fits. Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/02-types-and-values.md §2; docs/spec/15-source-language.md §5
|
||||
module cast.rejection
|
||||
fn f(x: usize) -> u64 effects [] { return x as u64; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1 @@
|
||||
[{"kind":"numeric_cast_modes","hint":"The target-independent `as` rule excludes `usize`/`isize`, even when the value fits. Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/02-types-and-values.md §2; docs/spec/15-source-language.md §5
|
||||
module cast.rejection
|
||||
fn f(x: usize) -> usize effects [] { return x as usize; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1 @@
|
||||
[{"kind":"numeric_cast_modes","hint":"The target-independent `as` rule excludes `usize`/`isize`, even when the value fits. Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
|
||||
@@ -1,2 +1,2 @@
|
||||
[{"kind":"numeric_cast_modes","hint":"Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
|
||||
[{"kind":"numeric_cast_modes","hint":"Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
|
||||
[{"kind":"numeric_cast_modes","hint":"The target-independent `as` rule excludes `usize`/`isize`, even when the value fits. Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
|
||||
[{"kind":"numeric_cast_modes","hint":"The target-independent `as` rule excludes `usize`/`isize`, even when the value fits. Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
|
||||
@@ -1 +1 @@
|
||||
[{"kind":"numeric_cast_modes","hint":"Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
|
||||
[{"kind":"numeric_cast_modes","hint":"The target-independent `as` rule excludes `usize`/`isize`, even when the value fits. Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
|
||||
Reference in new issue
Block a user