Skip to content

remove gate macros from BUILTIN_ATTRIBUTES#155302

Draft
Bryntet wants to merge 3 commits intorust-lang:mainfrom
Bryntet:impl-gated
Draft

remove gate macros from BUILTIN_ATTRIBUTES#155302
Bryntet wants to merge 3 commits intorust-lang:mainfrom
Bryntet:impl-gated

Conversation

@Bryntet
Copy link
Copy Markdown
Contributor

@Bryntet Bryntet commented Apr 14, 2026

draft for removing gated!, ungated! and rustc_attr! macros from BUILTIN_ATTRIBUTES

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 14, 2026
Comment on lines -158 to -166
let attr_info = attr.name().and_then(|name| BUILTIN_ATTRIBUTE_MAP.get(&name));
// Check feature gates for built-in attributes.
if let Some(BuiltinAttribute {
gate: AttributeGate::Gated { feature, message, check, notes, .. },
..
}) = attr_info
{
gate_alt!(self, check(self.features), *feature, attr.span, *message, *notes);
}
Copy link
Copy Markdown
Contributor Author

@Bryntet Bryntet Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logic is moved to rustc_attr_parsing/src/feature_gate.rs which gets called from rustc_attr_parsing/src/interface.rs

@Bryntet Bryntet changed the title zImpl gated remove gate macros from BUILTIN_ATTRIBUTES Apr 14, 2026
@JonathanBrouwer JonathanBrouwer self-assigned this Apr 14, 2026
@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Executing "/scripts/stage_2_test_set1.sh"
+ /scripts/stage_2_test_set1.sh
PR_CI_JOB set; skipping tidy
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip compiler --skip src
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://static.rust-lang.org/dist/2026-03-05/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.xz
---
2   --> $DIR/on_move_simple.rs:15:15
3    |
4 LL |     let foo = Foo;

-    |         --- Bar
+    |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
6 LL |     takes_foo(foo);
7    |               --- value moved here
8 LL |     let bar = foo;


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args diagnostic_namespace/on_move/on_move_simple.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/diagnostic_namespace/on_move/on_move_simple.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/diagnostic_namespace/on_move/on_move_simple" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0382]: use of moved value: `foo`
##[error]  --> /checkout/tests/ui/diagnostic_namespace/on_move/on_move_simple.rs:15:15
   |
LL |     let foo = Foo;
   |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
LL |     takes_foo(foo);
   |               --- value moved here
LL |     let bar = foo;
   |               ^^^ value used here after move
   |
note: consider changing this parameter type in function `takes_foo` to borrow instead if owning the value isn't necessary
  --> /checkout/tests/ui/diagnostic_namespace/on_move/on_move_simple.rs:10:17
   |
LL | fn takes_foo(_: Foo) {}
   |    ---------    ^^^ this parameter takes ownership of the value
   |    |
   |    in this function
note: if `Foo` implemented `Clone`, you could clone the value
  --> /checkout/tests/ui/diagnostic_namespace/on_move/on_move_simple.rs:8:1
   |
LL | struct Foo;
   | ^^^^^^^^^^ consider implementing `Clone` for this type
