Rollup of 5 pull requests
Successful merges:
- #100071 (deps: dedupe `annotate-snippets` crate versions)
- #100127 (Remove Windows function preloading)
- #100130 (Avoid pointing out `return` span if it has nothing to do with type error)
- #100169 (Optimize `pointer::as_aligned_to`)
- #100175 (ascii -> ASCII in code comment)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Avoid pointing out `return` span if it has nothing to do with type error
This code:
```rust
fn f(_: String) {}
fn main() {
let x = || {
if true {
return ();
}
f("");
};
}
```
Emits this:
```
Compiling playground v0.0.1 (/playground)
error[E0308]: mismatched types
--> src/main.rs:8:11
|
8 | f("");
| ^^- help: try using a conversion method: `.to_string()`
| |
| expected struct `String`, found `&str`
|
note: return type inferred to be `String` here
--> src/main.rs:6:20
|
6 | return ();
| ^^
```
Specifically, that note has nothing to do with the type error in question. This is because the change implemented in #84244 tries to point out the `return` span on _any_ type coercion error within a closure that happens after a `return` statement, regardless of if the error has anything to do with it.
This is really easy to trigger -- just needs a closure (or an `async`) and an early return (or any other form, e.g. `?` operator suffices) -- and super distracting in production codebases. I'm letting #84128 regress because that issue is much harder to fix correctly, and I can re-open that issue after this lands.
As a drive-by, I added a `resolve_vars_if_possible` to the coercion error logic, which leads to some error improvements. Unrelated to the issue above, though.
Remove Windows function preloading
After `@Mark-Simulacrum` asked me to provide guidance for when optionally imported functions should be preloaded, I realised my justifications were now quite weak. I think the strongest argument that can be made is that it avoids some degree of nondeterminism when calling these functions (in as far as system API calls can be said to be deterministic). However, I don't think that's particularly convincing unless there's a real world use case where it matters. Further discussion with `@thomcc` has strengthened my feeling that preloading isn't really needed.
Note that `WaitOnAddress` needed some adjustment to work without preloading. I opted not to use a macro for this special case as it seemed silly to do so for just one thing (and I don't like macros tbh).
Bump cc version in bootstrap
Among other changes, the newer cc release pulls in this fix:
b2792e33ff
This fixes errors when building compiler_builtins for UEFI targets.
Rollup of 4 pull requests
Successful merges:
- #100094 (Detect type mismatch due to loop that might never iterate)
- #100132 (Use (actually) dummy place for let-else divergence)
- #100167 (Recover `require`, `include` instead of `use` in item)
- #100193 (Remove more Clean trait implementations)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Detect type mismatch due to loop that might never iterate
When loop as tail expression causes a miss match type E0308 error, recursively get the return statement and add diagnostic information on it.
Enable function merging when opt is for size
It is, of course, natural to want to merge aliasing functions when
optimizing for code size, since that can eliminate several bytes.
And an exhaustive match helps make the code less brittle.
Closes#98215.
It is, of course, natural to want to merge aliasing functions when
optimizing for code size, since that can eliminate several bytes.
And an exhaustive match helps make the code less brittle.
when loop as tail expression for miss match type E0308 error, recursively get
the return statement and add diagnostic information on it
use rustc_hir::intravisit to collect the return expression
modified: compiler/rustc_typeck/src/check/coercion.rs
new file: src/test/ui/typeck/issue-98982.rs
new file: src/test/ui/typeck/issue-98982.stderr
Improve diagnostics for `const a: = expr;`
Adds a suggestion to write a type when there is a colon, but the type is not present.
I've also shrunk spans a little, so the suggestions are a little nicer.
Resolves#100146
r? `@compiler-errors`
kmc-solid: Add a stub implementation of #98246 (`File::set_times`)
Fixes the build failure of the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets after #98246.
This target does not support setting a modification time and access time separately, hence stubbing out the implementation.
Add test for raw-dylib with an external variable
All existing tests of link kind `raw-dylib` only validate the ability to link against functions, but it is also possible to link against variables.
This adds tests for linking against a variable using `raw-dylib` both by-name and by-ordinal.
Warn about dead tuple struct fields
Continuation of #92972. Fixes#92790.
The language team has already commented on this in https://github.com/rust-lang/rust/pull/92972#issuecomment-1021511970; I have incorporated their requests here. Specifically, there is now a new allow-by-default `unused_tuple_struct_fields` lint (name bikesheddable), and fields of unit type are ignored (https://github.com/rust-lang/rust/pull/92972#issuecomment-1021815408), so error messages look like this:
```
error: field is never read: `1`
--> $DIR/tuple-struct-field.rs:6:21
|
LL | struct Wrapper(i32, [u8; LEN], String);
| ^^^^^^^^^
|
help: change the field to unit type to suppress this warning while preserving the field numbering
|
LL | struct Wrapper(i32, (), String);
| ~~
```
r? `@joshtriplett`
Split create_def and lowering of lifetimes for opaque types and bare async fns
r? `@cjgillot`
This work is kind of half-way, but I think it could be merged anyway.
I think we should be able to remove all the vacant arms in `new_named_lifetime_with_res`, if I'm not wrong that requires visiting more nodes. We can do that as a follow up.
In follow-up PRs, besides the thing mentioned previously, I'll be trying to remove `LifetimeCaptureContext`, `captured_lifetimes` as a global data structure, global `binders_to_ignore` and all their friends :).
Also try to remap in a more general way based on def-ids.
Add a test for issue #33172
Adds a test confirming that #33172 has been fixed.
CDB has some surprising results as it looks like the supposedly unmangled static's symbol name is prefixed when it shouldn't be.
r? `@wesleywiser`
Closes#33172
Increase the minimum linux-gnu versions
This is implementing the MCP from rust-lang/compiler-team#493. It is
increasing the minimum requirements of a couple Tier 1 targets, and
others at lower tiers, so this should go through FCP sign-offs for both
`T-compiler` and `T-release`.
The new `linux-gnu` baseline is kernel 3.2 and glibc 2.17. We will also
take that kernel as the minimum floor for _all_ `*-linux-*` targets, so
it may be broadly assumed in the implementation of the standard library.
That does not preclude specific targets from having greater requirements
where it makes sense, like a new arch needing something newer, or a
platform like `linux-android` choosing a newer baseline.
Rollup of 7 pull requests
Successful merges:
- #98796 (Do not exclusively suggest `;` when `,` is also a choice)
- #99772 (Re-enable submodule archive downloads.)
- #100058 (Suggest a positional formatting argument instead of a captured argument)
- #100093 (Enable unused_parens for match arms)
- #100095 (More EarlyBinder cleanups)
- #100138 (Remove more Clean trait implementations)
- #100148 (RustWrapper: update for TypedPointerType in LLVM)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup