Commit Graph

271388 Commits

Author SHA1 Message Date
bors
743003b1a6 Auto merge of #132329 - compiler-errors:fn-and-destruct, r=lcnr
Implement `~const Destruct` effect goal in the new solver

This also fixed a subtle bug/limitation of the `NeedsConstDrop` check. Specifically, the "`Qualif`" API basically treats const drops as totally structural, even though dropping something that has an explicit `Drop` implementation cannot be structurally decomposed. For example:

```rust
#![feature(const_trait_impl)]

#[const_trait] trait Foo {
    fn foo();
}

struct Conditional<T: Foo>(T);

impl Foo for () {
    fn foo() {
        println!("uh oh");
    }
}

impl<T> const Drop for Conditional<T> where T: ~const Foo {
    fn drop(&mut self) {
        T::foo();
    }
}

const FOO: () = {
    let _ = Conditional(());
    //~^ This should error.
};

fn main() {}
```

In this example, when checking if the `Conditional(())` rvalue is const-drop, since `Conditional` has a const destructor, we would previously recurse into the `()` value and determine it has nothing to drop, which means that it is considered to *not* need a const drop -- even though dropping `Conditional(())` would mean evaluating the destructor which relies on that `T: const Foo` bound to hold!

This could be fixed alternatively by banning any const conditions on `const Drop` impls, but that really sucks -- that means that basically no *interesting* const drop impls could be written. We have the capability to totally and intuitively support the right behavior, which I've implemented here.
2024-11-23 02:03:50 +00:00
bors
f5be3ca1e3 Auto merge of #133349 - ehuss:stabilize-2024, r=traviscross,compiler-errors
Stabilize the 2024 edition

This stabilizes the 2024 edition for Rust 1.85, scheduled to be released on February 20, 2025. 🎉

cc tracking issue: https://github.com/rust-lang/rust/issues/117258

There is a fair amount of follow-up work after this that I am working on (various docs, cargo, rustfmt, etc.), and this is will unblock those other changes.
2024-11-22 21:17:35 +00:00
Eric Huss
31c9222639 Stabilize the 2024 edition 2024-11-22 11:12:15 -08:00
Michael Goulet
69a38de977 Check drop is trivial before checking ty needs drop 2024-11-22 17:01:02 +00:00
Michael Goulet
af0d566e76 Deduplicate checking drop terminator 2024-11-22 16:54:41 +00:00
Michael Goulet
2088260852 Gate const drop behind const_destruct feature, and fix const_precise_live_drops post-drop-elaboration check 2024-11-22 16:54:40 +00:00
Michael Goulet
b75c1c3dd6 More comments, reverse polarity of structural check 2024-11-22 16:54:40 +00:00
Michael Goulet
59408add4d Implement ~const Destruct in new solver 2024-11-22 16:54:40 +00:00
bors
a47555110c Auto merge of #133339 - jieyouxu:rollup-gav0nvr, r=jieyouxu
Rollup of 8 pull requests

Successful merges:

 - #133238 (re-export `is_loongarch_feature_detected`)
 - #133288 (Support `each_ref` and `each_mut` in `[T; N]` in constant expressions.)
 - #133311 (Miri subtree update)
 - #133313 (Use arc4random of libc for RTEMS target)
 - #133319 (Simplify `fulfill_implication`)
 - #133323 (Bail in effects in old solver if self ty is ty var)
 - #133330 (library: update comment around close())
 - #133337 (Fix typo in `std:🧵:Scope::spawn` documentation.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-22 16:27:07 +00:00
bors
a7d9ebdf08 Auto merge of #133338 - BoxyUwU:bump_1_85, r=BoxyUwU
Bump to 1.85

https://forge.rust-lang.org/release/process.html#bump-the-stable-version-number-friday-the-week-before
2024-11-22 13:35:21 +00:00
许杰友 Jieyou Xu (Joe)
874cf85674
Rollup merge of #133337 - ColinFinck:thread-scoped-fix-typo, r=joboet
Fix typo in `std:🧵:Scope::spawn` documentation.

Just a simple fix for a typo that caught my attention.
2024-11-22 20:32:38 +08:00
许杰友 Jieyou Xu (Joe)
bbc4cbe3e2
Rollup merge of #133330 - RalfJung:close, r=the8472
library: update comment around close()

