about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-07-17cleanup: remove support for 3DNow! cpu featuresAugie Fackler-3/+1
In llvm/llvm-project@f0eb5587ceeb641445b64cb264c822b4751de04a all support for 3DNow! intrinsics and instructions were removed. Per the commit message there, only AMD chips between 1998 and 2011 or so actually supported these instructions, and they were effectively replaced by SSE which was available on many more chips. I'd be very surprised if anyone had ever used these from Rust.
2024-07-16Rollup merge of #127780 - compiler-errors:zip-args, r=jieyouxuTrevor Gross-0/+1
Make sure trait def ids match before zipping args in `note_function_argument_obligation` Fixes #126416 Fixes #127745 Didn't add both tests b/c I felt like it was unnecessary.
2024-07-16Rollup merge of #127709 - Zalathar:pair-mod, r=NadrierilTrevor Gross-245/+272
match lowering: Move `MatchPair` tree creation to its own module This makes it easier to see that `MatchPair::new` has only one non-recursive caller, because the recursive callers are all in this module. No functional changes. --- I have used `git diff --color-moved` to verify that the moved code is identical to the old code, except for reduced visibility on the helper methods.
2024-07-16Rollup merge of #120990 - chenyukang:yukang-fix-120327-dbg, r=oli-obkTrevor Gross-2/+63
Suggest a borrow when using dbg Fixes #120327 r? ````@estebank````
2024-07-16Auto merge of #127638 - adwinwhite:cache_string, r=oli-obkbors-10/+28
Add cache for `allocate_str` Best effort cache for string allocation in const eval. Fixes [rust-lang/miri#3470](https://github.com/rust-lang/miri/issues/3470).
2024-07-15Auto merge of #127629 - tesuji:suggest-option-ref-unwrap_or, r=estebankbors-0/+79
Suggest using `map_or` when `Option<&T>::unwrap_or where T: Deref` fails Fix #127545 Split from https://github.com/rust-lang/rust/pull/127596#pullrequestreview-2171898588
2024-07-15Make sure trait def ids match before zipping args in ↵Michael Goulet-0/+1
note_function_argument_obligation
2024-07-15Rollup merge of #127758 - Zalathar:expression-used, r=oli-obkMatthias Krüger-26/+37
coverage: Restrict `ExpressionUsed` simplification to `Code` mappings In the future, branch and MC/DC mappings might have expressions that don't correspond to any single point in the control-flow graph. That makes it trickier to keep track of which expressions should expect an `ExpressionUsed` node. We therefore sidestep that complexity by only performing `ExpressionUsed` simplification for expressions associated directly with ordinary `Code` mappings. (This simplification step is inherited from the original coverage implementation, which only supported `Code` mappings anyway, so there's no particular reason to extend it to other kinds of mappings unless we specifically choose to.) Relevant to: - #124154 - #126677 - #124278 ```@rustbot``` label +A-code-coverage
2024-07-15Rollup merge of #127729 - compiler-errors:ed-2024-gen, r=oli-obkMatthias Krüger-50/+58
Stop using the `gen` identifier in the compiler In preparation for edition 2024, this PR previews the fallout of removing usages of `gen` since it's being reserved as a keyword. There are two notable changes here: 1. Had to rename `fn gen(..)` in gen/kill analysis to `gen_`. Not certain there's a better name than that. 2. There are (false?[^1]) positives in `rustc_macros` when using synstructure, which uses `gen impl` to mark an implementation. We could suppress this in a one-off way, or perhaps just ignore `gen` in macros altogether, since if an identifier ends up in expanded code then it'll get properly denied anyways. Not relevant to the compiler, but it's gonna be really annoying to change `rand`'s `gen` fn in the library and miri... [^1]: I haven't looked at the synstructure proc macro code itself so I'm not certain if it'll start to fail when converted to ed2024 (or, e.g., when syn starts parsing `gen` as a kw).
2024-07-15Rollup merge of #127407 - estebank:parser-suggestions, r=oli-obkMatthias Krüger-200/+370
Make parse error suggestions verbose and fix spans Go over all structured parser suggestions and make them verbose style. When suggesting to add or remove delimiters, turn them into multiple suggestion parts.
2024-07-15Rollup merge of #124921 - RalfJung:offset-from-same-addr, r=oli-obkMatthias Krüger-15/+18
offset_from: always allow pointers to point to the same address This PR implements the last remaining part of the t-opsem consensus in https://github.com/rust-lang/unsafe-code-guidelines/issues/472: always permits offset_from when both pointers have the same address, no matter how they are computed. This is required to achieve *provenance monotonicity*. Tracking issue: https://github.com/rust-lang/rust/issues/117945 ### What is provenance monotonicity and why does it matter? Provenance monotonicity is the property that adding arbitrary provenance to any no-provenance pointer must never make the program UB. More specifically, in the program state, data in memory is stored as a sequence of [abstract bytes](https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#abstract-byte), where each byte can optionally carry provenance. When a pointer is stored in memory, all of the bytes it is stored in carry that provenance. Provenance monotonicity means: if we take some byte that does not have provenance, and give it some arbitrary provenance, then that cannot change program behavior or introduce UB into a UB-free program. We care about provenance monotonicity because we want to allow the optimizer to remove provenance-stripping operations. Removing a provenance-stripping operation effectively means the program after the optimization has provenance where the program before the optimization did not -- since the provenance removal does not happen in the optimized program. IOW, the compiler transformation added provenance to previously provenance-free bytes. This is exactly what provenance monotonicity lets us do. We care about removing provenance-stripping operations because `*ptr = *ptr` is, in general, (likely) a provenance-stripping operation. Specifically, consider `ptr: *mut usize` (or any integer type), and imagine the data at `*ptr` is actually a pointer (i.e., we are type-punning between pointers and integers). Then `*ptr` on the right-hand side evaluates to the data in memory *without* any provenance (because [integers do not have provenance](https://rust-lang.github.io/rfcs/3559-rust-has-provenance.html#integers-do-not-have-provenance)). Storing that back to `*ptr` means that the abstract bytes `ptr` points to are the same as before, except their provenance is now gone. This makes `*ptr = *ptr` a provenance-stripping operation (Here we assume `*ptr` is fully initialized. If it is not initialized, evaluating `*ptr` to a value is UB, so removing `*ptr = *ptr` is trivially correct.) ### What does `offset_from` have to do with provenance monotonicity? With `ptr = without_provenance(N)`, `ptr.offset_from(ptr)` is always well-defined and returns 0. By provenance monotonicity, I can now add provenance to the two arguments of `offset_from` and it must still be well-defined. Crucially, I can add *different* provenance to the two arguments, and it must still be well-defined. In other words, this must always be allowed: `ptr1.with_addr(N).offset_from(ptr2.with_addr(N))` (and it returns 0). But the current spec for `offset_from` says that the two pointers must either both be derived from an integer or both be derived from the same allocation, which is not in general true for arbitrary `ptr1`, `ptr2`. To obtain provenance monotonicity, this PR hence changes the spec for offset_from to say that if both pointers have the same address, the function is always well-defined. ### What further consequences does this have? It means the compiler can no longer transform `end2 = begin.offset(end.offset_from(begin))` into `end2 = end`. However, it can still be transformed into `end2 = begin.with_addr(end.addr())`, which later parts of the backend (when provenance has been erased) can trivially turn into `end2 = end`. The only alternative I am aware of is a fundamentally different handling of zero-sized accesses, where a "no provenance" pointer is not allowed to do zero-sized accesses and instead we have a special provenance that indicates "may be used for zero-sized accesses (and nothing else)". `offset` and `offset_from` would then always be UB on a "no provenance" pointer, and permit zero-sized offsets on a "zero-sized provenance" pointer. This achieves provenance monotonicity. That is, however, a breaking change as it contradicts what we landed in https://github.com/rust-lang/rust/pull/117329. It's also a whole bunch of extra UB, which doesn't seem worth it just to achieve that transformation. ### What about the backend? LLVM currently doesn't have an intrinsic for pointer difference, so we anyway cast to integer and subtract there. That's never UB so it is compatible with any relaxation we may want to apply. If LLVM gets a `ptrsub` in the future, then plausibly it will be consistent with `ptradd` and [consider two equal pointers to be inbounds](https://github.com/rust-lang/rust/pull/124921#issuecomment-2205795829).
2024-07-16Suggest a borrow when using dbgyukang-2/+63
2024-07-15Use multipart_suggestion to avoid place holder in span_to_snippetLzu Tao-8/+12
CO-AUTHORED-BY: Esteban Küber <esteban@kuber.com.ar>
2024-07-15Add support for `Result<&T, _>'Lzu Tao-10/+9
2024-07-15coverage: Restrict `ExpressionUsed` simplification to `Code` mappingsZalathar-19/+27
In the future, branch and MC/DC mappings might have expressions that don't correspond to any single point in the control-flow graph. That makes it trickier to keep track of which expressions should expect an `ExpressionUsed` node. We therefore sidestep that complexity by only performing `ExpressionUsed` simplification for expressions associated directly with ordinary `Code` mappings.
2024-07-15coverage: Store a copy of `num_bcbs` in `ExtractedMappings`Zalathar-7/+10
This makes it possible to allocate per-BCB data structures without needing access to the whole graph.
2024-07-15Auto merge of #127265 - harmou01:dev/harmou01/target-spec-metadata, r=Nilstriebbors-887/+903
Fill out target-spec metadata for all targets **What does this PR try to resolve?** This PR completes the target-spec metadata fields for all targets. This is required for a corresponding Cargo PR which adds a check for whether a target supports building the standard library when the `-Zbuild-std=std` flag is passed ([see this issue](https://github.com/rust-lang/wg-cargo-std-aware/issues/87). This functionality in Cargo is reliant on the output of `--print=target-spec-json`. **How should we test and review this PR?** Check that a given target-spec metadata has been updated with: ``` $ ./x.py build library/std $ build/host/stage1/bin/rustc --print=target-spec-json --target <target_name> -Zunstable-options ``` **Additional Information** A few things to note: * Where a targets 'std' or 'host tools' support is listed as '?' in the rust docs, these are left as 'None' with this PR. The corresponding changes in cargo will only reject an attempt to build std if the 'std' field is 'Some(false)'. In the case it is 'None', cargo will continue trying to build * There's no rush for this to be merged. I understand that the format for this is not finalised yet. * Related: #120745
2024-07-14Auto merge of #127718 - cjgillot:find_field, r=compiler-errorsbors-55/+73
find_field does not need to be a query. The current implementation is quadratic in the number of nested fields. r? `@davidtwco` as you reviewed https://github.com/rust-lang/rust/pull/115367 Fixes https://github.com/rust-lang/rust/issues/121755
2024-07-14Rollup merge of #127630 - compiler-errors:type-ascription, r=chenyukangMatthias Krüger-3/+1
Remove lang feature for type ascription (since it's a lib feature now) It's not necessary since it's a library feature now, via the type ascription macro. We can't (and shouldn't) register it as a removed feature since I think that would give "this feature has been removed" errors even for people using the macro (well, I'm pretty sure, though I didn't check). r? `@Nilstrieb`
2024-07-14Rollup merge of #127587 - compiler-errors:all-features-at-once, r=NilstriebMatthias Krüger-20/+3
Report usage of lib features in ast validation No idea why it was split between ast validation for lang features and a later pass for lang features. r? `@Nilstrieb`
2024-07-14Rollup merge of #127273 - nnethercote:fix-DebugParser, r=workingjubileeMatthias Krüger-70/+310
Fix `DebugParser`. I tried using this and it didn't work at all. `prev_token` is never eof, so the accumulator is always false, which means the `then_some` always returns `None`, which means `scan` always returns `None`, and `tokens` always ends up an empty vec. I'm not sure how this code was supposed to work. (An aside: I find `Iterator::scan` to be a pretty wretched function, that produces code which is very hard to understand. Probably why this is just one of two uses of it in the entire compiler.) This commit changes it to a simpler imperative style that produces a valid `tokens` vec. r? `@workingjubilee`
2024-07-14Suppress some fallout from gen in synstructureMichael Goulet-0/+8
2024-07-14Stop using the gen keyword in the compilerMichael Goulet-50/+50
2024-07-14Add cache for `allocate_str`Adwin White-10/+28
2024-07-14find_field does not need to be a query.Camille GILLOT-55/+73
2024-07-14Auto merge of #127670 - compiler-errors:no-type-length-limit, r=jackh726bors-1/+5
Gate the type length limit check behind a nightly flag Effectively disables the type length limit by introducing a `-Zenforce-type-length-limit` which defaults to **`false`**, since making the length limit actually be enforced ended up having a worse fallout than expected. We still keep the code around, but the type length limit attr is now a noop (except for its usage in some diagnostics code?). r? `@lcnr` -- up to you to decide what team consensus we need here since this reverses an FCP decision. Reopens #125460 (if we decide to reopen it or keep it closed) Effectively reverses the decision FCP'd in #125507 Closes #127346
2024-07-14Auto merge of #127713 - matthiaskrgr:rollup-zxlyexf, r=matthiaskrgrbors-0/+14
Rollup of 5 pull requests Successful merges: - #127083 (Add release notes for 1.80) - #127322 (handle ci-rustc incompatible options during config parse) - #127697 (use std for file mtime and atime modifications) - #127704 (Fix minor typos in std::process doc on Win argv) - #127710 (clarify the meaning of the version number for accepted/removed features) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-14Rollup merge of #127710 - RalfJung:features, r=compiler-errorsMatthias Krüger-0/+14
clarify the meaning of the version number for accepted/removed features For accepted features this is pretty clear, we even use the version number in the warning that says "feature has been stabilized, please remove feature gate". For removed features we are inconsistent. [This PR](https://github.com/rust-lang/rust/commit/8cece636b22620717d6e242ec20fa8d5cf979072#diff-a82bdbaaa3c79096a30755dce8896aaf2885128a7f3f3a290072b767f05b6095) set the version to when it got removed, but [here](https://github.com/rust-lang/rust/pull/116958/files#diff-1ff08f89ad7e972538827e989fa63732c5918b4d0216ccd921de08698d6e18ca) they just got copied over so the version says when the feature was originally added. As far as I can tell, this version number is not actually used anywhere in user-visible diagnostics.
2024-07-14Auto merge of #127087 - cjgillot:small-map, r=oli-obkbors-131/+229
Only track mentioned places for jump threading This PR aims to reduce the state space size in jump threading and dataflow const-prop opts. The current implementation walks the types of all locals, and creates a place for each possible projection. This can easily lead to a large number of places and tracked values, most being useless to the actual pass. With this PR, we instead collect places that appear syntactically in the MIR (first commit). However, this is not sufficient (second commit), and we miss places that we could track in aggregate assignments. The third commit tracks such assignments to mirror place projections, see the inline comment. This is complementary to https://github.com/rust-lang/rust/pull/127036 r? `@oli-obk`
2024-07-14clarify the meaning of the version number for accepted/removed featuresRalf Jung-0/+14
2024-07-14Improve internal docs for `MatchPair`Zalathar-5/+24
2024-07-14Move `MatchPair` tree creation to its own moduleZalathar-240/+248
This makes it easier to see that `MatchPair::new` has only one non-recursive caller, because the recursive callers are all in this module.
2024-07-13Rollup merge of #127558 - nnethercote:more-Attribute-cleanups, r=petrochenkovJubilee-158/+150
More attribute cleanups A follow-up to #127308. r? ```@petrochenkov```
2024-07-13Rollup merge of #127477 - nnethercote:tweak-inner_attr_ranges, r=petrochenkovJubilee-8/+3
Clear `inner_attr_ranges` regularly. There's a comment saying we don't do it for performance reasons, but it doesn't actually affect performance. The commit also tweaks the control flow, to make clearer that two code paths are mutually exclusive. r? ````@petrochenkov````
2024-07-13Rollup merge of #127434 - onur-ozkan:use-bootstrap-instead-of-rustbuild, ↵Jubilee-2/+2
r=Mark-Simulacrum use "bootstrap" instead of "rustbuild" in comments and docs Let's stick with the single name "bootstrap" to refer to the bootstrap project to avoid confusion. This should make it clearer, especially for new contributors.
2024-07-13Merge commit '659243d85c7489412bd0faa1c068d904a6042941' into ↵bjorn3-77/+94
sync_cg_clif-2024-07-13
2024-07-13Propagate places through assignments.Camille GILLOT-10/+109
2024-07-13Create mapped places upon seeing them in the body.Camille GILLOT-131/+130
2024-07-13Fix `DebugParser`.Nicholas Nethercote-14/+104
It currently doesn't work at all. This commit changes it to a simpler imperative style that produces a valid `tokens` vec. (An aside: I find `Iterator::scan` to be a pretty wretched function, that produces code which is very hard to understand. Probably why this is just one of two uses of it in the entire compiler.)
2024-07-13Add a test for `Parser::debug_lookahead`.Nicholas Nethercote-0/+149
That method is currently badly broken, and the test output reflects this. The obtained tokens list is always empty, except in the case where we go two `bump`s past the final token, whereupon it will produce as many `Eof` tokens as asked for.
2024-07-13Rollup merge of #127654 - nikic:llvm-ndebug-fix, r=cuviperJacob Pratt-14/+8
Fix incorrect NDEBUG handling in LLVM bindings We currently compile our LLVM bindings using `-DNDEBUG` if debuginfo for LLVM is disabled. However, `NDEBUG` doesn't have any relation to debuginfo, it controls whether assertions are enabled. Split the LLVM_NDEBUG environment variable into two, so that assertions and debuginfo are controlled independently. After this change, `LLVMRustDIBuilderInsertDeclareAtEnd` triggers an assertion failure on LLVM 19 due to an incorrect cast. Fix it by removing the unused return value entirely. r? `@cuviper`
2024-07-13Change `look` from a macro to a function.Nicholas Nethercote-62/+63
Using `#[track_caller]` works if the assertion is moved outside of the closure.
2024-07-12Gate the type length limit check behind a nightly flagMichael Goulet-1/+5
2024-07-12Auto merge of #127665 - workingjubilee:rollup-g90yr21, r=workingjubileebors-129/+353
Rollup of 11 pull requests Successful merges: - #126502 (Ignore allocation bytes in some mir-opt tests) - #126922 (add lint for inline asm labels that look like binary) - #127209 (Added the `xop` target-feature and the `xop_target_feature` feature gate) - #127310 (Fix import suggestion ice) - #127338 (Migrate `extra-filename-with-temp-outputs` and `issue-85019-moved-src-dir` `run-make` tests to rmake) - #127381 (Migrate `issue-83045`, `rustc-macro-dep-files` and `env-dep-info` `run-make` tests to rmake) - #127535 (Fire unsafe_code lint on unsafe extern blocks) - #127619 (Suggest using precise capturing for hidden type that captures region) - #127631 (Remove `fully_normalize`) - #127632 (Implement `precise_capturing` support for rustdoc) - #127660 (Rename the internal `const_strlen` to just `strlen`) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-12Rollup merge of #127632 - compiler-errors:precise-capturing-rustdoc, r=fmeaseJubilee-0/+7
Implement `precise_capturing` support for rustdoc Implements rustdoc (+json) support for local (i.e. non-cross-crate-inlined) RPITs with `use<...>` precise capturing syntax. Tests kinda suck. They're really hard to write 😰 r? `@fmease` or re-roll if you're too busy! also cc `@aDotInTheVoid` for the json side Tracking: * https://github.com/rust-lang/rust/issues/127228#issuecomment-2201443216 (not fully fixed for cross-crate-inlined opaques) * https://github.com/rust-lang/rust/issues/123432
2024-07-12Rollup merge of #127631 - compiler-errors:yeet-fully-norm, r=lcnrJubilee-74/+36
Remove `fully_normalize` Yeet this function and replace it w/ some `ObligationCtxt` instead. It wasn't called very often anyways. r? lcnr
2024-07-12Rollup merge of #127619 - compiler-errors:precise-capturing-better-sugg, ↵Jubilee-12/+142
r=oli-obk Suggest using precise capturing for hidden type that captures region Adjusts the "add `+ '_`" suggestion for opaques to instead suggest adding or reusing the `+ use<>` in the opaque. r? oli-obk or please re-roll if you're busy!
2024-07-12Rollup merge of #127535 - spastorino:unsafe_code-unsafe_extern_blocks, r=oli-obkJubilee-0/+10
Fire unsafe_code lint on unsafe extern blocks Fixes #126738
2024-07-12Rollup merge of #127310 - chenyukang:yukang-fix-suggest-import-ice, r=estebankJubilee-5/+5
Fix import suggestion ice Fixes #127302 #127302 only crash in edition 2015 #120074 can only reproduced in edition 2021 so I added revisions in test file.
2024-07-12Rollup merge of #127209 - sayantn:xop, r=AmanieuJubilee-0/+5
Added the `xop` target-feature and the `xop_target_feature` feature gate This is an effort towards #127208. This adds the `xop` target feature gated by `xop_target_feature`.