Skip to content

Commit f7ca9df

Browse files
committed
Auto merge of #113006 - GuillaumeGomez:rollup-l2js0wa, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - #112703 ([-Ztrait-solver=next, mir-typeck] instantiate hidden types in the root universe) - #112854 (fix: add cfg diagnostic for unresolved import error) - #112912 (style-guide: Rewrite let-else section for clarity, without changing formatting) - #112915 (Update runtests.py : grammar correction) - #112971 (issue template: add clippy entry which points to the clippy repo) - #112989 (Add a regression test for #109141) - #113002 (bootstrap: Backup `settings.json` to the correct filename) - #113003 (Fix old python deprecation check in x.py) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 69a6373 + 4d9ba1a commit f7ca9df

File tree

15 files changed

+313
-53
lines changed

15 files changed

+313
-53
lines changed

.github/ISSUE_TEMPLATE/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ contact_links:
66
- name: Feature Request
77
url: https://internals.rust-lang.org/
88
about: Please discuss language feature requests on the internals forum.
9+
- name: Clippy Bug
10+
url: https://github.com/rust-lang/rust-clippy/issues/new/choose
11+
about: Please report Clippy bugs such as false positives in the Clippy repo.

compiler/rustc_borrowck/src/type_check/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
5050
use rustc_mir_dataflow::move_paths::MoveData;
5151
use rustc_mir_dataflow::ResultsCursor;
5252