...
LL |     takes_foo(foo);
   |               --- you could clone this value

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0382`.
------------------------------------------
---
2   --> $DIR/on_move_with_format.rs:25:15
3    |
4 LL |     let foo = Foo;

-    |         --- Bar for Foo
+    |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
6 LL |     takes_foo(foo);
7    |               --- value moved here
8 LL |     let bar = foo;

24 LL |     takes_foo(foo);
25    |               --- you could clone this value
26 
- error[E0382]: Foo for i32
+ error[E0382]: use of moved value: `mytype`
28   --> $DIR/on_move_with_format.rs:30:15
29    |
30 LL |     let mytype = MyType { _x: 0 };

-    |         ------ Bar for i32
+    |         ------ move occurs because `mytype` has type `MyType<i32>`, which does not implement the `Copy` trait
32 LL |     takes_mytype(mytype);
33    |                  ------ value moved here
34 LL |     let baz = mytype;


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args diagnostic_namespace/on_move/on_move_with_format.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/diagnostic_namespace/on_move/on_move_with_format" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0382]: use of moved value: `foo`
##[error]  --> /checkout/tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs:25:15
   |
LL |     let foo = Foo;
   |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
LL |     takes_foo(foo);
   |               --- value moved here
LL |     let bar = foo;
   |               ^^^ value used here after move
   |
note: consider changing this parameter type in function `takes_foo` to borrow instead if owning the value isn't necessary
  --> /checkout/tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs:18:17
   |
LL | fn takes_foo(_: Foo) {}
   |    ---------    ^^^ this parameter takes ownership of the value
   |    |
   |    in this function
note: if `Foo` implemented `Clone`, you could clone the value
  --> /checkout/tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs:8:1
   |
LL | struct Foo;
   | ^^^^^^^^^^ consider implementing `Clone` for this type
...
LL |     takes_foo(foo);
   |               --- you could clone this value

error[E0382]: use of moved value: `mytype`
##[error]  --> /checkout/tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs:30:15
   |
LL |     let mytype = MyType { _x: 0 };
   |         ------ move occurs because `mytype` has type `MyType<i32>`, which does not implement the `Copy` trait
LL |     takes_mytype(mytype);
   |                  ------ value moved here
LL |     let baz = mytype;
   |               ^^^^^^ value used here after move
   |
note: consider changing this parameter type in function `takes_mytype` to borrow instead if owning the value isn't necessary
  --> /checkout/tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs:20:23
   |
LL | fn takes_mytype<X>(_: MyType<X>) {}
   |    ------------       ^^^^^^^^^ this parameter takes ownership of the value
   |    |
   |    in this function
note: if `MyType<i32>` implemented `Clone`, you could clone the value
  --> /checkout/tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs:14:1
   |
LL | struct MyType<X> {
   | ^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
...
LL |     takes_mytype(mytype);
   |                  ------ you could clone this value

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0382`.
------------------------------------------
---
2   --> $DIR/error_is_shown_in_downstream_crates.rs:12:15
3    |
4 LL |     let foo = Foo;

-    |         --- Bar
+    |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
6 LL |     takes_foo(foo);
7    |               --- value moved here
8 LL |     let bar = foo;


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args diagnostic_namespace/on_move/error_is_shown_in_downstream_crates.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/diagnostic_namespace/on_move/error_is_shown_in_downstream_crates.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/diagnostic_namespace/on_move/error_is_shown_in_downstream_crates" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/diagnostic_namespace/on_move/error_is_shown_in_downstream_crates/auxiliary"
stdout: none
--- stderr -------------------------------
error[E0382]: use of moved value: `foo`
##[error]  --> /checkout/tests/ui/diagnostic_namespace/on_move/error_is_shown_in_downstream_crates.rs:12:15
   |
LL |     let foo = Foo;
   |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
LL |     takes_foo(foo);
   |               --- value moved here
LL |     let bar = foo;
   |               ^^^ value used here after move
   |
note: consider changing this parameter type in function `takes_foo` to borrow instead if owning the value isn't necessary
  --> /checkout/tests/ui/diagnostic_namespace/on_move/error_is_shown_in_downstream_crates.rs:7:17
   |
LL | fn takes_foo(_: Foo) {}
   |    ---------    ^^^ this parameter takes ownership of the value
   |    |
   |    in this function

error: aborting due to 1 previous error

---
23    |
24 LL |     let foo = Foo;

-    |         --- first label
+    |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
26 LL |     takes_foo(foo);
27    |               --- value moved here
28 LL |     let bar = foo;

