Commit Graph

23913 Commits

Author SHA1 Message Date
Matthias Krüger
637d9ddc35
Rollup merge of #110578 - bvanjoi:fix-issue-110547, r=jackh726
fix(error): normalize whitespace during msg_to_buffer

close https://github.com/rust-lang/rust/issues/110547
2023-04-21 06:44:30 +02:00
Matthias Krüger
7d046551a7
Rollup merge of #110555 - compiler-errors:subst-missing-trait-items, r=cjgillot
Substitute missing trait items suggestion correctly

Properly substitute missing item suggestions, so that when they reference generics from their parent trait they actually have the right time for the impl.

Also, some other minor tweaks like using `/* Type */` to signify a GAT's type is actually missing, and fixing generic arg suggestions for GATs in general.
2023-04-21 06:44:29 +02:00
bohan
a2f275da51 fix(error): normalize whitespace during msg_to_buffer 2023-04-21 08:40:00 +08:00
bors
d19b64fb54 Auto merge of #109999 - m-ou-se:flatten-format-args, r=oli-obk
Enable flatten-format-args by default.

Part of https://github.com/rust-lang/rust/issues/99012.

This enables the `flatten-format-args` feature that was added by https://github.com/rust-lang/rust/pull/106824:

> This change inlines string literals, integer literals and nested format_args!() into format_args!() during ast lowering, making all of the following pairs result in equivalent hir:
>
> ```rust
> println!("Hello, {}!", "World");
> println!("Hello, World!");
> ```
>
> ```rust
> println!("[info] {}", format_args!("error"));
> println!("[info] error");
> ```
>
> ```rust
> println!("[{}] {}", status, format_args!("error: {}", msg));
> println!("[{}] error: {}", status, msg);
> ```
>
> ```rust
> println!("{} + {} = {}", 1, 2, 1 + 2);
> println!("1 + 2 = {}", 1 + 2);
> ```
>
> And so on.
>
> This is useful for macros. E.g. a `log::info!()` macro could just pass the tokens from the user directly into a `format_args!()` that gets efficiently flattened/inlined into a `format_args!("info: {}")`.
>
> It also means that `dbg!(x)` will have its file, line, and expression name inlined:
>
> ```rust
> eprintln!("[{}:{}] {} = {:#?}", file!(), line!(), stringify!(x), x); // before
> eprintln!("[example.rs:1] x = {:#?}", x); // after
> ```
>
> Which can be nice in some cases, but also means a lot more unique static strings than before if dbg!() is used a lot.

