about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2023-12-07Add tests to allocation methods and fix is_null()Celina G. Val-7/+114
2023-12-07Fix conversion to StaticDef and add testCelina G. Val-2/+18
2023-12-07Add instance evaluation and methods to read allocCelina G. Val-22/+295
The instance evaluation is needed to handle intrinsics such as `type_id` and `type_name`. Since we now use Allocation to represent all evaluated constants, provide a few methods to help process the data inside an allocation.
2023-12-08add regression testslcnr-0/+43
2023-12-08implement and use `NormalizesTo`lcnr-125/+135
2023-12-07Build Fuchsia in CITyler Mandry-11/+144
2023-12-08Auto merge of #118442 - tmiasko:fuel-inc, r=lqdbors-11/+22
-Zfuel is incompatible with incremental compilation
2023-12-08Fuel is incompatible with incremental compilationTomasz Miąsko-1/+16
2023-12-08Tweak `GenKillAnalysis`.Nicholas Nethercote-21/+24
`GenKillAnalysis` has five methods that take a transfer function arg: - `statement_effect` - `before_statement_effect` - `terminator_effect` - `before_terminator_effect` - `call_return_effect` All the transfer function args have type `&mut impl GenKill<Self::Idx>`, except for `terminator_effect`, which takes the simpler `Self::Domain`. But only the first two need to be `impl GenKill`. The other three can all be `Self::Domain`, just like `Analysis`. So this commit changes the last two to take `Self::Domain`, making `GenKillAnalysis` and `Analysis` more similar. (Another idea would be to make all these methods `impl GenKill`. But that doesn't work: `MaybeInitializedPlaces::terminator_effect` requires the arg be `Self::Domain` so that `self_is_unwind_dead(place, state)` can be called on it.)
2023-12-08Remove `BorrowckAnalyses`.Nicholas Nethercote-28/+18
This results in two non-generic types being used: `BorrowckResults` and `BorrowckFlowState`. It's a net reduction in lines of code, and a little easier to read.
2023-12-07Auto merge of #118723 - matthiaskrgr:rollup-409e9u1, r=matthiaskrgrbors-97/+310
Rollup of 6 pull requests Successful merges: - #116420 (discard invalid spans in external blocks) - #118686 (Only check principal trait ref for object safety) - #118688 (Add method to get type of an Rvalue in StableMIR) - #118707 (Ping GuillaumeGomez for changes in rustc_codegen_gcc) - #118712 (targets: remove not-added {i386,i486}-unknown-linux-gnu) - #118719 (CFI: Add char to CFI integer normalization) Failed merges: - #117586 (Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-07Inline check_thread_count implementationTomasz Miąsko-11/+7
2023-12-07Auto merge of #16028 - Young-Flash:fix-issue-16012, r=HKalbasibors-4/+18
fix: make drop inlay hint more readable ![drop_inlay_hint](https://github.com/rust-lang/rust-analyzer/assets/71162630/bb18707f-3278-435d-a938-ccff4c685586) follow up https://github.com/rust-lang/rust-analyzer/pull/16000, close https://github.com/rust-lang/rust-analyzer/issues/16012
2023-12-07Resolve assoc item bindings by namespaceLeón Orell Valerian Liehr-416/+598
If a const is expected, resolve a const. If a type is expected, resolve a type. Don't try to resolve a type first falling back to consts.
2023-12-07Auto merge of #16045 - HKalbasi:rustc-tests-fixup, r=HKalbasibors-3/+27
Fix panic with closure inside array len I was working on #15947 and found out that we panic on this test: ``` fn main() { let x = [(); &(&'static: loop { |x| {}; }) as *const _ as usize] } ``` This PR fixes the panic. Closures in array len are still broken, but closure in const eval is not stable anyway.
2023-12-08Fix panic with closure inside array lenhkalbasi-3/+27
2023-12-08Remove `impl_visitable!`.Nicholas Nethercote-67/+64
It is used just once. With it removed, the relevant code is a little boilerplate-y but much easier to read, and is the same length. Overall I think it's an improvement.
2023-12-08Remove unused arguments from `ResultsVisitor::visit_block_{start,end}`.Nicholas Nethercote-34/+8
2023-12-08OnceLock: Rework example, statics aren't droppedIan Rees-14/+25
2023-12-07Rollup merge of #118719 - rcvalle:rust-cfi-normalize-integers-118032, ↵Matthias Krüger-63/+29
r=compiler-errors CFI: Add char to CFI integer normalization Adds char to CFI integer normalization to conform to #118032 for cross-language CFI support.
2023-12-07Rollup merge of #118712 - davidtwco:targets-remove-i386-i486, r=compiler-errorsMatthias Krüger-16/+0
targets: remove not-added {i386,i486}-unknown-linux-gnu These files were added to the repository but never wired up so they could be used - and that was a few years ago without anyone noticing - so let's remove these, they can be re-added if someone wants them. cc #80662 r? ```@pnkfelix``` (familiar with the tier policy and Wesley is on vacation)
2023-12-07Rollup merge of #118707 - GuillaumeGomez:ping-cg_gcc, r=antoyoMatthias Krüger-1/+1
Ping GuillaumeGomez for changes in rustc_codegen_gcc Since I work on it and also added its testsuite into rustc's CI, I'd like to know if there are changes.
2023-12-07Rollup merge of #118688 - celinval:smir-rvalue-ty, r=compiler-errorsMatthias Krüger-5/+202
Add method to get type of an Rvalue in StableMIR Provide a method to StableMIR users to retrieve the type of an Rvalue operation. There were two possible implementation: 1. Create the logic inside stable_mir to process the type according to the Rvalue semantics, which duplicates the logic of `rustc_middle::mir::Rvalue::ty()`. 2. Implement the Rvalue translation from StableMIR back to internal representation, invoke the `rustc_middle::mir::Rvalue::ty()`, and translate the return value to StableMIR. I chose the first one for now since the duplication was fairly small, and the option 2 would require way more work to translate everything back to rustc internal representation. If we eventually add those translations, we could easily swap to the option 2. ```@compiler-errors``` / ```@ouz-a``` Please let me know if you have any strong opinion here. r? ```@compiler-errors```
2023-12-07Rollup merge of #118686 - compiler-errors:object-safety, r=lcnrMatthias Krüger-10/+7
Only check principal trait ref for object safety It should make things a bit faster, in case we end up registering a bunch of object safety preds. r? ```@ghost```
2023-12-07Rollup merge of #116420 - bvanjoi:fix-116203, r=NilstriebMatthias Krüger-2/+71
discard invalid spans in external blocks Fixes #116203 This PR has discarded the invalid `const_span`, thereby making the format more neat. r? ``@Nilstrieb``
2023-12-07Auto merge of #118568 - DianQK:no-builtins-symbols, r=pnkfelixbors-4/+30
Avoid adding builtin functions to `symbols.o` We found performance regressions in #113923. The problem seems to be that `--gc-sections` does not remove these symbols. I tested that lld removes these symbols, but ld and gold do not. I found that `used` adds symbols to `symbols.o` at https://github.com/rust-lang/rust/blob/3e202ead604be31f4c1a5798a296953d3159da7e/compiler/rustc_codegen_ssa/src/back/linker.rs#L1786-L1791. The PR removes builtin functions. Note that under LTO, ld still preserves these symbols. (lld will still remove them.) The first commit also fixes #118559. But I think the second commit also makes sense.
2023-12-07rustdoc: remove unused parameter `reversed` from onEach(Lazy)Michael Howell-19/+6
This feature was added in edec5807ac5ba90cbc0c61a5ec7b80f29e1eea33 to support JavaScript-based toggles that were later replaced with HTML `<details>`.
2023-12-07CFI: Add char to CFI integer normalizationRamon de C Valle-63/+29
Adds char to CFI integer normalization to conform to #118032 for cross-language CFI support.
2023-12-07Explicitly implement `DynSync` and `DynSend` for `TyCtxt`John Kåre Alsaker-1/+13
2023-12-07Fix rustc test suitebjorn3-0/+2
2023-12-07Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlinbors-2/+4
compile-time evaluation: detect writes through immutable pointers This has two motivations: - it unblocks https://github.com/rust-lang/rust/pull/116745 (and therefore takes a big step towards `const_mut_refs` stabilization), because we can now detect if the memory that we find in `const` can be interned as "immutable" - it would detect the UB that was uncovered in https://github.com/rust-lang/rust/pull/117905, which was caused by accidental stabilization of `copy` functions in `const` that can only be called with UB When UB is detected, we emit a future-compat warn-by-default lint. This is not a breaking change, so completely in line with [the const-UB RFC](https://rust-lang.github.io/rfcs/3016-const-ub.html), meaning we don't need t-lang FCP here. I made the lint immediately show up for dependencies since it is nearly impossible to even trigger this lint without `const_mut_refs` -- the accidentally stabilized `copy` functions are the only way this can happen, so the crates that popped up in #117905 are the only causes of such UB (in the code that crater covers), and the three cases of UB that we know about have all been fixed in their respective crates already. The way this is implemented is by making use of the fact that our interpreter is already generic over the notion of provenance. For CTFE we now use the new `CtfeProvenance` type which is conceptually an `AllocId` plus a boolean `immutable` flag (but packed for a more efficient representation). This means we can mark a pointer as immutable when it is created as a shared reference. The flag will be propagated to all pointers derived from this one. We can then check the immutable flag on each write to reject writes through immutable pointers. I just hope perf works out.
2023-12-07Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlinbors-462/+784
compile-time evaluation: detect writes through immutable pointers This has two motivations: - it unblocks https://github.com/rust-lang/rust/pull/116745 (and therefore takes a big step towards `const_mut_refs` stabilization), because we can now detect if the memory that we find in `const` can be interned as "immutable" - it would detect the UB that was uncovered in https://github.com/rust-lang/rust/pull/117905, which was caused by accidental stabilization of `copy` functions in `const` that can only be called with UB When UB is detected, we emit a future-compat warn-by-default lint. This is not a breaking change, so completely in line with [the const-UB RFC](https://rust-lang.github.io/rfcs/3016-const-ub.html), meaning we don't need t-lang FCP here. I made the lint immediately show up for dependencies since it is nearly impossible to even trigger this lint without `const_mut_refs` -- the accidentally stabilized `copy` functions are the only way this can happen, so the crates that popped up in #117905 are the only causes of such UB (in the code that crater covers), and the three cases of UB that we know about have all been fixed in their respective crates already. The way this is implemented is by making use of the fact that our interpreter is already generic over the notion of provenance. For CTFE we now use the new `CtfeProvenance` type which is conceptually an `AllocId` plus a boolean `immutable` flag (but packed for a more efficient representation). This means we can mark a pointer as immutable when it is created as a shared reference. The flag will be propagated to all pointers derived from this one. We can then check the immutable flag on each write to reject writes through immutable pointers. I just hope perf works out.
2023-12-07Auto merge of #16009 - werifu:fix-extract-function, r=Veykrilbors-1/+27
fix: bug in extract_function.rs There is a little bug in extract_function: It appends `use path::to::ControlFlow;` if the function created contains string "ControlFlow". A case below (also in the test named `does_not_import_control_flow` which will fail in the original code) <img width="322" alt="image" src="https://github.com/rust-lang/rust-analyzer/assets/53432474/4b80bb58-0cfd-4d56-b64c-d9649eed336e"> <img width="391" alt="image" src="https://github.com/rust-lang/rust-analyzer/assets/53432474/3d7262f4-8a4c-44ea-822d-304b8b23fe28"> Now I have changed the condition determining whether adding import statement. Only when the new function body contains ControlFlow::Break or ControlFlow::Continue can the import statement be added. Last related PR: https://github.com/rust-lang/rust-analyzer/pull/10309
2023-12-07add unused `NormalizesTo` predicatelcnr-64/+128
2023-12-07Fix testing of portable-simdbjorn3-0/+29
2023-12-07avoid marking as immutable what is already immutableRalf Jung-6/+16
this has been demonstrated to help performance
2023-12-07ctfe interpreter: extend provenance so that it can track whether a pointer ↵Ralf Jung-2/+4
is immutable
2023-12-07also print 'immutable' flagRalf Jung-138/+139
2023-12-07compile-time evaluation: emit a lint when a write through an immutable ↵Ralf Jung-185/+380
pointer occurs
2023-12-07ctfe interpreter: extend provenance so that it can track whether a pointer ↵Ralf Jung-145/+261
is immutable
2023-12-07Fix const drop checkingMichael Goulet-67/+57
2023-12-07Auto merge of #16041 - roife:fix-line-index-widechar, r=Veykrilbors-3/+30
Fix WideChar offsets calculation in `line-index` Fix #15981. This PR addresses the issue with the WideChar's offset calculation, ensuring accurate line-specific positions during text analysis in the `lib/line-index` module. ## Changes Made - Corrected the calculation for `WideChar` offsets, ensuring they reflect positions within respective lines. - Added tests to verify the accuracy of `WideChar` offset calculations, and correct existing tests.
2023-12-07Auto merge of #118706 - Urgau:update-rccg-gcc-libc, r=GuillaumeGomezbors-2/+3
Fix `rustc_codegen_gcc` build and tests failure in CI https://github.com/rust-lang/rust/pull/118463 seems to have broke the PR CI, more specificaly the `x86_64-gnu-llvm-16` builder which [fail with](https://github.com/rust-lang/rust/actions/runs/7128709674/job/19411205695?pr=118705#step:26:1668): ``` Building stage1 codegen backend gcc (x86_64-unknown-linux-gnu) Compiling libc v0.2.147 Compiling rustix v0.38.8 Compiling memchr v2.5.0 Compiling bitflags v2.4.0 Compiling linux-raw-sys v0.4.5 Compiling fastrand v2.0.0 Compiling smallvec v1.10.0 error: invalid `--check-cfg` argument: `values(freebsd10)` (expected `cfg(name, values("value1", "value2", ... "valueN"))`) error: could not compile `libc` (lib) due to previous error ``` Updating to `libc` version 0.2.150 fixes the build issue since it includes the support for the new check-cfg syntax. Then it [failed](https://github.com/rust-lang/rust/actions/runs/7129280743/job/19413025132?pr=118706#step:26:2218) with a missing `#![allow(internal_features)]` in one of the example. r? `@GuillaumeGomez`
2023-12-07targets: remove not-added {i386,i486}-unknown-linux-gnuDavid Wood-16/+0
These files were added to the repository but never wired up so they could be used - and that was a few years ago without anyone noticing - so let's remove these, they can be re-added if someone wants them. Signed-off-by: David Wood <david@davidtw.co>
2023-12-07Elaborate on ip_addr bit conversion endiannessChris Eckhardt-4/+48
Adds explanation of how endianness is handled when converting `Ipv4Addr` and `Ipv6Addr` to and from bits. Addresses #113744
2023-12-07avoid instantiating infer vars with inferlcnr-4/+9
2023-12-07Rustup to rustc 1.76.0-nightly (1fdfe1234 2023-12-06)bjorn3-21/+36
2023-12-07Allow internal_features in rustc_codegen_gcc examplesUrgau-0/+1
2023-12-07Sync from rust 1fdfe1234795a289af1088aefa92ef80191cb611bjorn3-3/+3
2023-12-07Ping GuillaumeGomez for changes in rustc_codegen_gccGuillaume Gomez-1/+1