44 LL |     takes_foo(foo);
45    |               --- you could clone this value
46 
- error: aborting due to 1 previous error; 2 warnings emitted
+ error: aborting due to 1 previous error
48 
49 For more information about this error, try `rustc --explain E0382`.
---
To only update this specific test, also pass `--test-args diagnostic_namespace/on_move/report_warning_on_duplicated_options.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_duplicated_options.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/diagnostic_namespace/on_move/report_warning_on_duplicated_options" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0382]: use of moved value: `foo`
##[error]  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_duplicated_options.rs:20:15
   |
LL |     let foo = Foo;
   |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
LL |     takes_foo(foo);
   |               --- value moved here
LL |     let bar = foo;
   |               ^^^ value used here after move
   |
note: consider changing this parameter type in function `takes_foo` to borrow instead if owning the value isn't necessary
  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_duplicated_options.rs:15:17
   |
LL | fn takes_foo(_: Foo) {}
   |    ---------    ^^^ this parameter takes ownership of the value
   |    |
   |    in this function
note: if `Foo` implemented `Clone`, you could clone the value
  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_duplicated_options.rs:13:1
   |
LL | struct Foo;
   | ^^^^^^^^^^ consider implementing `Clone` for this type
...
LL |     takes_foo(foo);
   |               --- you could clone this value

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0382`.
------------------------------------------
---

- warning: unknown parameter `Baz`
-   --> $DIR/report_warning_on_invalid_formats.rs:4:21
-    |
- LL |     message = "Foo {Baz}",
-    |                     ^^^
-    |
-    = help: expect either a generic argument name or `{Self}` as format argument
-    = note: `#[warn(malformed_diagnostic_format_literals)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default
- 
- error[E0382]: Foo {Baz}
+ error[E0382]: use of moved value: `foo`
11   --> $DIR/report_warning_on_invalid_formats.rs:16:15
12    |
13 LL |     let foo = Foo;

-    |         --- Bar
+    |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
15 LL |     takes_foo(foo);
16    |               --- value moved here
17 LL |     let bar = foo;

33 LL |     takes_foo(foo);
34    |               --- you could clone this value
35 
- error: aborting due to 1 previous error; 1 warning emitted
+ error: aborting due to 1 previous error
37 
38 For more information about this error, try `rustc --explain E0382`.
---
To only update this specific test, also pass `--test-args diagnostic_namespace/on_move/report_warning_on_invalid_formats.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_invalid_formats.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/diagnostic_namespace/on_move/report_warning_on_invalid_formats" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0382]: use of moved value: `foo`
##[error]  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_invalid_formats.rs:16:15
   |
LL |     let foo = Foo;
   |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
LL |     takes_foo(foo);
   |               --- value moved here
LL |     let bar = foo;
   |               ^^^ value used here after move
   |
note: consider changing this parameter type in function `takes_foo` to borrow instead if owning the value isn't necessary
  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_invalid_formats.rs:11:17
   |
LL | fn takes_foo(_: Foo) {}
   |    ---------    ^^^ this parameter takes ownership of the value
   |    |
   |    in this function
note: if `Foo` implemented `Clone`, you could clone the value
  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_invalid_formats.rs:9:1
   |
LL | struct Foo;
   | ^^^^^^^^^^ consider implementing `Clone` for this type
...
LL |     takes_foo(foo);
   |               --- you could clone this value

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0382`.
------------------------------------------
---
14   --> $DIR/report_warning_on_non_adt.rs:21:15
15    |
16 LL |     let foo = Foo;

-    |         --- Bar
+    |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
18 LL |     takes_foo(foo);
19    |               --- value moved here
20 LL |     let bar = foo;

36 LL |     takes_foo(foo);
37    |               --- you could clone this value
38 
- error: aborting due to 1 previous error; 1 warning emitted
+ error: aborting due to 1 previous error
40 
41 For more information about this error, try `rustc --explain E0382`.
---
To only update this specific test, also pass `--test-args diagnostic_namespace/on_move/report_warning_on_non_adt.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_non_adt.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/diagnostic_namespace/on_move/report_warning_on_non_adt" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0382]: use of moved value: `foo`
##[error]  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_non_adt.rs:21:15
   |