r? `@the8472`
2024-11-22 20:32:38 +08:00
许杰友 Jieyou Xu (Joe)
74b8522855
Rollup merge of #133323 - compiler-errors:bail-if-self-var, r=lcnr
Bail in effects in old solver if self ty is ty var

Otherwise when we try to check something like `?t: ~const Trait` we'll immediately stick it to the first param-env candidate, lol.

r? lcnr
2024-11-22 20:32:37 +08:00
许杰友 Jieyou Xu (Joe)
8fdba31f8b
Rollup merge of #133319 - compiler-errors:simpler-fulfill, r=lcnr
Simplify `fulfill_implication`

calm before the storm
2024-11-22 20:32:36 +08:00
许杰友 Jieyou Xu (Joe)
b8453c9023
Rollup merge of #133313 - thesummer:fix-arc4random, r=cuviper
Use arc4random of libc for RTEMS target

Switch to the `arc4random` from libc. It is available since libc 0.2.162
2024-11-22 20:32:36 +08:00
许杰友 Jieyou Xu (Joe)
71440da2b3
Rollup merge of #133311 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2024-11-22 20:32:35 +08:00
许杰友 Jieyou Xu (Joe)
2e93a759a3
Rollup merge of #133288 - bjoernager:const-array-each-ref, r=jhpratt
Support `each_ref` and `each_mut` in `[T; N]` in constant expressions.

Tracking issue: #133289

The methods `<[T; N]>::each_ref` and `<[T; N]>::each_mut` can easily be reimplemented to allow marking them with the `const` specifier.

This specific implementation takes a different approach than the original as to avoid using iterators (which are illegal in constant expressions).
2024-11-22 20:32:35 +08:00
许杰友 Jieyou Xu (Joe)
9eb67bb25c
Rollup merge of #133238 - heiher:loong-stdarch-rexport, r=Amanieu
re-export `is_loongarch_feature_detected`

r? ``@Amanieu``
2024-11-22 20:32:34 +08:00
Boxy
1355304a69 Bump to 1.85 2024-11-22 11:08:33 +00:00
bors
f1e0752404 Auto merge of #130867 - michirakara:steps_between, r=dtolnay
distinguish overflow and unimplemented in Step::steps_between
2024-11-22 10:54:22 +00:00
Colin Finck
d0384f3ba5
Fix typo in std:🧵:Scope::spawn documentation. 2024-11-22 11:51:38 +01:00
Ralf Jung
729d3aa0fe library: update comment around close() 2024-11-22 08:43:51 +01:00
bors
2cf7908998 Auto merge of #129238 - umgefahren:stabilize-ipv6-unique-local, r=dtolnay
Stabilize `Ipv6Addr::is_unique_local` and `Ipv6Addr::is_unicast_link_local`

Make `Ipv6Addr::is_unique_local` and `Ipv6Addr::is_unicast_link_local` stable (+const).

Newly stable API:

```rust
impl Ipv6Addr {
	// Newly stable under `ipv6_is_unique_local`
	const fn is_unique_local(&self) -> bool;

	// Newly stable under `ipv6_is_unique_local`
	const fn is_unicast_link_local(&self) -> bool;
}
```

These stabilise a subset of the following tracking issue:
- #27709

I have looked and could not find any issues with `is_unique_local` and `is_unicast_link_local`. There is a well received comment calling for stabilisation of the latter function.

