Skip to content

Conversation

@mu001999
Copy link
Contributor

@mu001999 mu001999 commented Sep 24, 2025

Fixes #146967

we have had UnnamedCrateRootImport for things like use crate::self, reusing it for $crate seems good enough

Emit error CrateImported when we meet use $crate::{self}

r? petrochenkov

@rustbot
Copy link
Collaborator

rustbot commented Sep 24, 2025

Failed to set assignee to [petrochenkov]: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 24, 2025
resolve_unnamed_crate_root_import =
crate root imports need to be explicitly named: `use crate as name;`
{$dollar ->
[true] crate root imports need to be explicitly named: `use $crate as name;`
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is a valid suggestion. Per this, use $crate as x; is not allowed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Though I suppose it is a separate question if that restriction makes sense if there is an as. Is there a reason to also prevent that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes! Updated, now will also emit $crate may not be imported for use $crate::{self} things

Copy link
Contributor

Choose a reason for hiding this comment

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

The whole pre-existing logic here is garbage (#119776 (comment)), and this PR adds more.
The only restriction that we really need here is for imports to always end up with a name (*) - #35612 (comment).

use super; // bad
use super as name; // good
use super::{self}; // bad
use super::{self as name}; // good
use self; // bad
use self as name; // good
use crate; // bad
use crate as name; // good
use crate::{self}; // bad
use crate::{self as name}; // good
use $crate; // bad
use $crate as name; // good
use $crate::{self}; // bad
use $crate::{self as name}; // good

// etc

Many of these examples do not work correctly atm for various reasons.

(*) The name can even be underscore _, but it will just always be reported as unused in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

More than a partial fixup, I'd rather want to see an exhaustive test listing the possible cases of imports using only path segment keywords (self, super, crate, $crate) in the input path with FIXMEs as a declaration of intent.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mu001999
Could you add such a test?
Adding some partial fixup on top of that would also be fine, but ideally this stuff just needs to be rewritten.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for the case use $crate as name; // good in the above examples, @ehuss said in rust-lang/reference#2010 (comment):

but for some reason use $crate as foo doesn't work either.


And I'd like to rewrite the whole logic

ehuss added a commit to ehuss/reference that referenced this pull request Sep 24, 2025
The previous wording for this restriction was pretty confusing to me. I
don't remember what I was thinking when I wrote it, and I can't find any
historical explanation either. `use` paths can use `$crate` as long as
they have more than one segment (`use $crate::foo` is obviously OK).

I have rewritten this to make it clear it is specifically about `use
$crate`. One could say that restriction is already covered by the
previous point that says `use crate;` requires an `as`, but for some
reason `use $crate as foo` doesn't work either. So I have left this as a
separate rule for now.

cc rust-lang/rust#146972 (comment)
for context.
@mu001999 mu001999 force-pushed the fix/use-dollar-crate branch from ce2578f to 49c425d Compare September 25, 2025 01:54
@mu001999 mu001999 changed the title Emit error UnnamedCrateRootImport also for DollarCrate Disable use $crate::{self} like use $crate Sep 25, 2025
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 26, 2025
@mu001999 mu001999 marked this pull request as draft October 8, 2025 06:43
@mu001999 mu001999 force-pushed the fix/use-dollar-crate branch from 49c425d to d0d3a9d Compare October 9, 2025 03:40
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the fix/use-dollar-crate branch from d0d3a9d to c8526a5 Compare October 13, 2025 15:10
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the fix/use-dollar-crate branch from c8526a5 to db9bb42 Compare October 14, 2025 14:40
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the fix/use-dollar-crate branch 2 times, most recently from df75a52 to 96820fa Compare October 16, 2025 13:28
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the fix/use-dollar-crate branch from 96820fa to 1473c4c Compare October 16, 2025 15:47
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the fix/use-dollar-crate branch from 1473c4c to e0d5fa0 Compare October 23, 2025 14:50
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the fix/use-dollar-crate branch from e0d5fa0 to 4c38159 Compare October 23, 2025 15:42
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the fix/use-dollar-crate branch from 4c38159 to aca5e4e Compare October 24, 2025 14:49
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the fix/use-dollar-crate branch from aca5e4e to 30a19ad Compare October 24, 2025 17:22
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the fix/use-dollar-crate branch from 30a19ad to e181d80 Compare October 26, 2025 14:26
@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
-   --> $DIR/dollar-crate-is-keyword-2.rs:6:16
+ error: imports need to be explicitly named: `use $crate as name;`
+   --> $DIR/dollar-crate-is-keyword-2.rs:5:16
3    |
- LL |         use a::$crate::b;
-    |                ^^^^^^ `$crate` in paths can only be used in start position
+ LL |         use a::$crate;
+    |                ^^^^^^
6 ...
7 LL | m!();
8    | ---- in this macro invocation

9    |
10    = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
11 
- error[E0432]: unresolved import `a::$crate`
-   --> $DIR/dollar-crate-is-keyword-2.rs:5:13
+ error[E0433]: failed to resolve: `$crate` in paths can only be used in start position
+   --> $DIR/dollar-crate-is-keyword-2.rs:6:16
14    |
- LL |         use a::$crate;
-    |             ^^^^^^^^^ no `$crate` in `a`
+ LL |         use a::$crate::b;
+    |                ^^^^^^ `$crate` in paths can only be used in start position
17 ...
18 LL | m!();
19    | ---- in this macro invocation

33 
---
38 

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs:5:16
- LL |         use a::$crate; //~ ERROR unresolved import `a::$crate`
-   --> /checkout/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs:6:16
- LL |         use a::$crate::b; //~ ERROR `$crate` in paths can only be used in start position
+ error: imports need to be explicitly named: `use $crate as name;`
+   --> $DIR/dollar-crate-is-keyword-2.rs:5:16
+ LL |         use a::$crate;
+    |                ^^^^^^
+ error[E0433]: failed to resolve: `$crate` in paths can only be used in start position
+   --> $DIR/dollar-crate-is-keyword-2.rs:6:16
+ LL |         use a::$crate::b;
+    |                ^^^^^^ `$crate` in paths can only be used in start position
+ For more information about this error, try `rustc --explain E0433`.


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 dollar-crate/dollar-crate-is-keyword-2.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/dollar-crate/dollar-crate-is-keyword-2.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/dollar-crate/dollar-crate-is-keyword-2" "-A" "unused" "-W" "unused_attributes" "-A" "internal_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: imports need to be explicitly named: `use $crate as name;`
##[error]  --> /checkout/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs:5:16
   |
LL |         use a::$crate; //~ ERROR unresolved import `a::$crate`
   |                ^^^^^^
...
LL | m!();
   | ---- in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: `$crate` in paths can only be used in start position
##[error]  --> /checkout/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs:6:16
   |
LL |         use a::$crate::b; //~ ERROR `$crate` in paths can only be used in start position
   |                ^^^^^^ `$crate` in paths can only be used in start position
...
LL | m!();
   | ---- in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: `$crate` in paths can only be used in start position
##[error]  --> /checkout/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs:7:21
   |
LL |         type A = a::$crate; //~ ERROR `$crate` in paths can only be used in start position
   |                     ^^^^^^ `$crate` in paths can only be used in start position
...
LL | m!();
   | ---- in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
---
+    |
+ LL |         use $crate as $crate;
+    |                       ^^^^^^
+ ...
+ LL | m!();
+    | ---- in this macro invocation
+    |
+    = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
+ 
+ error: aborting due to 5 previous errors
46 
47 

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/dollar-crate/dollar-crate-is-keyword.rs:10:23
- LL |         use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate`
+ error: imports need to be explicitly named: `use $crate as name;`
+   --> $DIR/dollar-crate-is-keyword.rs:10:23
+    |
+ LL |         use $crate as $crate;
+    |                       ^^^^^^
+ ...
+ LL | m!();
+    | ---- in this macro invocation
+    |
+    = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
+ 
+ error: aborting due to 5 previous errors
---
To only update this specific test, also pass `--test-args dollar-crate/dollar-crate-is-keyword.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/dollar-crate/dollar-crate-is-keyword.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/dollar-crate/dollar-crate-is-keyword" "-A" "unused" "-W" "unused_attributes" "-A" "internal_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: expected identifier, found reserved identifier `$crate`
##[error]  --> /checkout/tests/ui/dollar-crate/dollar-crate-is-keyword.rs:6:20
   |
LL |             struct $crate {} //~ ERROR expected identifier, found reserved identifier `$crate`
   |                    ^^^^^^ expected identifier, found reserved identifier
...
LL | m!();
   | ---- in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected identifier, found reserved identifier `$crate`
##[error]  --> /checkout/tests/ui/dollar-crate/dollar-crate-is-keyword.rs:10:23
   |
LL |         use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate`
   |                       ^^^^^^ expected identifier, found reserved identifier
...
LL | m!();
   | ---- in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `$crate` may not be imported
##[error]  --> /checkout/tests/ui/dollar-crate/dollar-crate-is-keyword.rs:9:9
   |
LL |         use $crate; //~ ERROR `$crate` may not be imported
   |         ^^^^^^^^^^^
...
LL | m!();
   | ---- in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `$crate` may not be imported
##[error]  --> /checkout/tests/ui/dollar-crate/dollar-crate-is-keyword.rs:10:9
   |
LL |         use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate`
   |         ^^^^^^^^^^^^^^^^^^^^^
...
LL | m!();
   | ---- in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error: imports need to be explicitly named: `use $crate as name;`
##[error]  --> /checkout/tests/ui/dollar-crate/dollar-crate-is-keyword.rs:10:23
   |
LL |         use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate`
   |                       ^^^^^^
...
LL | m!();
   | ---- in this macro invocation
   |
---
14 

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/dollar-crate/use-dollar-crate-self.rs:3:22
- LL |         use $crate::{self}; //~ ERROR `$crate` may not be imported
+ error: imports need to be explicitly named: `use $crate as name;`
+   --> $DIR/use-dollar-crate-self.rs:3:22
+    |
+ LL |         use $crate::{self};
+    |                      ^^^^
+ ...
---
To only update this specific test, also pass `--test-args dollar-crate/use-dollar-crate-self.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/dollar-crate/use-dollar-crate-self.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/dollar-crate/use-dollar-crate-self" "-A" "unused" "-W" "unused_attributes" "-A" "internal_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: `$crate` may not be imported
##[error]  --> /checkout/tests/ui/dollar-crate/use-dollar-crate-self.rs:3:22
   |
LL |         use $crate::{self}; //~ ERROR `$crate` may not be imported
   |                      ^^^^
...
LL | foo!();
   | ------ in this macro invocation
   |
   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)

error: imports need to be explicitly named: `use $crate as name;`
##[error]  --> /checkout/tests/ui/dollar-crate/use-dollar-crate-self.rs:3:22
   |
LL |         use $crate::{self}; //~ ERROR `$crate` may not be imported
   |                      ^^^^
...
LL | foo!();
   | ------ in this macro invocation
   |
---
+    |
+ LL | use foo as self;
+    |            ^^^^
+ 
7 error[E0429]: `self` imports are only allowed within a { } list
8   --> $DIR/import-self.rs:12:8
9    |

48 help: you can use `as` to change the binding name of the import
49    |
---
To only update this specific test, also pass `--test-args imports/issue-45829/import-self.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/imports/issue-45829/import-self.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/imports/issue-45829/import-self" "-A" "unused" "-W" "unused_attributes" "-A" "internal_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: expected identifier, found keyword `self`
##[error]  --> /checkout/tests/ui/imports/issue-45829/import-self.rs:9:12
   |
---
   |
LL | use foo as self;
   |            ^^^^

error[E0429]: `self` imports are only allowed within a { } list
##[error]  --> /checkout/tests/ui/imports/issue-45829/import-self.rs:12:8
   |
LL | use foo::self; //~ ERROR is defined multiple times
   |        ^^^^^^
   |
help: consider importing the module directly
   |
LL - use foo::self; //~ ERROR is defined multiple times
LL + use foo; //~ ERROR is defined multiple times
   |
help: alternatively, use the multi-path `use` syntax to import `self`
   |
LL | use foo::{self}; //~ ERROR is defined multiple times
   |          +    +

error[E0255]: the name `foo` is defined multiple times
##[error]  --> /checkout/tests/ui/imports/issue-45829/import-self.rs:6:11
   |
---
   |
   = note: `foo` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
   |
LL - use foo::self; //~ ERROR is defined multiple times
LL + use self as other_foo; //~ ERROR is defined multiple times
   |

error[E0252]: the name `A` is defined multiple times
##[error]  --> /checkout/tests/ui/imports/issue-45829/import-self.rs:16:11
   |
LL | use foo::A;
   |     ------ previous import of the type `A` here
LL | use foo::{self as A};
   |           ^^^^^^^^^ `A` reimported here
   |
   = note: `A` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
   |
LL | use foo::{self as OtherA};
---
---- [ui] tests/ui/imports/issue-47623.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/imports/issue-47623/issue-47623.stderr`
diff of stderr:

- error[E0429]: `self` imports are only allowed within a { } list
+ error: imports need to be explicitly named: `use self as name;`
2   --> $DIR/issue-47623.rs:1:5
3    |
4 LL | use self;

6 
---
To only update this specific test, also pass `--test-args imports/issue-47623.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/imports/issue-47623.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/imports/issue-47623" "-A" "unused" "-W" "unused_attributes" "-A" "internal_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: imports need to be explicitly named: `use self as name;`
##[error]  --> /checkout/tests/ui/imports/issue-47623.rs:1:5
   |
LL | use self; //~ERROR `self` imports are only allowed within a { } list
   |     ^^^^

error: aborting due to 1 previous error
------------------------------------------

---
To only update this specific test, also pass `--test-args self/self_type_keyword.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/self/self_type_keyword.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/self/self_type_keyword" "-A" "unused" "-W" "unused_attributes" "-A" "internal_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: expected identifier, found keyword `Self`
##[error]  --> /checkout/tests/ui/self/self_type_keyword.rs:2:10
   |
---
   |
LL |         mut Self => (),
   |         ^^^^
   |
   = note: `mut` may be followed by `variable` and `variable @ pattern`
help: remove the `mut` prefix
   |
LL -         mut Self => (),
LL +         Self => (),
   |

---
   |
LL | struct Bar<'Self>;
   |            ^^^^^ unused lifetime parameter
   |
   = help: consider removing `'Self`, referring to it in a field, or using a marker such as `PhantomData`

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/self/self_type_keyword.rs:21:9
   |
LL |     match 15 {
---
error: ui test did not emit an error
note: by default, ui tests are expected not to compile.
hint: use check-pass, build-pass, or run-pass directive to change this behavior.
status: exit status: 0
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/use/use-keyword.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/use/use-keyword" "-A" "unused" "-W" "unused_attributes" "-A" "internal_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: none

---- [ui] tests/ui/use/use-keyword.rs stdout end ----
---- [ui] tests/ui/use/use-mod/use-mod-2.rs stdout ----
---
To only update this specific test, also pass `--test-args use/use-mod/use-mod-2.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/use/use-mod/use-mod-2.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/use/use-mod/use-mod-2" "-A" "unused" "-W" "unused_attributes" "-A" "internal_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: imports need to be explicitly named: `use self as name;`
##[error]  --> /checkout/tests/ui/use/use-mod/use-mod-2.rs:2:16
   |

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

Labels

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.

use $crate::{self}; should not be accepted

5 participants