LL |     let foo = Foo;
   |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
LL |     takes_foo(foo);
   |               --- value moved here
LL |     let bar = foo;
   |               ^^^ value used here after move
   |
note: consider changing this parameter type in function `takes_foo` to borrow instead if owning the value isn't necessary
  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_non_adt.rs:16:17
   |
LL | fn takes_foo(_: Foo) {}
   |    ---------    ^^^ this parameter takes ownership of the value
   |    |
   |    in this function
note: if `Foo` implemented `Clone`, you could clone the value
  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_non_adt.rs:7:1
   |
LL | struct Foo;
   | ^^^^^^^^^^ consider implementing `Clone` for this type
...
LL |     takes_foo(foo);
   |               --- you could clone this value

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0382`.
------------------------------------------
---
11   --> $DIR/report_warning_on_unknown_options.rs:17:15
12    |
13 LL |     let foo = Foo;

-    |         --- Bar
+    |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
15 LL |     takes_foo(foo);
16    |               --- value moved here
17 LL |     let bar = foo;


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args diagnostic_namespace/on_move/report_warning_on_unknown_options.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_unknown_options.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/diagnostic_namespace/on_move/report_warning_on_unknown_options" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
warning: unknown or malformed `on_move` attribute
##[warning]  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_unknown_options.rs:6:5
   |
LL |     baz="Baz"
   |     ^^^^^^^^^ invalid option found here
   |
   = help: only `message`, `note` and `label` are allowed as options. Their values must be string literals
   = note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default

error[E0382]: use of moved value: `foo`
##[error]  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_unknown_options.rs:17:15
   |
LL |     let foo = Foo;
   |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
LL |     takes_foo(foo);
   |               --- value moved here
LL |     let bar = foo;
   |               ^^^ value used here after move
   |
note: consider changing this parameter type in function `takes_foo` to borrow instead if owning the value isn't necessary
  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_unknown_options.rs:12:17
   |
LL | fn takes_foo(_: Foo) {}
   |    ---------    ^^^ this parameter takes ownership of the value
   |    |
   |    in this function
note: if `Foo` implemented `Clone`, you could clone the value
  --> /checkout/tests/ui/diagnostic_namespace/on_move/report_warning_on_unknown_options.rs:10:1
   |
LL | struct Foo;
   | ^^^^^^^^^^ consider implementing `Clone` for this type
...
LL |     takes_foo(foo);
   |               --- you could clone this value

error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0382`.
------------------------------------------
---
- error[E0382]: the type `Arc` does not implement `Copy`
+ error[E0382]: use of moved value: `results`
2   --> $DIR/arc-consumed-in-looped-closure.rs:30:22
3    |
4 LL |     let results = Arc::new(Mutex::new(Vec::new()));