53-
use crate::renumber::RegionCtxt;
5453
use crate::session_diagnostics::MoveUnsized;
5554
use crate::{
5655
borrow_set::BorrowSet,
@@ -1040,9 +1039,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
10401039
.collect();
10411040

10421041
let renumbered_opaques = self.infcx.tcx.fold_regions(opaques, |_, _| {
1043-
self.infcx.next_nll_region_var(
1042+
self.infcx.next_nll_region_var_in_universe(
10441043
NllRegionVariableOrigin::Existential { from_forall: false },
1045-
|| RegionCtxt::Unknown,
1044+
ty::UniverseIndex::ROOT,
10461045
)
10471046
});
10481047

compiler/rustc_infer/src/infer/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,7 @@ impl<'tcx> InferCtxt<'tcx> {
14741474
/// universes. Updates `self.universe` to that new universe.
14751475
pub fn create_next_universe(&self) -> ty::UniverseIndex {
14761476
let u = self.universe.get().next_universe();
1477+
debug!("create_next_universe {u:?}");
14771478
self.universe.set(u);
14781479
u
14791480
}

compiler/rustc_resolve/src/imports.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
609609
}
610610
}
611611

612-
fn throw_unresolved_import_error(&self, errors: Vec<(&Import<'_>, UnresolvedImportError)>) {
612+
fn throw_unresolved_import_error(&mut self, errors: Vec<(&Import<'_>, UnresolvedImportError)>) {
613613
if errors.is_empty() {
614614
return;
615615
}
@@ -679,6 +679,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
679679
_ => {}
680680
}
681681
}
682+
683+
match &import.kind {
684+
ImportKind::Single { source, .. } => {
685+
if let Some(ModuleOrUniformRoot::Module(module)) = import.imported_module.get()
686+
&& let Some(module) = module.opt_def_id()
687+
{
688+
self.find_cfg_stripped(&mut diag, &source.name, module)
689+
}
690+
},
691+
_ => {}
692+
}
682693
}
683694

684695
diag.emit();

src/bootstrap/setup.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
582582
Some(false) => {
583583
// exists and is not current version or outdated, so back it up
584584
let mut backup = vscode_settings.clone();
585-
backup.set_extension("bak");
585+
backup.set_extension("json.bak");
586586
eprintln!("warning: copying `settings.json` to `settings.json.bak`");
587587
fs::copy(&vscode_settings, &backup)?;
588588
"Updated"

src/doc/style-guide/src/statements.md

+62-43
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,69 @@ let Foo {
103103

104104
#### else blocks (let-else statements)
105105

106-
If a let statement contains an `else` component, also known as a let-else statement,
107-
then the `else` component should be formatted according to the same rules as the `else` block
108-
in [control flow expressions (i.e. if-else, and if-let-else expressions)](./expressions.md#control-flow-expressions).
109-
Apply the same formatting rules to the components preceding
110-
the `else` block (i.e. the `let pattern: Type = initializer_expr ...` portion)
111-
as described [above](#let-statements)
112-
113-
Similarly to if-else expressions, if the initializer
114-
expression is multi-lined, then the `else` keyword and opening brace of the block (i.e. `else {`)
115-
should be put on the same line as the end of the initializer
116-
expression with a preceding space if all the following are true:
106+
A let statement can contain an `else` component, making it a let-else statement.
107+
In this case, always apply the same formatting rules to the components preceding
108+
the `else` block (i.e. the `let pattern: Type = initializer_expr` portion)
109+
as described [for other let statements](#let-statements).
110+
111+
The entire let-else statement may be formatted on a single line if all the
112+
following are true:
113+
114+
* the entire statement is *short*
115+
* the `else` block contains only a single-line expression and no statements
116+
* the `else` block contains no comments
117+
* the let statement components preceding the `else` block can be formatted on a single line
118+
119+
```rust
120+
let Some(1) = opt else { return };
121+
```
122+
123+
Formatters may allow users to configure the value of the threshold
124+
used to determine whether a let-else statement is *short*.
125+
126+
Otherwise, the let-else statement requires some line breaks.
127+
128+
If breaking a let-else statement across multiple lines, never break between the
129+
`else` and the `{`, and always break before the `}`.
130+
131+
If the let statement components preceding the `else` can be formatted on a
132+
single line, but the let-else does not qualify to be placed entirely on a
133+
single line, put the `else {` on the same line as the initializer expression,
134+
with a space between them, then break the line after the `{`. Indent the
135+
closing `}` to match the `let`, and indent the contained block one step
136+
further.
137+
138+
```rust
139+
let Some(1) = opt else {
140+
return;
141+
};
142+
143+
let Some(1) = opt else {
144+
// nope
145+
return
146+
};
147+
```
148+
149+
If the let statement components preceding the `else` can be formatted on a
150+
single line, but the `else {` does not fit on the same line, break the line
151+
before the `else`.
152+
153+
```rust
154+
let Some(x) = some_really_really_really_really_really_really_really_really_really_long_name
155+
else {
156+
return;
157+
};
158+
```
159+
160+
If the initializer expression is multi-line, the `else` keyword and opening
161+
brace of the block (i.e. `else {`) should be put on the same line as the end of
162+
the initializer expression, with a space between them, if all the following are
163+
true:
117164

118165
* The initializer expression ends with one or more closing
119166
parentheses, square brackets, and/or braces
120167
* There is nothing else on that line
121-
* That line is not indented beyond the indent of the first line containing the `let` keyword
168+
* That line has the same indentation level as the initial `let` keyword.
122169

123170
For example:
124171

@@ -135,7 +182,9 @@ let Some(x) = y.foo(
135182
}
136183
```
137184

138-
Otherwise, the `else` keyword and opening brace should be placed on the next line after the end of the initializer expression, and should not be indented (the `else` keyword should be aligned with the `let` keyword).
185+
Otherwise, the `else` keyword and opening brace should be placed on the next
186+
line after the end of the initializer expression, and the `else` keyword should
187+
have the same indentation level as the `let` keyword.
139188

140189
For example:
141190

@@ -155,11 +204,6 @@ fn main() {
155204
return
156205
};
157206

158-
let Some(x) = some_really_really_really_really_really_really_really_really_really_long_name
159-
else {
160-
return;
161-
};
162-
163207
let Some(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) =
164208
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
165209
else {
@@ -168,31 +212,6 @@ fn main() {
168212
}
169213
```
170214

171-
##### Single line let-else statements
172-
173-
The entire let-else statement may be formatted on a single line if all the following are true:
174-
175-
* the entire statement is *short*
176-
* the `else` block contains a single-line expression and no statements
177-
* the `else` block contains no comments
178-
* the let statement components preceding the `else` block can be formatted on a single line
179-
180-
```rust
181-
let Some(1) = opt else { return };
182-
183-
let Some(1) = opt else {
184-
return;
185-
};
186-
187-
let Some(1) = opt else {
188-
// nope
189-
return
190-
};
191-
```
192-
193-
Formatters may allow users to configure the value of the threshold
194-
used to determine whether a let-else statement is *short*.
195-
196215
### Macros in statement position
197216

198217
A macro use in statement position should use parentheses or square brackets as

src/etc/test-float-parse/runtests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def write_errors():
127127
if not have_seen_error:
128128
have_seen_error = True
129129
msg("Something is broken:", *args)
130-
msg("Future errors logged to errors.txt")
130+
msg("Future errors will be logged to errors.txt")
131131
exit_status = 101
132132

133133

tests/ui/cfg/diagnostics-reexport.rs

+24
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@ pub mod inner {
99
//~^ NOTE found an item that was configured out
1010
}
1111

12+
pub use a::x;
13+
//~^ ERROR unresolved import `a::x`
14+
//~| NOTE no `x` in `a`
15+
16+
mod a {
17+
#[cfg(no)]
18+
pub fn x() {}
19+
//~^ NOTE found an item that was configured out
20+
}
21+
22+
pub use b::{x, y};
23+
//~^ ERROR unresolved imports `b::x`, `b::y`
24+
//~| NOTE no `x` in `b`
25+
//~| NOTE no `y` in `b`
26+
27+
mod b {
28+
#[cfg(no)]
29+
pub fn x() {}
30+
//~^ NOTE found an item that was configured out
31+
#[cfg(no)]
32+
pub fn y() {}
33+
//~^ NOTE found an item that was configured out
34+
}
35+
1236
fn main() {
1337
// There is no uwu at this path - no diagnostic.
1438
inner::uwu(); //~ ERROR cannot find function
+35-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
1+
error[E0432]: unresolved import `a::x`
2+
--> $DIR/diagnostics-reexport.rs:12:9
3+
|
4+
LL | pub use a::x;
5+
| ^^^^ no `x` in `a`
6+
|
7+
note: found an item that was configured out
8+
--> $DIR/diagnostics-reexport.rs:18:12
9+
|
10+
LL | pub fn x() {}
11+
| ^
12+
13+
error[E0432]: unresolved imports `b::x`, `b::y`
14+
--> $DIR/diagnostics-reexport.rs:22:13
15+
|
16+
LL | pub use b::{x, y};
17+
| ^ ^ no `y` in `b`
18+
| |
19+
| no `x` in `b`
20+
|
21+
note: found an item that was configured out
22+
--> $DIR/diagnostics-reexport.rs:29:12
23+
|
24+
LL | pub fn x() {}
25+
| ^
26+
note: found an item that was configured out
27+
--> $DIR/diagnostics-reexport.rs:32:12
28+
|
29+
LL | pub fn y() {}
30+
| ^
31+
132
error[E0425]: cannot find function `uwu` in module `inner`
2-
--> $DIR/diagnostics-reexport.rs:14:12
33+
--> $DIR/diagnostics-reexport.rs:38:12
334
|
435
LL | inner::uwu();
536
| ^^^ not found in `inner`
@@ -10,6 +41,7 @@ note: found an item that was configured out
1041
LL | pub use super::uwu;
1142
| ^^^
1243

13-
error: aborting due to previous error
44+
error: aborting due to 3 previous errors
1445

15-
For more information about this error, try `rustc --explain E0425`.
46+
Some errors have detailed explanations: E0425, E0432.
47+
For more information about an error, try `rustc --explain E0425`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(generic_const_exprs)]
2+
#![allow(incomplete_features)]
3+
4+
impl EntriesBuffer {
5+
fn a(&self) -> impl Iterator {
6+
self.0.iter_mut() //~ ERROR: cannot borrow `*self.0` as mutable, as it is behind a `&` reference
7+
}
8+
}
9+
10+
struct EntriesBuffer(Box<[[u8; HashesEntryLEN]; 5]>);
11+
//~^ ERROR: cannot find value `HashesEntryLEN` in this scope
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0425]: cannot find value `HashesEntryLEN` in this scope
2+
--> $DIR/issue-109141.rs:10:32
3+
|
4+
LL | struct EntriesBuffer(Box<[[u8; HashesEntryLEN]; 5]>);
5+
| ^^^^^^^^^^^^^^ not found in this scope
6+
|
7+
help: you might be missing a const parameter
8+
|
9+
LL | struct EntriesBuffer<const HashesEntryLEN: /* Type */>(Box<[[u8; HashesEntryLEN]; 5]>);
10+
| ++++++++++++++++++++++++++++++++++
11+
12+
error[E0596]: cannot borrow `*self.0` as mutable, as it is behind a `&` reference
13+
--> $DIR/issue-109141.rs:6:9
14+
|
15+
LL | self.0.iter_mut()
16+
| ^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
17+
|
18+
help: consider changing this to be a mutable reference
19+
|
20+
LL | fn a(&mut self) -> impl Iterator {
21+
| ~~~~~~~~~
22+
23+
error: aborting due to 2 previous errors
24+
25+
Some errors have detailed explanations: E0425, E0596.
26+
For more information about an error, try `rustc --explain E0425`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// compile-flags: -Ztrait-solver=next
2+
// check-pass
3+
4+
trait Trait {
5+
type Ty;
6+
}
7+
8+
impl Trait for for<'a> fn(&'a u8, &'a u8) {
9+
type Ty = ();
10+
}
11+
12+
// argument is necessary to create universes before registering the hidden type.
13+
fn test<'a>(_: <fn(&u8, &u8) as Trait>::Ty) -> impl Sized {
14+
"hidden type is `&'?0 str` with '?0 member of ['static,]"
15+
}
16+
17+
fn main() {}

0 commit comments

Comments
 (0)