about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-03-05Optimize write with as_const_str for shorter codeYuri Astrakhan-10/+26
2024-03-06Auto merge of #122041 - matthiaskrgr:rollup-imsmdke, r=matthiaskrgrbors-220/+584
Rollup of 8 pull requests Successful merges: - #121202 (Limit the number of names and values in check-cfg diagnostics) - #121301 (errors: share `SilentEmitter` between rustc and rustfmt) - #121658 (Hint user to update nightly on ICEs produced from outdated nightly) - #121846 (only compare ambiguity item that have hard error) - #121961 (add test for #78894 #71450) - #121975 (hir_analysis: enums return `None` in `find_field`) - #121978 (Fix duplicated path in the "not found dylib" error) - #121991 (Merge impl_trait_in_assoc_types_defined_by query back into `opaque_types_defined_by`) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-05Auto merge of #121576 - Jarcho:visitor3, r=oli-obkbors-586/+496
Convert the rest of the visitors to use `VisitorResult` Continuing from #121256.
2024-03-05Rollup merge of #121991 - oli-obk:merge_opaque_types_defined_by_queries, ↵Matthias Krüger-53/+35
r=compiler-errors Merge impl_trait_in_assoc_types_defined_by query back into `opaque_types_defined_by` Instead, when we're collecting opaques for associated items, we choose the right collection mode depending on whether we're collecting for an associated item of a trait impl or not. r? ```@compiler-errors``` follow up to https://github.com/rust-lang/rust/pull/121838
2024-03-05Rollup merge of #121978 - GuillaumeGomez:dylib-duplicated-path, r=bjorn3Matthias Krüger-1/+16
Fix duplicated path in the "not found dylib" error While working on the gcc backend, I couldn't figure out why I had this error: ``` error: couldn't load codegen backend /checkout/compiler/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so/checkout/compiler/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so: cannot open shared object file: No such file or directory ``` As you can see, the path is duplicated for some reason. After investigating a bit more, I realized that `libloading::Error::LoadLibraryExW` starts with the path of the not found dylib, making it appear twice in our error afterward (because we do render it like this: `{path}{err}`, and since the `err` starts with the path...). Thanks to `````@bjorn3````` for linking me to https://github.com/rust-lang/rust/pull/121392. :)
2024-03-05Rollup merge of #121975 - davidtwco:issue-121757, r=petrochenkovMatthias Krüger-1/+76
hir_analysis: enums return `None` in `find_field` Fixes #121757. Unnamed union fields with enums are checked for, but if `find_field` causes an ICE then the compiler won't get to that point.
2024-03-05Rollup merge of #121961 - surechen:add_test_20240304, r=petrochenkovMatthias Krüger-0/+124
add test for #78894 #71450 fixes #78894 fixes #71450
2024-03-05Rollup merge of #121846 - bvanjoi:fix-121760, r=petrochenkovMatthias Krüger-4/+62
only compare ambiguity item that have hard error Fixes #121760 An easy fix, r? ``@petrochenkov``
2024-03-05Rollup merge of #121658 - jieyouxu:ice-outdated-nightly, r=oli-obkMatthias Krüger-5/+47
Hint user to update nightly on ICEs produced from outdated nightly This is a conservative best-effort approach to detect a potentially outdated nightly; it will fallback to the regular ICE-reporting if any of the following cases are true: - Channel is not nightly - Version information is not available - Version date is not parseable as a YYYY-MM-DD or is missing - System time is at least 36 hours ahead of the user's nightly release datetime. - Any internal features are used. Note that I'm not sure how to make a test for this: I tested this manually by `CFG_VER_DATE="2020-02-02" ./x build library --stage 1`, and also changing the channel detection in `rustc_driver_impl` from `Some("nightly")` to `Some("nightly" | "dev")`, and then running `rustc +stage1 test.rs -Ztreat-err-as-bug=1` with a non-existent `test.rs`. <img width="1145" alt="Screenshot 2024-02-27 at 01 12 28" src="https://github.com/rust-lang/rust/assets/39484203/eff6af2e-4b19-4a70-af57-cd739ecf0e84"> Closes #118832.
2024-03-05Rollup merge of #121301 - davidtwco:rustfmt-silent-emitter, r=pnkfelixMatthias Krüger-108/+131
errors: share `SilentEmitter` between rustc and rustfmt Fixes rust-lang/rustfmt#6082. Shares the `SilentEmitter` between rustc and rustfmt, and gives it a fallback bundle (since it can emit diagnostics in some contexts).
2024-03-05Rollup merge of #121202 - Urgau:check-cfg-limit-diagnostics, r=pnkfelixMatthias Krüger-48/+93
Limit the number of names and values in check-cfg diagnostics The Rust for Linux [feedback](https://github.com/rust-lang/rust/issues/82450#issuecomment-1947462977) to the check-cfg Call for Testing, revealed a weakness in the check-cfg. They are unbounded and in the case RfL they have ~20k cfgs and having them printed (even once) is unbearable. This PR limits it to 35 (28 rustc well known + `feature` + `docsrs` + 5 custom) which feels like a good middle ground for regular users (i.e. Cargo users). When it goes over that limit print the N first with " and X more". ``@rustbot`` label +F-check-cfg
2024-03-05Auto merge of #121905 - Nilstrieb:add-empty-targets, r=davidtwcobors-0/+234
Add a `description` field to target definitions Starts addressing https://github.com/rust-lang/rust/pull/121051#pullrequestreview-1890562844 This is the short description (`64-bit MinGW (Windows 7+)`) including the platform requirements. The reason for doing it like this is that this PR will be quite prone to conflicts whenever targets get added, so it should be as simple as possible to get it merged. Future PRs which migrate targets are scoped to groups of targets, so they will not conflict as they can just touch these. This moves some of the information from the rustc book into the compiler. It cannot be queried yet, that is future work. It is also future work to fill out all the descriptions, which will coincide with the work of moving over existing target docs to the new format. r? `@davidtwco` but anyone is also free to steal it
2024-03-05Convert `ProofTreeVisitor` to use `VisitorResult`Jason Newcomb-31/+28
2024-03-05Convert `SpannedTypeVisitor` to use `VisitorResult`Jason Newcomb-28/+24
2024-03-05Convert `TypeVisitor` and `DefIdVisitor` to use `VisitorResult`Jason Newcomb-448/+345
2024-03-05Move visitor utils to `rustc_ast_ir`Jason Newcomb-79/+99
2024-03-05Merge `impl_trait_in_assoc_types_defined_by` query back into ↵Oli Scherer-53/+35
`opaque_types_defined_by` Instead, when we're collecting opaques for associated items, we choose the right collection mode depending on whether we're collecting for an associated item of a trait impl or not.
2024-03-05Add a `description` field to target definitionsNilstrieb-0/+234
This is the short description (`64-bit MinGW (Windows 7+)`) including the platform requirements. The reason for doing it like this is that this PR will be quite prone to conflicts whenever targets get added, so it should be as simple as possible to get it merged. Future PRs which migrate targets are scoped to groups of targets, so they will not conflict as they can just touch these. This moves some of the information from the rustc book into the compiler. It cannot be queried yet, that is future work. It is also future work to fill out all the descriptions, which will coincide with the work of moving over existing target docs to the new format.
2024-03-05Auto merge of #121428 - okaneco:ipaddr_parse, r=cuviperbors-21/+131
net: Don't use checked arithmetic when parsing numbers with known max digits Add a branch to `Parser::read_number` that determines whether checked or regular arithmetic is used. - If `max_digits.is_some()`, then we know we are parsing a `u8` or `u16` because `read_number` is only called with `Some(3)` or `Some(4)`. Both types fit within a `u32` without risk of overflow. Thus, we can use plain arithmetic to avoid extra instructions from `checked_mul` and `checked_add`. Add benches for `IpAddr`, `Ipv4Addr`, `Ipv6Addr`, `SocketAddr`, `SocketAddrV4`, and `SocketAddrV6` parsing
2024-03-05Auto merge of #121992 - jieyouxu:fix-tidy-unpaired-revision, r=onur-ozkanbors-8/+27
tidy: split dots in filename not the entire path when checking for stray stdout/stderr files I committed a path crime by splitting the entire path on `.`, when I meant to split on the filename. This means that any parent folders which contain `.` will cause tidy failure. Added a regression test so that doesn't happen again. ### Follow-up - [ ] Adjust rustc-dev-guide to document assert on test name not containing dots. https://github.com/rust-lang/rustc-dev-guide/pull/1927 Fixes #121986.
2024-03-05Auto merge of #121138 - Swatinem:grapheme-extend-ascii, r=cuviperbors-1/+1
Add ASCII fast-path for `char::is_grapheme_extended` I discovered that `impl Debug for str` is quite slow because it ends up doing a `unicode_data::grapheme_extend::lookup` for each char, which ends up doing a binary search. This introduces a fast-path for ASCII chars which do not have this property. The `lookup` is thus completely gone from profiles. --- As a followup, maybe it’s worth implementing this fast path directly in `unicode_data` so that it can check for the lower bound directly before going to a potentially expensive binary search.
2024-03-05errors: share `SilentEmitter` between rustc and rustfmtDavid Wood-108/+131
Signed-off-by: David Wood <david@davidtw.co>
2024-03-05Update test names to not have dots许杰友 Jieyou Xu (Joe)-1/+1
2024-03-05Assert that test names cannot contain dots许杰友 Jieyou Xu (Joe)-0/+6
This is so that we can catch stray test output files, since test names without dots can form predictable patterns we can match on.
2024-03-05Auto merge of #122012 - matthiaskrgr:rollup-bzqjj2n, r=matthiaskrgrbors-284/+435
Rollup of 10 pull requests Successful merges: - #121213 (Add an example to demonstrate how Rc::into_inner works) - #121262 (Add vector time complexity) - #121287 (Clarify/add `must_use` message for Rc/Arc/Weak::into_raw.) - #121664 (Adjust error `yield`/`await` lowering) - #121826 (Use root obligation on E0277 for some cases) - #121838 (Use the correct logic for nested impl trait in assoc types) - #121913 (Don't panic when waiting on poisoned queries) - #121987 (pattern analysis: abort on arity mismatch) - #121993 (Avoid using unnecessary queries when printing the query stack in panics) - #121997 (interpret/cast: make more matches on FloatTy properly exhaustive) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-05Limit the number of names and values in check-cfg diagnosticsUrgau-48/+93
2024-03-05Rollup merge of #121997 - RalfJung:cast-float-ty, r=compiler-errorsMatthias Krüger-23/+35
interpret/cast: make more matches on FloatTy properly exhaustive Actually implementing these is pretty trivial (at least once all the scalar methods are added, which happens in https://github.com/rust-lang/rust/pull/121926), but I'm staying consistent with the other f16/f128 PRs. Also adding adding all the tests to Miri would be quite a lot of work. There's probably some way to reduce the code duplication here with more use of generics... but that's a future refactor.^^ r? ```@tgross35```
2024-03-05Rollup merge of #121993 - Zoxc:query-stack-panic-queries, r=compiler-errorsMatthias Krüger-2/+7
Avoid using unnecessary queries when printing the query stack in panics This should fix https://github.com/rust-lang/rust/issues/121974. Alternative to https://github.com/rust-lang/rust/pull/121981.
2024-03-05Rollup merge of #121987 - Nadrieril:abort-on-arity-mismatch, r=compiler-errorsMatthias Krüger-7/+15
pattern analysis: abort on arity mismatch This is one more PR replacing panics by `Err()` aborts. I recently audited all the `unwrap()` calls, but I had forgotten about array accesses. (Again [discovered by rust-analyzer](https://github.com/rust-lang/rust-analyzer/issues/16746)). r? ```@compiler-errors```
2024-03-05Rollup merge of #121913 - Zoxc:query-fix, r=compiler-errorsMatthias Krüger-3/+2
Don't panic when waiting on poisoned queries This fixes a bug introduced in https://github.com/rust-lang/rust/pull/119086.
2024-03-05Rollup merge of #121838 - oli-obk:impl_trait_in_assoc_tys_fix, r=compiler-errorsMatthias Krüger-81/+61
Use the correct logic for nested impl trait in assoc types Previously we accidentally continued with the TAIT visitor, which allowed more than we wanted to. r? ```@compiler-errors```
2024-03-05Rollup merge of #121826 - estebank:e0277-root-obligation-2, r=oli-obkMatthias Krüger-157/+212
Use root obligation on E0277 for some cases When encountering trait bound errors that satisfy some heuristics that tell us that the relevant trait for the user comes from the root obligation and not the current obligation, we use the root predicate for the main message. This allows to talk about "X doesn't implement Pattern<'_>" over the most specific case that just happened to fail, like "char doesn't implement Fn(&mut char)" in `tests/ui/traits/suggest-dereferences/root-obligation.rs` The heuristics are: - the type of the leaf predicate is (roughly) the same as the type from the root predicate, as a proxy for "we care about the root" - the leaf trait and the root trait are different, so as to avoid talking about `&mut T: Trait` and instead remain talking about `T: Trait` instead - the root trait is not `Unsize`, as to avoid talking about it in `tests/ui/coercion/coerce-issue-49593-box-never.rs`. ``` error[E0277]: the trait bound `&char: Pattern<'_>` is not satisfied --> $DIR/root-obligation.rs:6:38 | LL | .filter(|c| "aeiou".contains(c)) | -------- ^ the trait `Fn<(char,)>` is not implemented for `&char`, which is required by `&char: Pattern<'_>` | | | required by a bound introduced by this call | = note: required for `&char` to implement `FnOnce<(char,)>` = note: required for `&char` to implement `Pattern<'_>` note: required by a bound in `core::str::<impl str>::contains` --> $SRC_DIR/core/src/str/mod.rs:LL:COL help: consider dereferencing here | LL | .filter(|c| "aeiou".contains(*c)) | + ``` Fix #79359, fix #119983, fix #118779, cc #118415 (the suggestion needs to change), cc #121398 (doesn't fix the underlying issue).
2024-03-05Rollup merge of #121664 - compiler-errors:adjust-error-yield-lowering, ↵Matthias Krüger-9/+64
r=spastorino Adjust error `yield`/`await` lowering Adjust the lowering of `yield`/`await` outside of their correct scopes so that we no longer make orpan HIR exprs. Previously, `yield EXPR` would be lowered directly to `hir::TyKind::Error` (which I'll call `<error>`) which means that `EXPR` was not present in the HIR, but now we lower it to `{ EXPR; <error> }` so that `EXPR` is not orphaned. Fixes #121096
2024-03-05Rollup merge of #121287 - zachs18:rc-into-raw-must-use, r=cuviperMatthias Krüger-2/+3
Clarify/add `must_use` message for Rc/Arc/Weak::into_raw. The current `#[must_use]` messages for `{sync,rc}::Weak::into_raw` ("`self` will be dropped if the result is not used") are misleading, as `self` is consumed and will *not* be dropped. This PR changes their `#[must_use]` message to the same as `Arc::into_raw`'s[ current `#[must_use]` message](https://github.com/rust-lang/rust/blob/d5735645753e990a72446094f703df9b5e421555/library/alloc/src/sync.rs#L1482) ("losing the pointer will leak memory"), and also adds it to `Rc::into_raw`, which is not currently `#[must_use]`.
2024-03-05Rollup merge of #121262 - 20jasper:add-vector-time-complexity, r=cuviperMatthias Krüger-0/+21
Add vector time complexity Added time complexity for `Vec` methods `push`, `push_within_capacity`, `pop`, and `insert`. <details> <summary> Reference images </summary> ![`Vec::push` documentation](https://github.com/rust-lang/rust/assets/78604367/dc966bbd-e92e-45a6-af82-35afabfa79a9) ![`Vec::push_within_capacity` documentation](https://github.com/rust-lang/rust/assets/78604367/9aadaf48-46ed-4fad-bdd5-74b98a61f4bb) ![`Vec::pop` documentation](https://github.com/rust-lang/rust/assets/78604367/88ec0389-a346-4ea5-a3b7-17caf514dd8b) ![`Vec::insert` documentation](https://github.com/rust-lang/rust/assets/78604367/960c15c3-ef8e-4aa7-badc-35ce80f6f221) </details> I followed a convention to use `#Time complexity` that I found in [the `BinaryHeap` documentation](https://doc.rust-lang.org/std/collections/struct.BinaryHeap.html#time-complexity-1). Looking through the rest of standard library collections, there is not a consistent way to handle this. [`Vec::swap_remove`](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.swap_remove) does not have a dedicated section for time complexity but does list it. [`VecDeque::rotate_left`](https://doc.rust-lang.org/std/collections/struct.VecDeque.html#complexity) uses a `#complexity` heading.
2024-03-05Rollup merge of #121213 - Takashiidobe:takashi/example-for-rc-into-inner, ↵Matthias Krüger-0/+15
r=cuviper Add an example to demonstrate how Rc::into_inner works This PR adds an example to Rc::into_inner, since it didn't have one previously.
2024-03-05Auto merge of #121001 - nyurik:optimize-core-fmt, r=cuviperbors-0/+6
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-05Auto merge of #121780 - nnethercote:diag-renaming2, r=davidtwcobors-639/+609
Diagnostic renaming 2 A sequel to #121489. r? `@davidtwco`
2024-03-05add test for #71450surechen-0/+110
2024-03-05Adjust `Diag::new` signature.Nicholas Nethercote-1/+1
Make it use `impl Into<DiagMessage>` like all the other methods nearby.
2024-03-05Rename `DiagnosticMetadata` as `DiagMetadata`.Nicholas Nethercote-92/+86
2024-03-05Rename `StructuredDiagnostic` as `StructuredDiag`.Nicholas Nethercote-12/+10
2024-03-05Rename `BuiltinLintDiagnostics` as `BuiltinLintDiag`.Nicholas Nethercote-113/+105
Not the dropping of the trailing `s` -- this type describes a single diagnostic and its name should be singular.
2024-03-05Rename `DiagnosticExt` as `DiagExt`.Nicholas Nethercote-4/+4
2024-03-05Rename `DiagnosticMode` as `DiagMode`.Nicholas Nethercote-22/+19
2024-03-05Rename `SubdiagnosticMessageOp` as `SubdiagMessageOp`.Nicholas Nethercote-57/+55
2024-03-05Rename `SubdiagnosticMessage` as `SubdiagMessage`.Nicholas Nethercote-85/+83
2024-03-05Fix some out-of-date comments.Nicholas Nethercote-4/+4
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-261/+253
2024-03-05Disable `tests/ui-fulldeps/internal-lints/diagnostics.rs` on stage 1.Nicholas Nethercote-7/+8
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.