about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-06-06Rollup merge of #126103 - veera-sivarajan:improve-docs-hir-impl, r=fmeaseJubilee-1/+7
Improve Docs for `hir::Impl` and `hir::ImplItem` Based on https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20Difference.20between.20.60hir.3A.3AImplItem.60.20and.20.60hir.3A.3AImpl.60.3F/near/442650915 r​? fmease
2024-06-06Rollup merge of #126101 - lqd:revert-124099, r=wesleywiserJubilee-30/+13
Revert "Disallow ambiguous attributes on expressions" on nightly As discussed in [today's t-compiler meeting](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-06-06/near/443079505), this reverts PR #124099 to fix P-critical beta regressions #125199. r? ``@wesleywiser`` Opening as draft so that ``@wesleywiser`` and ``@apiraino,`` you can tell me whether you wanted: 1. a `beta-accepted` revert of #124099 on nightly (this PR)? That will need to be backported to beta (even though #126093 may be the last of those) 2. a revert of #124099 on beta? 3. all of the above? I also opened #126102, another draft PR to revert #124099 on beta, should you choose options 2 or 3.
2024-06-06Rollup merge of #126099 - Nilstrieb:crate-loader-cleanups, r=jieyouxuJubilee-38/+29
Crate loader cleanups Minor cleanups I found while trying to understand how all of this works
2024-06-06Rollup merge of #126040 - Urgau:unreachable_pub-fields-less, r=petrochenkovJubilee-6/+15
Don't warn on fields in the `unreachable_pub` lint This PR restrict the `unreachable_pub` lint by not linting on `pub` fields of `pub(restricted)` structs and unions. This is done because that can quickly clutter the code for an uncertain value, in particular since the "real" visibility is defined by the parent (the struct it-self). This is meant to address one of the last concern of the `unreachable_pub` lint. r? ``@petrochenkov``
2024-06-06Rollup merge of #125724 - compiler-errors:uplift-relate, r=lcnrJubilee-1063/+1331
Uplift `Relate`/`TypeRelation` into `rustc_next_trait_solver` For use in the new solver. This doesn't yet uplift `ObligationEmittingRelation`. r? lcnr
2024-06-06Improve Docs for `hir::Impl` and `hir::ImplItem`Veera-1/+7
2024-06-06Auto merge of #126104 - workingjubilee:rollup-t1ac2ld, r=workingjubileebors-5/+20
Rollup of 12 pull requests Successful merges: - #125220 (Repair several `riscv64gc-unknown-linux-gnu` codegen tests) - #126033 (CI: fix publishing of toolstate history) - #126034 (Clarify our tier 1 Windows Server support) - #126035 (Some minor query system cleanups) - #126051 (Clarify an `x fmt` error.) - #126059 (Raise `DEFAULT_MIN_STACK_SIZE` to at least 64KiB) - #126064 (Migrate `run-make/manual-crate-name` to `rmake.rs`) - #126072 (compiletest: Allow multiple `//@ run-flags:` headers) - #126073 (Port `tests/run-make-fulldeps/obtain-borrowck` to ui-fulldeps) - #126081 (Do not use relative paths to Rust source root in run-make tests) - #126086 (use windows compatible executable name for libcxx-version) - #126096 ([RFC-2011] Allow `core_intrinsics` when activated) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-06Rollup merge of #126096 - c410-f3r:tests-tests-tests, r=jhprattJubilee-1/+0
[RFC-2011] Allow `core_intrinsics` when activated Fix #120612
2024-06-06Rollup merge of #126035 - oli-obk:query_macro_errors, r=fmeaseJubilee-4/+20
Some minor query system cleanups * Improves diagnostics on conflicting query flags * removes unnecessary impls * `track_caller` pulled out of https://github.com/rust-lang/rust/pull/115613
2024-06-06Revert "Rollup merge of #124099 - voidc:disallow-ambiguous-expr-attrs, ↵Rémy Rakic-30/+13
r=davidtwco" This reverts commit 57dad1d75e562ff73051c1c43b07eaf65c7dbd74, reversing changes made to 36316df9fe6c3e246153fe6e78967643cf08c148.
2024-06-06Auto merge of #126068 - lqd:revert-124976, r=petrochenkovbors-45/+31
Revert "use `tcx.used_crates(())` more" before it reaches beta There are more open issues caused by #124976 than will be fixed by #125493 alone. The beta cut is soon, so let's revert it and buy some time to analyze and fix these issues in our own time. fixes https://github.com/rust-lang/rust/issues/125474 fixes https://github.com/rust-lang/rust/issues/125484 fixes https://github.com/rust-lang/rust/issues/125646 fixes https://github.com/rust-lang/rust/issues/125707 fixes #126066 fixes #125934 fixes https://github.com/rust-lang/rust/issues/126021 r? `@petrochenkov` `@bors` p=1
2024-06-06Improve naming and path operations in crate loaderNilstrieb-18/+14
Simplify the path operation with `join`, clarify some of the names.
2024-06-06Simplify string operations in crate loaderNilstrieb-6/+12
2024-06-06Remove constant parameter from `CrateLocator::new`Nilstrieb-14/+3
2024-06-06[RFC-2011] Allow `core_intrinsics` when activatedCaio-1/+0
2024-06-06Don't warn on fields in the `unreachable_pub` lintUrgau-6/+15
2024-06-06Uplift TypeRelation and RelateMichael Goulet-864/+1110
2024-06-06Uplift TypeErrorMichael Goulet-193/+216
2024-06-06Make middle not rely on next_trait_solverMichael Goulet-6/+5
2024-06-06Auto merge of #125406 - tbu-:pr_rm_path_with_extension, r=Nadrierilbors-7/+2
Directly add extension instead of using `Path::with_extension` `Path::with_extension` has a nice footgun when the original path doesn't contain an extension: Anything after the last dot gets removed.
2024-06-06Revert "Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk"Rémy Rakic-45/+31
This reverts commit eda4a35f365535af72118118a3597edf5a13c12d, reversing changes made to eb6b35b5bcb3c2a594cb29cd478aeb2893f49d30.
2024-06-06Make the panic info more usefulOli Scherer-4/+20
2024-06-06Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obkbors-83/+305
Unsafe extern blocks This implements RFC 3484. Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484 This is better reviewed commit by commit.
2024-06-06Auto merge of #126056 - matthiaskrgr:rollup-ytwg62v, r=matthiaskrgrbors-129/+136
Rollup of 6 pull requests Successful merges: - #124731 (Add translation support by mdbook-i18n-helpers to bootstrap) - #125168 (Match ergonomics 2024: align implementation with RFC) - #125925 (Don't trigger `unsafe_op_in_unsafe_fn` for deprecated safe fns) - #125987 (When `derive`ing, account for HRTB on `BareFn` fields) - #126045 (check_expr_struct_fields: taint context with errors if struct definit…) - #126048 (Fix typos in cargo-specifics.md) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-06Auto merge of #125958 - BoxyUwU:remove_const_ty, r=lcnrbors-873/+703
Remove the `ty` field from type system `Const`s Fixes #125556 Fixes #122908 Part of the work on `adt_const_params`/`generic_const_param_types`/`min_generic_const_exprs`/generally making the compiler nicer. cc rust-lang/project-const-generics#44 Please review commit-by-commit otherwise I wasted a lot of time not just squashing this into a giant mess (and also it'll be SO much nicer because theres a lot of fluff changes mixed in with other more careful changes if looking via File Changes --- Why do this? - The `ty` field keeps causing ICEs and weird behaviour due to it either being treated as "part of the const" or it being forgotten about leading to ICEs. - As we move forward with `adt_const_params` and a potential `min_generic_const_exprs` it's going to become more complex to actually lower the correct `Ty<'tcx>` - It muddles the idea behind how we check `Const` arguments have the correct type. By having the `ty` field it may seem like we ought to be relating it when we relate two types, or that its generally important information about the `Const`. - Brings the compiler more in line with `a-mir-formality` as that also tracks the type of type system `Const`s via `ConstArgHasType` bounds in the env instead of on the `Const` itself. - A lot of stuff is a lot nicer when you dont have to pass around the type of a const lol. Everywhere we construct `Const` is now significantly nicer :sweat_smile: See #125671's description for some more information about the `ty` field --- General summary of changes in this PR: - Add `Ty` to `ConstKind::Value` as otherwise there is no way to implement `ConstArgHasType` to ensure that const arguments are correctly typed for the parameter when we stop creating anon consts for all const args. It's also just incredibly difficult/annoying to thread the correct `Ty` around to a bunch of ctfe functions otherwise. - Fully implement `ConstArgHasType` in both the old and new solver. Since it now has no reliance on the `ty` field it serves its originally intended purpose of being able to act as a double check that trait vs impls have correctly typed const parameters. It also will now be able to be responsible for checking types of const arguments to parameters under `min_generic_const_exprs`. - Add `Ty` to `mir::Const::Ty`. I dont have a great understanding of why mir constants are setup like this to be honest. Regardless they need to be able to determine the type of the const and the easiest way to make this happen was to simply store the `Ty` along side the `ty::Const`. Maybe we can do better here in the future but I'd have to spend way more time looking at everywhere we use `mir::Const`. - rustdoc has its own `Const` which also has a `ty` field. It was relatively easy to remove this. --- r? `@lcnr` `@compiler-errors`
2024-06-06Rollup merge of #126045 - olafes:master, r=compiler-errorsMatthias Krüger-0/+9
check_expr_struct_fields: taint context with errors if struct definit… Taint errors while checking `struct { field: 1 }` below if struct definition has duplicated fields so that we don't pass it to const eval. fixes #125842, fixes #124464, fixes #124552 ```rust struct Struct { field: Option<u8>, field: u8, } static STATIC: Struct = Struct { field: 1, }; pub fn main() {} ``` (This was #125947 but i messed something up, sorry) r? ``@compiler-errors``
2024-06-06Rollup merge of #125987 - estebank:issue-122622, r=NadrierilMatthias Krüger-1/+11
When `derive`ing, account for HRTB on `BareFn` fields When given ```rust trait SomeTrait { type SomeType<'a>; } #[derive(Clone)] struct Foo<T: SomeTrait> { x: for<'a> fn(T::SomeType<'a>) } ``` expand to ```rust impl<T: ::core::clone::Clone + SomeTrait> ::core::clone::Clone for Foo<T> where for<'a> T::SomeType<'a>: ::core::clone::Clone { #[inline] fn clone(&self) -> Foo<T> { Foo { x: ::core::clone::Clone::clone(&self.x) } } } ``` instead of the previous invalid ``` impl<T: ::core::clone::Clone + SomeTrait> ::core::clone::Clone for Foo<T> where T::SomeType<'a>: ::core::clone::Clone { #[inline] fn clone(&self) -> Foo<T> { Foo { x: ::core::clone::Clone::clone(&self.x) } } } ``` Fix #122622. <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> -->
2024-06-06Rollup merge of #125925 - tbu-:pr_unsafe_env_unsafe_op_in_unsafe_fn, r=NadrierilMatthias Krüger-34/+47
Don't trigger `unsafe_op_in_unsafe_fn` for deprecated safe fns Fixes #125875. Tracking: - #124866
2024-06-06Rollup merge of #125168 - ↵Matthias Krüger-94/+69
Jules-Bertholet:match-ergonomics-2024-align-with-rfc, r=Nadrieril Match ergonomics 2024: align implementation with RFC - Remove eat-two-layers (`ref_pat_everywhere`) - Consolidate `mut_preserve_binding_mode_2024` into `ref_pat_eat_one_layer_2024` - `&mut` no longer peels off `&` - Apply "no `ref mut` behind `&`" rule on all editions with `ref_pat_eat_one_layer_2024` - Require `mut_ref` feature gate for all mutable by-reference bindings r? ``@Nadrieril`` cc https://github.com/rust-lang/rust/issues/123076 ``@rustbot`` label A-edition-2024 A-patterns
2024-06-06Auto merge of #122505 - oli-obk:visit_nested_body2, r=tmiaskobors-8/+38
Don't walk the bodies of free constants for reachability. follow-up to #122371 cc #119214 This avoids codegening items (e.g. functions) that are only used during const eval, but do not reach their final constant value (e.g. via function pointers). r? `@tmiasko`
2024-06-05Don't trigger `unsafe_op_in_unsafe_fn` for deprecated safe fnsTobias Bucher-34/+47
Fixes #125875.
2024-06-05ty::Expr reviewsBoxy-7/+11
2024-06-05Misc fixes (pattern type lowering, cfi, pretty printing)Boxy-40/+36
2024-06-05Misc fixes to cranelift/clippy/miriBoxy-0/+1
2024-06-05Add `Ty` to `mir::Const::Ty`Boxy-51/+81
2024-06-05Fully implement `ConstArgHasType`Boxy-103/+158
2024-06-05Add `Ty` to `ConstKind::Value`Boxy-189/+183
2024-06-05Basic removal of `Ty` from places (boring)Boxy-581/+331
2024-06-05Auto merge of #126038 - matthiaskrgr:rollup-h4rm3x2, r=matthiaskrgrbors-89/+140
Rollup of 9 pull requests Successful merges: - #124840 (resolve: mark it undetermined if single import is not has any bindings) - #125622 (Winnow private method candidates instead of assuming any candidate of the right name will apply) - #125648 (Remove unused(?) `~/rustsrc` folder from docker script) - #125672 (Add more ABI test cases to miri (RFC 3391)) - #125800 (Fix `mut` static task queue in SGX target) - #125871 (Orphanck[old solver]: Consider opaque types to never cover type parameters) - #125893 (Handle all GVN binops in a single place.) - #126008 (Port `tests/run-make-fulldeps/issue-19371` to ui-fulldeps) - #126032 (Update description of the `IsTerminal` example) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-05check_expr_struct_fields: taint context with errors if struct definition is ↵Olaf Siwiński-0/+9
malformed
2024-06-05Rollup merge of #125893 - cjgillot:gvn-newops, r=oli-obkMatthias Krüger-30/+40
Handle all GVN binops in a single place. <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> --> Addresses https://github.com/rust-lang/rust/pull/125359/files#r1608185319 r? ``@oli-obk``
2024-06-05Rollup merge of #125871 - fmease:fix-orphanck-opaques, r=lcnrMatthias Krüger-35/+24
Orphanck[old solver]: Consider opaque types to never cover type parameters This fixes an oversight of mine in #117164. The change itself has already been FCP'ed. This only affects the old solver, the next solver already correctly rejects the added test since #117164. r? ``@lcnr``
2024-06-05Rollup merge of #126022 - lcnr:generalize-alias-bivariant, r=compiler-errorsMatthias Krüger-2/+10
set `has_unconstrained_ty_var` when generalizing aliases in bivariant contexts this previously prevented the `regression-31157` benchmark from building r? `@compiler-errors`
2024-06-05Rollup merge of #125672 - Lokathor:update-miri-result-ffi, r=RalfJungMatthias Krüger-9/+22
Add more ABI test cases to miri (RFC 3391) Part of https://github.com/rust-lang/rust/issues/110503 cc `@RalfJung`
2024-06-05Rollup merge of #125921 - Zalathar:buckets, r=oli-obkMatthias Krüger-137/+237
coverage: Carve out hole spans in a separate early pass When extracting spans from MIR for use in coverage instrumentation, we sometimes need to identify *hole spans* (currently just closures), and carve up the other spans so that they don't overlap with holes. This PR simplifies the main coverage-span-refiner by extracting the hole-carving process into a separate early pass. That pass produces a series of independent buckets, and we run the span-refiner on each bucket separately. There is almost no difference in the resulting mappings, other than in some edge cases involving macros.
2024-06-05Rollup merge of #125622 - oli-obk:define_opaque_types15, r=compiler-errorsMatthias Krüger-11/+25
Winnow private method candidates instead of assuming any candidate of the right name will apply partially reverts https://github.com/rust-lang/rust/pull/60721 My original motivation was just to avoid the `delay_span_bug` (by attempting to thread the `ErrorGuaranteed` through to here). But then I realized that the error message is wrong. It refers to the `Foo<A>::foo` instead of `Foo<B>::foo`. This is almost invisible, because both functions are the same, but on different lines, so `-Zui-testing` makes it so the test is the same no matter which of these two functions is referenced. But there's a much more obvious bug: If `Foo<B>` does not have a `foo` method at all, but `Foo<A>` has a private `foo` method, then we'll refer to that one. This has now been fixed, and we report a normal `method not found` error. The way this is done is by creating a list of all possible private functions (just like we create a list of the public functions that can actually be called), and then winnowing it by analyzing where bounds and `Self` types to see if any of the found methods can actually apply (again, just like with the list of public functions). I wonder if there is room for doing the same thing with unstable functions instead of running all of method resolution twice. r? ``@compiler-errors`` for method resolution stuff
2024-06-05Rollup merge of #124840 - bvanjoi:fix-124490, r=petrochenkovMatthias Krüger-4/+29
resolve: mark it undetermined if single import is not has any bindings - Fixes #124490 - Fixes #125013 This issue arises from incorrect resolution updates, for example: ```rust mod a { pub mod b { pub mod c {} } } use a::*; use b::c; use c as b; fn main() {} ``` 1. In the first loop, binding `(root, b)` is refer to `root::a::b` due to `use a::*`. 1. However, binding `(root, c)` isn't defined by `use b::c` during this stage because `use c as b` falls under the `single_imports` of `(root, b)`, where the `imported_module` hasn't been computed yet. This results in marking the `path_res` for `b` as `Indeterminate`. 2. Then, the `imported_module` for `use c as b` will be recorded. 2. In the second loop, `use b::c` will be processed again: 1. Firstly, it attempts to find the `path_res` for `(root, b)`. 2. It will iterate through the `single_imports` of `use b::c`, encounter `use c as b`, attempt to resolve `c` in `root`, and ultimately return `Err(Undetermined)`, thus passing the iterator. 3. Use the binding `(root, b)` -> `root::a::b` introduced by `use a::*` and ultimately return `root::a::b` as the `path_res` of `b`. 4. Then define the binding `(root, c)` -> `root::a::b::c`. 3. Then process `use c as b`, update the resolution for `(root, b)` to refer to `root::a::b::c`, ultimately causing inconsistency. In my view, step `2.2` has an issue where it should exit early, similar to the behavior when there's no `imported_module`. Therefore, I've added an attribute called `indeterminate` to `ImportData`. This will help us handle only those single imports that have at least one determined binding. r? ``@petrochenkov``
2024-06-05Rollup merge of #125861 - name1e5s:fix/rpath_null_panic, r=michaelwoeristerMatthias Krüger-0/+21
rustc_codegen_ssa: fix `get_rpath_relative_to_output` panic when lib only contains file name <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> --> When compiles program with `-C rpath=yes` but with no output filename specified, or with filename ONLY, we will get an ICE for now. Fix it by treat empty `output` path in `get_rpath_relative_to_output` as current dir. Before this patch: ```bash rustc -C prefer_dynamic=yes -C rpath=yes -O h.rs # ICE, no output filename specified rustc -o hello -C prefer_dynamic=yes -C rpath=yes -O h.rs # ICE, output filename has no path rustc -o ./hello -C prefer_dynamic=yes -C rpath=yes -O h.rs # Works ``` All those examples work after the patch. Close #119571. Close #125785.
2024-06-05Rollup merge of #125819 - oli-obk:localize, r=fmeaseMatthias Krüger-210/+221
Various `HirTyLowerer` cleanups Previously there was some ad-hoc specialization going on, because you could call `allows_infer`, which basically was deciding between whether the trait object was backed by `FnCtxt` or by `ItemCtxt`. I moved all the different logic into dedicated methods on `HirTyLowerer` and removed `allows_infer` best reviewed commit-by-commit
2024-06-05Rollup merge of #125792 - compiler-errors:dont-drop-upcast-cand, r=lcnrMatthias Krüger-0/+6
Don't drop `Unsize` candidate in intercrate mode Fixes #125767