1
Fork 0
Commit graph

273122 commits

Author SHA1 Message Date
许杰友 Jieyou Xu (Joe)
56efa0a7bf Adjust as-precedence.rs
- Document `as-precedence.rs`
- Move `as-precedence.rs` under `tests/ui/parser/`
2024-12-10 11:34:13 +08:00
Jieyou Xu
4652b14f9b Adjust artificial-block.rs
- Document `artificial-block.rs`
- Move `artificial-block.rs` under `tests/ui/reachable`
2024-12-10 11:34:13 +08:00
Jieyou Xu
d734d22bd8 Adjust anonymous-higher-ranked-lifetime.rs
- Document `anonymous-higher-ranked-lifetime.rs`
- Move `anonymous-higher-ranked-lifetime.rs` to `tests/ui/higher-ranked`
2024-12-10 11:31:13 +08:00
Jieyou Xu
b5c7a55250 Adjust allow-non-lint-warnings.rs
- Document `allow-non-lint-warnings.rs`
- Move `allow-non-lint-warnings.rs` under `tests/ui/diagnostic-flags/`
- Improve the test to use two *differential* revisions:
    1. One revision checks that without `-A warnings` the code sample
       actually emits a warning.
    2. The other revision checks that `-A warnings` suppresses the
       warning.
  This makes sure that if the code sample no longer warns, the test
  doesn't silently pass but fail to check its intended purpose.
2024-12-10 11:29:43 +08:00
Jieyou Xu
dd3b313b56 Adjust alias-uninit-value.rs
- Document and tidy up `alias-uninit-value.rs`
- Move `alias-uninit-value.rs` to `tests/ui/codegen/`
2024-12-10 11:20:19 +08:00
Wesley Wiser
88c8b1056d Add compiler-maintainers who requested to be on review rotation 2024-12-09 20:47:44 -06:00
Michael Goulet
5d1b6bfc6a Validate self in host predicates correctly 2024-12-10 02:31:15 +00:00
Giga Bowser
b76734f20e minor: Migrate remove_unnecessary_wrapper to SyntaxEditor 2024-12-09 21:16:31 -05:00
Giga Bowser
4898f3f591 fix: Handle the final statement in SyntaxFactory::block_expr properly
This caused a bug that was rather tricky to hunt down!
2024-12-09 21:15:15 -05:00
Giga Bowser
a73a6a0058 Add diagnostic fix to remove unnecessary wrapper in type mismatch
I also reorganized the tests in a more logical order, and removed the redundant `test_` prefix from their names.
2024-12-09 21:15:15 -05:00
Nicholas Nethercote
dddc09d2c3 Reorder some Analysis methods.
In most places, the `early` method is listed before the corresponding
`primary` method, like you'd expect. This commit fixes two places where
that isn't the case.
2024-12-10 12:09:25 +11:00
Michael Goulet
6e2e9f676c Don't ICE when encountering never in pattern 2024-12-10 01:08:18 +00:00
Nicholas Nethercote
1d56943f34 Rename some Analysis and ResultsVisitor methods.
The words "before" and "after" have an obvious temporal meaning, e.g.
`seek_before_primary_effect`,
`visit_statement_{before,after}_primary_effect`. But "before" is also
used to name the effect that occurs before the primary effect of a
statement/terminator; this is `Effect::Before`. This leads to the
confusing possibility of talking about things happening "before/after
the before event".

This commit removes this awkward overloading of "before" by renaming
`Effect::Before` as `Effect::Early`. It also renames some of the
`Analysis` and `ResultsVisitor` methods to be more consistent.

Here are the before and after names:

- `Effect::{Before,Primary}`              -> `Effect::{Early,Primary}`
- `apply_before_statement_effect`         -> `apply_early_statement_effect`
- `apply_statement_effect`                -> `apply_primary_statement_effect`
- `visit_statement_before_primary_effect` -> `visit_after_early_statement_effect`
- `visit_statement_after_primary_effect`  -> `visit_after_primary_statement_effect`