This is mostly an optimization, except that it will be visible through [`fmt::Arguments::as_str()`](https://doc.rust-lang.org/nightly/std/fmt/struct.Arguments.html#method.as_str).

In https://github.com/rust-lang/rust/pull/106823, there was already a libs-api FCP about the documentation of `fmt::Arguments::as_str()` to allow it to give `Some` rather than `None` depending on optimizations like this. That was just a documentation update though. This PR is the one that actually makes the user visible change:

```rust
assert_eq!(format_args!("abc").as_str(), Some("abc")); // Unchanged.
assert_eq!(format_args!("ab{}", "c").as_str(), Some("abc")); // Was `None` before!
```
2023-04-20 23:19:19 +00:00
bors
8bdcc62cb0 Auto merge of #110616 - m-ou-se:fmt-lang-items, r=jyn514
Remove public doc(hidden) core::fmt::rt::v1

All the types used by format_arg!() are now lang items, so they are no longer required as publicly exported items.

Part of #99012

After this change, the `rt` module is private, and contains only three lang items used by format_args (`Placeholder`, `Alignment`, and `Count`): 441682cca9/library/core/src/fmt/rt.rs
2023-04-20 21:11:54 +00:00
Mara Bos
441682cca9 Update comments in format args lowering.
These lang items have been moved/renamed.
2023-04-20 18:09:32 +02:00
Matthias Krüger
c430d6111a
Rollup merge of #110599 - WaffleLapkin:bonk_tygenericarg_transmutes, r=compiler-errors
Remove an unused `&[Ty]` <-> `&[GenericArg]`

Missed this one in #110496, oops.

r? `@compiler-errors`
2023-04-20 17:59:55 +02:00
Matthias Krüger
462461699a
Rollup merge of #110558 - spastorino:smir-call-terminator, r=oli-obk
Add Call terminator to SMIR

This adds internal MIR `TerminatorKind::Call` to SMIR `Terminator::Call` conversion.

r? `@oli-obk`
2023-04-20 17:59:54 +02:00
Matthias Krüger
7dc211f5ce
Rollup merge of #108795 - thomcc:x86_64h-target, r=wesleywiser
Add support for the x86_64h-apple-darwin target

See https://github.com/rust-lang/compiler-team/issues/599 for MCP.

r? compiler-team

CC `@BlackHoleFox` who recently overhauled the apple target code in `rustc-target`.

## Target Support Checklist

> - A tier 3 target must have a designated developer or developers (the "target
>   maintainers") on record to be CCed when issues arise regarding the target.
>   (The mechanism to track and CC such developers may evolve over time.)

I'm the designated developer.

> - Targets must use naming consistent with any existing targets; for instance, a
>   target for the same CPU or OS as an existing Rust target should use the same
>   name for that CPU or OS. Targets should normally use the same names and
>   naming conventions as used elsewhere in the broader ecosystem beyond Rust
>   (such as in other toolchains), unless they have a very good reason to
>   diverge. Changing the name of a target can be highly disruptive, especially
>   once the target reaches a higher tier, so getting the name right is important
>   even for a tier 3 target.

This uses the same naming conventions used for the other macOS targets (`-apple-darwin`), combined with the convention used by LLVM for the `x86_64h` targets. LLVM's convention matches the architecture name used when invoking various tools such as `lipo`, `arch`, and (IMO) there's not really a compelling reason to depart from it.

> - Target names should not introduce undue confusion or ambiguity unless
>   absolutely necessary to maintain ecosystem compatibility. For example, if
>   the name of the target makes people extremely likely to form incorrect
>   beliefs about what it targets, the name should be changed or augmented to
>   disambiguate it.

I don't think this is especially likely, although I suppose someone could mistake it for `x86_64-apple-darwin`.

> - If possible, use only letters, numbers, dashes and underscores for the name.
>   Periods (`.`) are known to cause issues in Cargo.

👍

> - Tier 3 targets may have unusual requirements to build or use, but must not
>   create legal issues or impose onerous legal terms for the Rust project or for
>   Rust developers or users.
>   - The target must not introduce license incompatibilities.

It does not.

> - Anything added to the Rust repository must be under the standard Rust
>   license (`MIT OR Apache-2.0`).

It is.

> - The target must not cause the Rust tools or libraries built for any other
>   host (even when supporting cross-compilation to the target) to depend
>   on any new dependency less permissive than the Rust licensing policy. This
>   applies whether the dependency is a Rust crate that would require adding
>   new license exceptions (as specified by the `tidy` tool in the
>   rust-lang/rust repository), or whether the dependency is a native library
>   or binary. In other words, the introduction of the target must not cause a
>   user installing or running a version of Rust or the Rust tools to be
>   subject to any new license requirements.

There are no new dependencies that don't also apply to `x86_64-apple-darwin`.

> - Compiling, linking, and emitting functional binaries, libraries, or other
>   code for the target (whether hosted on the target itself or cross-compiling
>   from another target) must not depend on proprietary (non-FOSS) libraries.
>   Host tools built for the target itself may depend on the ordinary runtime
>   libraries supplied by the platform and commonly used by other applications
>   built for the target, but those libraries must not be required for code
>   generation for the target; cross-compilation to the target must not require
>   such libraries at all. For instance, `rustc` built for the target may
>   depend on a common proprietary C runtime library or console output library,
>   but must not depend on a proprietary code generation library or code
>   optimization library. Rust's license permits such combinations, but the
>   Rust project has no interest in maintaining such combinations within the
>   scope of Rust itself, even at tier 3.

This has the same requirements as the other macOS targets (e.g. `x86_64-apple-darwin` and similar).

> - "onerous" here is an intentionally subjective term. At a minimum, "onerous"
>   legal/licensing terms include but are *not* limited to: non-disclosure
>   requirements, non-compete requirements, contributor license agreements
>   (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms,
>   requirements conditional on the employer or employment of any particular
>   Rust developers, revocable terms, any requirements that create liability
>   for the Rust project or its developers or users, or any requirements that
>   adversely affect the livelihood or prospects of the Rust project or its
>   developers or users.

No change here.

> - Neither this policy nor any decisions made regarding targets shall create any
>   binding agreement or estoppel by any party. If any member of an approving
>   Rust team serves as one of the maintainers of a target, or has any legal or
>   employment requirement (explicit or implicit) that might affect their
>   decisions regarding a target, they must recuse themselves from any approval
>   decisions regarding the target's tier status, though they may otherwise
>   participate in discussions.

👍

> - This requirement does not prevent part or all of this policy from being
>   cited in an explicit contract or work agreement (e.g. to implement or
>   maintain support for a target). This requirement exists to ensure that a
>   developer or team responsible for reviewing and approving a target does not
>   face any legal threats or obligations that would prevent them from freely
>   exercising their judgment in such approval, even if such judgment involves
>   subjective matters or goes beyond the letter of these requirements.

👍

> - Tier 3 targets should attempt to implement as much of the standard libraries
>   as possible and appropriate (`core` for most targets, `alloc` for targets
>   that can support dynamic memory allocation, `std` for targets with an
>   operating system or equivalent layer of system-provided functionality), but
>   may leave some code unimplemented (either unavailable or stubbed out as
>   appropriate), whether because the target makes it impossible to implement or
>   challenging to implement. The authors of pull requests are not obligated to
>   avoid calling any portions of the standard library on the basis of a tier 3
>   target not implementing those portions.

The standard library tests seem to pass.

> - The target must provide documentation for the Rust community explaining how
>   to build for the target, using cross-compilation if possible. If the target
>   supports running binaries, or running tests (even if they do not pass), the
>   documentation must explain how to run such binaries or tests for the target,
>   using emulation if possible or dedicated hardware if necessary.

Documentation is provided.

> - Tier 3 targets must not impose burden on the authors of pull requests, or
>   other developers in the community, to maintain the target. In particular,
>   do not post comments (automated or manual) on a PR that derail or suggest a
>   block on the PR based on a tier 3 target. Do not send automated messages or
>   notifications (via any medium, including via ``@`)` to a PR author or others
>   involved with a PR regarding a tier 3 target, unless they have opted into
>   such messages.

Noted. This target is nearly identical to `x86_64-apple-darwin`, so this is
unlikely to cause issues anyway.

> - Backlinks such as those generated by the issue/PR tracker when linking to
>   an issue or PR are not considered a violation of this policy, within
>   reason. However, such messages (even on a separate repository) must not
>   generate notifications to anyone involved with a PR who has not requested
>   such notifications.

👍

> - Patches adding or updating tier 3 targets must not break any existing tier 2
>   or tier 1 target, and must not knowingly break another tier 3 target without
>   approval of either the compiler team or the maintainers of the other tier 3
>   target.
>   - In particular, this may come up when working on closely related targets,
>     such as variations of the same architecture with different features. Avoid
>     introducing unconditional uses of features that another variation of the
>     target may not have; use conditional compilation or runtime detection, as
>     appropriate, to let each target run code supported by that target.

👍
2023-04-20 17:59:53 +02:00
Santiago Pastorino
2f503345b4
Add Call terminator to SMIR 2023-04-20 12:00:41 -03:00
bors
791a7f22e3 Auto merge of #110598 - matthiaskrgr:rollup-0ybd9i3, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #110240 (Add `indent_style = tab` for `Makefile`s to `.editorconfig`)
 - #110545 (Add `GenericArgKind::as_{type,const,region}`)
 - #110574 ( fix out-of-date comment about rpath in bootstrap)
 - #110581 (Style fix for loongarch-linux.md)
 - #110584 (Allow overwriting the sysroot compile flag in compile tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-20 13:03:31 +00:00
Maybe Waffle
6d4b7fe9ed Remove an unused &[Ty] <-> &[GenericArg] 2023-04-20 12:41:46 +00:00
Matthias Krüger
17f6763a14
Rollup merge of #110545 - WaffleLapkin:generic_arg_as_x, r=cjgillot
Add `GenericArgKind::as_{type,const,region}`

This allows to make code nicer in some cases
2023-04-20 14:36:54 +02:00
bors
7e23d180c1 Auto merge of #109993 - scottmcm:transmute-niches, r=oli-obk
`assume` value ranges in `transmute`

Fixes #109958
2023-04-20 10:46:13 +00:00
bors
13fc33e3f2 Auto merge of #110585 - JohnTitor:rollup-gfffoiv, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #102341 (Implement `Neg` for signed non-zero integers.)
 - #110424 (Spelling misc)
 - #110448 (cmp doc examples improvements)
 - #110516 (bootstrap: Update linux-raw-sys to 0.3.2)
 - #110548 (Make `impl Debug for Span` not panic on not having session globals.)
 - #110554 (`deny(unsafe_op_in_unsafe_fn)` in `rustc_data_structures`)
 - #110575 (fix lint regression in `non_upper_case_globals`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-20 08:33:33 +00:00
Yuki Okushi
a2826dc4d4
Rollup merge of #110575 - Ezrashaw:fix-regression-110573, r=compiler-errors
fix lint regression in `non_upper_case_globals`

Fixes #110573

The issue also exists for inherent associated types (where I copied my impl from). `EarlyContext` is more involved to fix in this way, so I'll leave it be for now (note it's unstable so that's not urgent).

r? `@compiler-errors`
2023-04-20 17:03:26 +09:00
Yuki Okushi
a496ae6ac3
Rollup merge of #110554 - WaffleLapkin:rustc_data_structures_unsafe_op_in_unsafe_fn, r=Nilstrieb
`deny(unsafe_op_in_unsafe_fn)` in `rustc_data_structures`

r? `@Nilstrieb`

I couldn't bring myself to document the safety in big `unsafe` functions but ehh
2023-04-20 17:03:26 +09:00
Yuki Okushi
615669dbb2
Rollup merge of #110548 - kpreid:span, r=WaffleLapkin
Make `impl Debug for Span` not panic on not having session globals.

I hit the panic that this patch avoids while messing with the early lints in `rustc_session::config::build_session_options()`. The rest of that project is not finished, but this seemed like a self-contained improvement.

(Should changes like this add tests? I don't see similar unit tests.)
2023-04-20 17:03:25 +09:00
Scott McMurray
baf98e7515 Add transmute optimization tests and some extra comments 2023-04-19 23:17:35 -07:00
bors
23a76a8ab5 Auto merge of #110527 - nnethercote:lazy-graph, r=lqd
In `LexicalResolver`, don't construct graph unless necessary.

A small but easy perf win.

r? `@jackh726`
2023-04-20 06:14:55 +00:00
Ezra Shaw
8cad917e68
reimpl make non_upper_case_globals lint not report trait impls 2023-04-20 16:28:49 +12:00
bors
7fde08365c Auto merge of #110399 - cjgillot:infer-variance, r=aliemjay
Account for opaque variance in outlives

Fixes https://github.com/rust-lang/rust/issues/108591
Fixes https://github.com/rust-lang/rust/issues/108592
cc `@aliemjay`
2023-04-20 04:08:03 +00:00
bors
b9fd498fa7 Auto merge of #110061 - WaffleLapkin:duality_of_myself_and_this, r=cjgillot
Add suggestion to use closure argument instead of a capture on borrowck error

Fixes #109271
r? `@compiler-errors`

This should probably be refined a bit, but opening a PR so that I don't forget anything.
2023-04-19 23:39:03 +00:00
Michael Goulet
f362f6e9e6 Format missing GATs correctly 2023-04-19 23:37:41 +00:00
bors
39c6804b92 Auto merge of #106704 - ecnelises:big_archive, r=bjorn3
Support AIX-style archive type

Reading facility of AIX big archive has been supported by `object` since 0.30.0.

Writing facility of AIX big archive has already been supported by `ar_archive_writer`, but we need to bump the version to support the new archive type enum.
2023-04-19 21:21:17 +00:00
Maybe Waffle
cac143f0e3 Extend and use hir::Node::body_id 2023-04-19 19:13:45 +00:00
Maybe Waffle
102c0af5a7 Add suggestion to use a closure arg instead of a capture on bck error 2023-04-19 19:13:35 +00:00
bors
9c51cf7e7f Auto merge of #110546 - matthiaskrgr:rollup-346kik6, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #110123 ('./configure' now checks if 'config.toml' exists before writing to that destination)
 - #110429 (Spelling src bootstrap)
 - #110430 (Spelling src ci)
 - #110515 (Don't special-case download-rustc in `maybe_install_llvm`)
 - #110521 (Fix `x test lint-docs linkchecker` when download-rustc is enabled)
 - #110525 (Fix `tests/run-make-translation` when download-rustc is enabled)
 - #110531 (small type system cleanup)
 - #110533 (Missing blanket impl trait not public)
 - #110540 (Fix wrong comment in rustc_hir/src/hir.rs)
 - #110541 (Fix various configure bugs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-19 19:11:05 +00:00
Maybe Waffle
cfe5c3ca6c Add #[track_caller] to struct_span_err_with_code (drive-by cleanup)
We use caller information to track where a diagnostic was created,
so all "helper" diagnostic functions should use `#[track_caller]`
2023-04-19 19:10:37 +00:00
Maybe Waffle
ceabcd83e6 Remove useless check (drive-by cleanup)
While it might *seem* that this does something, it actually doesn't.
`mut_borrow_of_mutable_ref` returns a `bool` that is ignored by the
let-else. This was basically
```rust
if !self.body.local_decls.get(local).is_some() {
    return
}
```
Which is pretty useless
2023-04-19 19:10:25 +00:00
Maybe Waffle
f79df7d2a4 deny(unsafe_op_in_unsafe_fn) in rustc_data_structures 2023-04-19 18:00:48 +00:00
Maybe Waffle
25b9263b34 Move GenericArgKind::as_{type,const,region} to GenericArg 2023-04-19 17:59:30 +00:00
Michael Goulet
73038d3a64 Make missing impl item suggestions more obvious that they're missing 2023-04-19 17:57:37 +00:00
Michael Goulet
204c516293 Substitute missing item suggestion correctly 2023-04-19 17:47:39 +00:00
Kevin Reid
883606f2c0 fmt fix 2023-04-19 10:06:30 -07:00
bors
df0d9b492d Auto merge of #110496 - WaffleLapkin:🏳️‍⚧️sound, r=compiler-errors
Don't transmute `&List<GenericArg>` <-> `&List<Ty>`

In #93505 we allowed safely transmuting between `&List<GenericArg<'_>>` and `&List<Ty<'_>>`. This was possible because `GenericArg` is a tagged pointer and the tag for types is `0b00`, such that a `GenericArg` with a type inside has the same layout as `Ty`.

While this was meant as an optimization, it doesn't look like it was actually any perf or max-rss win (see https://github.com/rust-lang/rust/pull/94799#issuecomment-1064340003, https://github.com/rust-lang/rust/pull/94841, https://github.com/rust-lang/rust/pull/110496#issuecomment-1513799140).

Additionally the way it was done is quite fragile — `unsafe` code was not properly documented or contained in a module, types were not marked as `repr(C)` (making the transmutes possibly unsound). All of this makes the code maintenance harder and blocks other possible optimizations (as an example I've found out about these `transmutes` when my change caused them to sigsegv compiler).

Thus, I think we can safely (pun intended) remove those transmutes, making maintenance easier, optimizations possible, code less cursed, etc.

r? `@compiler-errors`
2023-04-19 17:01:06 +00:00
Kevin Reid
f17c805701 Make impl Debug for Span not panic on not having session globals. 2023-04-19 08:55:21 -07:00
Matthias Krüger
b59658c990
Rollup merge of #110540 - safinaskar:patch-1, r=WaffleLapkin
Fix wrong comment in rustc_hir/src/hir.rs
2023-04-19 17:54:43 +02:00
Matthias Krüger
75de33cd1d
Rollup merge of #110531 - lcnr:type-system-stuff, r=aliemjay
small type system cleanup
2023-04-19 17:54:42 +02:00
Maybe Waffle
3f15521396 Add GenericArgKind::as_{type,const,region} 2023-04-19 14:54:31 +00:00
Askar Safin
0b6b72e198
Fix wrong comment in rustc_hir/src/hir.rs 2023-04-19 16:38:04 +03:00
bors
3a5c8e91f0 Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obk
Rm const traits in libcore

See [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const.20Trait.60.20removal.20or.20rework)

* [x] Bless ui tests
* [ ] Re constify some unstable functions with workarounds if they are needed
2023-04-19 13:03:40 +00:00
lcnr
16d061ea77 small type system cleanup 2023-04-19 10:30:30 +02:00
bors
d7f9e81650 Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco
Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`

Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-19 08:26:47 +00:00
Nicholas Nethercote
8e6c9e0694 In LexicalResolver, don't construct graph unless necessary.
A small but easy perf win.
2023-04-19 16:17:29 +10:00
bors
c781584079 Auto merge of #110522 - matthiaskrgr:rollup-9m7rw3u, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #110432 (Report more detailed reason why `Index` impl is not satisfied)
 - #110451 (Minor changes to `IndexVec::ensure_contains_elem` & related methods)
 - #110476 (Delay a good path bug on drop for `TypeErrCtxt` (instead of a regular delayed bug))
 - #110498 (Switch to `EarlyBinder` for `collect_return_position_impl_trait_in_trait_tys`)
 - #110507 (boostrap: print output during building tools)
 - #110510 (Fix ICE for transmutability in candidate assembly)
 - #110513 (make `non_upper_case_globals` lint not report trait impls)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-19 05:08:54 +00:00
Qiu Chaofan
7c8c9cf470 Bump version of object and related crates 2023-04-19 12:42:20 +08:00
Matthias Krüger
78490ada7c
Rollup merge of #110513 - Ezrashaw:fix-trait-const-name-lint, r=compiler-errors
make `non_upper_case_globals` lint not report trait impls

We should not lint on trait `impl`s for `non_upper_case_globals`; the user doesn't have control over the name. This brings `non_upper_case_globals` into consistency with other `nonstandard_style` lints.
2023-04-19 06:35:36 +02:00
Matthias Krüger
fdd2f4bde8
Rollup merge of #110510 - bryangarza:issue-110467-safe-transmute, r=compiler-errors
Fix ICE for transmutability in candidate assembly

Don't skip transmutability check just because there may be generics in the ParamEnv.

Fixes #110467
2023-04-19 06:35:36 +02:00
Matthias Krüger
9f0b16b2bb
Rollup merge of #110498 - kylematsuda:earlybinder-rpitit-tys, r=compiler-errors
Switch to `EarlyBinder` for `collect_return_position_impl_trait_in_trait_tys`

Part of the work to finish https://github.com/rust-lang/rust/issues/105779.

This PR adds `EarlyBinder` to the return type of the `collect_return_position_impl_trait_in_trait_tys` query and removes `bound_return_position_impl_trait_in_trait_tys`.

r? `@lcnr`
2023-04-19 06:35:35 +02:00