Skip to content

Commit 449c801

Browse files
committed
Auto merge of #141906 - chenyukang:rollup-k6v59ty, r=chenyukang
Rollup of 6 pull requests Successful merges: - #141884 (allow macro_use as first segment) - #141885 ([RTE-484] Update SGX maintainers) - #141892 (Fix false positive lint error from no_implicit_prelude attr) - #141894 (rustc-dev-guide subtree update) - #141895 (tshepang has a new email) - #141897 (Fix citool tests when executed locally) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2398bd6 + 8f240de commit 449c801

36 files changed

+369
-139
lines changed

.mailmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ Torsten Weber <TorstenWeber12@gmail.com> <torstenweber12@gmail.com>
653653
Trevor Gross <tmgross@umich.edu> <t.gross35@gmail.com>
654654
Trevor Gross <tmgross@umich.edu> <tgross@intrepidcs.com>
655655
Trevor Spiteri <tspiteri@ieee.org> <trevor.spiteri@um.edu.mt>
656-
Tshepang Mbambo <tshepang@gmail.com>
656+
Tshepang Mbambo <hopsi@tuta.io> <tshepang@gmail.com>
657657
Ty Overby <ty@pre-alpha.com>
658658
Tyler Mandry <tmandry@gmail.com> <tmandry@google.com>
659659
Tyler Ruckinger <t.ruckinger@gmail.com>

compiler/rustc_passes/src/check_attr.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2312,7 +2312,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
23122312
}
23132313

