Commit Graph

244166 Commits

Author SHA1 Message Date
Nadrieril
dbc1f074bc Tweak 2024-01-22 15:12:57 +01:00
Chris Denton
e74c667a53
Fix msys2 tty detection for /dev/ptmx
Our "true negative" detection assumes that if at least one std handle is a Windows console then no other handle will be a msys2 tty pipe. This turns out to be a faulty assumption in the case of  `/dev/ptmx`.
2024-01-22 13:44:21 +00:00
Oli Scherer
9454b51b05 Make generic const type mismatches not hide trait impls from the trait solver 2024-01-22 13:23:45 +00:00
bors
3066253050 Auto merge of #120080 - cuviper:128-align-packed, r=nikic
Pack u128 in the compiler to mitigate new alignment

This is based on #116672, adding a new `#[repr(packed(8))]` wrapper on `u128` to avoid changing any of the compiler's size assertions. This is needed in two places:

* `SwitchTargets`, otherwise its `SmallVec<[u128; 1]>` gets padded up to 32 bytes.
* `LitKind::Int`, so that entire `enum` can stay 24 bytes.
  * This change definitely has far-reaching effects though, since it's public.
2024-01-22 13:08:19 +00:00
bors
366d112fa6 Auto merge of #120226 - matthiaskrgr:rollup-9xwx0si, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #118714 ( Explanation that fields are being used when deriving `(Partial)Ord` on enums)
 - #119710 (Improve `let_underscore_lock`)
 - #119726 (Tweak Library Integer Division Docs)
 - #119746 (rustdoc: hide modals when resizing the sidebar)
 - #119986 (Fix error counting)
 - #120194 (Shorten `#[must_use]` Diagnostic Message for `Option::is_none`)
 - #120200 (Correct the anchor of an URL in an error message)
 - #120203 (Replace `#!/bin/bash` with `#!/usr/bin/env bash` in rust-installer tests)
 - #120212 (Give nnethercote more reviews)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-22 11:08:57 +00:00
bors
6fff796eac Auto merge of #120196 - matthiaskrgr:rollup-id2zocf, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #120005 (Update Readme)
 - #120045 (Un-hide `iter::repeat_n`)
 - #120128 (Make stable_mir::with_tables sound)
 - #120145 (fix: Drop guard was deallocating with the incorrect size)
 - #120158 (`rustc_mir_dataflow`: Restore removed exports)
 - #120167 (Capture the rationale for `-Zallow-features=` in bootstrap.py)
 - #120174 (Warn users about limited review for tier 2 and 3 code)
 - #120180 (Document some alternatives to `Vec::split_off`)

Failed merges:

 - #120171 (Fix assume and assert in jump threading)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-22 08:56:22 +00:00
Matthias Krüger
610f13d685
Rollup merge of #120212 - nnethercote:nnethercote-reviewer, r=compiler-errors
Give nnethercote more reviews

Gulp!
2024-01-22 07:56:45 +01:00
Matthias Krüger
e39608d64f
Rollup merge of #120203 - rowan-sl:usr-bin-env-bash, r=compiler-errors
Replace `#!/bin/bash` with `#!/usr/bin/env bash` in rust-installer tests

This allows the rust-installer tests to pass on NixOS

This change has [already been made](302ad2175d) for the actual installer, it appears that the tests were just forgotten.
2024-01-22 07:56:44 +01:00
Matthias Krüger
50d0f24620
Rollup merge of #120200 - noritada:fix/broken-error-message-link, r=dtolnay
Correct the anchor of an URL in an error message

Following error message from rustc points to a URL, but its anchor does not exist.
The destination seems to be https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib.
This PR makes that correction.

      = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
2024-01-22 07:56:44 +01:00
Matthias Krüger
1df60b2257
Rollup merge of #120194 - HTGAzureX1212:HTGAzureX1212shorten-option-must-use, r=Nilstrieb
Shorten `#[must_use]` Diagnostic Message for `Option::is_none`

