diff options
| author | bors <bors@rust-lang.org> | 2021-08-25 16:22:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-08-25 16:22:57 +0000 |
| commit | 7b0e554ee2c94e9b3865a8c2d24d720224512dec (patch) | |
| tree | c593474b55894db3cd17a5a78200005ba265bd53 /src | |
| parent | a992a11913b39a258158646bb1e03528c5aa5060 (diff) | |
| parent | d9ed23a9130b0941fd1ed4a651cbbec8a6621dd8 (diff) | |
| download | rust-7b0e554ee2c94e9b3865a8c2d24d720224512dec.tar.gz rust-7b0e554ee2c94e9b3865a8c2d24d720224512dec.zip | |
Auto merge of #88329 - LeSeulArtichaut:rollup-blg8hc0, r=LeSeulArtichaut
Rollup of 16 pull requests Successful merges: - #87944 (add Cell::as_array_of_cells, similar to Cell::as_slice_of_cells) - #88156 (Adjust / fix documentation of `Arc::make_mut`) - #88157 (bootstrap.py: recognize riscv64 when auto-detect) - #88196 (Refactor `named_asm_labels` to a HIR lint) - #88218 (Remove `Session.trait_methods_not_found`) - #88223 (Remove the `TryV2` alias) - #88226 (Fix typo “a Rc” → “an Rc” (and a few more)) - #88267 (2229: Update signature for truncate function) - #88273 (Fix references to `ControlFlow` in docs) - #88277 (Update books) - #88291 (Add SAFETY comments to core::slice::sort::partition_in_blocks) - #88293 (Fix grammar in alloc test) - #88298 (Errorkind reorder) - #88299 (Stabilise BufWriter::into_parts) - #88314 (Add type of a let tait test) - #88325 (Add mutable-noalias to the release notes for 1.54) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/bootstrap.py | 1 | ||||
| m--------- | src/doc/book | 0 | ||||
| m--------- | src/doc/reference | 0 | ||||
| m--------- | src/doc/rust-by-example | 0 | ||||
| m--------- | src/doc/rustc-dev-guide | 0 | ||||
| -rw-r--r-- | src/test/ui/asm/named-asm-labels.rs | 66 | ||||
| -rw-r--r-- | src/test/ui/asm/named-asm-labels.stderr | 125 | ||||
| -rw-r--r-- | src/test/ui/drop/dropck_legal_cycles.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/rfcs/rfc-1789-as-cell/from-mut.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/type_of_a_let.rs | 29 | ||||
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/type_of_a_let.stderr | 67 | ||||
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/type_of_a_let2.rs | 25 | ||||
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/type_of_a_let2.stderr | 21 |
13 files changed, 312 insertions, 33 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 3faf38c66ec..e34768bc2c9 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -301,6 +301,7 @@ def default_build_triple(verbose): 'ppc': 'powerpc', 'ppc64': 'powerpc64', 'ppc64le': 'powerpc64le', + 'riscv64': 'riscv64gc', 's390x': 's390x', 'x64': 'x86_64', 'x86': 'i686', diff --git a/src/doc/book b/src/doc/book -Subproject 7e49659102f0977d9142190e1ba23345c0f00eb +Subproject 687e21bde2ea10c261f79fa14797c5137425098 diff --git a/src/doc/reference b/src/doc/reference -Subproject 4884fe45c14f8b22121760fb117181bb4da8dfe +Subproject da6ea9b03f74cae0a292f40315723d7a3a97363 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example -Subproject 0dc9cd4e89f00cb5230f120e1a083916386e422 +Subproject 04f489c889235fe3b6dfe678ae5410d07deda95 diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide -Subproject c4644b427cbdaafc7a87be0ccdf5d8aaa07ac35 +Subproject cf0e151b7925a40f13fbc6573c6f97d5f94c7c1 diff --git a/src/test/ui/asm/named-asm-labels.rs b/src/test/ui/asm/named-asm-labels.rs index 803501b40b6..9f487bd8061 100644 --- a/src/test/ui/asm/named-asm-labels.rs +++ b/src/test/ui/asm/named-asm-labels.rs @@ -1,6 +1,14 @@ // only-x86_64 -#![feature(asm, global_asm)] +// Tests that the use of named labels in the `asm!` macro are linted against +// except for in `#[naked]` fns. +// Using a named label is incorrect as per the RFC because for most cases +// the compiler cannot ensure that inline asm is emitted exactly once per +// codegen unit (except for naked fns) and so the label could be duplicated +// which causes less readable LLVM errors and in the worst cases causes ICEs +// or segfaults based on system dependent behavior and codegen flags. + +#![feature(asm, global_asm, naked_functions)] #[no_mangle] pub static FOO: usize = 42; @@ -126,5 +134,61 @@ fn main() { } } +// Trigger on naked fns too, even though they can't be inlined, reusing a +// label or LTO can cause labels to break +#[naked] +pub extern "C" fn foo() -> i32 { + unsafe { asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1, options(noreturn)) } //~ ERROR avoid using named labels +} + +// Make sure that non-naked attributes *do* still let the lint happen +#[no_mangle] +pub extern "C" fn bar() { + unsafe { asm!(".Lbar: mov rax, {}; ret;", "nop", const 1, options(noreturn)) } + //~^ ERROR avoid using named labels +} + +#[naked] +pub extern "C" fn aaa() { + fn _local() {} + + unsafe { asm!(".Laaa: nop; ret;", options(noreturn)) } //~ ERROR avoid using named labels +} + +pub fn normal() { + fn _local1() {} + + #[naked] + pub extern "C" fn bbb() { + fn _very_local() {} + + unsafe { asm!(".Lbbb: nop; ret;", options(noreturn)) } //~ ERROR avoid using named labels + } + + fn _local2() {} +} + +// Make sure that the lint happens within closures +fn closures() { + || unsafe { + asm!("closure1: nop"); //~ ERROR avoid using named labels + }; + + move || unsafe { + asm!("closure2: nop"); //~ ERROR avoid using named labels + }; + + || { + #[naked] + unsafe extern "C" fn _nested() { + asm!("ret;", options(noreturn)); + } + + unsafe { + asm!("closure3: nop"); //~ ERROR avoid using named labels + } + }; +} + // Don't trigger on global asm global_asm!("aaaaaaaa: nop"); diff --git a/src/test/ui/asm/named-asm-labels.stderr b/src/test/ui/asm/named-asm-labels.stderr index 3c4a4db75e0..396f0a19424 100644 --- a/src/test/ui/asm/named-asm-labels.stderr +++ b/src/test/ui/asm/named-asm-labels.stderr @@ -1,5 +1,5 @@ error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:11:15 + --> $DIR/named-asm-labels.rs:19:15 | LL | asm!("bar: nop"); | ^^^ @@ -9,7 +9,7 @@ LL | asm!("bar: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:14:15 + --> $DIR/named-asm-labels.rs:22:15 | LL | asm!("abcd:"); | ^^^^ @@ -18,7 +18,7 @@ LL | asm!("abcd:"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:17:15 + --> $DIR/named-asm-labels.rs:25:15 | LL | asm!("foo: bar1: nop"); | ^^^ ^^^^ @@ -27,7 +27,7 @@ LL | asm!("foo: bar1: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:21:15 + --> $DIR/named-asm-labels.rs:29:15 | LL | asm!("foo1: nop", "nop"); | ^^^^ @@ -36,7 +36,7 @@ LL | asm!("foo1: nop", "nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:22:15 + --> $DIR/named-asm-labels.rs:30:15 | LL | asm!("foo2: foo3: nop", "nop"); | ^^^^ ^^^^ @@ -45,7 +45,7 @@ LL | asm!("foo2: foo3: nop", "nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:24:22 + --> $DIR/named-asm-labels.rs:32:22 | LL | asm!("nop", "foo4: nop"); | ^^^^ @@ -54,7 +54,7 @@ LL | asm!("nop", "foo4: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:25:15 + --> $DIR/named-asm-labels.rs:33:15 | LL | asm!("foo5: nop", "foo6: nop"); | ^^^^ @@ -63,7 +63,7 @@ LL | asm!("foo5: nop", "foo6: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:25:28 + --> $DIR/named-asm-labels.rs:33:28 | LL | asm!("foo5: nop", "foo6: nop"); | ^^^^ @@ -72,7 +72,7 @@ LL | asm!("foo5: nop", "foo6: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:30:15 + --> $DIR/named-asm-labels.rs:38:15 | LL | asm!("foo7: nop; foo8: nop"); | ^^^^ ^^^^ @@ -81,7 +81,7 @@ LL | asm!("foo7: nop; foo8: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:32:15 + --> $DIR/named-asm-labels.rs:40:15 | LL | asm!("foo9: nop; nop"); | ^^^^ @@ -90,7 +90,7 @@ LL | asm!("foo9: nop; nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:33:20 + --> $DIR/named-asm-labels.rs:41:20 | LL | asm!("nop; foo10: nop"); | ^^^^^ @@ -99,7 +99,7 @@ LL | asm!("nop; foo10: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:36:15 + --> $DIR/named-asm-labels.rs:44:15 | LL | asm!("bar2: nop\n bar3: nop"); | ^^^^ ^^^^ @@ -108,7 +108,7 @@ LL | asm!("bar2: nop\n bar3: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:38:15 + --> $DIR/named-asm-labels.rs:46:15 | LL | asm!("bar4: nop\n nop"); | ^^^^ @@ -117,7 +117,7 @@ LL | asm!("bar4: nop\n nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:39:21 + --> $DIR/named-asm-labels.rs:47:21 | LL | asm!("nop\n bar5: nop"); | ^^^^ @@ -126,7 +126,7 @@ LL | asm!("nop\n bar5: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:40:21 + --> $DIR/named-asm-labels.rs:48:21 | LL | asm!("nop\n bar6: bar7: nop"); | ^^^^ ^^^^ @@ -135,7 +135,7 @@ LL | asm!("nop\n bar6: bar7: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:46:13 + --> $DIR/named-asm-labels.rs:54:13 | LL | blah2: nop | ^^^^^ @@ -146,7 +146,7 @@ LL | blah3: nop = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:55:19 + --> $DIR/named-asm-labels.rs:63:19 | LL | nop ; blah4: nop | ^^^^^ @@ -155,7 +155,7 @@ LL | nop ; blah4: nop = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:69:15 + --> $DIR/named-asm-labels.rs:77:15 | LL | asm!("blah1: 2bar: nop"); | ^^^^^ @@ -164,7 +164,7 @@ LL | asm!("blah1: 2bar: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:72:15 + --> $DIR/named-asm-labels.rs:80:15 | LL | asm!("def: def: nop"); | ^^^ @@ -173,7 +173,7 @@ LL | asm!("def: def: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:73:15 + --> $DIR/named-asm-labels.rs:81:15 | LL | asm!("def: nop\ndef: nop"); | ^^^ @@ -182,7 +182,7 @@ LL | asm!("def: nop\ndef: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:74:15 + --> $DIR/named-asm-labels.rs:82:15 | LL | asm!("def: nop; def: nop"); | ^^^ @@ -191,7 +191,7 @@ LL | asm!("def: nop; def: nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:82:15 + --> $DIR/named-asm-labels.rs:90:15 | LL | asm!("fooo\u{003A} nop"); | ^^^^^^^^^^^^^^^^ @@ -200,7 +200,7 @@ LL | asm!("fooo\u{003A} nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:83:15 + --> $DIR/named-asm-labels.rs:91:15 | LL | asm!("foooo\x3A nop"); | ^^^^^^^^^^^^^ @@ -209,7 +209,7 @@ LL | asm!("foooo\x3A nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:86:15 + --> $DIR/named-asm-labels.rs:94:15 | LL | asm!("fooooo:\u{000A} nop"); | ^^^^^^ @@ -218,7 +218,7 @@ LL | asm!("fooooo:\u{000A} nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:87:15 + --> $DIR/named-asm-labels.rs:95:15 | LL | asm!("foooooo:\x0A nop"); | ^^^^^^^ @@ -227,7 +227,7 @@ LL | asm!("foooooo:\x0A nop"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:91:14 + --> $DIR/named-asm-labels.rs:99:14 | LL | asm!("\x41\x42\x43\x3A\x20\x6E\x6F\x70"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -236,7 +236,7 @@ LL | asm!("\x41\x42\x43\x3A\x20\x6E\x6F\x70"); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:102:13 + --> $DIR/named-asm-labels.rs:110:13 | LL | ab: nop // ab: does foo | ^^ @@ -245,7 +245,7 @@ LL | ab: nop // ab: does foo = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:114:14 + --> $DIR/named-asm-labels.rs:122:14 | LL | asm!(include_str!("named-asm-labels.s")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -254,18 +254,81 @@ LL | asm!(include_str!("named-asm-labels.s")); = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information warning: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:124:19 + --> $DIR/named-asm-labels.rs:132:19 | LL | asm!("warned: nop"); | ^^^^^^ | note: the lint level is defined here - --> $DIR/named-asm-labels.rs:122:16 + --> $DIR/named-asm-labels.rs:130:16 | LL | #[warn(named_asm_labels)] | ^^^^^^^^^^^^^^^^ = help: only local labels of the form `<number>:` should be used in inline asm = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information -error: aborting due to 28 previous errors; 1 warning emitted +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:141:20 + | +LL | unsafe { asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1, options(noreturn)) } + | ^^^^^ + | + = help: only local labels of the form `<number>:` should be used in inline asm + = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:147:20 + | +LL | unsafe { asm!(".Lbar: mov rax, {}; ret;", "nop", const 1, options(noreturn)) } + | ^^^^^ + | + = help: only local labels of the form `<number>:` should be used in inline asm + = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:155:20 + | +LL | unsafe { asm!(".Laaa: nop; ret;", options(noreturn)) } + | ^^^^^ + | + = help: only local labels of the form `<number>:` should be used in inline asm + = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:165:24 + | +LL | unsafe { asm!(".Lbbb: nop; ret;", options(noreturn)) } + | ^^^^^ + | + = help: only local labels of the form `<number>:` should be used in inline asm + = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:174:15 + | +LL | asm!("closure1: nop"); + | ^^^^^^^^ + | + = help: only local labels of the form `<number>:` should be used in inline asm + = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:178:15 + | +LL | asm!("closure2: nop"); + | ^^^^^^^^ + | + = help: only local labels of the form `<number>:` should be used in inline asm + = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:188:19 + | +LL | asm!("closure3: nop"); + | ^^^^^^^^ + | + = help: only local labels of the form `<number>:` should be used in inline asm + = note: see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information + +error: aborting due to 35 previous errors; 1 warning emitted diff --git a/src/test/ui/drop/dropck_legal_cycles.rs b/src/test/ui/drop/dropck_legal_cycles.rs index fb13fd764bf..27a599315dc 100644 --- a/src/test/ui/drop/dropck_legal_cycles.rs +++ b/src/test/ui/drop/dropck_legal_cycles.rs @@ -368,7 +368,7 @@ pub fn main() { // We can use refcells if we're single-threaded (as this test is). // If one were to generalize these constructions to a // multi-threaded context, then it might seem like we could choose - // between either a RwLock or a Mutex to hold the owned arcs on + // between either an RwLock or a Mutex to hold the owned arcs on // each node. // // Part of the point of this test is to actually confirm that the diff --git a/src/test/ui/rfcs/rfc-1789-as-cell/from-mut.rs b/src/test/ui/rfcs/rfc-1789-as-cell/from-mut.rs index ea3ad7aed49..329fadb150f 100644 --- a/src/test/ui/rfcs/rfc-1789-as-cell/from-mut.rs +++ b/src/test/ui/rfcs/rfc-1789-as-cell/from-mut.rs @@ -1,5 +1,7 @@ // run-pass +#![feature(as_array_of_cells)] + use std::cell::Cell; fn main() { @@ -8,4 +10,11 @@ fn main() { let slice_cell: &[Cell<i32>] = cell_slice.as_slice_of_cells(); assert_eq!(slice_cell.len(), 3); + + let mut array: [i32; 3] = [1, 2, 3]; + let cell_array: &Cell<[i32; 3]> = Cell::from_mut(&mut array); + let array_cell: &[Cell<i32>; 3] = cell_array.as_array_of_cells(); + + array_cell[0].set(99); + assert_eq!(array, [99, 2, 3]); } diff --git a/src/test/ui/type-alias-impl-trait/type_of_a_let.rs b/src/test/ui/type-alias-impl-trait/type_of_a_let.rs new file mode 100644 index 00000000000..7f8e6127cca --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/type_of_a_let.rs @@ -0,0 +1,29 @@ +#![feature(type_alias_impl_trait)] +#![allow(dead_code)] + +// FIXME This should compile, but it currently doesn't + +use std::fmt::Debug; + +type Foo = impl Debug; +//~^ ERROR: could not find defining uses + +fn foo1() -> u32 { + let x: Foo = 22_u32; + //~^ ERROR: mismatched types [E0308] + x + //~^ ERROR: mismatched types [E0308] +} + +fn foo2() -> u32 { + let x: Foo = 22_u32; + //~^ ERROR: mismatched types [E0308] + let y: Foo = x; + same_type((x, y)); + y + //~^ ERROR: mismatched types [E0308] +} + +fn same_type<T>(x: (T, T)) {} + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/type_of_a_let.stderr b/src/test/ui/type-alias-impl-trait/type_of_a_let.stderr new file mode 100644 index 00000000000..cac8d6841af --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/type_of_a_let.stderr @@ -0,0 +1,67 @@ +error[E0308]: mismatched types + --> $DIR/type_of_a_let.rs:12:18 + | +LL | type Foo = impl Debug; + | ---------- the expected opaque type +... +LL | let x: Foo = 22_u32; + | --- ^^^^^^ expected opaque type, found `u32` + | | + | expected due to this + | + = note: expected opaque type `impl Debug` + found type `u32` + +error[E0308]: mismatched types + --> $DIR/type_of_a_let.rs:14:5 + | +LL | type Foo = impl Debug; + | ---------- the found opaque type +... +LL | fn foo1() -> u32 { + | --- expected `u32` because of return type +... +LL | x + | ^ expected `u32`, found opaque type + | + = note: expected type `u32` + found opaque type `impl Debug` + +error[E0308]: mismatched types + --> $DIR/type_of_a_let.rs:19:18 + | +LL | type Foo = impl Debug; + | ---------- the expected opaque type +... +LL | let x: Foo = 22_u32; + | --- ^^^^^^ expected opaque type, found `u32` + | | + | expected due to this + | + = note: expected opaque type `impl Debug` + found type `u32` + +error[E0308]: mismatched types + --> $DIR/type_of_a_let.rs:23:5 + | +LL | type Foo = impl Debug; + | ---------- the found opaque type +... +LL | fn foo2() -> u32 { + | --- expected `u32` because of return type +... +LL | y + | ^ expected `u32`, found opaque type + | + = note: expected type `u32` + found opaque type `impl Debug` + +error: could not find defining uses + --> $DIR/type_of_a_let.rs:8:12 + | +LL | type Foo = impl Debug; + | ^^^^^^^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/type_of_a_let2.rs b/src/test/ui/type-alias-impl-trait/type_of_a_let2.rs new file mode 100644 index 00000000000..33d3f164ce1 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/type_of_a_let2.rs @@ -0,0 +1,25 @@ +#![feature(type_alias_impl_trait)] +#![allow(dead_code)] + +// FIXME This should be under a feature flag + +use std::fmt::Debug; + +fn foo1() -> u32 { + let x: impl Debug = 22_u32; + //~^ ERROR: `impl Trait` not allowed outside of function and method return types [E0562] + x // ERROR: we only know x: Debug, we don't know x = u32 +} + +fn foo2() -> u32 { + let x: impl Debug = 22_u32; + //~^ ERROR: `impl Trait` not allowed outside of function and method return types [E0562] + let y: impl Debug = x; + //~^ ERROR: `impl Trait` not allowed outside of function and method return types [E0562] + same_type((x, y)); // ERROR + x +} + +fn same_type<T>(x: (T, T)) {} + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/type_of_a_let2.stderr b/src/test/ui/type-alias-impl-trait/type_of_a_let2.stderr new file mode 100644 index 00000000000..7a1825a8e2d --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/type_of_a_let2.stderr @@ -0,0 +1,21 @@ +error[E0562]: `impl Trait` not allowed outside of function and method return types + --> $DIR/type_of_a_let2.rs:9:12 + | +LL | let x: impl Debug = 22_u32; + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and method return types + --> $DIR/type_of_a_let2.rs:15:12 + | +LL | let x: impl Debug = 22_u32; + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and method return types + --> $DIR/type_of_a_let2.rs:17:12 + | +LL | let y: impl Debug = x; + | ^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0562`. |