(And s/statement/terminator/ for all the terminator events.)
2024-12-10 12:07:13 +11:00
Nicholas Nethercote
119fbd32dc Improve terminology in elaborate_drops.rs.
It uses `MaybeInitializedPlaces` and `MaybeUninitializedPlaces`, but
calls the results `live` and `dead`. This is very confusing given that
there are also analyses called `MaybeLiveLocals` and `MaybeStorageLive`
and `MaybeStorageDead`.

This commit changes it to use `maybe_init` and `maybe_uninit`.
2024-12-10 12:06:03 +11:00
Nicholas Nethercote
b059ea857c Rename EntrySets as EntryStates.
"Set" doesn't make much sense here, we refer to domain values as "state"
everywhere else. (This name confused me for a while.)
2024-12-10 12:04:45 +11:00
Nicholas Nethercote
2298104f3f Call all Domain values state.
Currently they are called (most common) `state`, or `trans`, or (rare)
`on_entry`. I think `trans` is short for "transfer function", which
perhaps made more sense when `GenKillAnalysis` existed. Using `state`
everywhere now is more consistent.
2024-12-10 12:03:56 +11:00
Nicholas Nethercote
086233e282 Refer to a couple of domains indirectly.
Via the `Analysis::Domain` associated types, instead of the direct type
name.
2024-12-10 12:02:50 +11:00
Nicholas Nethercote
d490ea1f39 Remove lifetimes from BorrowckDomain.
They are only present because it's currently defined in terms of the
domains of `Borrows` and `MaybeUninitializedPlaces` and
`EverInitializedPlaces` via associated types. This commit introduces
typedefs for those domains, avoiding the lifetimes.
2024-12-10 12:02:48 +11:00
Nicholas Nethercote
83f67c5915 Remove unused dataflow trait impls and bounds. 2024-12-10 11:52:30 +11:00
Nicholas Nethercote
0dbb31f7e7 Fix an out-of-date comment. 2024-12-10 11:52:05 +11:00
Esteban Küber
4007fc9a0f Tweak wording of non-const traits used as const bounds
Use verbose suggestions and add additional labels/notes.

Add more test cases for stable/nightly and feature enabled/disabled.
2024-12-10 00:38:05 +00:00
bors
974ccc12e6 Auto merge of #129514 - estebank:default-field-values, r=compiler-errors
Introduce `default_field_values` feature

Initial implementation of `#[feature(default_field_values]`, proposed in https://github.com/rust-lang/rfcs/pull/3681.

We now parse const expressions after a `=` in a field definition, to specify a `struct` field default value.

We now allow `Struct { field, .. }` where there's no base after `..`.

`#[derive(Default)]` now uses the default value if present, continuing to use `Default::default()` if not.

```rust
#[derive(Debug)]
pub struct S;

#[derive(Debug, Default)]
pub struct Foo {
    pub bar: S = S,
    pub baz: i32 = 42 + 3,
}

fn main () {
    let x = Foo { .. };
    let y = Foo::default();
    let z = Foo { baz: 1, .. };

    assert_eq!(45, x.baz);
    assert_eq!(45, y.baz);
    assert_eq!(1, z.baz);
}
```
2024-12-10 00:07:00 +00:00
Waffle Lapkin
05d83185c3
provide libz.so.1 in the nix-dev-shell
`libz.so.1` is needed for some (?) things...

i personally found myself in need of it when running `x t linkchecker`,
which failed when running cargo build script or something.

