about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-11-08Auto merge of #117716 - GuillaumeGomez:rollup-83gnhll, r=GuillaumeGomezbors-478/+516
Rollup of 5 pull requests Successful merges: - #117263 (handle the case when the change-id isn't found) - #117282 (Recover from incorrectly ordered/duplicated function keywords) - #117679 (tests/rustdoc-json: Avoid needless use of `no_core` and `lang_items`) - #117702 (target: move base and target specifications) - #117713 (Add test for reexported hidden item with `--document-hidden-items`) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-08Rollup merge of #117702 - davidtwco:target-tier-refactors, r=petrochenkovGuillaume Gomez-475/+479
target: move base and target specifications Follow-up to #116004. In anticipation of later PRs where we'll want to add tidy checks to ensure that, for each target, we have a test or a platform support document or something like that, this PR moves target specifications into a directory on their own so that we can just list the files in this directory to get a list of all targets. - Base specifications are moved to `rustc_target::spec::base`. - Target specifications are moved to `rustc_target::spec::targets`. - All the other source files containing types used in the target specs remain in `rustc_target::spec`. - `rustc_target/src/spec/abi.rs` is moved to `rustc_target/src/spec/abi/mod.rs` (where there was already a `tests.rs`) for uniformity. r? ``@petrochenkov``
2023-11-08Rollup merge of #117282 - clubby789:recover-wrong-function-header, r=TaKO8KiGuillaume Gomez-3/+37
Recover from incorrectly ordered/duplicated function keywords Fixes #115714
2023-11-08Auto merge of #117560 - lqd:issue-117146, r=matthewjasperbors-13/+14
Compute polonius loan scopes over the region graph In issue #117146 a loan flows into an SCC containing a placeholder, and whose representative is an existential region. Since we currently compute loan scopes by looking at SCCs and their representatives only, polonius would compute kill points for this loan here whereas NLLs would not of course. There are a few ways to fix this: - don't try to be efficient by doing the computation over SCCs, and simply look for free regions and placeholders in the successors of the issuing region. - change how the SCC representatives are picked, biasing towards placeholders over existential regions. They *shouldn't* matter much, but some downstream code may subtly depend on the current scheme (though no tests fail if we do such a change). This is for unrelated reasons also the way #116891 changes the representative computation. So that PR would also fix issue #117146. - try to remove placeholders from the main path, and contain them to a pre-pass + a post-pass kind of polonius leak check. If possible, it would fix this issue by turning an outlives constraints to a placeholder into a constraint to 'static. This should also fix the issue, as the representative would be the free region in the SCC. We want to prototype this change to see if it's possible to try to simplify the borrowck main path from having to deal with placeholders and higher-ranked subtyping 🤞. I'd like to take advantage of fuzzing and a crater run sooner rather than later, so that we grow more confidence that the 2 models are indeed equivalent empirically. Therefore this PR implements option 1 to fix the issue now. We can take care of efficiency later after validation, and once we implement option 3 (which could also impact option 2 and that associated PR, maybe the lack of placeholders could remove the need to change the representative computation) to traverse SCCs and their representative again. (Or we maybe will have some kind of naive position-dependent outlives propagation by then and this code would have been changed) Fixes #117146. r? `@matthewjasper`
2023-11-08Auto merge of #117706 - matthiaskrgr:rollup-lscx7dg, r=matthiaskrgrbors-43/+97
Rollup of 7 pull requests Successful merges: - #114316 (Add AIX platform support document) - #117531 (rustdoc: properly elide cross-crate host effect args) - #117650 (Add -Zcross-crate-inline-threshold=yes) - #117663 (bump some deps) - #117667 (Document clippy_config in nightly-rustc docs) - #117698 (Clarify `space_between`) - #117700 (coverage: Rename the `run-coverage` test mode to `coverage-run`) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-08Rollup merge of #117698 - nnethercote:space_between-2, r=petrochenkovMatthias Krüger-30/+42
Clarify `space_between` r? ``@petrochenkov``
2023-11-08Rollup merge of #117650 - saethlin:inline-me-please, r=davidtwcoMatthias Krüger-13/+55
Add -Zcross-crate-inline-threshold=yes ``@thomcc`` says this would be useful for > seeing if it makes a difference in some code if i do it when building the sysroot, since -Zbuild-std + lto helps more than it seems like it should And I've changed the possible values as a reference to ``@Manishearth`` saying > LLVM's inlining heuristic is "yes".
2023-11-08Auto merge of #117542 - compiler-errors:only-normalize-predicate, r=lcnrbors-2/+8
Only use `normalize_param_env` when normalizing predicate in `check_item_bounds` Only use the `normalize_param_env` when normalizing the item bound predicate in `check_item_bounds`, instead of using it when processing this obligation as well. This causes <BUG> to reoccur, but hopefully with better caching in the future, we can fix this would having such bad effects on perf. This PR also fixes #117598. It turns out that the GAT predicate that we install is actually wrong -- given code like: ``` impl<'r> HasValueRef<'r> for Any { type Database = Any; } ``` We currently generate a predicate that looks like `<Any as HasValueRef<'r>>::Database = Any`, where `'r` is an early-bound variable. Really this GAT assumption should be universally quantified over the impl's args, i.e. `for<'r> <Any as HasValueRef<'r>>::Database = Any`, but then we'd need the binder to also include all the WC of the impl as well, which we don't support yet, lol.
2023-11-08rustc_target: move file for uniformityDavid Wood-0/+0
Signed-off-by: David Wood <david@davidtw.co>
2023-11-08targets: move target specs to spec/targetsDavid Wood-26/+26
Signed-off-by: David Wood <david@davidtw.co>
2023-11-08target: move base specs to spec/baseDavid Wood-449/+453
Signed-off-by: David Wood <david@davidtw.co>
2023-11-08Clarify `space_between`.Nicholas Nethercote-30/+42
To avoid `!matches!(...)`, which is hard to think about. Instead every case now uses direct pattern matching and returns true or false. Also add a couple of cases to the `stringify.rs` test that currently print badly.
2023-11-08Only use normalize_param_env when normalizing predicate in check_item_boundsMichael Goulet-2/+8
2023-11-08Rollup merge of #117655 - compiler-errors:method-tweaks, r=estebankMatthias Krüger-158/+138
Method suggestion code tweaks I was rummaging around the method suggestion code after https://github.com/rust-lang/rust/pull/117006#discussion_r1384153722 and saw a few things to simplify. This is two unrelated commits, both in the same file. Review them separately, if you'd like. r? estebank
2023-11-08Rollup merge of #117625 - nnethercote:clippy-perf, r=cuviperMatthias Krüger-8/+4
Fix some clippy perf lints `@matthiaskrgr` gave me the output of a clippy run with perf lints enabled. This PR fixes ones that I thought were worth fixing. r? `@cuviper`
2023-11-08Rollup merge of #116399 - WaffleLapkin:erase_small_things, r=cjgillotMatthias Krüger-6/+16
Small changes w/ `query::Erase<_>` r? `@cjgillot` cc `@Zoxc`
2023-11-08Rollup merge of #113925 - clubby789:const-ctor-repeat, r=estebankMatthias Krüger-19/+71
Improve diagnostic for const ctors in array repeat expressions Fixes #113912
2023-11-07Add -Zcross-crate-inline-threshold=yesBen Kimock-13/+55
2023-11-08rustc: minor changes suggested by clippy perf lints.Nicholas Nethercote-8/+4
2023-11-07Add an explanation for `transmute_unchecked`Maybe Waffle-0/+9
2023-11-07Rollup merge of #117675 - zmodem:vectorize_h, r=durin42Matthias Krüger-1/+0
llvm-wrapper: Remove include of non-existant Vectorize.h LLVM recently removed the header: https://github.com/llvm/llvm-project/commit/2400c54c37d5afdfec016b9a71f161ac10a49b31 It only contained a declaration of `createLoadStoreVectorizerPass()`, which Rust doesn't reference.
2023-11-07Rollup merge of #117616 - RalfJung:unstable-target-features, r=compiler-errorsMatthias Krüger-21/+50
warn when using an unstable feature with -Ctarget-feature Setting or unsetting the wrong target features can cause ABI incompatibility (https://github.com/rust-lang/rust/issues/116344, https://github.com/rust-lang/rust/issues/116558). We need to carefully audit features for their ABI impact before stabilization. I just learned that we currently accept arbitrary unstable features on stable and if they are in the list of Rust target features, even unstable, then we don't even warn about that!1 That doesn't seem great, so I propose we introduce a warning here. This has an obvious loophole via `-Ctarget-cpu`. I'm not sure how to best deal with that, but it seems better to fix what we can and think about the other cases later, maybe once we have a better idea for how to resolve the general mess that are ABI-affecting target features.
2023-11-07Rollup merge of #115485 - DaniPopes:rustdoc-macro-consts, r=jackh726,fmeaseMatthias Krüger-15/+17
Format macro const literals with pretty printer Fixes #115295
2023-11-07llvm-wrapper: Remove include of non-existant Vectorize.hHans Wennborg-1/+0
2023-11-07Auto merge of #117297 - clubby789:fn-trait-missing-paren, r=TaKO8Kibors-0/+46
Give a better diagnostic for missing parens in Fn* bounds Fixes #108109 It would be nice to try and recover here, but I'm not sure it's worth the effort, especially as the bounds on the recovered function would be incorrect.
2023-11-07Auto merge of #117229 - matthewjasper:thir-unsafeck-fixes, r=cjgillotbors-20/+126
Thir unsafeck fixes - Recognise thread local statics in THIR unsafeck - Add suggestion for unsafe_op_in_unsafe_fn - Fix unsafe checking of let expressions
2023-11-07Auto merge of #117610 - compiler-errors:object-hmm, r=aliemjaybors-14/+7
Only instantiate binder during dyn's built-in trait candidate probe once See UI test for demonstration of the issue. This was "caused" by #117131, but only because we're using the `normalize_param_env` (which has been augmented with a projection clause used to normalize GATs) which features non-lifetime bound vars in it. Fixes #117602 technically, though that's also fixed by #117542. r? types
2023-11-07Auto merge of #117418 - compiler-errors:better_error_body, r=oli-obkbors-29/+59
Build a better MIR body when errors are encountered Doesn't really have much of an effect on its own, but it does lead to a less confusing phony MIR body being generated when an error is detected during THIR/MIR/match building. This was quite confusing when I hacked `-Zunpretty=mir` to emit `mir_built` rather than `instance_mir`. This coincidentually also fixes #117413, but not as generally as #117416. cc `@Nadrieril`
2023-11-07Rework print_disambiguation_helpMichael Goulet-73/+53
2023-11-07Yeet MethodCallComponentsMichael Goulet-90/+90
2023-11-07Auto merge of #117006 - estebank:issue-69512, r=compiler-errorsbors-0/+88
When not finding assoc fn on type, look for builder fn When we have a resolution error when looking at a fully qualified path on a type, look for all associated functions on inherent impls that return `Self` and mention them to the user. ``` error[E0599]: no function or associated item named `new` found for struct `TcpStream` in the current scope --> tests/ui/resolve/fn-new-doesnt-exist.rs:4:28 | 4 | let stream = TcpStream::new(); | ^^^ function or associated item not found in `TcpStream` | note: if you're trying to build a new `TcpStream` consider using one of the following associated functions: TcpStream::connect TcpStream::connect_timeout --> /home/gh-estebank/rust/library/std/src/net/tcp.rs:156:5 | 156 | pub fn connect<A: ToSocketAddrs>(addr: A) -> io::Result<TcpStream> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 172 | pub fn connect_timeout(addr: &SocketAddr, timeout: Duration) -> io::Result<TcpStream> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` Fix #69512.
2023-11-07When not finding assoc fn on type, look for builder fnEsteban Küber-0/+88
When we have a resolution error when looking at a fully qualified path on a type, look for all associated functions on inherent impls that return `Self` and mention them to the user. Fix #69512.
2023-11-07Auto merge of #117511 - gurry:117406-err-packed-structs, r=compiler-errorsbors-1/+19
Emit explanatory note for move errors in packed struct derives Derive expansions for packed structs with non-`Copy` fields cause move errors because they prefer copying over borrowing since borrowing the fields of a packed struct can result in unaligned access. This underlying cause of the errors, however, is not apparent to the user. This PR adds a diagnostic note to make it clear to the user (the new note is on the second last line): ``` tests/ui/derives/deriving-with-repr-packed-move-errors.rs:13:16 | 12 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)] | ----- in this derive macro expansion 13 | struct StructA(String); | ^^^^^^ move occurs because `self.0` has type `String`, which does not implement the `Copy` trait | = note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) ``` Fixes #117406 Partially addresses #110777
2023-11-06Build a better MIR body when errors are encounteredMichael Goulet-29/+59
2023-11-06Don't instantiate the binder twice when assembling object candidateMichael Goulet-17/+7
2023-11-06Only check predicates for late-bound non-lifetime vars in object candidate ↵Michael Goulet-1/+4
assembly
2023-11-06Auto merge of #117641 - matthiaskrgr:rollup-f9c12td, r=matthiaskrgrbors-1/+2
Rollup of 4 pull requests Successful merges: - #117190 (add test for #113381) - #117516 (add test for #113375) - #117631 (Documentation cleanup for core::error::Request.) - #117637 (Check binders with bound vars for global bounds that don't hold) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-06Rollup merge of #117637 - lqd:trivial-bounds-with-binder-vars, r=compiler-errorsMatthias Krüger-1/+2
Check binders with bound vars for global bounds that don't hold This fixes `soa_derive-0.13.0` from #117589's crater run. r? `@compiler-errors`
2023-11-06Auto merge of #117292 - estebank:issue-80446, r=davidtwcobors-0/+34
Detect misparsed binop caused by missing semi When encountering ```rust foo() *bar = baz; ``` We currently emit potentially two errors, one for the return type of `foo` not being multiplicative by the type of `bar`, and another for `foo() * bar` not being assignable. We now check for this case and suggest adding a semicolon in the right place and emit only a single error. Fix #80446.
2023-11-06Silence redundant error on typo resulting on binopEsteban Küber-15/+12
2023-11-06Visit patterns in THIR let expressionsMatthew Jasper-9/+2
This fixes some THIR unsafety checking errors not being emitted for let expressions in these situations.
2023-11-06Add suggestion to THIR unsafe_op_in_unsafe_fn lintMatthew Jasper-10/+121
2023-11-06Recognise thread local statics in THIR unsafeckMatthew Jasper-1/+3
2023-11-06Auto merge of #117603 - HKalbasi:make-feature-additive, r=Nilstriebbors-9/+7
Make the randomize feature of rustc_abi additive The goal here is to make rust-analyzer able to build with the `rustc_private` versions of the rustc crates it depends on. See #116847
2023-11-06check binders with bound vars for global bounds that don't holdRémy Rakic-1/+2
(instead of just late bound vars)
2023-11-06Auto merge of #117630 - matthiaskrgr:rollup-v0d5p3f, r=matthiaskrgrbors-12/+12
Rollup of 3 pull requests Successful merges: - #117592 (Use the correct span when emitting the `env!` result) - #117613 (Remove from vacation and compiler review group) - #117615 (Couple of small changes) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-06Rollup merge of #117615 - bjorn3:misc_changes, r=davidtwcoMatthias Krüger-11/+11
Couple of small changes These are unrelated to each other, but they are each small enough that opening separate PR's doesn't make sense to me either. * Remove a place where the parse driver query is stolen. * Update an outdated doc comment * Use correct crate name in `-Zprint-vtable-sizes` when using `#![crate_name = "..."]`.
2023-11-06Rollup merge of #117592 - thomcc:env-span-wrong, r=davidtwcoMatthias Krüger-1/+1
Use the correct span when emitting the `env!` result The span used for the `env!` resut changed in 1.73, due to https://github.com/rust-lang/rust/commit/75df62d4a2c45175b8cb1eb4bdc10fa423c11c4c (from https://github.com/rust-lang/rust/pull/114014). This prevents [a lint in `plrustc`](https://github.com/tcdi/plrust/blob/main/plrustc/plrustc/src/lints/builtin_macros.rs#L54-L60)[^1] from working well, because the resulting span is not inside the region where the lint is `#[deny()]`ed. [^1]: Perhaps worth noting that the `env_macro` diagnostic item comes from [the std fork used with PL/Rust](https://github.com/tcdi/postgrestd/blob/rust-1.73.0/library/core/src/macros/mod.rs#L944). Unfortunately, I have no idea how to write a test for this since I don't think we can have a custom lint in a test. A suggestion was made to use a custom proc macro for it, but that seems pretty involved (frankly, I might not have time to do it). r? ``@davidtwco`` (since they're the author of the PR with the regression) P.S. We generally try to avoid bothering upstream about PL/Rust-specific stuff (we don't want to nag), but this seems like an actual bug, since the other similar macros, such as `option_env` use the other span (and are lintable as a result).
2023-11-06Auto merge of #117578 - compiler-errors:derive-encode-in-rustc_type_ir, ↵bors-486/+31
r=davidtwco Derive `TyEncodable`/`TyDecodable` in `rustc_type_ir` when `derive(TyEncodable)` or `derive(TyDecodable)` sees an `I` type parameter on a struct that has no `'tcx`, then parameterize the `TyEncoder`/`TyDecoder`'s interner over that variable rather than `TyCtxt<'tcx>`. Also, emit where clauses for fields rather than generics.
2023-11-06warn when using an unstable feature with -Ctarget-featureRalf Jung-21/+50