about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-05-20Rollup merge of #125302 - workingjubilee:prefer-my-stack-neat, r=compiler-errorsMatthias Krüger-9/+33
defrost `RUST_MIN_STACK=ice rustc hello.rs` I didn't think too hard about testing my previous PR rust-lang/rust#122847 which makes our stack overflow handler assist people in discovering the `RUST_MIN_STACK` variable (which apparently is surprisingly useful for Really Big codebases). After it was merged, some useful comments left in a drive-by review led me to discover I had added an ICE. This reworks the code a bit to explain the rationale, remove the ICE that I introduced, and properly test one of the diagnostics.
2024-05-20Rollup merge of #125301 - jwong101:fix-static-coro-suggest, r=compiler-errorsMatthias Krüger-0/+4
fix suggestion in E0373 for !Unpin coroutines Coroutines can be prefixed with the `static` keyword to make them `!Unpin`. However, given the following function: ```rust fn check() -> impl Sized { let x = 0; #[coroutine] static || { yield; x } } ``` We currently suggest prefixing `move` before `static`, which is syntactically incorrect: ``` error[E0373]: coroutine may outlive the current function, but it borrows ... --> src/main.rs:6:5 | 6 | static || { | ^^^^^^^^^ may outlive borrowed value `x` 7 | yield; 8 | x | - `x` is borrowed here | note: coroutine is returned here --> src/main.rs:6:5 | 6 | / static || { 7 | | yield; 8 | | x 9 | | } | |_____^ help: to force the coroutine to take ownership of `x` (and any other referenced variables), use the `move` keyword | // this is syntactically incorrect, it should be `static move ||` 6 | move static || { | ++++ ``` This PR suggests adding `move` after `static` for these coroutines. I also added a UI test for this case.
2024-05-20Rollup merge of #125282 - WaffleLapkin:never-type-unsafe-improvements, ↵Matthias Krüger-38/+47
r=compiler-errors Never type unsafe lint improvements - Move linting code to a separate method - Remove mentions of `core::convert::absurd` (#124311 was rejected) - Make the lint into FCW The last thing is a bit weird though. On one hand it should be `EditionSemanticsChange(2024)`, but on the other hand it shouldn't, because we also plan to break it on all editions some time later. _Also_, it's weird that we don't have `FutureReleaseSemanticsChangeReportInDeps`, IMO "this might cause UB in a future release" is important enough to be reported in deps... IMO we ought to have three enums instead of [`FutureIncompatibilityReason`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/enum.FutureIncompatibilityReason.html#): ```rust enum IncompatibilityWhen { FutureRelease, Edition(Edition), } enum IncompatibilyWhat { Error, SemanticChange, } enum IncompatibilityReportInDeps { No, Yes, } ``` Tracking: - https://github.com/rust-lang/rust/issues/123748
2024-05-19note value of RUST_MIN_STACK and explain unsettingJubilee Young-3/+9
2024-05-19defrost RUST_MIN_STACK=ice rustc hello.rsJubilee Young-9/+27
An earlier commit included the change for a suggestion here. Unfortunately, it also used unwrap instead of dying properly. Roll out the ~~rice paper~~ EarlyDiagCtxt before we do anything that might leave a mess.
2024-05-19fix suggestion in E0373 for !Unpin coroutinesJoshua Wong-0/+4
Coroutines can be prefixed with the `static` keyword to make them `!Unpin`. However, given the following function: ```rust fn check() -> impl Sized { let x = 0; #[coroutine] static || { yield; x } } ``` We currently suggest prefixing `move` before `static`, which is syntactically incorrect: ``` error[E0373]: coroutine may outlive the current function, but it borrows ... --> src/main.rs:6:5 | 6 | static || { | ^^^^^^^^^ may outlive borrowed value `x` 7 | yield; 8 | x | - `x` is borrowed here | note: coroutine is returned here --> src/main.rs:6:5 | 6 | / static || { 7 | | yield; 8 | | x 9 | | } | |_____^ help: to force the coroutine to take ownership of `x` (and any other referenced variables), use the `move` keyword | // this is syntactically incorrect, it should be `static move ||` 6 | move static || { | ++++ ``` This PR suggests adding `move` after `static` for these coroutines.
2024-05-19Auto merge of #125294 - matthiaskrgr:rollup-w42c829, r=matthiaskrgrbors-12/+8
Rollup of 4 pull requests Successful merges: - #124948 (chore: Remove repeated words (extension of #124924)) - #124992 (Add example to IsTerminal::is_terminal) - #125279 (make `Debug` impl for `Term` simpler) - #125286 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-19Rollup merge of #125279 - WaffleLapkin:unpacktermindebug, ↵Matthias Krüger-8/+4
r=aDotInTheVoid,Nilstrieb,BoxyUwU make `Debug` impl for `Term` simpler meow
2024-05-19Rollup merge of #124948 - blyxyas:remove-repeated-words, r=compiler-errorsMatthias Krüger-4/+4
chore: Remove repeated words (extension of #124924) When I saw #124924 I thought "Hey, I'm sure that there are far more than just two typos of this nature in the codebase". So here's some more typo-fixing. Some found with regex, some found with a spellchecker. Every single one manually reviewed by me (along with hundreds of false negatives by the tools)
2024-05-19Auto merge of #125006 - spastorino:generics-is-empty, r=compiler-errorsbors-15/+23
Add and use generics.is_empty() and generics.is_own_empty, rather than using generics' attributes r? `@compiler-errors` Related to #123929
2024-05-19Rollup merge of #125270 - pietroalbini:pa-no-sad-contributors, r=NilstriebMichael Goulet-6/+13
Followup fixes from #123344 ``@Nilstrieb`` doesn't deserve [to be sad](https://github.com/rust-lang/rust/pull/123344#issuecomment-2100978863), so this PR addresses the two pieces of feedback from that PR. r? ``@Nilstrieb``
2024-05-19make `Debug` impl for `Term` simplerWaffle Lapkin-8/+4
2024-05-19Add and use generics.is_empty() and generics.is_own_empty, rather than using ↵Santiago Pastorino-15/+23
generics' attributes
2024-05-19fix typoPietro Albini-6/+6
2024-05-19document what the span of UseTreeKind::Nested isPietro Albini-0/+7
2024-05-19Actually use the `#[do_not_recommend]` attribute if presentGeorg Semmler-0/+26
This change tweaks the error message generation to actually use the `#[do_not_recommend]` attribute if present by just skipping the marked trait impl in favour of the parent impl. It also adds a compile test for this behaviour. Without this change the test would output the following error: ``` error[E0277]: the trait bound `&str: Expression` is not satisfied --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:53:15 | LL | SelectInt.check("bar"); | ^^^^^ the trait `Expression` is not implemented for `&str`, which is required by `&str: AsExpression<Integer>` | = help: the following other types implement trait `Expression`: Bound<T> SelectInt note: required for `&str` to implement `AsExpression<Integer>` --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:26:13 | LL | impl<T, ST> AsExpression<ST> for T | ^^^^^^^^^^^^^^^^ ^ LL | where LL | T: Expression<SqlType = ST>, | ------------------------ unsatisfied trait bound introduced here ``` Note how that mentions `&str: Expression` before and now mentions `&str: AsExpression<Integer>` instead which is much more helpful for users. Open points for further changes before stabilization: * We likely want to move the attribute to the `#[diagnostic]` namespace to relax the guarantees given? * How does it interact with the new trait solver?
2024-05-19Auto merge of #125230 - compiler-errors:uplift-query-stuff, r=lcnrbors-681/+875
Uplift more query stuff - Uplift various query input/response internals - Uplift the `ProofTree` structures and make the `ProofTreeBuilder` stuff (mostly) generic over `Interner` - Stop using `TyCtxt::def_kind` in favor of `AliasTerm::kind` r? lcnr
2024-05-18Auto merge of #125257 - jieyouxu:rollup-11evnm9, r=jieyouxubors-1/+11
Rollup of 3 pull requests Successful merges: - #125214 (Only make GAT ambiguous in `match_projection_projections` considering shallow resolvability) - #125236 (Add tests for `-Zunpretty=expanded` ported from stringify's tests) - #125251 (Clarify how String::leak and into_boxed_str differ ) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-18Move NormalizesTo back downMichael Goulet-6/+10
I tried to rebase this down into the first commit but it is WAY too annoying x
2024-05-18Stop using def_kind() in solverMichael Goulet-17/+8
2024-05-18Make proof tree building genericMichael Goulet-93/+109
2024-05-18Uplift inspect into rustc_type_irMichael Goulet-318/+399
2024-05-18Uplift GenericArgKind, CanonicalVarValues, QueryInputMichael Goulet-268/+370
and make NestedGoals generic
2024-05-18Rollup merge of #125214 - compiler-errors:gat-guide, r=lcnr许杰友 Jieyou Xu (Joe)-1/+11
Only make GAT ambiguous in `match_projection_projections` considering shallow resolvability In #123537, I tweaked the hack from #93892 to use `resolve_vars_if_possible` instead of `shallow_resolve`. This considers more inference guidance ambiguous. This resulted in crater regressions in #125196. I've effectively reverted the change to the old behavior. That being said, I don't *like* this behavior, but I'd rather keep it for now since #123537 was not meant to make any behavioral changes. See the attached example. This also affects the new solver, for the record, which doesn't have any rules about not guiding inference from param-env candidates which may constrain GAT args as a side-effect. r? `@lcnr` or `@jackh726`
2024-05-18Auto merge of #125077 - spastorino:add-new-fnsafety-enum2, r=jackh726bors-361/+332
Rename Unsafe to Safety Alternative to #124455, which is to just have one Safety enum to use everywhere, this opens the posibility of adding `ast::Safety::Safe` that's useful for unsafe extern blocks. This leaves us today with: ```rust enum ast::Safety { Unsafe(Span), Default, // Safe (going to be added for unsafe extern blocks) } enum hir::Safety { Unsafe, Safe, } ``` We would convert from `ast::Safety::Default` into the right Safety level according the context.
2024-05-18Rollup merge of #125240 - lnicola:rustc-abi-nonzerousize, r=fee1-deadMatthias Krüger-6/+5
Temporarily revert to NonZeroUsize in rustc-abi to fix building on stable rust-analyzer uses an auto-published version of `rustc-abi`, but `NonZero` isn't yet stable. This prevents us from updating the RA subtree, which is quite old already. I can file a revert PR after the release.
2024-05-18Rollup merge of #125184 - scottmcm:fix-thin-ptr-ice, r=jieyouxuMatthias Krüger-1/+5
Fix ICE in non-operand `aggregate_raw_ptr` intrinsic codegen Introduced in #123840 Found in #121571, cc `@clarfonthey`
2024-05-18Rollup merge of #125117 - dev-ardi:improve-parser, r=wesleywiser,fmeaseMatthias Krüger-68/+75
Improve parser Fixes #124935. - Add a few more help diagnostics to incorrect semicolons - Overall improved that function - Addded a few comments - Renamed diff_marker fns to git_diff_marker
2024-05-18Fix typos (taking into account review comments)blyxyas-4/+4
2024-05-18Auto merge of #125180 - mu001999-contrib:improve/macro-diag, r=fee1-deadbors-13/+45
Improve error message: missing `;` in macro_rules Fixes #124968
2024-05-18Improve error message: missing `;` in macro_rulesr0cky-13/+45
2024-05-18Auto merge of #124611 - Urgau:rustdoc-stdin, r=GuillaumeGomezbors-0/+1
Add `-` (stdin) support in rustdoc This PR adds support for the special `-` input which threats the input as coming from *stdin* instead of being a filepath. Doing this also makes `rustdoc` consistent with `rustc` and ~~every~~ other tools. Full [motivation](https://github.com/rust-lang/rust/pull/124611#issuecomment-2094234876). Fixes https://github.com/rust-lang/rust/issues/123671 r? `@fmease`
2024-05-18Auto merge of #125004 - pymongo:issue-125002, r=estebankbors-9/+15
Fix println! ICE when parsing percent prefix number This PR fixes #125002 ICE occurring, for example, with `println!("%100000", 1)` or `println!("% 100000", 1)`. ## Test Case/Change Explanation The return type of `Num::from_str` has been changed to `Option<Self>` to handle errors when parsing large integers fails. 1. The first `println!` in the test case covers the change of the first `Num::from_str` usage in `format_foreign.rs:426`. 2. The second `println!` in the test case covers the change of the second `Num::from_str` usage in line 460. 3. The 3rd to 5th `Num::from_str` usages behave the same as before. The 3rd usage would cause an ICE when `num > u16::MAX` in the previous version, but this commit does not include a fix for the ICE in `println!("{:100000$}")`. I think we need to emit an error in the compiler and have more discussion in another issue/PR.
2024-05-18Temporarily revert to NonZeroUsize in rustc-abi to fix building on stableLaurențiu Nicola-6/+5
2024-05-18Auto merge of #125105 - nnethercote:rustc_resolve-cleanups, r=estebankbors-75/+23
`rustc_resolve` cleanups Some improvements I found while looking through this code. r? `@estebank`
2024-05-18Fix println! ICE when parsing percent prefix numberwuaoxiang-9/+15
2024-05-18Make `NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE` into an FCW and report it ext ↵Waffle Lapkin-1/+6
macros
2024-05-18Remove fixmeWaffle Lapkin-2/+1
(libs team decided not to add `absurd` to std)
2024-05-18Move `lint_never_type_fallback_flowing_into_unsafe_code` into a separate fnWaffle Lapkin-35/+40
2024-05-17Auto merge of #123865 - eholk:expr_2021, r=fmeasebors-24/+69
Update `expr` matcher for Edition 2024 and add `expr_2021` nonterminal This commit adds a new nonterminal `expr_2021` in macro patterns, and `expr_fragment_specifier_2024` feature flag. This change also updates `expr` so that on Edition 2024 it will also match `const { ... }` blocks, while `expr_2021` preserves the current behavior of `expr`, matching expressions without `const` blocks. Joint work with `@vincenzopalazzo.` Issue #123742
2024-05-17Rename Unsafe to SafetySantiago Pastorino-361/+332
2024-05-17Update compiler/rustc_parse/src/parser/nonterminal.rsEric Holk-2/+1
Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2024-05-17to_opt_poly_X_pred -> as_X_clauseMichael Goulet-23/+23
2024-05-17Only make GAT ambiguous in match_projection_projections considering shallow ↵Michael Goulet-1/+11
resolvability
2024-05-17use signature name for argardi-2/+2
2024-05-17s/(Ident, ItemKind)/ItemInfo/ardi-2/+2
2024-05-17Clarify that the diff_marker is talking about version control systemardi-38/+47
conflicts specifically and a few more improvements.
2024-05-17Rollup merge of #125191 - compiler-errors:wf, r=lcnrMatthias Krüger-20/+57
Report better WF obligation leaf obligations in new solver r? lcnr
2024-05-17Rollup merge of #123694 - Xiretza:expand-diagnostics, r=compiler-errorsMatthias Krüger-3/+11
expand: fix minor diagnostics bug The error mentions `///`, when it's actually `//!`: ``` error[E0658]: attributes on expressions are experimental --> test.rs:4:9 | 4 | //! wah | ^^^^^^^ | = note: see issue https://github.com/rust-lang/rust/issues/15701 <https://github.com/rust-lang/rust/issues/15701> for more information = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable = help: `///` is for documentation comments. For a plain comment, use `//`. ```
2024-05-17Auto merge of #124129 - lqd:enable-lld, r=Mark-Simulacrumbors-0/+13
Enable `rust-lld` on nightly `x86_64-unknown-linux-gnu` We believe we have done virtually all the internal work and tests we could to prepare for using `lld` as the default linker (at least on Linux). We're IMHO at a point where we'd need to expand testing and coverage in order to make progress on this effort. Therefore, for further testing and gathering real-world feedback, unexpected issues and use-cases, this PR enables `rust-lld` as the default linker: - on nightly only (and dev channel) - on `x86_64-unknown-linux-gnu` only - when not using an external LLVM (except `download-ci-llvm`), so that distros are not impacted as described in more detail in this [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Enabling.20.60rust-lld.60.20on.20nightly.20.60x86_64-unknown-linux-gnu.60/near/433709343). In case any issues happen to users, as e.g. lld is not bug-for-bug compatible with GNU ld, it's easy to disable with `-Zlinker-features=-lld` to revert to using the system's default linker. --- I don't know who should review this kind of things, as it's somewhat of a crosscutting effort. Compiler contributor, compiler performance WG and infra member sounds perfect, so r? `@Mark-Simulacrum.` The last crater run encountered a low number (44) of mainly avoidable issues, like small incompatibilities, user errors, and a difference between the two linkers about which default to use with `--gc-sections`. [Here's the triage report](https://hackmd.io/OAJxlxc6Te6YUot9ftYSKQ?view), categorizing the issues, with some analyses and workarounds. I'd appreciate another set of eyes looking at these results. The changes in this PR have been test-driven for CI changes, try builds with tests enabled, rustc-perf with bootstrapping, in PR #113382. For infra, about the CI change: this PR forces `rust.lld` to false on vanilla LLVM builders, just to make sure we have coverage without `rust-lld`. Though to be clear, just using an external LLVM is already enough to keep `rust.lld` to false, in turn reverting everything to using the system's default linker. cc `@rust-lang/bootstrap` for the bootstrap and config change cc `@petrochenkov` for the small compiler change cc `@rust-lang/wg-compiler-performance` The blog post announcing the change, that we expect to merge around the same time as we merge this PR, is open [on the blog repo](https://github.com/rust-lang/blog.rust-lang.org/pull/1319). Bootstrap change history: this PR changes the default of a config option on `x86_64-unknown-linux-gnu`. It's, however, not expected to cause issues, or require any changes to existing configurations. It's a big enough change that people should at least know about it, in case it causes unexpected problems. If that happens, set `rust.lld = false` in your `config.toml` (and open an issue).