although there are also mentions of rustc itself needing it:
<https://github.com/NixOS/nixpkgs/issues/92946>
2024-12-10 00:24:21 +01:00
Waffle Lapkin
6058cdcccc
remove instructions to git exclude files in src/nix-dev-shell/envrc-*
this is no longer needed as `.gitignore` contains both `/.envrc` and
`flake.lock` (and also `/.direnv/`)
2024-12-10 00:11:27 +01:00
Eric Holk
b9afc78585
Remove rustc_const_stable attribute on const NOOP
This was accidentally reintroduced while editing #133089.
2024-12-09 15:08:30 -08:00
Waffle Lapkin
5f99e96fbb
only ignore {flake,default}.nix and {.envrc,.direnv/} in the root
this makes it so files in `src/nix-dev-shell` are *not* ignored, as they
should not be. note that `flake.lock` is still ignored globally.
2024-12-10 00:08:26 +01:00
Kirill Bulatov
61c0b269d8 Clippy fixes 2024-12-10 01:04:02 +02:00
Kirill Bulatov
b203c73ccf Avoid hashing completion-related ranges as those may change during /resolve query 2024-12-10 00:45:57 +02:00
León Orell Valerian Liehr
5a33ab0d71
Rollup merge of #134084 - estebank:typo, r=compiler-errors
Fix typo in RFC mention 3598 -> 3593

https://github.com/rust-lang/rfcs/blob/master/text/3593-unprefixed-guarded-strings.md
2024-12-09 23:39:08 +01:00
León Orell Valerian Liehr
cb5f03cbce
Rollup merge of #134073 - DianQK:fix-131227, r=oli-obk
dataflow_const_prop: do not eval a ptr address in SwitchInt

Fixes #131227.
2024-12-09 23:39:07 +01:00
León Orell Valerian Liehr
e0bec9dabb
Rollup merge of #134055 - RalfJung:interpret-alloc-dedup, r=oli-obk
interpret: clean up deduplicating allocation functions

The "align" and "kind" arguments would be largely ignored in the "dedup" case, so let's move that to entirely separate function.

Let's also remove support for old-style miri_resolve_frame while we are at it. The docs have already said for a while that this must be set to 1.
2024-12-09 23:39:07 +01:00
León Orell Valerian Liehr
76fbe8d503
Rollup merge of #134053 - notriddle:notriddle/issue-d, r=GuillaumeGomez
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 10)

Follow up https://github.com/rust-lang/rust/pull/130287 et al

As always, it's easier to review the commits one at a time. Don't use the Files Changed tab. It's confusing.
2024-12-09 23:39:06 +01:00
León Orell Valerian Liehr
0cb12f9e84
Rollup merge of #134043 - ehuss:unicode-version, r=jieyouxu
Add test to check unicode identifier version

This adds a test to verify which version of Unicode is used for identifiers. This is part of the language, documented at https://doc.rust-lang.org/nightly/reference/identifiers.html#r-ident.unicode. The version here often changes implicitly due to dependency updates pulling in new versions, and thus we often don't notice it has changed leaving the documentation out of date. The intent here is to have a canary to give us a notification when it changes so that we can update the documentation.
2024-12-09 23:39:05 +01:00
León Orell Valerian Liehr
b282774aaf
Rollup merge of #134040 - clubby789:bootstrap-eprintln, r=jieyouxu
bootstrap: print{ln}! -> eprint{ln}! (take 2)

r? `@jieyouxu`

Reland of #133817 with the `print!`s changed as well.
2024-12-09 23:39:05 +01:00
León Orell Valerian Liehr
e0f3db0056
Rollup merge of #134032 - snprajwal:fix-docs, r=joboet
docs: better examples for `std::ops::ControlFlow`

Fixes #133963. Lesson learnt, never force-push from a bare clone of a repo 💀
2024-12-09 23:39:04 +01:00
León Orell Valerian Liehr
780b5bb1e1
Rollup merge of #134012 - aarikpokras:patch-1, r=saethlin
Grammar fixes

Fixed some grammar in README.md
2024-12-09 23:39:03 +01:00
León Orell Valerian Liehr
df5ec039fa
Rollup merge of #133996 - Zalathar:ui-link-native-libs, r=jieyouxu
Move most tests for `-l` and `#[link(..)]` into `tests/ui/link-native-libs`