23142314
fn check_macro_use(&self, hir_id: HirId, attr: &Attribute, target: Target) {
2315-
let name = attr.name().unwrap();
2315+
let Some(name) = attr.name() else {
2316+
return;
2317+
};
23162318
match target {
23172319
Target::ExternCrate | Target::Mod => {}
23182320
_ => {

compiler/rustc_resolve/src/check_unused.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ impl<'a, 'ra, 'tcx> UnusedImportCheckVisitor<'a, 'ra, 'tcx> {
193193
continue;
194194
}
195195

196+
let module = self
197+
.r
198+
.get_nearest_non_block_module(self.r.local_def_id(extern_crate.id).to_def_id());
199+
if module.no_implicit_prelude {
200+
// If the module has `no_implicit_prelude`, then we don't suggest
201+
// replacing the extern crate with a use, as it would not be
202+
// inserted into the prelude. User writes `extern` style deliberately.
203+
continue;
204+
}
205+
196206
let vis_span = extern_crate
197207
.vis_span
198208
.find_ancestor_inside(extern_crate.span)

src/ci/citool/tests/jobs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ fn get_matrix(event_name: &str, commit_msg: &str, branch_ref: &str) -> String {
5151
.env("GITHUB_EVENT_NAME", event_name)
5252
.env("COMMIT_MESSAGE", commit_msg)
5353
.env("GITHUB_REF", branch_ref)
54+
.env("GITHUB_RUN_ID", "123")
55+
.env("GITHUB_RUN_ATTEMPT", "1")
5456
.stdout(Stdio::piped())
5557
.output()
5658
.expect("Failed to execute command");

src/doc/rustc-dev-guide/.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Jynn Nelson <github@jyn.dev> <joshua@yottadb.com>
33
Jynn Nelson <github@jyn.dev> <jyn.nelson@redjack.com>
44
Jynn Nelson <github@jyn.dev> <jnelson@cloudflare.com>
55
Jynn Nelson <github@jyn.dev>
6+
Tshepang Mbambo <hopsi@tuta.io> <tshepang@gmail.com>

src/doc/rustc-dev-guide/rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e42bbfe1f7c26f8760a99c4b1f27d33aba1040bb
1+
99e7c15e81385b38a8186b51edc4577d5d7b5bdd

src/doc/rustc-dev-guide/src/appendix/compiler-lecture.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ These are videos where various experts explain different parts of the compiler:
4646

4747
## Code Generation
4848
- [January 2019: Cranelift](https://www.youtube.com/watch?v=9OIA7DTFQWU)
49+
- [December 2024: LLVM Developers' Meeting - Rust ❤️ LLVM](https://www.youtube.com/watch?v=Kqz-umsAnk8)

src/doc/rustc-dev-guide/src/borrow_check/two_phase_borrows.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ borrow.
7676
[`AutoBorrow`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/adjustment/enum.AutoBorrow.html
7777
[converted]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_build/thir/cx/expr/trait.ToBorrowKind.html#method.to_borrow_kind
7878
[`BorrowKind`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.BorrowKind.html
79-
[`GatherBorrows`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/visit/trait.Visitor.html#method.visit_local
79+
[`GatherBorrows`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_borrowck/borrow_set/struct.GatherBorrows.html
8080
[`BorrowData`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_borrowck/borrow_set/struct.BorrowData.html
8181

8282
## Checking two-phase borrows

src/doc/rustc-dev-guide/src/building/suggested.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ for two reasons:
9191
additional rebuilds in some cases.
9292

9393
To avoid these problems:
94-
- Add `--build-dir=build-rust-analyzer` to all of the custom `x` commands in
94+
- Add `--build-dir=build/rust-analyzer` to all of the custom `x` commands in
9595
your editor's rust-analyzer configuration.
9696
(Feel free to choose a different directory name if desired.)
9797
- Modify the `rust-analyzer.rustfmt.overrideCommand` setting so that it points
@@ -100,10 +100,7 @@ To avoid these problems:
100100
copy of `rust-analyzer-proc-macro-srv` in that other build directory.
101101

102102
Using separate build directories for command-line builds and rust-analyzer
103-
requires extra disk space, and also means that running `./x clean` on the
104-
command-line will not clean out the separate build directory. To clean the
105-
separate build directory, run `./x clean --build-dir=build-rust-analyzer`
106-
instead.
103+
requires extra disk space.
107104

108105
### Visual Studio Code
109106

@@ -137,7 +134,7 @@ Task] instead:
137134

138135
### Neovim
139136

140-
For Neovim users there are several options for configuring for rustc. The
137+
For Neovim users, there are a few options. The
141138
easiest way is by using [neoconf.nvim](https://github.com/folke/neoconf.nvim/),
142139
which allows for project-local configuration files with the native LSP. The
143140
steps for how to use it are below. Note that they require rust-analyzer to

src/doc/rustc-dev-guide/src/diagnostics.md

Lines changed: 101 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -866,19 +866,17 @@ struct](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/json/struct
866866
(and sub-structs) for the JSON serialization. Don't confuse this with
867867
[`errors::Diag`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Diag.html)!
868868

869-
## `#[rustc_on_unimplemented(...)]`
869+
## `#[rustc_on_unimplemented]`
870870

871-
The `#[rustc_on_unimplemented]` attribute allows trait definitions to add specialized
872-
notes to error messages when an implementation was expected but not found.
873-
You can refer to the trait's generic arguments by name and to the resolved type using `Self`.
874-
875-
For example:
871+
This attribute allows trait definitions to modify error messages when an implementation was
872+
expected but not found. The string literals in the attribute are format strings and can be
873+
formatted with named parameters. See the Formatting
874+
section below for what parameters are permitted.
876875

877876
```rust,ignore
878-
#![feature(rustc_attrs)]
879-
880-
#[rustc_on_unimplemented="an iterator over elements of type `{A}` \
881-
cannot be built from a collection of type `{Self}`"]
877+
#[rustc_on_unimplemented(message = "an iterator over \
878+
elements of type `{A}` cannot be built from a \
879+
collection of type `{Self}`")]
882880
trait MyIterator<A> {
883881
fn next(&mut self) -> A;
884882
}
@@ -895,32 +893,26 @@ fn main() {
895893
When the user compiles this, they will see the following;
896894

897895
```txt
898-
error[E0277]: the trait bound `&[{integer}]: MyIterator<char>` is not satisfied
899-
--> <anon>:14:5
896+
error[E0277]: an iterator over elements of type `char` cannot be built from a collection of type `&[{integer}]`
897+
--> src/main.rs:13:19
900898
|
901-
14 | iterate_chars(&[1, 2, 3][..]);
902-
| ^^^^^^^^^^^^^ an iterator over elements of type `char` cannot be built from a collection of type `&[{integer}]`
899+
13 | iterate_chars(&[1, 2, 3][..]);
900+
| ------------- ^^^^^^^^^^^^^^ the trait `MyIterator<char>` is not implemented for `&[{integer}]`
901+
| |
902+
| required by a bound introduced by this call
903903
|
904-
= help: the trait `MyIterator<char>` is not implemented for `&[{integer}]`
905-
= note: required by `iterate_chars`
904+
note: required by a bound in `iterate_chars`
906905
```
907906

908-
`rustc_on_unimplemented` also supports advanced filtering for better targeting
909-
of messages, as well as modifying specific parts of the error message. You
910-
target the text of:
911-
907+
You can modify the contents of:
912908
- the main error message (`message`)
913909
- the label (`label`)
914-
- an extra note (`note`)
910+
- the note(s) (`note`)
915911

916912
For example, the following attribute
917913

918914
```rust,ignore
919-
#[rustc_on_unimplemented(
920-
message="message",
921-
label="label",
922-
note="note"
923-
)]
915+
#[rustc_on_unimplemented(message = "message", label = "label", note = "note")]
924916
trait MyIterator<A> {
925917
fn next(&mut self) -> A;
926918
}
@@ -930,45 +922,61 @@ Would generate the following output:
930922

931923
```text
932924
error[E0277]: message
933-
--> <anon>:14:5
925+
--> <file>:10:19
934926
|
935-
14 | iterate_chars(&[1, 2, 3][..]);
936-
| ^^^^^^^^^^^^^ label
927+
10 | iterate_chars(&[1, 2, 3][..]);
928+
| ------------- ^^^^^^^^^^^^^^ label
929+
| |
930+
| required by a bound introduced by this call
937931
|
938-
= note: note
939932
= help: the trait `MyIterator<char>` is not implemented for `&[{integer}]`
940-
= note: required by `iterate_chars`
933+
= note: note
934+
note: required by a bound in `iterate_chars`
941935
```
942936

937+
The functionality discussed so far is also available with
938+
[`#[diagnostic::on_unimplemented]`](https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnosticon_unimplemented-attribute).
939+
If you can, you should use that instead.
940+
941+
### Filtering
942+
943943
To allow more targeted error messages, it is possible to filter the
944-
application of these fields based on a variety of attributes when using
945-
`on`:
944+
application of these fields with `on`.
946945

946+
You can filter on the following boolean flags:
947947
- `crate_local`: whether the code causing the trait bound to not be
948948
fulfilled is part of the user's crate. This is used to avoid suggesting
949949
code changes that would require modifying a dependency.
950-
- Any of the generic arguments that can be substituted in the text can be
951-
referred by name as well for filtering, like `Rhs="i32"`, except for
952-
`Self`.
953-
- `_Self`: to filter only on a particular calculated trait resolution, like
954-
`Self="std::iter::Iterator<char>"`. This is needed because `Self` is a
955-
keyword which cannot appear in attributes.
956-
- `direct`: user-specified rather than derived obligation.
957-
- `from_desugaring`: usable both as boolean (whether the flag is present)
958-
or matching against a particular desugaring. The desugaring is identified
959-
with its variant name in the `DesugaringKind` enum.
960-
961-
For example, the `Iterator` trait can be annotated in the following way:
950+
- `direct`: whether this is an user-specified rather than derived obligation.
951+
- `from_desugaring`: whether we are in some kind of desugaring, like `?`
952+
or a `try` block for example. This flag can also be matched on, see below.
953+
954+
You can match on the following names and values, using `name = "value"`:
955+
- `cause`: Match against one variant of the `ObligationCauseCode`
956+
enum. Only `"MainFunctionType"` is supported.
957+
- `from_desugaring`: Match against a particular variant of the `DesugaringKind`
958+
enum. The desugaring is identified by its variant name, for example
959+
`"QuestionMark"` for `?` desugaring or `"TryBlock"` for `try` blocks.
960+
- `Self` and any generic arguments of the trait, like `Self = "alloc::string::String"`
961+
or `Rhs="i32"`.
962+
963+
The compiler can provide several values to match on, for example:
964+
- the self_ty, pretty printed with and without type arguments resolved.
965+
- `"{integral}"`, if self_ty is an integral of which the type is known.
966+
- `"[]"`, `"[{ty}]"`, `"[{ty}; _]"`, `"[{ty}; $N]"` when applicable.
967+
- references to said slices and arrays.
968+
- `"fn"`, `"unsafe fn"` or `"#[target_feature] fn"` when self is a function.
969+
- `"{integer}"` and `"{float}"` if the type is a number but we haven't inferred it yet.
970+
- combinations of the above, like `"[{integral}; _]"`.
971+
972+
For example, the `Iterator` trait can be filtered in the following way:
962973

963974
```rust,ignore
964975
#[rustc_on_unimplemented(
965-
on(
966-
_Self="&str",
967-
note="call `.chars()` or `.as_bytes()` on `{Self}`"
968-
),
969-
message="`{Self}` is not an iterator",
970-
label="`{Self}` is not an iterator",
971-
note="maybe try calling `.iter()` or a similar method"
976+
on(Self = "&str", note = "call `.chars()` or `.as_bytes()` on `{Self}`"),
977+
message = "`{Self}` is not an iterator",
978+
label = "`{Self}` is not an iterator",
979+
note = "maybe try calling `.iter()` or a similar method"
972980
)]
973981
pub trait Iterator {}
974982
```
@@ -997,15 +1005,47 @@ error[E0277]: `&str` is not an iterator
9971005
= note: required by `std::iter::IntoIterator::into_iter`
9981006
```
9991007

1000-
If you need to filter on multiple attributes, you can use `all`, `any` or
1001-
`not` in the following way:
1008+
The `on` filter accepts `all`, `any` and `not` predicates similar to the `cfg` attribute:
10021009

10031010
```rust,ignore
1004-
#[rustc_on_unimplemented(
1005-
on(
1006-
all(_Self="&str", T="std::string::String"),
1007-
note="you can coerce a `{T}` into a `{Self}` by writing `&*variable`"
1008-
)
1009-
)]
1010-
pub trait From<T>: Sized { /* ... */ }
1011+
#[rustc_on_unimplemented(on(
1012+
all(Self = "&str", T = "alloc::string::String"),
1013+
note = "you can coerce a `{T}` into a `{Self}` by writing `&*variable`"
1014+
))]
1015+
pub trait From<T>: Sized {
1016+
/* ... */
1017+
}
1018+
```
1019+
1020+
### Formatting
1021+
1022+
The string literals are format strings that accept parameters wrapped in braces
1023+
but positional and listed parameters and format specifiers are not accepted.
1024+
The following parameter names are valid:
1025+
- `Self` and all generic parameters of the trait.
1026+
- `This`: the name of the trait the attribute is on, without generics.
1027+
- `Trait`: the name of the "sugared" trait. See `TraitRefPrintSugared`.
1028+
- `ItemContext`: the kind of `hir::Node` we're in, things like `"an async block"`,
1029+
`"a function"`, `"an async function"`, etc.
1030+
1031+
Something like:
1032+
1033+
```rust,ignore
1034+
#![feature(rustc_attrs)]
1035+
1036+
#[rustc_on_unimplemented(message = "Self = `{Self}`, \
1037+
T = `{T}`, this = `{This}`, trait = `{Trait}`, \
1038+
context = `{ItemContext}`")]
1039+
pub trait From<T>: Sized {
1040+
fn from(x: T) -> Self;
1041+
}
1042+
1043+
fn main() {
1044+
let x: i8 = From::from(42_i32);
1045+
}
1046+
```
1047+
1048+
Will format the message into
1049+
```text
1050+
"Self = `i8`, T = `i32`, this = `From`, trait = `From<i32>`, context = `a function`"
10111051
```

src/doc/rustc-dev-guide/src/early_late_parameters.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ As mentioned previously, the distinction between early and late bound parameters
174174
- When naming a function (early)
175175
- When calling a function (late)
176176

177-
There currently is no syntax for explicitly specifying generic arguments for late bound parameters as part of the call step, only specifying generic arguments when naming a function. The syntax `foo::<'static>();`, despite being part of a function call, behaves as `(foo::<'static>)();` and instantiates the early bound generic parameters on the function item type.
177+
There is currently no syntax for explicitly specifying generic arguments for late bound parameters during the call step; generic arguments can only be specified for early bound parameters when naming a function.
178+
The syntax `foo::<'static>();`, despite being part of a function call, behaves as `(foo::<'static>)();` and instantiates the early bound generic parameters on the function item type.
178179

179180
See the following example:
180181
```rust

src/doc/rustc-dev-guide/src/fuzzing.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,32 @@ To build a corpus, you may want to use:
7373

7474
- The rustc/rust-analyzer/clippy test suites (or even source code) --- though avoid
7575
tests that are already known to cause failures, which often begin with comments
76-
like `// failure-status: 101` or `// known-bug: #NNN`.
77-
- The already-fixed ICEs in [Glacier][glacier] --- though avoid the unfixed
78-
ones in `ices/`!
76+
like `//@ failure-status: 101` or `//@ known-bug: #NNN`.
77+
- The already-fixed ICEs in the archived [Glacier][glacier] repository --- though
78+
avoid the unfixed ones in `ices/`!
79+
80+
[glacier]: https://github.com/rust-lang/glacier
7981

8082
## Extra credit
8183

8284
Here are a few things you can do to help the Rust project after filing an ICE.
8385

84-
- [Bisect][bisect] the bug to figure out when it was introduced
86+
- [Bisect][bisect] the bug to figure out when it was introduced.
87+
If you find the regressing PR / commit, you can mark the issue with the label
88+
`S-has-bisection`. If not, consider applying `E-needs-bisection` instead.
8589
- Fix "distractions": problems with the test case that don't contribute to
8690
triggering the ICE, such as syntax errors or borrow-checking errors
87-
- Minimize the test case (see below)
88-
- Add the minimal test case to [Glacier][glacier]
91+
- Minimize the test case (see below). If successful, you can label the
92+
issue with `S-has-mcve`. Otherwise, you can apply `E-needs-mcve`.
93+
- Add the minimal test case to the rust-lang/rust repo as a [crashes test].
94+
While you're at it, consider including other "untracked" crashes in your PR.
95+
Please don't forget to mark your issue with `S-bug-has-test` afterwards.
96+
97+
See also [applying and removing labels][labeling].
8998

9099
[bisect]: https://rust-lang.github.io/cargo-bisect-rustc/
100+
[crashes test]: tests/compiletest.html#crashes-tests
101+
[labeling]: https://forge.rust-lang.org/release/issue-triaging.html#applying-and-removing-labels
91102

92103
## Minimization
93104

@@ -143,7 +154,6 @@ ICEs that require debug assertions to reproduce should be tagged
143154
- [tree-splicer][tree-splicer] generates new source files by combining existing
144155
ones while maintaining correct syntax
145156

146-
[glacier]: https://github.com/rust-lang/glacier
147157
[fuzz-rustc]: https://github.com/dwrensha/fuzz-rustc
148158
[icemaker]: https://github.com/matthiaskrgr/icemaker/
149159
[tree-splicer]: https://github.com/langston-barrett/tree-splicer/

src/doc/rustc-dev-guide/src/getting-started.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ filtering the search to areas you're interested in. For example:
8989
Not all important or beginner work has issue labels.
9090
See below for how to find work that isn't labelled.
9191

92-
[help-wanted-search]: https://github.com/issues?q=is%3Aopen+is%3Aissue+org%3Arust-lang+no%3Aassignee+label%3AE-easy%2C%22good+first+issue%22%2Cgood-first-issue%2CE-medium%2CEasy%2CE-help-wanted%2CE-mentor+-label%3AS-blocked+-linked:pr+
92+
[help-wanted-search]: https://github.com/issues?q=is%3Aopen+is%3Aissue+org%3Arust-lang+no%3Aassignee+label%3AE-easy%2C%22good+first+issue%22%2Cgood-first-issue%2CE-medium%2CEasy%2CE-help-wanted%2CE-mentor+-label%3AS-blocked+-linked%3Apr+
9393
[Triage]: ./contributing.md#issue-triage
9494

9595
### Recurring work
@@ -98,8 +98,6 @@ Some work is too large to be done by a single person. In this case, it's common
9898
issues" to co-ordinate the work between contributors. Here are some example tracking issues where
9999
it's easy to pick up work without a large time commitment:
100100

101-
- [Rustdoc Askama Migration](https://github.com/rust-lang/rust/issues/108868)
102-
- [Diagnostic Translation](https://github.com/rust-lang/rust/issues/100717)
103101
- [Move UI tests to subdirectories](https://github.com/rust-lang/rust/issues/73494)
104102

105103
If you find more recurring work, please feel free to add it here!

0 commit comments

Comments
 (0)