Both functions are well defined and consistent with implementations in other languages:
- [Go](https://cs.opensource.google/go/go/+/refs/tags/go1.23.0:src/net/netip/netip.go;l=518)
- [Python](e9d1bf353c/Lib/ipaddress.py (L2319-L2321))
- [Ruby (unique local)](https://ruby-doc.org/stdlib-2.5.1/libdoc/ipaddr/rdoc/IPAddr.html#private-3F-source)
- [Ruby (unicast link local)](https://ruby-doc.org/stdlib-2.5.1/libdoc/ipaddr/rdoc/IPAddr.html#link_local-3F-source)

cc implementor `@little-dude`
(I can't find the original PR for `is_unqiue_local`)

r? libs-api
`@rustbot` label +T-libs-api +needs-fcp
2024-11-22 06:38:39 +00:00
Michael Goulet
8dfed4ec98 Bail in effects in old solver if self ty is ty var 2024-11-22 03:12:50 +00:00
Michael Goulet
357665dae9 Simplify fulfill_implication 2024-11-22 01:03:17 +00:00
michirakara
de741d2093
distinguish overflow and unimplemented in Step::steps_between 2024-11-21 15:49:55 -08:00
Jan Sommer
a4a06b305d Use arc4random of libc for RTEMS target
Is available since libc 0.2.162
2024-11-21 23:10:19 +01:00
bors
5d3c6ee9b3 Auto merge of #132362 - mustartt:aix-dylib-detection, r=jieyouxu
[AIX] change system dynamic library format

Historically on AIX, almost all dynamic libraries are distributed in `.a` Big Archive Format which can consists of both static and shared objects in the same archive (e.g. `libc++abi.a(libc++abi.so.1)`). During the initial porting process, the dynamic libraries are kept as `.a` to simplify the migration, but semantically having an XCOFF object under the archive extension is wrong. For crate type `cdylib` we want to be able to distribute the libraries as archives as well.

We are migrating to archives with the following format:
```
$ ar -t lib<name>.a
lib<name>.so
```
where each archive contains a single member that is a shared XCOFF object that can be loaded.
2024-11-21 21:36:47 +00:00
bors
b19329a37c Auto merge of #133246 - MarcoIeni:debug-info-2-windows-disable, r=Kobzol
ci: Disable full `debuginfo-level=2` in windows alt job

try-job: dist-x86_64-msvc-alt
2024-11-21 18:46:51 +00:00
Henry Jiang
0db9059726 aix: fix archive format
fmt

fix cfg for windows

remove unused imports

address comments

update libc to 0.2.164

fmt

remove unused imports
2024-11-21 10:33:07 -05:00
bors
75703c1a78 Auto merge of #133287 - matthiaskrgr:rollup-ab9j3pu, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #130236 (unstable feature usage metrics)
 - #131544 (Make asm label blocks safe context)
 - #131586 (Support s390x z13 vector ABI)
 - #132489 (Fix closure arg extraction in `extract_callable_info`, generalize it to async closures)
 - #133078 (tests: ui/inline-consts: add issue number to a test, rename other tests)
 - #133283 (Don't exclude relnotes from `needs-triage` label)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-21 14:08:40 +00:00
Gabriel Bjørnager Jensen
7c799c3e0d Mark and implement 'each_ref' and 'each_mut' in '[T; N]' as const; 2024-11-21 12:27:18 +01:00
Matthias Krüger
df2413ce1c
Rollup merge of #133283 - jieyouxu:triage-relnotes, r=BoxyUwU
Don't exclude relnotes from `needs-triage` label

So initially we *didn't* exclude `needs-triage` label, then we did exclude them in #132825 as sometimes the `needs-triage` is redundant. However, I think they are probably worth double-checking because often some of the labels are only accurate/relevant for the *implementation* PR, but not for the purposes of the relnotes tracking issue. Furthermore, sometimes relevant team labels can be removed. So to make it less likely for relnotes to slip through, I think we should still label relnotes-tracking-issues with `needs-triage`.

cc https://rust-lang.zulipchat.com/#narrow/channel/241545-t-release/topic/Please.20CC.20lang

r? release
2024-11-21 11:58:41 +01:00
Matthias Krüger
825985981f
Rollup merge of #133078 - matthiaskrgr:uiuiui, r=davidtwco
tests: ui/inline-consts: add issue number to a test, rename other tests

rename other tests from a_b_c to a-b-c
2024-11-21 11:58:40 +01:00
Matthias Krüger
c064f6e1fc
Rollup merge of #132489 - compiler-errors:fn-sugg-tweaks, r=BoxyUwU
Fix closure arg extraction in `extract_callable_info`, generalize it to async closures

* Fix argument extraction in `extract_callable_info`
* FIx `extract_callable_info` to work for async closures
* Remove redundant `is_fn_ty` which is just a less general `extract_callable_info`
* More precisely name what is being called (i.e. call it a "closure" not a "function")

Review this without whitespace -- I ended up reformatting `extract_callable_info` because some pesky `//` comments were keeping the let-chains from being formatted.
2024-11-21 11:58:39 +01:00
Matthias Krüger
379b22123c
Rollup merge of #131586 - taiki-e:s390x-vector-abi, r=compiler-errors,uweigand
Support s390x z13 vector ABI

cc #130869

This resolves the following fixmes:
- 58420a065b/compiler/rustc_target/src/abi/call/s390x.rs (L1-L2)
- 58420a065b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs (L9-L11)

Refs: Section 1.2.3 "Parameter Passing" and section 1.2.5 "Return Values" in ELF Application Binary Interface s390x Supplement, Version 1.6.1 (lzsabi_s390x.pdf in https://github.com/IBM/s390x-abi/releases/tag/v1.6.1)

This PR extends ~~https://github.com/rust-lang/rust/pull/127731~~ https://github.com/rust-lang/rust/pull/132173 (merged) 's ABI check to handle cases where `vector` target feature is disabled.
If we do not do ABI check, we run into the ABI problems as described in https://github.com/rust-lang/rust/issues/116558 and https://github.com/rust-lang/rust/issues/130869#issuecomment-2408268044, and the problem of the compiler generating strange code (https://github.com/rust-lang/rust/pull/131586#discussion_r1799003554).

cc `@uweigand`

`@rustbot` label +O-SystemZ +A-ABI
2024-11-21 11:58:38 +01:00
Matthias Krüger
395649558a
Rollup merge of #131544 - nbdd0121:asm_goto_safe_block, r=petrochenkov
Make asm label blocks safe context

Tracking issue: https://github.com/rust-lang/rust/issues/119364

`asm!()` is forced to be wrapped inside unsafe. If there's no special treatment, the label blocks would also always be unsafe with no way of opting out. It was suggested that a simple fix is to make asm label blocks safe: https://github.com/rust-lang/rust/issues/119364#issuecomment-2316037703.

`@rustbot` labels: +A-inline-assembly +F-asm
2024-11-21 11:58:37 +01:00
Matthias Krüger
fe5403f517
Rollup merge of #130236 - yaahc:unstable-feature-usage, r=estebank
unstable feature usage metrics

example output

```
test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1
❯ cat src/lib.rs
───────┬───────────────────────────────────────────────────────
       │ File: src/lib.rs
───────┼───────────────────────────────────────────────────────
   1   │ #![feature(unix_set_mark)]
   2   │ pub fn add(left: u64, right: u64) -> u64 {
   3   │     left + right
   4   │ }
   5   │
   6   │ #[cfg(test)]
   7   │ mod tests {
   8   │     use super::*;
   9   │
  10   │     #[test]
  11   │     fn it_works() {
  12   │         let result = add(2, 2);
  13   │         assert_eq!(result, 4);
  14   │     }
  15   │ }
───────┴───────────────────────────────────────────────────────

test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1
❯ cargo +stage1 rustc -- -Zmetrics-dir=$PWD/metrics
   Compiling test-lib v0.1.0 (/home/yaahc/tmp/test-lib)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s

test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1
❯ cat metrics/unstable_feature_usage.json
───────┬─────────────────────────────────────────────────────────────────────
       │ File: metrics/unstable_feature_usage.json
───────┼─────────────────────────────────────────────────────────────────────
   1   │ {"lib_features":[{"symbol":"unix_set_mark"}],"lang_features":[]}
   ```

   related to https://github.com/rust-lang/rust/issues/129485
2024-11-21 11:58:36 +01:00
bors
717f5df2c3 Auto merge of #132629 - nnethercote:124141-preliminaries, r=petrochenkov
#124141 preliminaries

Preliminary changes required to start removing `Nonterminal` (https://github.com/rust-lang/rust/pull/124141).

r? `@petrochenkov`
2024-11-21 10:57:22 +00:00
Jieyou Xu
61a03fa98f Don't exclude relnotes from needs-triage label 2024-11-21 17:20:37 +08:00
bors
0b1bf71a71 Auto merge of #133280 - matthiaskrgr:rollup-8keusum, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #131736 (Emscripten: link with -sWASM_BIGINT)
 - #132207 (Store resolution for self and crate root module segments)
 - #133153 (Add visits to nodes that already have flat_maps in ast::MutVisitor)
 - #133218 (Implement `~const` item bounds in RPIT)
 - #133228 (Rewrite `show_md_content_with_pager`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-21 07:41:22 +00:00
Ralf Jung
12ac750f9b
Merge pull request #4044 from RalfJung/rustup
Rustup
2024-11-21 07:25:52 +00:00
Ralf Jung
ec6fe118d9 fmt 2024-11-21 07:59:07 +01:00
Ralf Jung
f5fd967283 Merge from rustc 2024-11-21 07:58:50 +01:00
Matthias Krüger
c83b6a3d0e
Rollup merge of #133228 - nnethercote:rewrite-show_md_content_with_pager, r=tgross35
Rewrite `show_md_content_with_pager`

`show_md_content_with_pager` is complex and has a couple of bugs. This PR improves it.

r? ``@tgross35``
2024-11-21 07:56:13 +01:00
Matthias Krüger
920092531f
Rollup merge of #133218 - compiler-errors:const-opaque, r=fee1-dead
Implement `~const` item bounds in RPIT

an RPIT in a `const fn` is allowed to be conditionally const itself :)

r? fee1-dead or reroll
2024-11-21 07:56:13 +01:00
Matthias Krüger
9d70af54e4
Rollup merge of #133153 - maxcabrajac:flat_maps, r=petrochenkov
Add visits to nodes that already have flat_maps in ast::MutVisitor

This PR aims to add `visit_` methods for every node that has a `flat_map_` in MutVisitor, giving implementers free choice over overriding `flat_map` for 1-to-n conversions or `visit` for a 1-to-1.

There is one major problem: `flat_map_stmt`.
While all other default implementations of `flat_map`s are 1-to-1 conversion, as they either only call visits or a internal 1-to-many conversions are natural, `flat_map_stmt` doesn't follow this pattern.

`flat_map_stmt`'s default implementation is a 1-to-n conversion that panics if n > 1 (effectively being a 1-to-[0;1]). This means that it cannot be used as is for a default `visit_stmt`, which would be required to be a 1-to-1.

Implementing `visit_stmt` without runtime checks would require it to reach over a potential `flat_map_item` or `filter_map_expr` overrides and call for their `visit` counterparts directly.
Other than that, if we want to keep the behavior of `flat_map_stmt` it cannot call `visit_stmt` internally.

To me, it seems reasonable to make all default implementations 1-to-1 conversions and let implementers handle `visit_stmt` if they need it, but I don't know if calling `visit` directly when a 1-to-1 is required is ok or not.

related to #128974 & #127615

r? ``@petrochenkov``
2024-11-21 07:56:12 +01:00
Matthias Krüger
b1008d1370
Rollup merge of #132207 - compiler-errors:tweak-res-mod-segment, r=petrochenkov
Store resolution for self and crate root module segments

Let's make sure to record the segment resolution for `self::`, `crate::` and `$crate::`.

I'm actually somewhat surprised that the only diagnostic that uses this is the one that errors on invalid generics on a module segment... but seems strictly more correct regardless, and there may be other diagnostics using these segments resolutions that just haven't been tested for `self`. Also includes a drive-by on `report_prohibit_generics_error`.
2024-11-21 07:56:12 +01:00
Matthias Krüger
61878ec254
Rollup merge of #131736 - hoodmane:emscripten-wasm-bigint, r=workingjubilee
Emscripten: link with -sWASM_BIGINT

When linking an executable without dynamic linking, this is a pure improvement. It significantly reduces code size and avoids a lot of buggy behaviors. It is supported in all browsers for many years and in all maintained versions of Node.

It does change the ABI, so people who are dynamically linking with a library or executable that uses the old ABI may need to turn it off. It can be disabled if needed by passing `-Clink-arg -sWASM_BIGINT=0` to `rustc`. But few people will want to turn it off.

Note this includes a libc bump to 0.2.162!
2024-11-21 07:56:11 +01:00
Ralf Jung
09ef8ece28 Preparing for merge from rustc 2024-11-21 07:45:20 +01:00