This shortens the `#[must_use]` diagnostics displayed, in light of the [review comment](https://github.com/rust-lang/rust/pull/62431/files#r300819839) on when this was originally added.
2024-01-22 07:56:43 +01:00
Matthias Krüger
bef2e85359
Rollup merge of #119986 - nnethercote:fix-error-counting, r=compiler-errors,oli-obk
Fix error counting

There is some messiness in how errors get counted. Here are some cleanups.

r? `@compiler-errors`
2024-01-22 07:56:43 +01:00
Matthias Krüger
6687e8e460
Rollup merge of #119746 - notriddle:notriddle/resize-close-modals, r=fmease
rustdoc: hide modals when resizing the sidebar

Follow-up for
https://github.com/rust-lang/rust/pull/119477#discussion_r1439085011

CC `@lukas-code`
2024-01-22 07:56:42 +01:00
Matthias Krüger
7d7c2257d3
Rollup merge of #119726 - NCGThompson:div-overflow-doc, r=Nilstrieb
Tweak Library Integer Division Docs

Improved the documentation and diagnostics related to panicking in the division-like methods in std:

* For signed methods that can overflow, clarified "results in overflow" to "self is -1 and rhs is Self::MIN." This is more concise than saying "results in overflow" and then explaining how it could overflow.
* For floor/ceil_div, corrected the documentation and made it more like the documentation in other methods.
* For signed methods that can overflow, explicitly mention that they are not affected by compiler flags.
* Removed all unused rustc_inherit_overflow_checks attributes. The non-division-like operations will never overflow.
* Added track_caller attributes to all methods that can panic. The panic messages will always be correct. For example, division methods all have / before %.
* Edited the saturating_div documentation to be consistent with similar methods.
2024-01-22 07:56:42 +01:00
Matthias Krüger
72dddeaeb7
Rollup merge of #119710 - Nilstrieb:let-_-=-oops, r=TaKO8Ki
Improve `let_underscore_lock`

- lint if the lock was in a nested pattern
- lint if the lock is inside a `Result<Lock, _>`

addresses https://github.com/rust-lang/rust/pull/119704#discussion_r1444044745
2024-01-22 07:56:41 +01:00
Matthias Krüger
6f7222c1e6
Rollup merge of #118714 - The-Ludwig:explain_ord_derive_enum_field, r=Nilstrieb
Explanation that fields are being used when deriving `(Partial)Ord` on enums

When deriving `std::cmp::Ord` or `std::cmp::PartialOrd` on enums, their fields are compared if the variants are equal.
This means that the last assertion in the following snipped panics.
```rust
use std::cmp::{PartialEq, Eq, PartialOrd, Ord};

#[derive(PartialEq, Eq, PartialOrd, Ord)]
enum Sizes {
    Small(usize),
    Big(usize),
}

fn main() {
    let a = Sizes::Big(3);
    let b = Sizes::Big(5);
    let c = Sizes::Small(10);
    assert!( c < a);
    assert_eq!(a, c);
}
```

This is more often expected behavior than not, and can be easily circumvented, as discussed in [this thread](https://users.rust-lang.org/t/how-to-sort-enum-variants/52291/4).
But it is addressed nowhere in the documentation, yet.
So I stumbled across this, as I personally did not expect fields being used in `PartialOrd`.
I added the explanation to the documentation.
2024-01-22 07:56:41 +01:00
micolous
7ce206d185
Fix -Zremap-path-scope typo 2024-01-22 15:12:19 +10:00
bors
a58ec8ff03 Auto merge of #120161 - cjgillot:static-pass-name, r=tmiasko
Make MIR pass name a compile-time constant.

Post-processing a compile-time string at runtime is a bit silly. This PR makes CTFE do it all.
2024-01-22 02:34:55 +00:00
Nicholas Nethercote
c4fc9ff0d3 Document Token{Stream,Tree}::Display more thoroughly.
To expressly warn against the kind of proc macro implementation that was
broken in #119875.
2024-01-22 13:31:52 +11:00
Michael Goulet
5297433747 Actually, just use nonterminal_may_begin_with 2024-01-22 02:19:42 +00:00
Nicholas Nethercote
774a47da28 Link to triagebot.toml documentation. 2024-01-22 13:13:20 +11:00
Michael Goulet
b93ae21441 Do not eagerly recover malformed AST in rustfmt 2024-01-22 01:49:33 +00:00
Michael Goulet
981e8b46c5 Check that a token can begin a nonterminal kind before parsing it as a macro arg in rustfmt 2024-01-22 01:49:33 +00:00
Nicholas Nethercote
012a304a16 Fix a trimmed_def_paths assertion failure.
`RegionHighlightMode::force_print_trimmed_def_path` can call
`trimmed_def_paths` even when `tcx.sess.opts.trimmed_def_paths` is
false. Based on the `force` in the method name, it seems this is
deliberate, so I have removed the assertion.

Fixes #120035.
2024-01-22 11:00:30 +11:00
Nicholas Nethercote
1f9fa2305a Tweak error counting.
We have several methods indicating the presence of errors, lint errors,
and delayed bugs. I find it frustrating that it's very unclear which one
you should use in any particular spot. This commit attempts to instill a
basic principle of "use the least general one possible", because that
reflects reality in practice -- `has_errors` is the least general one
and has by far the most uses (esp. via `abort_if_errors`).

Specifics:
- Add some comments giving some usage guidelines.
- Prefer `has_errors` to comparing `err_count` to zero.
- Remove `has_errors_or_span_delayed_bugs` because it's a weird one: in
  the cases where we need to count delayed bugs, we should really be
  counting lint errors as well.
- Rename `is_compilation_going_to_fail` as
  `has_errors_or_lint_errors_or_span_delayed_bugs`, for consistency with
  `has_errors` and `has_errors_or_lint_errors`.
- Change a few other `has_errors_or_lint_errors` calls to `has_errors`,
  as per the "least general" principle.

This didn't turn out to be as neat as I hoped when I started, but I
think it's still an improvement.
2024-01-22 10:14:01 +11:00
Nicholas Nethercote
807c8687de Count "unused extern" errors as lints rather than normal errors. 2024-01-22 10:14:01 +11:00
Nicholas Nethercote
f00c088393 Clarify comments about diagnostic count fields. 2024-01-22 10:14:00 +11:00
Michael Goulet
802d16ce3a Don't actually make bound ty/const for RTN 2024-01-21 23:08:03 +00:00
Nicholas Nethercote
b95ce3056b Add nnethercote to the full review rotation. 2024-01-22 09:53:04 +11:00
Nicholas Nethercote
ae3c00c28e Add a group for rustc_arena and put nnethercote in it. 2024-01-22 09:52:55 +11:00
Nicholas Nethercote
ab6216a1d3 Adjust whitespace. 2024-01-22 09:44:15 +11:00
Michal Nazarewicz
50cbbef86a review 2024-01-21 20:12:00 +01:00
Rowan S-L
30b8b44990 use /usr/bin/env bash instead of /bin/bash 2024-01-21 12:43:09 -05:00
bors
ef71f1047e Auto merge of #120198 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2024-01-21 16:14:51 +00:00
trevyn
b58a8a98cd maybe_lint_impl_trait: separate is_downgradable from is_object_safe 2024-01-21 20:04:39 +04:00
Noritada Kobayashi
ff02662d44 Correct the anchor of an URL in an error message 2024-01-22 01:02:20 +09:00
onur-ozkan
1afd216f76 use u64 to represent file size
This increases the maximum supported file size (previously limited to 4GB)
and avoids potential issues with u32 to u64 conversions, which are no longer
needed.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-01-21 18:16:22 +03:00
Laurențiu Nicola
595b4c3c32 Merge commit 'a9116523604c998e7781f60d3b5a6f586e0414a9' into sync-from-ra 2024-01-21 16:53:06 +02:00
bors
d9d89fd53d Auto merge of #119807 - Emilgardis:track_caller_from_impl_into, r=Nilstrieb
Add `#[track_caller]` to the "From implies Into" impl

This pr implements what was mentioned in https://github.com/rust-lang/rust/issues/77474#issuecomment-1074480790

This follows from my URLO https://users.rust-lang.org/t/104497

```rust
#![allow(warnings)]
fn main() {
    // Gives a good location
    let _: Result<(), Loc> = dbg!(Err::<(), _>(()).map_err(|e| e.into()));

    // still doesn't work, gives location of `FnOnce::call_once()`
    let _: Result<(), Loc> = dbg!(Err::<(), _>(()).map_err(Into::into));
}

#[derive(Debug)]
pub struct Loc {
    pub l: &'static std::panic::Location<'static>,
}

impl From<()> for Loc {
    #[track_caller]
    fn from(_: ()) -> Self {
        Loc {
            l: std::panic::Location::caller(),
        }
    }
}
```
2024-01-21 14:17:25 +00:00
bohan
9c3091e9cf exclude unexported macro bindings from extern crate 2024-01-21 20:24:40 +08:00
Matthias Krüger
3eb7fe32a1
Rollup merge of #120180 - Zalathar:vec-split-off-alternatives, r=dtolnay
Document some alternatives to `Vec::split_off`

One of the discussion points that came up in #119917 is that some people use `Vec::split_off` in cases where they probably shouldn't, because the alternatives (like `mem::take`) are hard to discover.

This PR adds some suggestions to the documentation of `split_off` that should point people towards alternatives that might be more appropriate for their use-case.

I've deliberately tried to keep these changes as simple and uncontroversial as possible, so that they don't depend on how the team decides to handle the concerns raised in #119917. That's why I haven't touched the existing documentation for `split_off`, and haven't added links to `split_off` to the documentation of other methods.
2024-01-21 12:28:55 +01:00
Matthias Krüger
1229d4cde3
Rollup merge of #120174 - Mark-Simulacrum:link-libs-policy, r=dtolnay
Warn users about limited review for tier 2 and 3 code

Needs https://github.com/rust-lang/std-dev-guide/pull/61
2024-01-21 12:28:55 +01:00
Matthias Krüger
ac713695f3
Rollup merge of #120167 - dtolnay:bootstrap, r=clubby789
Capture the rationale for `-Zallow-features=` in bootstrap.py

Based on the discussion in https://github.com/rust-lang/rust/pull/120096.
2024-01-21 12:28:54 +01:00
Matthias Krüger
e59a6fe63f
Rollup merge of #120158 - jubnzv:120130-mirdf-exports, r=nnethercote
`rustc_mir_dataflow`: Restore removed exports

Added back previously available exports:

* `Forward`/`Backward`: used when implementing `AnalysisDomain`
* `Engine`: used in user's code to solve the dataflow problem
* `SwitchIntEdgeEffects`: used when implementing functions of the `Analysis` trait
* `graphviz`: potentially useful for debugging purposes

Closes #120130
2024-01-21 12:28:53 +01:00
Matthias Krüger
4a941d384d
Rollup merge of #120145 - the8472:fix-inplace-dest-drop, r=cuviper
fix: Drop guard was deallocating with the incorrect size

InPlaceDstBufDrop holds onto the allocation before the shrinking happens which means it must deallocate the destination elements but the source allocation.

Thanks `@cuviper` for spotting this.
2024-01-21 12:28:53 +01:00
Matthias Krüger
a72d6c114b
Rollup merge of #120128 - oli-obk:smir_internal_lift, r=celinval
Make stable_mir::with_tables sound

See the first commit for the actual soundness fix. The rest is just fallout from that and is entirely safe code. Includes most of #120120

The major difference to #120120 is that we don't need an unsafe trait, as we can now rely on the type system (the only unsafe part, and the actual source of the unsoundness was in `with_tables`)

r? `@celinval`
2024-01-21 12:28:52 +01:00
Matthias Krüger
092d62734a
Rollup merge of #120045 - scottmcm:unhide-repeat-n, r=Mark-Simulacrum
Un-hide `iter::repeat_n`

ACP accepted in https://github.com/rust-lang/libs-team/issues/120#issuecomment-1894144403
2024-01-21 12:28:52 +01:00
Matthias Krüger
7119ca15ff
Rollup merge of #120005 - atouchet:rd3, r=Mark-Simulacrum
Update Readme

A couple minor formatting fixes and re-add missing "Installing from Source" section to the table of contents.
2024-01-21 12:28:51 +01:00
bors
fa404339c9 Auto merge of #85528 - the8472:iter-markers, r=dtolnay
Implement iterator specialization traits on more adapters

This adds

* `TrustedLen` to `Skip` and `StepBy`
* `TrustedRandomAccess` to `Skip`
* `InPlaceIterable` and `SourceIter` to  `Copied` and `Cloned`

The first two might improve performance in the compiler itself since `skip` is used in several places. Constellations that would exercise the last point are probably rare since it would require an owning iterator that has references as Items somewhere in its iterator pipeline.

Improvements for `Skip`:

```
# old
test iter::bench_skip_trusted_random_access                     ... bench:       8,335 ns/iter (+/- 90)

# new
test iter::bench_skip_trusted_random_access                     ... bench:       2,753 ns/iter (+/- 27)
```
2024-01-21 11:17:46 +00:00
HTGAzureX1212
1821bfaa09
chore: suggest wrapping in an assert!() instead
This shortens the `#[must_use]` diagnostics displayed, in light of the [review comment](https://github.com/rust-lang/rust/pull/62431/files#r300819839) on when this was originally added.
2024-01-21 18:39:09 +08:00
bors
cb25c5bc3d Auto merge of #120187 - Nadrieril:rollup-xfwrb0c, r=Nadrieril
Rollup of 8 pull requests

Successful merges:

 - #116090 (Implement strict integer operations that panic on overflow)
 - #118811 (Use `bool` instead of `PartiolOrd` as return value of the comparison closure in `{slice,Iteraotr}::is_sorted_by`)
 - #119081 (Add Ipv6Addr::is_ipv4_mapped)
 - #119461 (Use an interpreter in MIR jump threading)
 - #119996 (Move OS String implementation into `sys`)
 - #120015 (coverage: Format all coverage tests with `rustfmt`)
 - #120027 (pattern_analysis: Remove `Ty: Copy` bound)
 - #120084 (fix(rust-analyzer): use new pkgid spec to compare)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-21 09:18:48 +00:00