Tests for the closely-related `-l` flag and `#[link(..)]` attribute are spread across a few different directories, and in some cases have ended up in a test directory intended for other linker-related functionality.

This PR moves most of them into a single `tests/ui/link-native-libs` directory.

---

Part of #133895.

try-job: i686-mingw

r? jieyouxu
2024-12-09 23:39:03 +01:00
Aarik Pokras
2d71dd5a0f Grammar fixes 2024-12-09 17:17:27 -05:00
Esteban Küber
fa331f4d0d Support x-crate default fields 2024-12-09 21:58:07 +00:00
Esteban Küber
0757641f4d Unconditionally error at definition if default field value has const errors
Emit E0080 always on struct definition with default fields that have unconditional const errors and remove `default_field_always_invalid_const` lint.
2024-12-09 21:58:00 +00:00
Esteban Küber
2d6e763cc6 Disallow #[default] Variant {} regardless of feature flag 2024-12-09 21:55:13 +00:00
Esteban Küber
148a77dfde review comments: rewordings 2024-12-09 21:55:13 +00:00
Esteban Küber
e0752ad257 Provide diagnostic for Struct(a, .., z) expression
People might extrapolate from `Struct { .. }` that `Struct(..)` would work, but it doesn't.
2024-12-09 21:55:12 +00:00
Esteban Küber
550bcae8aa Detect struct S(ty = val);
Emit a specific error for unsupported default field value syntax in tuple structs.
2024-12-09 21:55:12 +00:00
Esteban Küber
9ac95c10c0 Introduce default_field_values feature
Initial implementation of `#[feature(default_field_values]`, proposed in https://github.com/rust-lang/rfcs/pull/3681.

Support default fields in enum struct variant

Allow default values in an enum struct variant definition:

```rust
pub enum Bar {
    Foo {
        bar: S = S,
        baz: i32 = 42 + 3,
    }
}
```

Allow using `..` without a base on an enum struct variant

```rust
Bar::Foo { .. }
```

`#[derive(Default)]` doesn't account for these as it is still gating `#[default]` only being allowed on unit variants.

Support `#[derive(Default)]` on enum struct variants with all defaulted fields

```rust
pub enum Bar {
    #[default]
    Foo {
        bar: S = S,
        baz: i32 = 42 + 3,
    }
}
```

Check for missing fields in typeck instead of mir_build.

Expand test with `const` param case (needs `generic_const_exprs` enabled).

Properly instantiate MIR const

The following works:

```rust
struct S<A> {
    a: Vec<A> = Vec::new(),
}
S::<i32> { .. }
```

Add lint for default fields that will always fail const-eval

We *allow* this to happen for API writers that might want to rely on users'
getting a compile error when using the default field, different to the error
that they would get when the field isn't default. We could change this to
*always* error instead of being a lint, if we wanted.

This will *not* catch errors for partially evaluated consts, like when the
expression relies on a const parameter.

Suggestions when encountering `Foo { .. }` without `#[feature(default_field_values)]`:

 - Suggest adding a base expression if there are missing fields.
 - Suggest enabling the feature if all the missing fields have optional values.
 - Suggest removing `..` if there are no missing fields.
2024-12-09 21:55:01 +00:00
Alona Enraght-Moony
e6bc4278f2 jsondocck: Parse, don't validate commands. 2024-12-09 21:46:22 +00:00
Yuki Sireneva
9aebb5c930
crates/r-a: Fix typo in debug message 2024-12-10 00:13:17 +03:00
Kirill Bulatov
160cb324c1 Unite more bool hashing 2024-12-09 22:38:55 +02:00
Kirill Bulatov
78ea49e4e7 Stop excluding Helix from the general resolve path 2024-12-09 22:26:00 +02:00
Kirill Bulatov
e8e3949698 Always compute the hash when r-a wants the imports to be resolved 2024-12-09 22:26:00 +02:00