-    |         ------- this move could be avoided by cloning the original `Arc`, which is inexpensive
+    |         ------- move occurs because `results` has type `Arc<std::sync::Mutex<Vec<i32>>>`, which does not implement the `Copy` trait
6 ...
7 LL |     for i in 0..20 {
8    |     -------------- inside of this loop

13 LL |             let mut r = results.lock().unwrap();
---
To only update this specific test, also pass `--test-args moves/arc-consumed-in-looped-closure.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/moves/arc-consumed-in-looped-closure.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/moves/arc-consumed-in-looped-closure" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0382]: use of moved value: `results`
##[error]  --> /checkout/tests/ui/moves/arc-consumed-in-looped-closure.rs:30:22
   |
LL |     let results = Arc::new(Mutex::new(Vec::new())); //~ NOTE this move could be avoided by cloning the original `Arc`, which is inex...
   |         ------- move occurs because `results` has type `Arc<std::sync::Mutex<Vec<i32>>>`, which does not implement the `Copy` trait
...
LL |     for i in 0..20 { //~ NOTE inside of this loop
   |     -------------- inside of this loop
LL |         // let results = Arc::clone(&results); // Forgot this.
LL |         pool.execute(move || { //~ ERROR E0382
   |                      ^^^^^^^ value moved into closure here, in previous iteration of loop
...
LL |             let mut r = results.lock().unwrap(); //~ NOTE use occurs due to use in closure
   |                         ------- use occurs due to use in closure
   |
help: consider cloning the value before moving it into the closure
   |
LL ~         let value = results.clone();
LL ~         pool.execute(move || { //~ ERROR E0382
LL |             //~^ NOTE value moved into closure here, in previous iteration of loop
LL |             //~| NOTE consider using `Arc::clone`
LL |             //~| HELP consider cloning the value before moving it into the closure
LL ~             let mut r = value.lock().unwrap(); //~ NOTE use occurs due to use in closure
   |

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0382`.
---
- error[E0382]: the type `Rc` does not implement `Copy`
+ error[E0382]: use of moved value: `rc_foo`
106   --> $DIR/move-fn-self-receiver.rs:55:5
107    |
108 LL |     let rc_foo = Rc::new(Foo);

-    |         ------ this move could be avoided by cloning the original `Rc`, which is inexpensive
+    |         ------ move occurs because `rc_foo` has type `Rc<Foo>`, which does not implement the `Copy` trait
110 LL |     rc_foo.use_rc_self();
111    |            ------------- `rc_foo` moved due to this method call
112 LL |     rc_foo;

113    |     ^^^^^^ value used here after move
114    |
-    = note: consider using `Rc::clone`
116 note: `Foo::use_rc_self` takes ownership of the receiver `self`, which moves `rc_foo`
117   --> $DIR/move-fn-self-receiver.rs:16:20
118    |


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args moves/move-fn-self-receiver.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/moves/move-fn-self-receiver.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/moves/move-fn-self-receiver" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0382]: use of moved value: `val.0`
##[error]  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:30:5
   |
LL |     val.0.into_iter().next();
   |           ----------- `val.0` moved due to this method call
LL |     val.0; //~ ERROR use of moved
   |     ^^^^^ value used here after move
   |
note: `into_iter` takes ownership of the receiver `self`, which moves `val.0`
  --> /rustc/FAKE_PREFIX/library/core/src/iter/traits/collect.rs:312:17
   = note: move occurs because `val.0` has type `Vec<bool>`, which does not implement the `Copy` trait
help: you can `clone` the value and consume it, but this might not be your desired behavior
   |
LL |     val.0.clone().into_iter().next();
   |          ++++++++

error[E0382]: use of moved value: `foo`
---
   |         ---------- `foo` moved due to this method call
LL |     foo; //~ ERROR use of moved
   |     ^^^ value used here after move
   |
note: `Foo::use_self` takes ownership of the receiver `self`, which moves `foo`
  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:13:17
   |
LL |     fn use_self(self) {}
   |                 ^^^^

error[E0382]: use of moved value: `second_foo`
##[error]  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:38:5
   |
LL |     let second_foo = Foo;
   |         ---------- move occurs because `second_foo` has type `Foo`, which does not implement the `Copy` trait
LL |     second_foo.use_self();
   |                ---------- `second_foo` moved due to this method call
LL |     second_foo; //~ ERROR use of moved
   |     ^^^^^^^^^^ value used here after move

error[E0382]: use of moved value: `boxed_foo`
##[error]  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:42:5
   |
LL |     let boxed_foo = Box::new(Foo);
   |         --------- move occurs because `boxed_foo` has type `Box<Foo>`, which does not implement the `Copy` trait
LL |     boxed_foo.use_box_self();
   |               -------------- `boxed_foo` moved due to this method call
LL |     boxed_foo; //~ ERROR use of moved
   |     ^^^^^^^^^ value used here after move
   |
note: `Foo::use_box_self` takes ownership of the receiver `self`, which moves `boxed_foo`
  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:14:21
   |
LL |     fn use_box_self(self: Box<Self>) {}
   |                     ^^^^
help: you could `clone` the value and consume it, if the `Foo: Clone` trait bound could be satisfied
   |
LL |     boxed_foo.clone().use_box_self();
   |              ++++++++
help: consider annotating `Foo` with `#[derive(Clone)]`
   |
LL + #[derive(Clone)]
LL | struct Foo;
   |

error[E0382]: use of moved value: `pin_box_foo`
##[error]  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:46:5
   |
LL |     let pin_box_foo = Box::pin(Foo);
   |         ----------- move occurs because `pin_box_foo` has type `Pin<Box<Foo>>`, which does not implement the `Copy` trait
LL |     pin_box_foo.use_pin_box_self();
   |                 ------------------ `pin_box_foo` moved due to this method call
LL |     pin_box_foo; //~ ERROR use of moved
   |     ^^^^^^^^^^^ value used here after move
   |
note: `Foo::use_pin_box_self` takes ownership of the receiver `self`, which moves `pin_box_foo`
  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:15:25
   |
LL |     fn use_pin_box_self(self: Pin<Box<Self>>) {}
   |                         ^^^^
help: you could `clone` the value and consume it, if the `Foo: Clone` trait bound could be satisfied
   |
LL |     pin_box_foo.clone().use_pin_box_self();
   |                ++++++++
help: consider annotating `Foo` with `#[derive(Clone)]`
   |
LL + #[derive(Clone)]
LL | struct Foo;
   |

error[E0505]: cannot move out of `mut_foo` because it is borrowed
##[error]  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:50:5
   |
LL |     let mut mut_foo = Foo;
   |         ----------- binding `mut_foo` declared here
LL |     let ret = mut_foo.use_mut_self();
   |               ------- borrow of `mut_foo` occurs here
LL |     mut_foo; //~ ERROR cannot move out
   |     ^^^^^^^ move out of `mut_foo` occurs here
LL |     ret;
   |     --- borrow later used here

error[E0382]: use of moved value: `rc_foo`
##[error]  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:55:5
   |
LL |     let rc_foo = Rc::new(Foo);
   |         ------ move occurs because `rc_foo` has type `Rc<Foo>`, which does not implement the `Copy` trait
LL |     rc_foo.use_rc_self();
   |            ------------- `rc_foo` moved due to this method call
LL |     rc_foo; //~ ERROR the type `Rc` does not implement `Copy`
   |     ^^^^^^ value used here after move
   |
note: `Foo::use_rc_self` takes ownership of the receiver `self`, which moves `rc_foo`
  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:16:20
   |
LL |     fn use_rc_self(self: Rc<Self>) {}
   |                    ^^^^
help: you can `clone` the value and consume it, but this might not be your desired behavior
   |
LL |     rc_foo.clone().use_rc_self();
   |           ++++++++

error[E0382]: use of moved value: `foo_add`
##[error]  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:59:5
   |
LL |     let foo_add = Foo;
   |         ------- move occurs because `foo_add` has type `Foo`, which does not implement the `Copy` trait
LL |     foo_add + Foo;
   |     ------------- `foo_add` moved due to usage in operator
LL |     foo_add; //~ ERROR use of moved
   |     ^^^^^^^ value used here after move
   |
note: if `Foo` implemented `Clone`, you could clone the value
  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:5:1
   |
LL | struct Foo;
   | ^^^^^^^^^^ consider implementing `Clone` for this type
...
LL |     foo_add + Foo;
   |     ------- you could clone this value
note: calling this operator moves the left-hand side
  --> /rustc/FAKE_PREFIX/library/core/src/ops/arith.rs:91:11

error[E0382]: use of moved value: `implicit_into_iter`
##[error]  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:63:5
   |
LL |     let implicit_into_iter = vec![true];
   |         ------------------ move occurs because `implicit_into_iter` has type `Vec<bool>`, which does not implement the `Copy` trait
LL |     for _val in implicit_into_iter {}
   |                 ------------------ `implicit_into_iter` moved due to this implicit call to `.into_iter()`
LL |     implicit_into_iter; //~ ERROR use of moved
   |     ^^^^^^^^^^^^^^^^^^ value used here after move
   |
help: consider iterating over a slice of the `Vec<bool>`'s content to avoid moving into the `for` loop
   |
LL |     for _val in &implicit_into_iter {}
   |                 +

error[E0382]: use of moved value: `explicit_into_iter`
##[error]  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:67:5
   |
LL |     let explicit_into_iter = vec![true];
   |         ------------------ move occurs because `explicit_into_iter` has type `Vec<bool>`, which does not implement the `Copy` trait
LL |     for _val in explicit_into_iter.into_iter() {}
   |                                    ----------- `explicit_into_iter` moved due to this method call
LL |     explicit_into_iter; //~ ERROR use of moved
   |     ^^^^^^^^^^^^^^^^^^ value used here after move
   |
help: you can `clone` the value and consume it, but this might not be your desired behavior
   |
LL |     for _val in explicit_into_iter.clone().into_iter() {}
   |                                   ++++++++

error[E0382]: use of moved value: `container`
##[error]  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:71:5
   |
LL |     let container = Container(vec![]);
   |         --------- move occurs because `container` has type `Container`, which does not implement the `Copy` trait
LL |     for _val in container.custom_into_iter() {}
   |                           ------------------ `container` moved due to this method call
LL |     container; //~ ERROR use of moved
   |     ^^^^^^^^^ value used here after move
   |
note: `Container::custom_into_iter` takes ownership of the receiver `self`, which moves `container`
  --> /checkout/tests/ui/moves/move-fn-self-receiver.rs:23:25
   |
LL |     fn custom_into_iter(self) -> impl Iterator<Item = bool> {
---
LL |     let foo2 = Foo;
   |         ---- move occurs because `foo2` has type `Foo`, which does not implement the `Copy` trait
LL |     loop {
   |     ---- inside of this loop
LL |         foo2.use_self(); //~ ERROR use of moved
   |         ^^^^ ---------- `foo2` moved due to this method call, in previous iteration of loop

error: aborting due to 12 previous errors

Some errors have detailed explanations: E0382, E0505.
For more information about an error, try `rustc --explain E0382`.
---
- error[E0382]: the type `Arc` does not implement `Copy`
+ error[E0382]: borrow of moved value: `arc_v`
2   --> $DIR/no-capture-arc.rs:12:18
3    |
4 LL |     let arc_v = Arc::new(v);

-    |         ----- this move could be avoided by cloning the original `Arc`, which is inexpensive
+    |         ----- move occurs because `arc_v` has type `Arc<Vec<i32>>`, which does not implement the `Copy` trait
6 LL |
7 LL |     thread::spawn(move|| {
8    |                   ------ value moved into closure here

12 LL |     assert_eq!((*arc_v)[2], 3);
13    |                  ^^^^^ value borrowed here after move
14    |
-    = note: consider using `Arc::clone`
16    = note: borrow occurs due to deref coercion to `Vec<i32>`
17 help: consider cloning the value before moving it into the closure
---
To only update this specific test, also pass `--test-args moves/no-capture-arc.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/moves/no-capture-arc.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/moves/no-capture-arc" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0382]: borrow of moved value: `arc_v`
##[error]  --> /checkout/tests/ui/moves/no-capture-arc.rs:12:18
   |
LL |     let arc_v = Arc::new(v);
   |         ----- move occurs because `arc_v` has type `Arc<Vec<i32>>`, which does not implement the `Copy` trait
LL |
LL |     thread::spawn(move|| {
   |                   ------ value moved into closure here
LL |         assert_eq!((*arc_v)[3], 4);
   |                      ----- variable moved due to use in closure
...
LL |     assert_eq!((*arc_v)[2], 3); //~ ERROR the type `Arc` does not implement `Copy`
   |                  ^^^^^ value borrowed here after move
   |
   = note: borrow occurs due to deref coercion to `Vec<i32>`
help: consider cloning the value before moving it into the closure
   |
LL ~     let value = arc_v.clone();
LL ~     thread::spawn(move|| {
LL ~         assert_eq!((*value)[3], 4);
   |

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0382`.
---
- error[E0382]: the type `Arc` does not implement `Copy`
+ error[E0382]: borrow of moved value: `arc_v`
2   --> $DIR/no-reuse-move-arc.rs:13:18
3    |
4 LL |     let arc_v = Arc::new(v);

-    |         ----- this move could be avoided by cloning the original `Arc`, which is inexpensive
+    |         ----- move occurs because `arc_v` has type `Arc<Vec<i32>>`, which does not implement the `Copy` trait
6 LL |
7 LL |     thread::spawn(move|| {
8    |                   ------ value moved into closure here

12 LL |     assert_eq!((*arc_v)[2], 3);
13    |                  ^^^^^ value borrowed here after move
14    |
-    = note: consider using `Arc::clone`
16    = note: borrow occurs due to deref coercion to `Vec<i32>`
17 help: consider cloning the value before moving it into the closure
---
To only update this specific test, also pass `--test-args moves/no-reuse-move-arc.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/moves/no-reuse-move-arc.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/moves/no-reuse-move-arc" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0382]: borrow of moved value: `arc_v`
##[error]  --> /checkout/tests/ui/moves/no-reuse-move-arc.rs:13:18
   |
LL |     let arc_v = Arc::new(v);
   |         ----- move occurs because `arc_v` has type `Arc<Vec<i32>>`, which does not implement the `Copy` trait
LL |
LL |     thread::spawn(move|| {
   |                   ------ value moved into closure here
LL |         assert_eq!((*arc_v)[3], 4);
   |                      ----- variable moved due to use in closure
...
LL |     assert_eq!((*arc_v)[2], 3); //~ ERROR the type `Arc` does not implement `Copy`
   |                  ^^^^^ value borrowed here after move
   |
   = note: borrow occurs due to deref coercion to `Vec<i32>`
help: consider cloning the value before moving it into the closure
   |
LL ~     let value = arc_v.clone();
LL ~     thread::spawn(move|| {
LL ~         assert_eq!((*value)[3], 4);
   |

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0382`.
---
- error[E0382]: the type `Rc` does not implement `Copy`
+ error[E0382]: use of moved value: `t`
2   --> $DIR/use_of_moved_value_clone_suggestions.rs:3:9
3    |
4 LL | fn duplicate_rc<T>(t: std::rc::Rc<T>) -> (std::rc::Rc<T>, std::rc::Rc<T>) {

-    |                    - this move could be avoided by cloning the original `Rc`, which is inexpensive
+    |                    - move occurs because `t` has type `Rc<T>`, which does not implement the `Copy` trait
6 LL |     (t, t)
7    |      -  ^ value used here after move
---
To only update this specific test, also pass `--test-args moves/use_of_moved_value_clone_suggestions.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/moves/use_of_moved_value_clone_suggestions.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/moves/use_of_moved_value_clone_suggestions" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0382]: use of moved value: `t`
##[error]  --> /checkout/tests/ui/moves/use_of_moved_value_clone_suggestions.rs:3:9
   |
LL | fn duplicate_rc<T>(t: std::rc::Rc<T>) -> (std::rc::Rc<T>, std::rc::Rc<T>) {
   |                    - move occurs because `t` has type `Rc<T>`, which does not implement the `Copy` trait
LL |     (t, t) //~ ERROR the type `Rc` does not implement `Copy`
   |      -  ^ value used here after move
   |      |
   |      value moved here
   |
help: clone the value to increment its reference count
   |
LL |     (t.clone(), t) //~ ERROR the type `Rc` does not implement `Copy`
   |       ++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0382`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants