about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2023-03-15Make impl_trait_in_trait_container consider newly generated RPITITsSantiago Pastorino-4/+10
2023-03-15Properly implement generics_of for traitsSantiago Pastorino-2/+31
2023-03-15Rename impl_trait_in_trait_parent to impl_trait_in_trait_parent_fnSantiago Pastorino-10/+10
2023-03-15Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, ↵bors-48/+358
r=WaffleLapkin,JakobDegen Ensure `ptr::read` gets all the same LLVM `load` metadata that dereferencing does I was looking into `array::IntoIter` optimization, and noticed that it wasn't annotating the loads with `noundef` for simple things like `array::IntoIter<i32, N>`. Trying to narrow it down, it seems that was because `MaybeUninit::assume_init_read` isn't marking the load as initialized (<https://rust.godbolt.org/z/Mxd8TPTnv>), which is unfortunate since that's basically its reason to exist. The root cause is that `ptr::read` is currently implemented via the *untyped* `copy_nonoverlapping`, and thus the `load` doesn't get any type-aware metadata: no `noundef`, no `!range`. This PR solves that by lowering `ptr::read(p)` to `copy *p` in MIR, for which the backends already do the right thing. Fortuitiously, this also improves the IR we give to LLVM for things like `mem::replace`, and fixes a couple of long-standing bugs where `ptr::read` on `Copy` types was worse than `*`ing them. Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Move.20array.3A.3AIntoIter.20to.20ManuallyDrop/near/341189936> cc `@erikdesjardins` `@JakobDegen` `@workingjubilee` `@the8472` Fixes #106369 Fixes #73258
2023-03-15Auto merge of #109089 - compiler-errors:opt_rpitit_info-follow-up, r=spastorinobors-8/+16
Encode `opt_rpitit_info` for associated types Follow-up, only last commit matters r? `@spastorino` This needs a perf run after the parent pr lands
2023-03-15Split the mem-replace codegen testScott McMurray-22/+36
Apparently in CI it's getting generated in the opposite order, one function per file will make the test pass either way.
2023-03-14Improved implementation and comments after code review feedbackScott McMurray-77/+124
2023-03-15Auto merge of #107376 - aliemjay:remove-givens, r=lcnrbors-152/+87
remove obsolete `givens` from regionck Fixes #106567 r? `@lcnr` (feel free to reassign)
2023-03-14Encode opt_rpitit_info for associated typesMichael Goulet-8/+16
2023-03-14Auto merge of #109130 - matthiaskrgr:rollup-dm3jza6, r=matthiaskrgrbors-106/+612
Rollup of 9 pull requests Successful merges: - #108722 (Support for Fuchsia RISC-V target) - #108880 (Remove tests/ui/impl-trait/in-trait/new-lowering-strategy in favor of using revisions on existing tests) - #108909 (Fix object safety checks for new RPITITs) - #108915 (Remove some direct calls to local_def_id_to_hir_id on diagnostics) - #108923 (Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty) - #109101 (Fall back to old metadata computation when type references errors) - #109105 (Don't ICE for late-bound consts across `AnonConstBoundary`) - #109110 (Don't codegen impossible to satisfy impls) - #109116 (Emit diagnostic when calling methods on the unit type in method chains) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-14Rollup merge of #109116 - ↵Matthias Krüger-31/+102
MaciejWas:add-modifies-receiver-diagn-when-method-not-found, r=petrochenkov Emit diagnostic when calling methods on the unit type in method chains Fixes #104204. What this PR does: If a method is not found somewhere in a call chain, we check if we called earlier a method with signature `(&mut T, ...) -> ()`. If this is the case then we emit a diagnostic message. For example given input: ``` vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); ``` the current output is: ``` error[E0599]: no method named `sort` found for unit type `()` in the current scope --> hello.rs:3:72 | 3 | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); | ^^^^ method not found in `()` ``` after this PR it will be: ``` error[E0599]: no method named `sort` found for unit type `()` in the current scope --> ./hello.rs:3:72 | 3 | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); | ^^^^ method not found in `()` | note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains. --> ./hello.rs:3:53 | 3 | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); | ^^^^^^^^^^^ this call modifies its receiver in-place ```
2023-03-14Rollup merge of #109110 - compiler-errors:impossible-impl-mono, r=jackh726Matthias Krüger-0/+28
Don't codegen impossible to satisfy impls Fixes #109098
2023-03-14Rollup merge of #109105 - compiler-errors:late-ct-in-anon-ct, r=oli-obkMatthias Krüger-7/+37
Don't ICE for late-bound consts across `AnonConstBoundary` Fixes #108194
2023-03-14Rollup merge of #109101 - compiler-errors:layout-err, r=michaelwoeristerMatthias Krüger-2/+32
Fall back to old metadata computation when type references errors Projection is a bit too aggressive normalizing `<dyn Trait<[type error]> as Pointee>::Metadata` to `[type error]`, rather than to `DynMetadata<..>`. Side-step that by just falling back to the old structural metadata computation. Fixes #109078
2023-03-14Rollup merge of #108923 - spastorino:new-rpitit-9, r=compiler-errorsMatthias Krüger-3/+16
Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty Only the last two commits are meaningful. r? `@compiler-errors`
2023-03-14Rollup merge of #108915 - spastorino:new-rpitit-8, r=compiler-errorsMatthias Krüger-2/+6
Remove some direct calls to local_def_id_to_hir_id on diagnostics Was playing with `tests/ui/impl-trait/in-trait/default-body-with-rpit.rs` and was able to remove some ICEs. Still getting ... ``` error[E0277]: `impl Future<Output = Foo::{opaque#0}>` is not a future --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ `impl Future<Output = Foo::{opaque#0}>` is not a future | = help: the trait `Future` is not implemented for `impl Future<Output = Foo::{opaque#0}>` = note: impl Future<Output = Foo::{opaque#0}> must be a future or must implement `IntoFuture` to be awaited note: required by a bound in `Foo::{opaque#1}` --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ required by this bound in `Foo::{opaque#1}` error[E0277]: the size for values of type `impl Future<Output = Foo::{opaque#0}>` cannot be known at compilation time --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `impl Future<Output = Foo::{opaque#0}>` note: required by a bound in `Foo::{opaque#1}` --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ required by this bound in `Foo::{opaque#1}` error: internal compiler error: compiler/rustc_hir_typeck/src/closure.rs:724:18: async fn generator return type not an inference variable: Foo::{opaque#1}<'_> --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:39 | 10 | async fn baz(&self) -> impl Debug { | _______________________________________^ 11 | | "" 12 | | } | |_____^ ``` But I guess this is a little bit of progress anyway. This one goes on top of #108700 and #108945 r? `@compiler-errors`
2023-03-14Rollup merge of #108909 - spastorino:new-rpitit-7, r=compiler-errorsMatthias Krüger-15/+134
Fix object safety checks for new RPITITs This one goes on top of #108869 r? `@compiler-errors`
2023-03-14Rollup merge of #108880 - spastorino:new-rpitit-6, r=compiler-errorsMatthias Krüger-46/+236
Remove tests/ui/impl-trait/in-trait/new-lowering-strategy in favor of using revisions on existing tests r? `@compiler-errors` This one again sits on top of existing approved PRs and it still needs to add revisions to tests in `tests/ui/impl-trait/in-trait` as it only does so for async in traits.
2023-03-14Rollup merge of #108722 - petrhosek:fuchsia-riscv, r=petrochenkovMatthias Krüger-0/+21
Support for Fuchsia RISC-V target Fuchsia is in the process of implementing the RISC-V support. This change implements the minimal Rust compiler support. The support for building runtime libraries will be implemented in follow up changes once Fuchsia SDK has the RISC-V support.
2023-03-14Don't codegen impossible to satisfy implsMichael Goulet-0/+28
2023-03-14Emit "modifies receiver" diagnostic when no method is foundMaciej Wasilewski-31/+102
If no method is found when checking method call, we check if we called a method with signature (&mut T, ...) -> (). If this is the case then we emit a diagnostic message
2023-03-14Remove some direct calls to local_def_id_to_hir_id on diagnosticsSantiago Pastorino-2/+6
2023-03-14Auto merge of #106505 - Nilstrieb:format-args-string-literal-episode-2, ↵bors-63/+233
r=petrochenkov Properly allow macro expanded `format_args` invocations to uses captures Originally, this was kinda half-allowed. There were some primitive checks in place that looked at the span to see whether the input was likely a literal. These "source literal" checks are needed because the spans created during `format_args` parsing only make sense when it is indeed a literal that was written in the source code directly. This is orthogonal to the restriction that the first argument must be a "direct literal", not being exanpanded from macros. This restriction was imposed by [RFC 2795] on the basis of being too confusing. But this was only concerned with the argument of the invocation being a literal, not whether it was a source literal (maybe in spirit it meant it being a source literal, this is not clear to me). Since the original check only really cared about source literals (which is good enough to deny the `format_args!(concat!())` example), macros expanding to `format_args` invocations were able to use implicit captures if they spanned the string in a way that lead back to a source string. The "source literal" checks were not strict enough and caused ICEs in certain cases (see #106191). So I tightened it up in #106195 to really only work if it's a direct source literal. This caused the `indoc` crate to break. `indoc` transformed the source literal by removing whitespace, which made it not a "source literal" anymore (which is required to fix the ICE). But since `indoc` spanned the literal in ways that made the old check think that it's a literal, it was able to use implicit captures (which is useful and nice for the users of `indoc`). This commit properly seperates the previously introduced concepts of "source literal" and "direct literal" and therefore allows `indoc` invocations, which don't create "source literals" to use implicit captures again. Fixes #106191 [RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene
2023-03-14Improve heuristics for format_args literal being suggestableNilstrieb-1/+35
Sometimes, we want to create subspans and point at code in the literal if possible. But this doesn't always make sense, sometimes the literal may come from macro expanded code and isn't actually there in the source. Then, we can't really make these suggestions. This now makes sure that the literal is actually there as we see it so that we will not run into ICEs on weird literal transformations.
2023-03-14Make fns from other crates with RPITIT workSantiago Pastorino-1/+13
2023-03-14Properly allow macro expanded `format_args` invocations to uses capturesNilstrieb-62/+198
Originally, this was kinda half-allowed. There were some primitive checks in place that looked at the span to see whether the input was likely a literal. These "source literal" checks are needed because the spans created during `format_args` parsing only make sense when it is indeed a literal that was written in the source code directly. This is orthogonal to the restriction that the first argument must be a "direct literal", not being exanpanded from macros. This restriction was imposed by [RFC 2795] on the basis of being too confusing. But this was only concerned with the argument of the invocation being a literal, not whether it was a source literal (maybe in spirit it meant it being a source literal, this is not clear to me). Since the original check only really cared about source literals (which is good enough to deny the `format_args!(concat!())` example), macros expanding to `format_args` invocations were able to use implicit captures if they spanned the string in a way that lead back to a source string. The "source literal" checks were not strict enough and caused ICEs in certain cases (see # 106191 (the space is intended to avoid spammy backreferences)). So I tightened it up in # 106195 to really only work if it's a direct source literal. This caused the `indoc` crate to break. `indoc` transformed the source literal by removing whitespace, which made it not a "source literal" anymore (which is required to fix the ICE). But since `indoc` spanned the literal in ways that made the old check think that it's a literal, it was able to use implicit captures (which is useful and nice for the users of `indoc`). This commit properly seperates the previously introduced concepts of "source literal" and "direct literal" and therefore allows `indoc` invocations, which don't create "source literals" to use implicit captures again. [RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene
2023-03-14Get impl defaultness using querySantiago Pastorino-2/+3
2023-03-14Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errorsbors-357/+145
Remove `identity_future` indirection This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm. Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation. Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-14Auto merge of #109057 - compiler-errors:rpitit-info-again, r=spastorinobors-23/+31
Don't `opt_rpitit_info` as a separate query ... another attempt to undo regressions r? `@ghost`
2023-03-14Auto merge of #108992 - petrochenkov:qcstore2, r=cjgillotbors-250/+169
resolve: Querify most cstore access methods (subset) A subset of https://github.com/rust-lang/rust/pull/108346 that is not on a hot path in any way.
2023-03-14Auto merge of #109097 - matthiaskrgr:rollup-6ydc4ri, r=matthiaskrgrbors-141/+451
Rollup of 9 pull requests Successful merges: - #108419 (Stabilize `atomic_as_ptr`) - #108507 (use `as_ptr` to determine the address of atomics) - #108607 (Don't use fd-lock on Solaris in bootstrap) - #108830 (Treat projections with infer as placeholder during fast reject in new solver) - #109055 (create `config::tests::detect_src_and_out` test for bootstrap) - #109058 (Document BinOp::is_checkable) - #109081 (simd-wide-sum test: adapt for LLVM 17 codegen change) - #109083 (Update books) - #109088 (Gracefully handle `#[target_feature]` on statics) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-13Don't ICE for late-bound consts across AnonConstBoundaryMichael Goulet-7/+37
2023-03-13Layout of `&dyn Trait<[type error]>` is still wideMichael Goulet-2/+32
2023-03-13Rollup merge of #109088 - Nilstrieb:target-feature-on-statics-when, ↵Matthias Krüger-36/+139
r=compiler-errors Gracefully handle `#[target_feature]` on statics The was careful around not calling `fn_sig` on not-functions but well, it wasn't careful enough. This commit makes it a little more careful and also adds tests for a bunch more item kinds. I was sadly not able to fully bless the test locally because I'm on an aarch64 machine but I hope some manual editing made it work 😅 Fix #109079
2023-03-13Rollup merge of #109083 - rustbot:docs-update, r=ehussMatthias Krüger-0/+0
Update books ## rust-lang/nomicon 1 commits in 79b53665a7c61d171fb8c5ad0b73b371f9ee6ba7..1f3e4cd4fd88b5b5d45feb86a11b6d2f93e5a974 2023-03-12 21:51:29 UTC to 2023-03-12 21:51:29 UTC - Change incorrect reference to "above" in ffi.md (rust-lang/nomicon#404) ## rust-lang/reference 4 commits in a9afb04b47a84a6753e4dc657348c324c876102c..24c87f6663aed55b05d2cc286878f28f21918825 2023-03-11 13:53:24 UTC to 2023-02-28 16:07:20 UTC - Document movbe target feature (rust-lang/reference#1336) - fix typo (rust-lang/reference#1339) - fix: Typo/reference (rust-lang/reference#1338) - Document `cmpxchg16b` target feature (rust-lang/reference#1331) ## rust-lang/rustc-dev-guide 13 commits in b06dab84083390e0ee1e998f466545a8a1a76a9f..b1b6d693cd1461e53de4132c1b183ace31cd36e5 2023-03-13 02:42:00 UTC to 2023-03-03 11:12:51 UTC - Rename `config.toml.example` to `config.example.toml` (rust-lang/rustc-dev-guide#1641) - fix typo `SubstRef` to `SubstsRef` (rust-lang/rustc-dev-guide#1642) - tracing log along diff crates (rust-lang/rustc-dev-guide#1640) - Fix Rust Analyzer settings location (rust-lang/rustc-dev-guide#1637) - Reflect the changes in rust-lang/rust#67000 (rust-lang/rustc-dev-guide#1632) - improve capacity note (rust-lang/rustc-dev-guide#1634) - Remove mention to lexer/parser refactoring (rust-lang/rustc-dev-guide#1629) - Update date reference about infer context variables (rust-lang/rustc-dev-guide#1630) - Update explnation about `Body.basic_blocks` (rust-lang/rustc-dev-guide#1631) - Add detail to contributing guide (rust-lang/rustc-dev-guide#1628) - Making the sentence more clear (rust-lang/rustc-dev-guide#1624) - Fixed typing error (rust-lang/rustc-dev-guide#1623) - update error code docs to reflect recent changes (rust-lang/rustc-dev-guide#1625)
2023-03-13Rollup merge of #109081 - krasimirgg:llvm-17-simd-wide-sum, r=nikicMatthias Krüger-1/+1
simd-wide-sum test: adapt for LLVM 17 codegen change After https://github.com/llvm/llvm-project/commit/0d4a709bb876824a0afa5f86e138e8ffdcaf7661 LLVM becomes more clever and turns ```@wider_reduce_loop``` into an alias: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/17806#0186da6b-582c-46bf-a227-1565fa0859ac/743-766 This adapts the test to prevent this.
2023-03-13Rollup merge of #109058 - tmiasko:is-checkable, r=jackh726Matthias Krüger-0/+3
Document BinOp::is_checkable
2023-03-13Rollup merge of #109055 - ozkanonur:detect_src_and_out, r=albertlarsan68Matthias Krüger-2/+33
create `config::tests::detect_src_and_out` test for bootstrap Resolves one of the `FIXME` in bootstrap
2023-03-13Rollup merge of #108830 - compiler-errors:new-solver-fast-reject-faster, r=lcnrMatthias Krüger-83/+250
Treat projections with infer as placeholder during fast reject in new solver r? ``@lcnr`` Kind of a shame that we need to change all of the call sites for `for_each_relevant_impl`, etc. to pass an extra parameter. I guess I could have the "default" fn which calls a configurable fn?
2023-03-13Rollup merge of #108607 - psumbera:solaris-no-flock-bootstrap, r=albertlarsan68Matthias Krüger-8/+15
Don't use fd-lock on Solaris in bootstrap ...as Solaris is missing flock() fixes #103630
2023-03-13Rollup merge of #108507 - hermitcore:new, r=m-ou-seMatthias Krüger-4/+3
use `as_ptr` to determine the address of atomics The PR #107736 renamed atomic `as_mut_ptr` to `as_ptr`. Consequently, the futex implementation of the tier-3 platform `RutyHermit` has to use this new interface. In addition, this PR removes also an unused import.
2023-03-13Rollup merge of #108419 - tgross35:atomic-as-ptr, r=m-ou-seMatthias Krüger-7/+7
Stabilize `atomic_as_ptr` Fixes #66893 This stabilizes the `as_ptr` methods for atomics. The stabilization feature gate used here is `atomic_as_ptr` which supersedes `atomic_mut_ptr` to match the change in https://github.com/rust-lang/rust/pull/107736. This needs FCP. New stable API: ```rust impl AtomicBool { pub const fn as_ptr(&self) -> *mut bool; } impl AtomicI32 { pub const fn as_ptr(&self) -> *mut i32; } // Includes all other atomic types impl<T> AtomicPtr<T> { pub const fn as_ptr(&self) -> *mut *mut T; } ``` r? libs-api ``@rustbot`` label +needs-fcp
2023-03-13Auto merge of #109094 - Nilstrieb:no-thin-lto-on-windows, r=jyn514bors-2/+1
Revert "enable ThinLTO for rustc on x86_64-pc-windows-msvc dist builds" This lead to a miscompilation in at least `char::is_whitespace` and probably in more unknown places..... See #109067 This reverts commit 684663ed380d0e6a6e135aed9c6055ab4ba94ac8, PR #103591.
2023-03-13Revert "enable ThinLTO for rustc on x86_64-pc-windows-msvc dist builds"Nilstrieb-2/+1
This lead to a miscompilation in at least `char::is_whitespace` and probably in more unknown places..... This reverts commit 684663ed380d0e6a6e135aed9c6055ab4ba94ac8.
2023-03-13Gracefully handle `#[target_feature]` on staticsNilstrieb-36/+139
The was careful around not calling `fn_sig` on not-functions but well, it wasn't careful enough. This commit makes it a little more careful and also adds tests for a bunch more item kinds.
2023-03-13Don't opt_rpitit_info as a separate queryMichael Goulet-23/+31
2023-03-13Update booksrustbot-0/+0
2023-03-13Auto merge of #109069 - lnicola:rust-analyzer-2023-03-13, r=lnicolabors-3055/+12635
:arrow_up: `rust-analyzer` r? `@ghost`
2023-03-13Don't use fd-lock on Solaris in bootstrapPetr Sumbera-8/+15
...as Solaris is missing flock() fixes #103630
2023-03-13Better names?Michael Goulet-49/+55