about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2023-06-30add whether `LinkerFlavor` invokes the linker via a C/C++ compilerRémy Rakic-0/+19
2023-06-30add whether `LinkerFlavor` uses `lld`Rémy Rakic-0/+18
2023-06-30Auto merge of #113200 - ferrocene:pa-fix-mir-opt-bless, r=oli-obkbors-1/+13
Fix loading target specs in compiletest not working with custom targets In https://github.com/rust-lang/rust/pull/112454#issuecomment-1611351168 it was pointed out that the PR broke blessing mir-opt tests. Since #112418, blessing mir-opt tests generates "synthetic targets", which are custom target specs. Those specs are not included in `--print=all-target-specs-json`, and #112454 required that the current target was returned by that flag. This PR fixes the breakage by loading the target spec for the current target explicitly, if a custom target is detected. r? `@oli-obk`
2023-06-30fix loading target specs in compiletest not working with custom targetsPietro Albini-1/+13
2023-06-30Auto merge of #109524 - bzEq:aix-embed-llvmbc, r=nagisabors-2/+19
Support embedding LLVM bitcode on AIX
2023-06-30Auto merge of #106619 - agausmann:avr-object-file, r=nagisabors-1/+350
Fix unset e_flags in ELF files generated for AVR targets Closes #106576 ~~Sort-of blocked by gimli-rs/object#500~~ (merged) I'm not sure whether the list of AVR CPU names is okay here. Maybe it could be moved out-of-line to improve the readability of the function.
2023-06-30Auto merge of #113188 - matthiaskrgr:rollup-j3abaks, r=matthiaskrgrbors-99/+327
Rollup of 6 pull requests Successful merges: - #107624 (Stabilize `const_cstr_methods`) - #111403 (suggest `slice::swap` for `mem::swap(&mut x[0], &mut x[1])` borrowck error) - #113071 (Account for late-bound vars from parent arg-position impl trait) - #113165 (Encode item bounds for `DefKind::ImplTraitPlaceholder`) - #113171 (Properly implement variances_of for RPITIT GAT) - #113177 (Use structured suggestion when telling user about `for<'a>`) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-30Rollup merge of #113177 - estebank:hrlt-sugg, r=compiler-errorsMatthias Krüger-64/+157
Use structured suggestion when telling user about `for<'a>` ``` error[E0637]: `&` without an explicit lifetime name cannot be used here --> $DIR/E0637.rs:13:13 | LL | T: Into<&u32>, | ^ explicit lifetime name needed here | help: consider introducing a higher-ranked lifetime here | LL | T: for<'a> Into<&'a u32>, | +++++++ ++ ```
2023-06-30Rollup merge of #113171 - spastorino:new-rpitit-25, r=compiler-errorsMatthias Krüger-9/+34
Properly implement variances_of for RPITIT GAT This fixes some of the issues found by crater run in https://github.com/rust-lang/rust/pull/112988#issuecomment-1610019572 r? ``@compiler-errors``
2023-06-30Rollup merge of #113165 - compiler-errors:rpitits-foreign-bounds, r=spastorinoMatthias Krüger-0/+7
Encode item bounds for `DefKind::ImplTraitPlaceholder` This was lost in a refactoring -- `hir::ItemKind::OpaqueTy` doesn't always map to `DefKind::Opaque`, specifically for RPITITs, so the check was migrated subtly wrong, and unfortunately I never had a test for this 🙃 Fixes #113155 r? ``@cjgillot``
2023-06-30Rollup merge of #113071 - ↵Matthias Krüger-15/+114
compiler-errors:no-parent-non-lifetime-args-in-apit, r=eholk Account for late-bound vars from parent arg-position impl trait We should be reporting an error like we do for late-bound args coming from a parent APIT. Fixes #113016
2023-06-30Rollup merge of #111403 - y21:suggest-slice-swap, r=compiler-errorsMatthias Krüger-3/+5
suggest `slice::swap` for `mem::swap(&mut x[0], &mut x[1])` borrowck error Recently saw someone ask why this code (example slightly modified): ```rs fn main() { let mut foo = [1, 2]; std::mem::swap(&mut foo[0], &mut foo[1]); } ``` triggers this error and how to fix it: ``` error[E0499]: cannot borrow `foo[_]` as mutable more than once at a time --> src/main.rs:4:33 | 4 | std::mem::swap(&mut foo[0], &mut foo[1]); | -------------- ----------- ^^^^^^^^^^^ second mutable borrow occurs here | | | | | first mutable borrow occurs here | first borrow later used by call | = help: consider using `.split_at_mut(position)` or similar method to obtain two mutable non-overlapping sub-slices ``` The current help message is nice and goes in the right direction, but I think we can do better for this specific instance and suggest `slice::swap`, which makes this compile
2023-06-30Rollup merge of #107624 - tgross35:const-cstr-methods, r=dtolnayMatthias Krüger-8/+10
Stabilize `const_cstr_methods` This PR seeks to stabilize `const_cstr_methods`. Fixes most of #101719 ## New const stable API ```rust impl CStr { // depends: memchr pub const fn from_bytes_with_nul(bytes: &[u8]) -> Result<&Self, FromBytesWithNulError> {...} // depends: const_slice_index pub const fn to_bytes(&self) -> &[u8] {} // depends: pointer casts pub const fn to_bytes_with_nul(&self) -> &[u8] {} // depends: str::from_utf8 pub const fn to_str(&self) -> Result<&str, str::Utf8Error> {} } ``` I don't think any of these methods will have any issue when `CStr` becomes a thin pointer as long as `memchr` is const (which also allows for const `strlen`) . ## Notes - `from_bytes_until_nul` relies on `const_slice_index`, which relies on `const_trait_impls`, and generally this should be avoided. After talking with Oli, it should be OK in this case because we could replace the ranges with pointer tricks if needed (worst case being those feature gates disappear). https://github.com/rust-lang/rust/pull/107624#discussion_r1101468480 - Making `from_ptr` const is deferred because it depends on `const_eval_select`. I have moved this under the new flag `const_cstr_from_ptr` https://github.com/rust-lang/rust/pull/107624#discussion_r1101555239 cc ``@oli-obk`` I think you're the const expert ``@rustbot`` modify labels: +T-libs-api +needs-fcp
2023-06-30Auto merge of #113162 - matthiaskrgr:rollup-fct3wj7, r=matthiaskrgrbors-790/+1053
Rollup of 7 pull requests Successful merges: - #111322 (Support for native WASM exceptions) - #112086 (resolve: Remove artificial import ambiguity errors) - #112234 (refactor `tool_doc!`) - #112300 (Convert `run-make/coverage-reports` tests to use a custom compiletest mode) - #112795 (Migrate some rustc_builtin_macros to SessionDiagnostic) - #113144 (Make the `Elaboratable` trait take clauses) - #113161 (Fix type privacy lints error message) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-29Properly implement variances_of for RPITIT GATSantiago Pastorino-9/+34
2023-06-30Auto merge of #113116 - nnethercote:codegen-opts, r=oli-obkbors-117/+32
A mish-mash of micro-optimizations These were aimed at speeding up LLVM codegen, but ended up affecting other places as well. r? `@bjorn3`
2023-06-30Use structured suggestion when telling user about `for<'a>`Esteban Küber-64/+157
``` error[E0637]: `&` without an explicit lifetime name cannot be used here --> $DIR/E0637.rs:13:13 | LL | T: Into<&u32>, | ^ explicit lifetime name needed here | help: consider introducing a higher-ranked lifetime here | LL | T: for<'a> Into<&'a u32>, | +++++++ ++ ```
2023-06-29Auto merge of #112682 - spastorino:new-rpitit-21, r=compiler-errorsbors-104/+207
Add bidirectional where clauses on RPITIT synthesized GATs Given the following: ```rust struct MyStruct<'a, T>(&'a T); trait MyTrait<'a, T> { fn my_fn<'b, 'c, 'd, V>(item: &'c String) -> impl Sized + 'a + 'b + 'c where V: 'b, V: 'd; } impl<'a, T> MyTrait<'a, T> for MyStruct<'a, T> { fn my_fn<'b, 'c, 'd, V>(_: &'c String) -> impl Sized + 'a + 'b + 'c where V: 'b, V: 'd, { unimplemented!(); } } ``` We need the desugaring to be: ```rust trait MyTrait<'a, T> { type MyFn<'bf, 'df, Vf, 'a2, 'b2, 'c2>: Sized + 'a2 + 'b2 + 'c2 where Vf: 'b2, 'a2: 'a, 'a: 'a2, 'b2: 'bf, 'bf: 'b2; fn my_fn<'b, 'c, 'd, V>(item: &'c String) -> MyStruct<'a>::MyFn<'b, 'd, V, 'a, 'b, 'c> where V: 'b, V: 'd { type opaque<'a3, 'b3, 'c3>; }; } impl<'a, T> MyIter<'a, T> for MyStruct<'a, T> { type MyFn<'bf, 'df, Vf, 'a2, 'b2, 'c2> = impl Sized + 'a2 + 'b2 + 'c2 where Vf: b2, 'a2: 'a, 'a: 'a2, 'b2: 'bf, 'bf: 'b2; fn my_fn<'b, 'c, 'd, V>(_: &'c String) -> MyStruct<'a>::MyFn<'a, 'b, 'c, V> where V: 'b, V: 'd { type opaque<'a3, 'b3, 'c3>; unimplemented!(); } } ``` This PR adds the where clauses for the `MyFn` generated GATs. This is a draft with a very ugly solution so we can make comments over concrete code. r? `@compiler-errors`
2023-06-29Auto merge of #113059 - Kobzol:ci-concurrency-fix, r=pietroalbinibors-4/+5
CI: do not cancel concurrent builds on the same branch Do not cancel concurrent builds on the same branch (outside of PRs). Instead, only cancel them if the builds have the same commit SHA. From the [documentation](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context): > The commit SHA that triggered the workflow. The value of this commit SHA depends on the event that triggered the workflow. For more information, see "[Events that trigger workflows](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows)." For example, ffac537e6cbbf934b08745a378932722df287a53. Fixes: https://github.com/rust-lang/rust/pull/112955#discussion_r1242273658 r? `@pietroalbini`
2023-06-29Do not generate lifetime_mapping for RPIT no in_traitSantiago Pastorino-12/+32
2023-06-29Add bidirectional where clauses on RPITIT synthesized GATsSantiago Pastorino-36/+92
2023-06-29add `slice::swap` suggestiony21-3/+5
2023-06-29Intern OpaqueTy on ItemKind::OpaqueTySantiago Pastorino-9/+9
2023-06-29Reorganize opaque lowering codeSantiago Pastorino-43/+50
2023-06-29Do not remove previously added predicates in param_env, extend them insteadSantiago Pastorino-1/+3
2023-06-29Extract compute_bidirectional_outlives_predicates fnSantiago Pastorino-33/+51
2023-06-29Encode item bounds for DefKind::ImplTraitPlaceholderMichael Goulet-0/+7
2023-06-29Auto merge of #113108 - ↵bors-24/+95
compiler-errors:normalize-opaques-with-late-bound-vars-again, r=jackh726 Normalize opaques with late-bound vars again We have a hack in the compiler where if an opaque has escaping late-bound vars, we skip revealing it even though we *could* reveal it from a technical perspective. First of all, this is weird, since we really should be revealing all opaques in `Reveal::All` mode. Second of all, it causes subtle bugs (linked below). I attempted to fix this in #100980, which was unfortunately reverted due to perf regressions on codebases that used really deeply nested futures in some interesting ways. The worst of which was #103423, which caused the project to hang on build. Another one was #104842, which was just a slow-down, but not a hang. I took some time afterwards to investigate how to rework `normalize_erasing_regions` to take advantage of better caching, but that effort kinda fizzled out (#104133). However, recently, I was made aware of more bugs whose root cause is not revealing opaques during codegen. That made me want to fix this again -- in the process, interestingly, I took the the minimized example from https://github.com/rust-lang/rust/issues/103423#issuecomment-1292947043, and it doesn't seem to hang any more... Thinking about this harder, there have been some changes to the way we lower and typecheck async futures that may have reduced the pathologically large number of outlives obligations (see description of #103423) that we were encountering when normalizing opaques with bound vars the last time around: * #104321 (lower `async { .. }` directly as a generator that implements `Future`, removing the `from_generator` shim) * #104833 (removing an `identity_future` fn that was wrapping desugared future generators) ... so given that I can see: * No significant regression on rust perf bot (https://github.com/rust-lang/rust/pull/107620#issuecomment-1600070317) * No timeouts in crater run I did (https://github.com/rust-lang/rust/pull/107620#issuecomment-1605428952, rechecked failing crates in https://github.com/rust-lang/rust/pull/107620#issuecomment-1605973434) ... and given that this PR: * Fixes #104601 * Fixes #107557 * Fixes #109464 * Allows us to remove a `DefiningAnchor::Bubble` from codegen (75a8f681837c70051e0200a14f58ae07dbe58e66) I'm inclined to give this another shot at landing this. Best case, it just works -- worst case, we get more examples to study how we need to improve the compiler to make this work. r? types
2023-06-29Rollup merge of #113161 - Bryanskiy:err_msg, r=petrochenkovMatthias Krüger-109/+120
Fix type privacy lints error message Type privacy lints diagnostic messages are not related to spans. r? `@petrochenkov`
2023-06-29Rollup merge of #113144 - compiler-errors:elaborate-clauses, r=oli-obkMatthias Krüger-40/+42
Make the `Elaboratable` trait take clauses We only ever elaborate clauses, so make this explicit in the trait's definition rather than having a bunch of `.expect_clause()` calls everywhere.
2023-06-29Rollup merge of #112795 - He1pa:translation_builtin_macros, r=davidtwcoMatthias Krüger-32/+134
Migrate some rustc_builtin_macros to SessionDiagnostic Part of https://github.com/rust-lang/rust/issues/100717. ``@rustbot`` label +A-translation
2023-06-29Rollup merge of #112300 - Zalathar:run-coverage, r=wesleywiserMatthias Krüger-356/+523
Convert `run-make/coverage-reports` tests to use a custom compiletest mode I was frustrated by the fact that most of the coverage tests are glued together with makefiles and shell scripts, so I tried my hand at converting most of them over to a newly-implemented `run-coverage` mode/suite in compiletest. This ~~*mostly*~~ resolves #85009, ~~though I've left a small number of the existing tests as-is because they would require more work to fix/support~~. --- I had time to go back and add support for the more troublesome tests that I had initially skipped over, so this PR now manages to completely get rid of `run-make/coverage-reports`. --- The patches are arranged as follows: - Declare the new mode/suite in bootstrap - Small changes to compiletest that will be used by the new mode - Implement the new mode in compiletest - Migrate most of the tests over - Add more code to bootstrap and compiletest to support the remaining tests - Migrate the remaining tests (with some temporary hacks to avoid re-blessing them) - Remove the temporary hacks and re-bless the migrated tests - Remove the unused remnants of `run-make/coverage-reports`
2023-06-29Rollup merge of #112234 - ozkanonur:hotfix, r=jyn514Matthias Krüger-9/+41
refactor `tool_doc!` resolves https://github.com/rust-lang/rust/pull/112211#discussion_r1215190510
2023-06-29Rollup merge of #112086 - petrochenkov:impambig, r=oli-obkMatthias Krüger-230/+53
resolve: Remove artificial import ambiguity errors Fixes https://github.com/rust-lang/rust/issues/56414. FCP report: https://github.com/rust-lang/rust/pull/112086#issuecomment-1568713662
2023-06-29Rollup merge of #111322 - mirkootter:master, r=davidtwcoMatthias Krüger-14/+140
Support for native WASM exceptions ### Motivation Currently, rustc does not support native WASM exceptions. It does support JavaScript based exceptions for the wasm32-emscripten-target, but this requires back&forth with javascript for many calls, which is very slow. Native wasm support for exceptions is quite common: Clang+LLVM implemented them years ago, and all major browsers support them by now. They enable zero-cost exceptions, at least with regard to runtime-performance-cost. They may increase startup-time and code size, though. ### Important: This PR does not change default behaviour Exceptions usually add a lot of code in form of unwinding blocks, increasing the binary size. Most users probably do not want that, especially which regard to web development. Therefore, wasm exceptions play a similar role as WASM-threads: rustc should support them, like clang does, but users who want to use it have to use some command-line magic like rustflags to opt in. ### What does this PR do? As stated above, the default behaviour is not changed. It is already possible to opt-in into wasm exceptions using the command line. Unfortunately, the LLVM IR is invalid and the LLVM backend crashes. ``` rustc <sourcefile> --target wasm32-unknown-unknown -C panic=unwind -C llvm-args=-wasm-enable-eh -C target-feature=+exception-handling ``` As it turns out, LLVM is quite picky when it comes to IR for exception handling. If the IR does not look exactly like it should, some LLVM-assertions fail and the code generation crashes. This PR adds the necessary modifications to the code generator to make it work. It also adds `exception-handling` as a wasm target feature. ### What this PR does not / what is missing This PR is not a full fledges solution. It is the first step. A few parts are still missing; however, it is already useable (see next section). Currently missing: * The std library has to be adapted. Currently, only [no_std] crates work * Usually, nested exceptions abort the program (i.e. a panic during the cleanup of another panic). This is currently not done yet. - Currently, code inside cleanup handlers does not unwind - To fix this requires a little more work: The code generator currently maintains a single terminate block per function for this. Unfortunately, WASM requires funclet based exception handling. Therefore, we need to create a terminate block per funclet. This is probably not a big problem, but I want to keep this PR simple. ### How to use the compiler given this PR? This PR does not add any command line flags or features. It uses those which are already there. To compile with exceptions enabled, you need * to set the panic strategy to unwind, i.e. `-C panic=unwind` * to enable the exception-handling target feature, i.e. `-C target-feature=+exception-handling` * to tell LLVM about the exception handling, i.e. `-C llvm-args=-wasm-enable-eh` Since the standard library has not been adapted, you can only use it in [no_std] crates as of now. The intrinsic `core::intrinsics::r#try` works. To throw exceptions, you need the ```@llvm.wasm.throw``` intrinsic. I created a sample application which works for me: https://github.com/mirkootter/rust-wasm-demos This example can be run at https://webassembly.sh
2023-06-29Fix type privacy lints error messageBryanskiy-109/+120
2023-06-29CI: do not cancel concurrent builds on the same branchJakub Beránek-4/+5
Add an exception for try and try-perf branches to enable concurrent try builds and unrolled rollup builds.
2023-06-29Auto merge of #113151 - RalfJung:miri, r=RalfJung,oli-obkbors-474/+3206
update Miri r? `@ghost`
2023-06-29Use a valid `target` directory in miri ui testsOli Scherer-0/+1
2023-06-29resolve: Remove artificial import ambiguity errorsVadim Petrochenkov-230/+53
2023-06-29refactor `tool_doc!` so that it can accept additional arguments.ozkanonur-9/+41
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-06-29update lockfileRalf Jung-10/+2
2023-06-29Auto merge of #113134 - TaKO8Ki:rollup-4hvqzf6, r=TaKO8Kibors-56/+164
Rollup of 5 pull requests Successful merges: - #112946 (Improve cgu naming and ordering) - #113048 (Fix build on Solaris where fd-lock cannot be used.) - #113100 (Fix display of long items in search results) - #113107 (add check for ConstKind::Value(_) to in_operand()) - #113119 (rustdoc: Reduce internal function visibility.) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-29Auto merge of #2946 - RalfJung:rustup, r=RalfJungbors-420/+434
Rustup
2023-06-29Merge from rustcRalf Jung-419/+433
2023-06-29Preparing for merge from rustcRalf Jung-1/+1
2023-06-29Auto merge of #113146 - matthiaskrgr:rollup-bxtr51e, r=matthiaskrgrbors-204/+569
Rollup of 7 pull requests Successful merges: - #112670 (privacy: Type privacy lints fixes and cleanups) - #112929 (Test that we require implementing trait items whose bounds don't hold in the current impl) - #113054 (Make `rustc_on_unimplemented` std-agnostic) - #113137 (don't suggest `move` for borrows that aren't closures) - #113139 (style-guide: Clarify let-else further) - #113140 (style-guide: Add an example of formatting a multi-line attribute) - #113143 (style-guide: Narrow guidance about references and dereferencing) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-29Rollup merge of #113143 - ↵Matthias Krüger-1/+2
joshtriplett:style-guide-narrow-dereference-guidance, r=calebcartwright style-guide: Narrow guidance about references and dereferencing The style guide advises "prefer dereferencing to taking references", but doesn't give guidance on when that "preference" should get overridden by other considerations. Give an example of when it's fine to ignore that advice.
2023-06-29Rollup merge of #113140 - ↵Matthias Krüger-0/+5
joshtriplett:style-guide-example-multi-line-attribute, r=calebcartwright style-guide: Add an example of formatting a multi-line attribute We already say to format attributes like functions, but we didn't have an example of formatting a multi-line attribute.
2023-06-29Rollup merge of #113139 - joshtriplett:style-clarify-let-else, r=calebcartwrightMatthias Krüger-2/+24
style-guide: Clarify let-else further Give some additional examples with multi-line patterns. Make it clearer to go on to the next case if the conditions aren't met.