Commit Graph

248015 Commits

Author SHA1 Message Date
David Wood
2ee0409f32
errors: share SilentEmitter between rustc and rustfmt
Signed-off-by: David Wood <david@davidtw.co>
2024-03-05 10:14:36 +00:00
bors
5a1e5449c8 Auto merge of #121001 - nyurik:optimize-core-fmt, r=cuviper
perf: improve write_fmt to handle simple strings

In case format string has no arguments, simplify its implementation with a direct call to `output.write_str(value)`. This builds on `@dtolnay` original [suggestion](https://github.com/serde-rs/serde/pull/2697#issuecomment-1940376414). This does not change any expectations because the original `fn write()` implementation calls `write_str` for parts of the format string.

```rust
write!(f, "text")  ->  f.write_str("text")
```

```diff
 /// [`write!`]: crate::write!
+#[inline]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
+    if let Some(s) = args.as_str() { output.write_str(s) } else { write_internal(output, args) }
+}
+
+/// Actual implementation of the [`write`], but without the simple string optimization.
+fn write_internal(output: &mut dyn Write, args: Arguments<'_>) -> Result {
     let mut formatter = Formatter::new(output);
     let mut idx = 0;
```

* Hopefully it will improve the simple case for the https://github.com/rust-lang/rust/issues/99012
* Another related (original?) issues #10761
* Previous similar attempt to fix it by by `@Kobzol` #100700

CC: `@m-ou-se` as probably the biggest expert in everything `format!`
2024-03-05 05:33:17 +00:00
bors
1547c076bf Auto merge of #121780 - nnethercote:diag-renaming2, r=davidtwco
Diagnostic renaming 2

A sequel to #121489.

r? `@davidtwco`
2024-03-05 02:58:34 +00:00
Nicholas Nethercote
1cd957498b Adjust Diag::new signature.
Make it use `impl Into<DiagMessage>` like all the other methods nearby.
2024-03-05 12:15:13 +11:00
Nicholas Nethercote
5cce28725f Rename DiagnosticMetadata as DiagMetadata. 2024-03-05 12:15:13 +11:00
Nicholas Nethercote
f8429390ec Rename StructuredDiagnostic as StructuredDiag. 2024-03-05 12:15:12 +11:00
Nicholas Nethercote
7aa0eea19c Rename BuiltinLintDiagnostics as BuiltinLintDiag.
Not the dropping of the trailing `s` -- this type describes a single
diagnostic and its name should be singular.
2024-03-05 12:15:10 +11:00
Nicholas Nethercote
d98ad0a181 Rename DiagnosticExt as DiagExt. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
d0e9bab51b Rename DiagnosticMode as DiagMode. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
573267cf3c Rename SubdiagnosticMessageOp as SubdiagMessageOp. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
60ea6e2831 Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
f16a8d0390 Fix some out-of-date comments. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
18715c98c6 Rename DiagnosticMessage as DiagMessage. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
d849f5c225 Disable tests/ui-fulldeps/internal-lints/diagnostics.rs on stage 1.
When you make a change to the diagnostic lints, it uses the old version
of the lints with stage 1 and the new version with stage 2, which often
leads to failures in stage 1. Let's just stick to stage 2.
2024-03-05 12:14:49 +11:00
bors
2eeff462b7 Auto merge of #120675 - oli-obk:intrinsics3.0, r=pnkfelix
Add a scheme for moving away from `extern "rust-intrinsic"` entirely

All `rust-intrinsic`s can become free functions now, either with a fallback body, or with a dummy body and an attribute, requiring backends to actually implement the intrinsic.

This PR demonstrates the dummy-body scheme with the `vtable_size` intrinsic.

cc https://github.com/rust-lang/rust/issues/63585

follow-up to #120500

MCP at https://github.com/rust-lang/compiler-team/issues/720
2024-03-05 00:13:01 +00:00
bors
50e77f133f Auto merge of #121998 - matthiaskrgr:rollup-l7lzwpb, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #120976 (constify a couple thread_local statics)
 - #121683 (Fix LVI tests after frame pointers are enabled by default)
 - #121703 (Add a way to add constructors for `rustc_type_ir` types)
 - #121732 (Improve assert_matches! documentation)
 - #121928 (Extract an arguments struct for `Builder::then_else_break`)
 - #121939 (Small enhancement to description of From trait)
 - #121968 (Don't run test_get_os_named_thread on win7)
 - #121969 (`ParseSess` cleanups)
 - #121977 (Doc: Fix incorrect reference to integer in Atomic{Ptr,Bool}::as_ptr.)
 - #121994 (Update platform-support.md with supported musl version)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-04 21:56:57 +00:00
Matthias Krüger
5e13bc45fb
Rollup merge of #121994 - wesleywiser:update_musl_version_docs, r=ehuss
Update platform-support.md with supported musl version

This just reflects the current status quo, there is no actual change here since the update to musl 1.2.3 occurred in #107129 and was approved in https://github.com/rust-lang/compiler-team/issues/572.

I also normalized all mentions of musl libc to "musl" (non-capitalized per the project's site and Wikipedia page).

r? ``@ehuss``
2024-03-04 22:16:34 +01:00
Matthias Krüger
c83ca5ba9a
Rollup merge of #121977 - Lee-Janggun:master, r=WaffleLapkin
Doc: Fix incorrect reference to integer in Atomic{Ptr,Bool}::as_ptr.

I am assuming "resulting integer" is an error, since we are talking about pointers and booleans here. Seems like it was missed while copy & pasting the docs from the integer versions. I also checked the rest of the docs, and this was the only mention of integers.
2024-03-04 22:16:34 +01:00
Matthias Krüger
13b971209a
Rollup merge of #121969 - nnethercote:ParseSess-cleanups, r=wesleywiser
`ParseSess` cleanups

The main change here is to rename all `ParseSess` values as `psess`. Plus a few other small cleanups.

r? `@wesleywiser`
2024-03-04 22:16:33 +01:00
Matthias Krüger
4944ab449a
Rollup merge of #121968 - roblabla:fix-win7, r=jhpratt
Don't run test_get_os_named_thread on win7

This test won't work on windows 7, as the Thread::set_name function is not implemented there (win7 does not provide a documented mechanism to set thread names).
2024-03-04 22:16:33 +01:00
Matthias Krüger
9d81d4e46b
Rollup merge of #121939 - jonaspleyer:patch-typo-core-From-descr, r=workingjubilee
Small enhancement to description of From trait

- fix small typo
- avoid repetition of formulations
2024-03-04 22:16:32 +01:00
Matthias Krüger
58a0f64c8b
Rollup merge of #121928 - Zalathar:then-else-args, r=Nadrieril
Extract an arguments struct for `Builder::then_else_break`

Most of this method's arguments are usually or always forwarded as-is to recursive invocations.

Wrapping them in a dedicated struct allows us to document each struct field, and lets us use struct-update syntax to indicate which arguments are being modified when making a recursive call.

---

While trying to understand the lowering of `if` expressions, I found it difficult to keep track of the half-dozen arguments passed through to every call to `then_else_break`. I tried switching over to an arguments struct, and I found that it really helps to make sense of what each argument does, and how each call is modifying the arguments.

I have some further ideas for how to streamline these recursive calls, but I've kept those out of this PR so that it's a pure refactoring with no behavioural changes.
2024-03-04 22:16:32 +01:00
Matthias Krüger
008ab3387b
Rollup merge of #121732 - Voultapher:improve-assert_matches-documentation, r=cuviper
Improve assert_matches! documentation

This new documentation tries to limit the impact of the conceptual pitfall, that the if guard relaxes the constraint, when really it tightens it. This is achieved by changing the text and examples. The previous documentation also chose a rather weird and non-representative example for the if guard, that made it needlessly complicated to understand.
2024-03-04 22:16:31 +01:00
Matthias Krüger
e7bb224219
Rollup merge of #121703 - compiler-errors:new, r=lcnr
Add a way to add constructors for `rustc_type_ir` types

Introduces a module called `rustc_type_ir`, in which we can place traits which are named `Ty`/`Region`/`Const`/etc. which expose constructors for the `rustc_type_ir` types. This means we can construct things `Interner::Ty` with `Ty::new_x(...)`, which is needed to uplift the new trait solver into an interner-agnostic crate.

These traits are placed into a *separate* module because they're only intended to be used in interner-agnostic code, and they should mirror the constructors that are provided by the inherent constructor methods in `rustc_middle`.

Putting this up for vibe-check mostly. I haven't copied over any of the type constructors, except for one to create bound types for use in the canonicalizer.

r? lcnr
2024-03-04 22:16:31 +01:00
Matthias Krüger
8886c310e4
Rollup merge of #121683 - fortanix:raoul/lvi_fixes, r=cuviper
Fix LVI tests after frame pointers are enabled by default

#121203 enables frame pointers by default. This affects LVI mitigations for the `x86_64-fortanix-unknown-sgx` target. LVI remained mitigated correctly, but the tests were too strict.

``@nshyrei`` , ``@jethrogb``
2024-03-04 22:16:31 +01:00
Matthias Krüger
706fe0b7d8
Rollup merge of #120976 - matthiaskrgr:constify_TL_statics, r=lcnr
constify a couple thread_local statics
2024-03-04 22:16:30 +01:00
Nicholas Nethercote
80d2bdb619 Rename all ParseSess variables/fields/lifetimes as psess.
Existing names for values of this type are `sess`, `parse_sess`,
`parse_session`, and `ps`. `sess` is particularly annoying because
that's also used for `Session` values, which are often co-located, and
it can be difficult to know which type a value named `sess` refers to.
(That annoyance is the main motivation for this change.) `psess` is nice
and short, which is good for a name used this much.

The commit also renames some `parse_sess_created` values as
`psess_created`.
2024-03-05 08:11:45 +11:00
Wesley Wiser
748da32efb Update platform-support.md with supported musl version 2024-03-04 13:50:28 -06:00
bors
d18480b84f Auto merge of #120468 - alexcrichton:start-wasm32-wasi-rename, r=wesleywiser
Add a new `wasm32-wasip1` target to rustc

This commit adds a new target called `wasm32-wasip1` to rustc. This new target is explained in these two MCPs:

* https://github.com/rust-lang/compiler-team/issues/607
* https://github.com/rust-lang/compiler-team/issues/695

In short, the previous `wasm32-wasi` target is going to be renamed to `wasm32-wasip1` to better live alongside the [new `wasm32-wasip2` target](https://github.com/rust-lang/rust/pull/119616). This new target is added alongside the `wasm32-wasi` target and has the exact same definition as the previous target. This PR is effectively a rename of `wasm32-wasi` to `wasm32-wasip1`. Note, however, that as explained in rust-lang/compiler-team#695 the previous `wasm32-wasi` target is not being removed at this time. This change will reach stable Rust before even a warning about the rename will be printed. At this time this change is just the start where a new target is introduced and users can start migrating if they support only Nightly for example.
2024-03-04 18:55:14 +00:00
Oli Scherer
c04f0caaff make intrinsic query legal for any DefId 2024-03-04 16:28:33 +00:00
Oli Scherer
bf5fc6e5d7 Remove some depgraph edges on the HIR by invoking the intrinsic query instead of checking the attribute 2024-03-04 16:13:51 +00:00
Oli Scherer
b3dcbc2931 Avoid some boolean argument footguns 2024-03-04 16:13:51 +00:00
Oli Scherer
1e57df1969 Add a scheme for moving away from extern "rust-intrinsic" entirely 2024-03-04 16:13:50 +00:00
Oli Scherer
f2612daf58 Return a struct from query intrinsic to be able to add another field in the next commit 2024-03-04 16:13:50 +00:00
Oli Scherer
aa2ae6b491 Add is_intrinsic helper 2024-03-04 16:13:50 +00:00
Michael Goulet
1eedca8bdf Allow a way to add constructors for rustc_type_ir types 2024-03-04 15:39:59 +00:00
Janggun Lee
05e68facbb
Fix comment in Atomic{Ptr,Bool}::as_ptr. 2024-03-04 22:15:05 +09:00
Raoul Strackx
ede25ad319 Fix LVI tests after making frame pointers easily enableable 2024-03-04 11:05:13 +01:00
Jonas Pleyer
e46306043b
include feedback from workingjubilee
- Refer to trait directly
- small typo in encapsulate

Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2024-03-04 10:04:46 +01:00
roblabla
9eb927e025 Don't run test_get_os_named_thread on win7
This test won't work on windows 7, as the Thread::set_name function is
not implemented there (win7 does not provide a documented mechanism to
set thread names).
2024-03-04 09:24:41 +01:00
bors
7606c13961 Auto merge of #121964 - matthiaskrgr:rollup-rtcju5m, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #121130 (Suggest moving definition if non-found macro_rules! is defined later)
 - #121912 (Properly deal with GATs when looking for method chains to point at)
 - #121927 (Add a proper `with_no_queries` to printing)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-04 08:07:34 +00:00
Zalathar
4146136d6d Extract an arguments struct for Builder::then_else_break
Most of this method's arguments are usually or always forwarded as-is to
recursive invocations.

Wrapping them in a dedicated struct allows us to document each struct field,
and lets us use struct-update syntax to indicate which arguments are being
modified when making a recursive call.
2024-03-04 18:42:12 +11:00
Matthias Krüger
de95c39a78
Rollup merge of #121927 - Zoxc:print-no-query, r=estebank
Add a proper `with_no_queries` to printing
2024-03-04 07:57:57 +01:00
Matthias Krüger
cd9e5b5f43
Rollup merge of #121912 - fmease:diag-method-chains-gat, r=compiler-errors,estebank
Properly deal with GATs when looking for method chains to point at

Fixes #121898.

~~While it prevents an ICE and the structured suggestion is correct, the method chain diagnostic notes are weird / useless / incorrect judging by a quick look. I guess I should improve that in this PR.~~ Sufficiently taken care of.

r? estebank or compiler-errors (#105332, #105674).
2024-03-04 07:57:56 +01:00
Matthias Krüger
c620ae5be9
Rollup merge of #121130 - chenyukang:yukang-fix-121061-macro-later, r=matthiaskrgr
Suggest moving definition if non-found macro_rules! is defined later

Fixes #121061
2024-03-04 07:57:56 +01:00
Nicholas Nethercote
4260f7ec67 Rename a misnamed Session parameter. 2024-03-04 16:32:37 +11:00
bors
f7cb53e54b Auto merge of #121900 - chenyukang:yukang-fix-121425-repr-pack-error, r=compiler-errors
Fix misleading message in struct repr alignment and packed

Fixes #121425

By the way, fix the spans for the argument in the second commit.
2024-03-04 05:32:26 +00:00
Nicholas Nethercote
0d4ebe1c1b Move sess function and use it more. 2024-03-04 16:26:51 +11:00
Nicholas Nethercote
3996447b37 Remove file_path_mapping param from ParseSess::new.
It's always empty.
2024-03-04 16:22:06 +11:00
Nicholas Nethercote
aa38c26bbf Tweak parse_asm_args.
It doesn't need a `Parser` and a `ParseSess`, because the former
contains the latter.
2024-03-04 16:12:33 +11:00