Commit Graph

235601 Commits

Author SHA1 Message Date
Matthias Krüger 08cc7428d9
Rollup merge of #116415 - ouz-a:move_subtyper, r=oli-obk
Move subtyper below reveal_all and change reveal_all

In previous attempt https://github.com/rust-lang/rust/pull/116378 we tried to handle `Opaque` in few different places, but this isn't necessary, after moving subtyper below reveal_all and calling `super_place` on reveal_all, issues cease to exist.

r? ``@oli-obk``

Fixes https://github.com/rust-lang/rust/issues/116332
Fixes https://github.com/rust-lang/rust/issues/116265
Fixes https://github.com/rust-lang/rust/issues/116383
Fixes https://github.com/rust-lang/rust/issues/116333
2023-10-05 19:24:34 +02:00
Matthias Krüger b301bd4220
Rollup merge of #116288 - ouz-a:smir_spans, r=spastorino
Add Span to various smir types

Had to make few extra changes to few structs to attach spans to them.

r? ``@oli-obk``
2023-10-05 19:24:34 +02:00
Matthias Krüger 864e5d8d94
Rollup merge of #116220 - llogiq:stabilize-option-as-slice, r=BurntSushi
stabilize `Option::as_`(`mut_`)`slice`

This is the stabilization to #108545. Thanks to everyone who helped getting this into Rust proper.
2023-10-05 19:24:33 +02:00
ouz-a 3088c4b046 move subtyper change reveal_all 2023-10-05 18:56:30 +03:00
Camille GILLOT 14c846cb05 Do not assert that hidden types don't have erased regions. 2023-10-05 15:50:36 +00:00
bors 3bcad65fbf Auto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee
docs: Correct terminology in std::cmp

This PR is the result of some discussions on URLO:

* [Traits in `std::cmp` and mathematical terminology](https://users.rust-lang.org/t/traits-in-std-cmp-and-mathematical-terminology/69887)
* [Are poker hands `Ord` or `PartialOrd`?](https://users.rust-lang.org/t/are-poker-hands-ord-or-partialord/82644)

Arguably, the documentation currently isn't very precise regarding mathematical terminology. This can lead to misunderstandings of what `PartialEq`, `Eq`, `PartialOrd`, and `Ord` actually do.

While I believe this PR doesn't give any new API guarantees, it expliclitly mentions that `PartialEq::eq(a, b)` may return `true` for two distinct values `a` and `b` (i.e. where `a` and `b` are not equal in the mathematical sense). This leads to the consequence that `Ord` may describe a weak ordering instead of a total ordering.

In either case, I believe this PR should be thoroughly reviewed, ideally by someone with mathematical background to make sure the terminology is correct now, and also to ensure that no unwanted new API guarantees are made.

In particular, the following problems are addressed:

* Some clarifications regarding used (mathematical) terminology:
    * Avoid using the terms "total equality" and "partial equality" in favor of "equivalence relation" and "partial equivalence relation", which are well-defined and unambiguous.
    * Clarify that `Ordering` is an ordering between two values (and not an order in the mathematical sense).
    * Avoid saying that `PartialEq` and `Eq` are "equality comparisons" because the terminology "equality comparison" could be misleading: it's possible to implement `PartialEq` and `Eq` for other (partial) equivalence relations, in particular for relations where `a == b` for some `a` and `b` even when `a` and `b` are not the same value.
    * Added a section "Strict and non-strict partial orders" to document that the `<=` and `>=` operators do not correspond to non-strict partial orders.
    * Corrected section "Corollaries" in documenation of `Ord` in regard to `<` only describing a strict total order in cases where `==` conforms to mathematical equality.
    * ~~Added a section "Weak orders" to explain that `Ord` may also describe a weak order or total preorder, depending on how `PartialEq::eq` has been implemented.~~ (Removed, see [comment](https://github.com/rust-lang/rust/pull/103046#issuecomment-1279929676))
* Made documentation easier to understand:
    * Explicitly state at the beginning of `PartialEq`'s documentation comment that implementing the trait will provide the `==` and `!=` operators.
    * Added an easier to understand rule when to implement `Eq` in addition to `PartialEq`: "if it’s guaranteed that `PartialEq::eq(a, a)` always returns `true`."
    *  Explicitly mention in documentation of `Eq` that the properties "symmetric" and "transitive" are already required by `PartialEq`.
2023-10-05 15:24:54 +00:00
Jakub Beránek 098dd97939 Remove `try-merge` from CI workflow 2023-10-05 16:13:52 +02:00
Jakub Beránek f6017250f8 Enable new bors try branch to run on CI 2023-10-05 16:13:52 +02:00
bors cf9fd95b1c Auto merge of #114042 - liushuyu:ubuntu/i586-fpmath, r=workingjubilee
core library: Disable fpmath tests for i586 ...

This patch disables the floating-point epsilon test for i586 since x87 registers are too imprecise and can't produce the expected results.
2023-10-05 13:35:18 +00:00
Jan Behrens 86b031b734 docs: Correct terminology in std::cmp
Some clarifications regarding used (mathematical) terminology:

* Avoid using the terms "total equality" and "partial equality" in favor
  of "equivalence relation" and "partial equivalence relation", which
  are well-defined and unambiguous.
* Clarify that `Ordering` is an ordering between two values (and not an
  order in the mathematical sense).
* Avoid saying that `PartialEq` and `Eq` are "equality comparisons"
  because the terminology "equality comparison" could be misleading:
  it's possible to implement `PartialEq` and `Eq` for other (partial)
  equivalence relations, in particular for relations where `a == b` for
  some `a` and `b` even when `a` and `b` are not the same value.
* Added a section "Strict and non-strict partial orders" to document
  that the `<=` and `>=` operators do not correspond to non-strict
  partial orders.
* Corrected section "Corollaries" in documenation of Ord in regard to
  `<` only describing a strict total order in cases where `==` conforms
  to mathematical equality.

Made documentation easier to understand:

* Explicitly state at the beginning of `PartialEq`'s documentation
  comment that implementing the trait will provide the `==` and `!=`
  operators.
* Added an easier to understand rule when to implement `Eq` in addition
  to `PartialEq`: "if it’s guaranteed that `PartialEq::eq(a, a)` always
  returns `true`."
* Explicitly mention in documentation of `Eq` that the properties
  "symmetric" and "transitive" are already required by `PartialEq`.
2023-10-05 14:44:42 +02:00
bors 90f3a6f920 Auto merge of #104153 - tspiteri:doc-float-constants, r=workingjubilee
doc: expand description for f32 and f64 associated constants

This explains the meaning of some of the floating-point associated constants.
2023-10-05 11:46:55 +00:00
bors 5c3a0e932b Auto merge of #116427 - cjgillot:no-internal, r=oli-obk
Remove mir::LocalDecl::internal.

It does not serve any purpose, as we don't have typeck-based generator witnesses any more.
2023-10-05 09:59:14 +00:00
Nicholas Nethercote 81d1f7ea9d Use a closure when setting `State::Active`. 2023-10-05 19:56:19 +11:00
Oğuz Ağcayazı a49138e46e impl stable for kinds 2023-10-05 11:15:34 +03:00
ouz-a a79567b01c add span to statements 2023-10-05 11:15:34 +03:00
bors e293927016 Auto merge of #116443 - workingjubilee:rollup-r9mh13f, r=workingjubilee
Rollup of 5 pull requests

Successful merges:

 - #116223 (Fix misuses of a vs an)
 - #116296 (More accurately point to where default return type should go)
 - #116429 (Diagnostics: Be more careful when suggesting struct fields)
 - #116431 (Tweak wording of E0562)
 - #116432 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 2))

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-05 08:12:55 +00:00
Jubilee 4a14a80605
Rollup merge of #116432 - notriddle:master, r=fmease
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 2)

Follow up https://github.com/rust-lang/rust/pull/116214
2023-10-05 00:56:31 -07:00
Jubilee d7b02c3d40
Rollup merge of #116431 - estebank:issue-80476, r=compiler-errors
Tweak wording of E0562

Fix #80476.
2023-10-05 00:56:30 -07:00
Jubilee a9a389cf44
Rollup merge of #116429 - fmease:clean-up-struct-field-suggs, r=compiler-errors
Diagnostics: Be more careful when suggesting struct fields

Consolidate the various places which filter out struct fields that shouldn't be suggested into a single function.

Previously, each of those code paths had slightly different and incomplete metrics for no good reason. Now, there's only a single 'complete' metric (namely `is_field_suggestable`) which also filters out hygienic fields that come from different syntax contexts.

Fixes #116334.
2023-10-05 00:56:30 -07:00
Jubilee cfce3a919d
Rollup merge of #116296 - compiler-errors:default-return, r=estebank
More accurately point to where default return type should go

When getting the "default return type" span, instead of pointing to the low span of the next token, point to the high span of the previous token. This:

1. Makes forming return type suggestions more uniform, since we expect them all in the same place.
2. Arguably makes labels easier to understand, since we're pointing to where the implicit `-> ()` would've gone, rather than the starting brace or the semicolon.

r? ```@estebank```
2023-10-05 00:56:29 -07:00
Jubilee ea3454eabb
Rollup merge of #116223 - catandcoder:master, r=cjgillot
Fix misuses of a vs an

Fixes the misuse of "a" vs "an", according to English grammatical
expectations and using https://www.a-or-an.com/
2023-10-05 00:56:29 -07:00
bors ff3e990e42 Auto merge of #3106 - RalfJung:tree-borrows-initial, r=RalfJung
Tree Borrows: do not create new tags as 'Active'

Cc `@Vanille-N`
2023-10-05 07:06:54 +00:00
Nicholas Nethercote 9d4e49b386 Use `declared_features` to avoid two lookups. 2023-10-05 18:01:11 +11:00
Nicholas Nethercote 56fd2531ac Add two setter functions to `Features`. 2023-10-05 18:01:11 +11:00
Nicholas Nethercote 95d1aa075f Record all declared features.
Currently `rust_20XX_preview` features aren't recorded as declared even
when they are explicit declared. Similarly, redundant edition-dependent
features (e.g. `test_2018_feature`) aren't recorded as declared.

This commit marks them as recorded. There is no detectable functional
change, but it makes things more consistent.
2023-10-05 18:01:11 +11:00
Nicholas Nethercote eb209057b1 Rename `Resolver::active_features`.
For the reasons described in the previous commit.
2023-10-05 18:01:11 +11:00
Nicholas Nethercote 4602d9257d Rename `Features::active_features`.
The word "active" is currently used in two different and confusing ways:
- `ACTIVE_FEATURES` actually means "available unstable features"
- `Features::active_features` actually means "features declared in the
  crate's code", which can include feature within `ACTIVE_FEATURES` but
  also others.

(This is also distinct from "enabled" features which includes declared
features but also some edition-specific features automatically enabled
depending on the edition in use.)

This commit changes the `Features::active_features` to
`Features::declared_features` which actually matches its meaning.
Likewise, `Features::active` becomes `Features::declared`.
2023-10-05 18:01:11 +11:00
Nicholas Nethercote b229be0127 Overhaul `config::features`.
The new way of doing things:
- Avoids some code duplication.
- Distinguishes the `crate_edition` (which comes from `--edition`) and
  the `features_edition` (which combines `--edition` along with any
  `rustc_20XX_preview` features), which is useful.
- Has a simpler initial loop, one that just looks for
  `rustc_20XX_preview` features in order to compute `features_edition`.
- Creates a fallible alternative to `Features::enabled`, which is
  useful.

It's not easy to see how exactly the old and new code are equivalent,
but it's reassuring to know that the test coverage is quite good for
this stuff.
2023-10-05 18:00:29 +11:00
Ralf Jung 5178ae60a1 Tree Borrows: do not create new tags as 'Active' 2023-10-05 08:18:56 +02:00
bors 6ed502d012 Auto merge of #3000 - RalfJung:no_std, r=oli-obk
auto-detect no_std where possible

r? `@oli-obk`
Cc https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/restricted_std.20sysroot.3F
2023-10-05 06:07:27 +00:00
bors 5236c8e1fa Auto merge of #116273 - compiler-errors:refine2, r=tmandry
Only trigger `refining_impl_trait` lint on reachable traits

Public but unreachable traits don't matter 😸

r? `@tmandry`
2023-10-05 03:00:30 +00:00
bors b781645332 Auto merge of #116184 - compiler-errors:afit-lint, r=tmandry
Add `async_fn_in_trait` lint

cc https://github.com/rust-lang/rust/pull/115822#issuecomment-1731168465

Mostly unsure what the messaging should be. Feedback required.

r? `@tmandry`
2023-10-05 01:14:25 +00:00
Alex Macleod 5453a9f34d Add a note to duplicate diagnostics 2023-10-05 01:04:41 +00:00
Nicholas Nethercote 8ba9137840 Merge `STABLE_REMOVED_FEATURES` list into `REMOVED_FEATURES`.
There is a single features (`no_stack_check`) in
`STABLE_REMOVED_FEATURES`. But the treatment of
`STABLE_REMOVED_FEATURES` and `REMOVED_FEATURES` is actually identical.
So this commit just merges them, and uses a comment to record
`no_stack_check`'s unique "stable removed" status.

This also lets `State::Stabilized` (which was a terrible name) be
removed.
2023-10-05 11:42:32 +11:00
Nicholas Nethercote 5d9559e026 Inline and remove `feature_removed` function.
It has a single call site. This increases consistency because other
errors within `features` are emitted directly.
2023-10-05 11:18:51 +11:00
Nicholas Nethercote 9e2cd038b0 Factor out some repeated feature-getting code. 2023-10-05 11:16:14 +11:00
Nicholas Nethercote e24f394404 Add comments to `config::features`.
I found this function very confusing, and it took me quite some time to
work out what it was doing. These comments capture that hard-earned
knowledge.
2023-10-05 11:16:05 +11:00
Nicholas Nethercote 1ddb2872dd Streamline `find_lang_feature_issue`.
It currently processes `ACTIVE_FEATURES` separately from
`ACCEPTED_FEATURES`, `REMOVED_FEATURES`, and `STABLE_REMOVED_FEATURES`,
for no good reason. This commit treats them uniformly.
2023-10-05 10:23:26 +11:00
Nicholas Nethercote 3c1b60c1b4 Split `declare_features!`.
It's a macro with four clauses, three of which are doing one thing, and
the fourth is doing something completely different. This commit splits
it into two macros, which is more sensible.
2023-10-05 10:23:20 +11:00
Nicholas Nethercote 043a9873b9 Remove `set!` macro.
It has a single call site.
2023-10-05 10:23:20 +11:00
Nicholas Nethercote 53fe37de2e Remove unused `Span` from the `set` function in `State::Active`. 2023-10-05 10:18:29 +11:00
bors afe67fa2ef Auto merge of #116370 - nnethercote:more-arena-stuff, r=cjgillot
Remove the `TypedArena::alloc_from_iter` specialization.

It was added in #78569. It's complicated and doesn't actually help
performance.

r? `@cjgillot`
2023-10-04 22:32:46 +00:00
Tyler Mandry 2f5249019e
Apply suggestions from code review
Co-authored-by: Travis Cross <tc@traviscross.com>
2023-10-04 18:20:05 -04:00
Michael Goulet c5c6d703de Point to closure return instead of output if defaulted 2023-10-04 21:09:54 +00:00
Michael Goulet dd5f26c42d Fix spans for comments in rustfmt 2023-10-04 21:09:54 +00:00
Michael Goulet 56794fa5f1 Fix clippy 2023-10-04 21:09:54 +00:00
Michael Goulet 1f079cfb44 Point to closure return instead of output if defaulted 2023-10-04 21:09:54 +00:00
Michael Goulet 89b14ae212 Fix clippy 2023-10-04 21:09:54 +00:00
Michael Goulet 137b6d0b01 Point to where missing return type should go 2023-10-04 21:09:54 +00:00
bors 2bbb619893 Auto merge of #114417 - chinedufn:fix-expect-unused-in-impl-block-rust-issue-114416, r=cjgillot
Fix multiple `expect` attribs in impl block

Closes #114416
2023-10-04 20:44:38 +00:00