Commit Graph

245860 Commits

Author SHA1 Message Date
bors 65a644190d Auto merge of #16424 - dfireBird:let-stmt-guarded-return-assist, r=Veykril
implement convert to guarded return assist for `let` statement with type that implements `std::ops::Try`

I've tried to implement the assist that #16390 talked about

If there are any improvements that I can make in implementation, please suggest them.

![Peek 2024-02-05 19-01](https://github.com/rust-lang/rust-analyzer/assets/40687700/d6af3222-4f23-4ade-a930-8a78cc75e821)
2024-02-09 13:42:20 +00:00
Tetsuharu Ohzeki 1e4171bc6e clippy: Enable `non_canonical_partial_ord_impl` rule 2024-02-09 22:42:16 +09:00
Matthias Krüger 4a46914bac
Rollup merge of #120831 - Nikokrock:pr/disappearing_startup_objects, r=onur-ozkan
Startup objects disappearing from sysroot

When launching tests with --keep-stage option, startup objects such as rsbegin.o an rsend.o may disappear from the corresponding stageN compiler.

Fix issue #120784
2024-02-09 14:41:52 +01:00
Matthias Krüger 2f1ac412ec
Rollup merge of #120828 - nnethercote:fix-stash-steal, r=oli-obk
Fix `ErrorGuaranteed` unsoundness with stash/steal.

When you stash an error, the error count is incremented. You can then use the non-zero error count to get an `ErrorGuaranteed`. You can then steal the error, which decrements the error count. You can then cancel the error.

Example code:
```
fn unsound(dcx: &DiagCtxt) -> ErrorGuaranteed {
    let sp = rustc_span::DUMMY_SP;
    let k = rustc_errors::StashKey::Cycle;
    dcx.struct_err("bogus").stash(sp, k);           // increment error count on stash
    let guar = dcx.has_errors().unwrap();           // ErrorGuaranteed from error count > 0
    let err = dcx.steal_diagnostic(sp, k).unwrap(); // decrement error count on steal
    err.cancel();                                   // cancel error
    guar                                            // ErrorGuaranteed with no error emitted!
}
```

This commit fixes the problem in the simplest way: by not counting stashed errors in `DiagCtxt::{err_count,has_errors}`.

However, just doing this without any other changes leads to over 40 ui test failures. Mostly because of uninteresting extra errors (many saying "type annotations needed" when type inference fails), and in a few cases, due to delayed bugs causing ICEs when no normal errors are printed.

To fix these, this commit adds `DiagCtxt::stashed_err_count`, and uses it in three places alongside `DiagCtxt::{has_errors,err_count}`. It's dodgy to rely on it, because unlike `DiagCtxt::err_count` it can go up and down. But it's needed to preserve existing behaviour, and at least the three places that need it are now obvious.

r? oli-obk
2024-02-09 14:41:52 +01:00
Matthias Krüger 116efb5bb1
Rollup merge of #120817 - compiler-errors:more-mir-errors, r=oli-obk
Fix more `ty::Error` ICEs in MIR passes

Fixes #120791 - Add a check for `ty::Error` in the `ByMove` coroutine pass
Fixes #120816 - Add a check for `ty::Error` in the MIR validator

Also a drive-by fix for a FIXME I had asked oli to add

r? oli-obk
2024-02-09 14:41:51 +01:00
Matthias Krüger 475c47a3c1
Rollup merge of #120809 - reitermarkus:generic-nonzero-constructors, r=Nilstrieb
Use `transmute_unchecked` in `NonZero::new`.

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

See https://github.com/rust-lang/rust/pull/120521#discussion_r1482615129.
2024-02-09 14:41:51 +01:00
Matthias Krüger df2281b058
Rollup merge of #120704 - amandasystems:silly-region-name-rewrite, r=compiler-errors
A drive-by rewrite of `give_region_a_name()`

This drive-by rewrite makes the cache-updating nature of the method clearer, using the Entry API into the hash table for region names to capture the update-insert nature of the method. May be marginally more efficient since it only runtime-borrows and indexes the map once, but in this context the performance impact is almost certainly completely negligible.

Note that this commit should preserve all externally visible behaviour. Notably, it preserves the debug logging:

1. printing even in the case of a `None` for the new computed name, and
2. only printing on new values, begin silent on reused values
2024-02-09 14:41:50 +01:00
Matthias Krüger 46a0448405
Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwco
Invert diagnostic lints.

That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics.

This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.

r? ````@davidtwco````
2024-02-09 14:41:50 +01:00
Matthias Krüger 8b8adfd05d
Rollup merge of #120308 - utkarshgupta137:duration-opt, r=m-ou-se
core/time: avoid divisions in Duration::new

In our (decently large) code base, we use `SystemTime::UNIX_EPOCH.elapsed()` in a lot of places & often in a loop or in the hot path. On [Unix](https://github.com/rust-lang/rust/blob/1.75.0/library/std/src/sys/unix/time.rs#L153-L162) at least, it seems we do calculations before hand to ensure that nanos is within the valid range, yet `Duration::new()` still checks it again, using 2 divisions. It seems like adding a branch can make this function 33% faster on ARM64 in the cases where nanos is already in the valid range & seems to have no effect in the other case.

Benchmarks:
M1 Pro (14-inch base model):
```
duration/current/checked
                        time:   [1.5945 ns 1.6167 ns 1.6407 ns]
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) high mild
  3 (3.00%) high severe
duration/current/unchecked
                        time:   [1.5941 ns 1.6051 ns 1.6179 ns]
Found 2 outliers among 100 measurements (2.00%)
  1 (1.00%) high mild
  1 (1.00%) high severe

duration/branched/checked
                        time:   [1.1997 ns 1.2048 ns 1.2104 ns]
Found 8 outliers among 100 measurements (8.00%)
  4 (4.00%) high mild
  4 (4.00%) high severe
duration/branched/unchecked
                        time:   [1.5881 ns 1.5957 ns 1.6039 ns]
Found 6 outliers among 100 measurements (6.00%)
  3 (3.00%) high mild
  3 (3.00%) high severe
```
EC2 c7gd.16xlarge (Graviton 3):
```
duration/current/checked
                        time:   [2.7996 ns 2.8000 ns 2.8003 ns]
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) low severe
  3 (3.00%) low mild
duration/current/unchecked
                        time:   [2.9922 ns 2.9925 ns 2.9928 ns]
Found 7 outliers among 100 measurements (7.00%)
  4 (4.00%) low severe
  1 (1.00%) low mild
  2 (2.00%) high mild

duration/branched/checked
                        time:   [2.0830 ns 2.0843 ns 2.0857 ns]
Found 3 outliers among 100 measurements (3.00%)
  1 (1.00%) low severe
  1 (1.00%) low mild
  1 (1.00%) high mild
duration/branched/unchecked
                        time:   [2.9879 ns 2.9886 ns 2.9893 ns]
Found 5 outliers among 100 measurements (5.00%)
  3 (3.00%) low severe
  2 (2.00%) low mild
```
EC2 r7iz.16xlarge (Intel Xeon Scalable-based (Sapphire Rapids)):
```
duration/current/checked
                        time:   [980.60 ps 980.79 ps 980.99 ps]
Found 10 outliers among 100 measurements (10.00%)
  4 (4.00%) low severe
  2 (2.00%) low mild
  3 (3.00%) high mild
  1 (1.00%) high severe
duration/current/unchecked
                        time:   [979.53 ps 979.74 ps 979.96 ps]
Found 6 outliers among 100 measurements (6.00%)
  2 (2.00%) low severe
  1 (1.00%) low mild
  2 (2.00%) high mild
  1 (1.00%) high severe

duration/branched/checked
                        time:   [938.72 ps 938.96 ps 939.22 ps]
Found 4 outliers among 100 measurements (4.00%)
  1 (1.00%) low mild
  1 (1.00%) high mild
  2 (2.00%) high severe
duration/branched/unchecked
                        time:   [1.0103 ns 1.0110 ns 1.0118 ns]
Found 10 outliers among 100 measurements (10.00%)
  2 (2.00%) low mild
  7 (7.00%) high mild
  1 (1.00%) high severe
```

Bench code (ran using stable 1.75.0 & criterion latest 0.5.1):
I couldn't find any benches for `Duration` in this repo, so I just copied the relevant types & recreated it.
```rust
use criterion::{black_box, criterion_group, criterion_main, Criterion};

pub fn duration_bench(c: &mut Criterion) {
    const NANOS_PER_SEC: u32 = 1_000_000_000;

    #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
    #[repr(transparent)]
    struct Nanoseconds(u32);

    impl Default for Nanoseconds {
        #[inline]
        fn default() -> Self {
            // SAFETY: 0 is within the valid range
            unsafe { Nanoseconds(0) }
        }
    }

    #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
    pub struct Duration {
        secs: u64,
        nanos: Nanoseconds, // Always 0 <= nanos < NANOS_PER_SEC
    }

    impl Duration {
        #[inline]
        pub const fn new_current(secs: u64, nanos: u32) -> Duration {
            let secs = match secs.checked_add((nanos / NANOS_PER_SEC) as u64) {
                Some(secs) => secs,
                None => panic!("overflow in Duration::new"),
            };
            let nanos = nanos % NANOS_PER_SEC;
            // SAFETY: nanos % NANOS_PER_SEC < NANOS_PER_SEC, therefore nanos is within the valid range
            Duration { secs, nanos: unsafe { Nanoseconds(nanos) } }
        }

        #[inline]
        pub const fn new_branched(secs: u64, nanos: u32) -> Duration {
            if nanos < NANOS_PER_SEC {
                // SAFETY: nanos < NANOS_PER_SEC, therefore nanos is within the valid range
                Duration { secs, nanos: unsafe { Nanoseconds(nanos) } }
            } else {
                let secs = match secs.checked_add((nanos / NANOS_PER_SEC) as u64) {
                    Some(secs) => secs,
                    None => panic!("overflow in Duration::new"),
                };
                let nanos = nanos % NANOS_PER_SEC;
                // SAFETY: nanos % NANOS_PER_SEC < NANOS_PER_SEC, therefore nanos is within the valid range
                Duration { secs, nanos: unsafe { Nanoseconds(nanos) } }
            }
        }
    }

    let mut group = c.benchmark_group("duration/current");
    group.bench_function("checked", |b| {
        b.iter(|| black_box(Duration::new_current(black_box(1_000_000_000), black_box(1_000_000))));
    });
    group.bench_function("unchecked", |b| {
        b.iter(|| {
            black_box(Duration::new_current(black_box(1_000_000_000), black_box(2_000_000_000)))
        });
    });
    drop(group);
    let mut group = c.benchmark_group("duration/branched");
    group.bench_function("checked", |b| {
        b.iter(|| {
            black_box(Duration::new_branched(black_box(1_000_000_000), black_box(1_000_000)))
        });
    });
    group.bench_function("unchecked", |b| {
        b.iter(|| {
            black_box(Duration::new_branched(black_box(1_000_000_000), black_box(2_000_000_000)))
        });
    });
}

criterion_group!(duration_benches, duration_bench);
criterion_main!(duration_benches);
```
2024-02-09 14:41:49 +01:00
Matthias Krüger f41d0d90c2
Rollup merge of #113671 - oli-obk:normalize_weak_tys, r=petrochenkov
Make privacy visitor use types more (instead of HIR)

r? ``@petrochenkov``

This is a prerequisite to normalizing projections, as otherwise we have too many invalid bound vars (hir_ty_to_ty is creating types that have bound vars, but no binder).

The commits are still chaotic, I'm gonna clean them up, but I just wanted to let you know about the general direction and wondering if we could land this before adding normalization, as normalization is where behavioral changes happen, and I'd like to keep that part as minimal as possible.

[context can be found on zulip](https://rust-lang.zulipchat.com/#narrow/stream/315482-t-compiler.2Fetc.2Fopaque-types/topic/weak.20type.20aliases.20and.20privacy)
2024-02-09 14:41:48 +01:00
Tetsuharu Ohzeki 2601d19bac clippy: Enable `non_canonical_clone_impl` rule 2024-02-09 22:37:42 +09:00
bors 8fb67fb37f Auto merge of #120594 - saethlin:delayed-debug-asserts, r=oli-obk
Toggle assert_unsafe_precondition in codegen instead of expansion

The goal of this PR is to make some of the unsafe precondition checks in the standard library available in debug builds. Some UI tests are included to verify that it does that.

The diff is large, but most of it is blessing mir-opt tests and I've also split up this PR so it can be reviewed commit-by-commit.

This PR:
1. Adds a new intrinsic, `debug_assertions` which is lowered to a new MIR NullOp, and only to a constant after monomorphization
2. Rewrites `assume_unsafe_precondition` to check the new intrinsic, and be monomorphic.
3. Skips codegen of the `assume` intrinsic in unoptimized builds, because that was silly before but with these checks it's *very* silly
4. The checks with the most overhead are `ptr::read`/`ptr::write` and `NonNull::new_unchecked`. I've simply added `#[cfg(debug_assertions)]` to the checks for `ptr::read`/`ptr::write` because I was unable to come up with any (good) ideas for decreasing their impact. But for `NonNull::new_unchecked` I found that the majority of callers can use a different function, often a safe one.

Yes, this PR slows down the compile time of some programs. But in our benchmark suite it's never more than 1% icount, and the average icount change in debug-full programs is 0.22%. I think that is acceptable for such an improvement in developer experience.

https://github.com/rust-lang/rust/issues/120539#issuecomment-1922687101
2024-02-09 13:33:38 +00:00
Tetsuharu Ohzeki 7669619f9a clippy: Enable `self_named_constructors` rule 2024-02-09 22:31:21 +09:00
Guillaume Gomez 14e0dab96b Unify item relative path computation in one function 2024-02-09 14:16:37 +01:00
lcnr 5051637979 hide impls if trait bound is proven from env 2024-02-09 12:41:39 +01:00
bors d24bb7e289 Auto merge of #16517 - davidbarsky:david/fix-panic-in-generation-function, r=Veykril
internal: fix crash inside `filter_unnecessary_bounds` for a missing generic param

`@Wilfred` reported a crash here shortly after reporting https://github.com/rust-lang/rust-analyzer/issues/16516, which makes us think that the blast radius of ambiguities in Chalk can be larger than expected. This PR tries to be a bit more defensive as a result.

(The 20th frame is the salient frame in the backtrace below.)

<details>
<summary>Backtrace of the crash</summary>

```
request handler panicked: no entry found for key
backtrace:
   0: stdx::panic_context::PanicContext::init::{{closure}}::{{closure}}::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/panic_context.rs:32:43
   1: stdx::panic_context::with_backtrace::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/panic_context.rs:61:32
   2: std:🧵:local::LocalKey<T>::try_with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
   3: std:🧵:local::LocalKey<T>::with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
   4: stdx::panic_context::with_backtrace
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/panic_context.rs:61:5
   5: stdx::panic_context::PanicContext::init::{{closure}}::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/panic_context.rs:31:21
   6: stdx::panic_context::with_ctx::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/panic_context.rs:53:20
   7: std:🧵:local::LocalKey<T>::try_with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
   8: std:🧵:local::LocalKey<T>::with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
   9: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2021:9
  10: std::panicking::rust_panic_with_hook
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:783:13
  11: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
  12: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
  13: rust_begin_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
  14: core::panicking::panic_fmt
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
  15: core::panicking::panic_display
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:178:5
  16: core::panicking::panic_str
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:152:5
  17: core::option::expect_failed
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/option.rs:1985:5
  18: core::option::Option<T>::expect
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/option.rs:894:21
  19: <std::collections:#️⃣:map::HashMap<K,V,S> as core::ops::index::Index<&Q>>::index
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/collections/hash/map.rs:1341:23
  20: ide_assists::handlers::generate_function::filter_unnecessary_bounds::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:911:71
  21: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:305:13
  22: core::option::Option<T>::map
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/option.rs:1072:29
  23: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/iter/adapters/map.rs:103:26
  24: ide_assists::handlers::generate_function::Graph::compute_reachable_nodes
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:1158:20
  25: ide_assists::handlers::generate_function::filter_unnecessary_bounds
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:912:21
  26: ide_assists::handlers::generate_function::fn_generic_params
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:640:5
  27: ide_assists::handlers::generate_function::FunctionBuilder::from_call
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:283:13
  28: ide_assists::handlers::generate_function::gen_fn
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:78:28
  29: ide_assists::handlers::generate_function::generate_function
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/handlers/generate_function.rs:55:5
  30: ide_assists::assists::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/lib.rs:99:9
  31: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::for_each
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/slice/iter/macros.rs:254:21
  32: ide_assists::assists
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide-assists/src/lib.rs:98:5
  33: ide::Analysis::assists_with_fixes::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide/src/lib.rs:667:27
  34: ide::Analysis::with_db::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide/src/lib.rs:764:29
  35: std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  36: std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  37: std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  38: salsa::Cancelled::catch
             at /var/twsvcscm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rust-analyzer-salsa-0.17.0-pre.5/src/lib.rs:631:15
  39: ide::Analysis::with_db
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide/src/lib.rs:764:9
  40: ide::Analysis::assists_with_fixes
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/ide/src/lib.rs:656:9
  41: rust_analyzer::handlers::request::handle_code_action
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/rust-analyzer/src/handlers/request.rs:1149:19
  42: rust_analyzer::dispatch::RequestDispatcher::on_with_thread_intent::{{closure}}::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/rust-analyzer/src/dispatch.rs:198:54
  43: std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  44: std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  45: std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  46: rust_analyzer::dispatch::RequestDispatcher::on_with_thread_intent::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/rust-analyzer/src/dispatch.rs:198:26
  47: rust_analyzer::task_pool::TaskPool<T>::spawn::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/rust-analyzer/src/task_pool.rs:26:33
  48: stdx:🧵:pool::Pool::spawn::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/thread/pool.rs:82:13
  49: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
  50: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9
  51: stdx:🧵:pool::Pool:🆕:{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/thread/pool.rs:61:29
  52: stdx:🧵:Builder::spawn::{{closure}}
             at /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust-analyzer/master/crates/stdx/src/thread.rs:66:13
  53: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:154:18
  54: std:🧵:Builder::spawn_unchecked_::{{closure}}::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/mod.rs:529:17
  55: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panic/unwind_safe.rs:272:9
  56: std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  57: std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  58: std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  59: std:🧵:Builder::spawn_unchecked_::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/mod.rs:528:30
  60: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
  61: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9
  62: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9
  63: std::sys::unix:🧵:Thread:🆕:thread_start
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys/unix/thread.rs:108:17
  64: start_thread
  65: clone3
  ```
  </details>
2024-02-09 11:19:28 +00:00
Guillaume Gomez f3c24833c5 Add regression test for non local items link generation 2024-02-09 11:29:40 +01:00
Guillaume Gomez f0d002b890 Correctly generate path for non-local items in source code pages 2024-02-09 11:29:40 +01:00
bors 972452c447 Auto merge of #120238 - joboet:always_confirm_lock_success, r=Mark-Simulacrum
Always check the result of `pthread_mutex_lock`

Fixes #120147.

Instead of manually adding a list of "good" platforms, I've simply made the check unconditional. pthread's mutex is already quite slow on most platforms, so one single well-predictable branch shouldn't hurt performance too much.
2024-02-09 10:27:16 +00:00
lcnr a913c243da add comment 2024-02-09 10:44:19 +01:00
Oli Scherer e2349ea2e1 A trait's local impls are trivially coherent if there are no impls.
This avoids creating a dependency edge on the hir or the specialization graph
2024-02-09 09:33:56 +00:00
Nicolas Roche 575e0aa592 Startup objects disappearing from sysroot
When launching tests with --keep-stage option, startup objects
such as rsbegin.o an rsend.o may disappear from the corresponding
stageN compiler.

Fix issue #120784
2024-02-09 09:09:26 +01:00
DianQK bc31920c63
Print image input file and checksum in CI only 2024-02-09 15:38:14 +08:00
LegionMammal978 c94bbb24db Clarify that atomic and regular integers can differ in alignment
The documentation for atomic integers says that they have the "same
in-memory representation" as their underlying integers. This might be
misconstrued as implying that they have the same layout. Therefore,
clarify that atomic integers' alignment is equal to their size.
2024-02-08 22:59:36 -05:00
Gurinder Singh 6e37f955e5 Emit more specific diagnostics when enums fail to cast with `as` 2024-02-09 09:19:44 +05:30
Nicholas Nethercote 7619792107 Fix `ErrorGuaranteed` unsoundness with stash/steal.
When you stash an error, the error count is incremented. You can then
use the non-zero error count to get an `ErrorGuaranteed`. You can then
steal the error, which decrements the error count. You can then cancel
the error.

Example code:
```
fn unsound(dcx: &DiagCtxt) -> ErrorGuaranteed {
    let sp = rustc_span::DUMMY_SP;
    let k = rustc_errors::StashKey::Cycle;
    dcx.struct_err("bogus").stash(sp, k);           // increment error count on stash
    let guar = dcx.has_errors().unwrap();           // ErrorGuaranteed from error count > 0
    let err = dcx.steal_diagnostic(sp, k).unwrap(); // decrement error count on steal
    err.cancel();                                   // cancel error
    guar                                            // ErrorGuaranteed with no error emitted!
}
```

This commit fixes the problem in the simplest way: by not counting
stashed errors in `DiagCtxt::{err_count,has_errors}`.

However, just doing this without any other changes leads to over 40 ui
test failures. Mostly because of uninteresting extra errors (many saying
"type annotations needed" when type inference fails), and in a few
cases, due to delayed bugs causing ICEs when no normal errors are
printed.

To fix these, this commit adds `DiagCtxt::stashed_err_count`, and uses
it in three places alongside `DiagCtxt::{has_errors,err_count}`. It's
dodgy to rely on it, because unlike `DiagCtxt::err_count` it can go up
and down. But it's needed to preserve existing behaviour, and at least
the three places that need it are now obvious.
2024-02-09 13:50:03 +11:00
David Barsky 2d09d69fbe internal: fix crash inside `filter_unnecessary_bounds` for a missing generic param 2024-02-08 20:58:48 -05:00
Ben Kimock dbf817bae1 Add and use Unique::as_non_null_ptr 2024-02-08 19:56:30 -05:00
Ben Kimock 611c3cb561 Bless/fix tests 2024-02-08 19:56:30 -05:00
Ben Kimock 9e1b2d909b Add new ui tests 2024-02-08 19:56:30 -05:00
bors 57fda121d8 Auto merge of #16467 - DropDemBits:structured-snippet-migrate-6, r=DropDemBits
internal: Migrate assists to the structured snippet API, part 6/7

Continuing from #16082

Migrates the following assists:

- `extract_function`
- `generate_getter_or_setter`
- `generate_impl`
- `generate_new`
- `replace_derive_with_manual_impl`

Would've been the final PR in the structured snippet migration series, but I didn't notice that `generate_trait_from_impl` started to use `{insert,replace}_snippet` when I first started the migration 😅. This appears to be a pretty self-contained change, so I'll leave that for a separate future PR.

This also removes the last usages of `render_snippet`, which was a follow up goal of #11638. 🎉
2024-02-09 00:54:31 +00:00
Michael Goulet e32c1ddc52 Don't ice in validation when error body is created 2024-02-09 00:40:43 +00:00
DropDemBits 05b8ccc378
Fix clippy lints 2024-02-08 19:39:04 -05:00
Michael Goulet 698a3c7ade Don't ICE in ByMoveBody when coroutine is tainted 2024-02-09 00:36:30 +00:00
Michael Goulet 7057188c54 make it recursive 2024-02-09 00:13:52 +00:00
Michael Goulet 7a63d3f16a Add tests for untested capabilities 2024-02-09 00:13:52 +00:00
Michael Goulet 548929dc5e Don't unnecessarily lower associated type bounds to impl trait 2024-02-09 00:13:51 +00:00
Michael Goulet 22d582a38d For a rigid projection, recursively look at the self type's item bounds 2024-02-09 00:13:51 +00:00
DropDemBits 1161082051
Remove unused code in `utils`
All usages of `render_snippet` and `Cursor` have been removed as part of the migration
2024-02-08 19:13:10 -05:00
DropDemBits 8eebf1701b
Migrate `replace_derive_with_manual_impl` to mutable ast 2024-02-08 19:13:10 -05:00
DropDemBits 18ea09feca
Migrate `generate_new` to mutable ast 2024-02-08 19:13:10 -05:00
DropDemBits e28f5514e1
Add `AssocItemList::add_item_at_start`
Needed to recreate the behavior of `generate_new` addding the `new` method at the start of the impl
2024-02-08 19:13:10 -05:00
DropDemBits e0117154cf
Migrate `generate_impl` to mutable ast 2024-02-08 19:13:10 -05:00
DropDemBits ab2233e562
Migrate `generate_getter_or_setter` to mutable ast 2024-02-08 19:13:09 -05:00
DropDemBits f1293a8fc4
Add newline to body when where clause is present 2024-02-08 19:13:09 -05:00
DropDemBits 0519414c19
Make `ReferenceConversion` methods return ast types 2024-02-08 19:13:09 -05:00
DropDemBits 039b3d0abb
Add `make::ext::expr_self`
Shortcut version of `make::expr_path(make::path_unqualified(make::path_segment_self()))`
2024-02-08 19:09:33 -05:00
DropDemBits 0e39257e5b
Migrate `extract_function` to mutable ast 2024-02-08 19:09:33 -05:00
DropDemBits 3924a0ef7c
Add ast versions of `generate{_trait}_impl_text{_intransitive}` 2024-02-08 19:09:33 -05:00
DropDemBits 8c0661b2de
Use `GenericArgList` for `make::impl{_trait}`
`make::impl_` no longer merges generic params and args in order to be in line
with `make::impl_`, which doesn't do it either.
2024-02-08 19:09:32 -05:00