Commit Graph

206691 Commits

Author SHA1 Message Date
yukang
e747201ad8 find the correct lang item for ranges 2022-10-04 21:02:07 +08:00
yukang
5dd44d4d4c fix #102396, suggest parentheses for possible range methods 2022-10-04 17:30:52 +08:00
bors
d9f8b4b985 Auto merge of #102395 - davidtwco:translation-rename-typeck, r=compiler-errors
errors: rename `typeck.ftl` to `hir_analysis.ftl`

In #102306, `rustc_typeck` was renamed to `rustc_hir_analysis` but the diagnostic resources were not renamed - which is what this pull request changes.
2022-10-04 03:57:50 +00:00
bors
1f1defc2f6 Auto merge of #99099 - Stargateur:phantomdata_debug, r=joshtriplett
Add T to PhantomData impl Debug

This add debug information for `PhantomData`, I believe it's make sense to add this to debug impl of `PhantomData` since `T` is what define what is the `PhantomData` just write `"PhantomData"` is not very useful for debugging.

Alternative:

* `PhantomData::<{}>`
* `PhantomData { t: "str_type" }`

`@rustbot` label +T-libs-api -T-libs
2022-10-04 00:56:14 +00:00
bors
f83e0266cf Auto merge of #102632 - matthiaskrgr:rollup-h8s3zmo, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #98218 (Document the conditional existence of `alloc::sync` and `alloc::task`.)
 - #99216 (docs: be less harsh in wording for Vec::from_raw_parts)
 - #99460 (docs: Improve AsRef / AsMut docs on blanket impls)
 - #100470 (Tweak `FpCategory` example order.)
 - #101040 (Fix `#[derive(Default)]` on a generic `#[default]` enum adding unnecessary `Default` bounds)
 - #101308 (introduce `{char, u8}::is_ascii_octdigit`)
 - #102486 (Add diagnostic struct for const eval error in `rustc_middle`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-03 20:22:18 +00:00
Matthias Krüger
1b9014f273
Rollup merge of #102486 - pierwill:middle-const-eval-err, r=compiler-errors
Add diagnostic struct for const eval error in `rustc_middle`

Part of #100717.

r? `@ghost`
2022-10-03 20:58:56 +02:00
Matthias Krüger
a5488826a9
Rollup merge of #101308 - nerdypepper:feature/is-ascii-octdigit, r=joshtriplett
introduce `{char, u8}::is_ascii_octdigit`

This feature adds two new APIs: `char::is_ascii_octdigit` and `u8::is_ascii_octdigit`, under the feature gate `is_ascii_octdigit`. These methods are shorthands for `char::is_digit(self, 8)` and `u8::is_digit(self, 8)`:

```rust
// core::char

impl char {
    pub fn is_ascii_octdigit(self) -> bool;
}

// core::num

impl u8 {
    pub fn is_ascii_octdigit(self) -> bool;
}
```

---

Couple of things I need help understanding:

- `const`ness: have I used the right attribute in this case?
- is there a way to run the tests for `core::char` alone, instead of `./x.py test library/core`?
2022-10-03 20:58:56 +02:00
Matthias Krüger
df11395a55
Rollup merge of #101040 - danielhenrymantilla:no-bounds-for-default-annotated-derive, r=joshtriplett
Fix `#[derive(Default)]` on a generic `#[default]` enum adding unnecessary `Default` bounds

That is, given something like:

```rs
// #[default] on a generic enum does not add `Default` bounds to the type params.
#[derive(Default)]
enum MyOption<T> {
    #[default]
    None,
    Some(T),
}
```

then `MyOption<T> : Default`_as currently implemented_ only holds when `T : Default`, as reported by ```@5225225``` [over Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.23.5Bderive.28Default.29.5D.20for.20enums.20with.20fields).

This is contrary to [what the accepted RFC proposes](https://rust-lang.github.io/rfcs/3107-derive-default-enum.html#generated-bounds) (_i.e._, that `T` be allowed not to be itself `Default`), and indeed seems to be a rather unnecessary limitation.
2022-10-03 20:58:55 +02:00
Matthias Krüger
c7f1b8e41d
Rollup merge of #100470 - reitermarkus:patch-1, r=joshtriplett
Tweak `FpCategory` example order.

Follow same order for variable declarations and assertions.
2022-10-03 20:58:55 +02:00
Matthias Krüger
eedb51210c
Rollup merge of #99460 - JanBeh:PR_asref_asmut_docs, r=joshtriplett
docs: Improve AsRef / AsMut docs on blanket impls

There are several issues with the current state of `AsRef` and `AsMut` as [discussed here on IRLO](https://internals.rust-lang.org/t/semantics-of-asref/17016). See also #39397, #45742, #73390, #98905, and the FIXMEs [here](https://github.com/rust-lang/rust/blob/1.62.0/library/core/src/convert/mod.rs#L509-L515) and [here](https://github.com/rust-lang/rust/blob/1.62.0/library/core/src/convert/mod.rs#L530-L536). These issues are difficult to fix. This PR aims to update the documentation to better reflect the status-quo and to give advice on how `AsRef` and `AsMut` should be used.

In particular:

- Explicitly mention that `AsRef` and `AsMut` do not auto-dereference generally for all dereferencable types (but only if inner type is a shared and/or mutable reference)
- Give advice to not use `AsRef` or `AsMut` for the sole purpose of dereferencing
- Suggest providing a transitive `AsRef` or `AsMut` implementation for types which implement `Deref`
- Add new section "Reflexivity" in documentation comments for `AsRef` and `AsMut`
- Provide better example for `AsMut`
- Added heading "Relation to `Borrow`" in `AsRef`'s docs to improve structure
2022-10-03 20:58:54 +02:00
Matthias Krüger
2110d2de5a
Rollup merge of #99216 - duarten:master, r=joshtriplett
docs: be less harsh in wording for Vec::from_raw_parts

In particular, be clear that it is sound to specify memory not
originating from a previous `Vec` allocation. That is already suggested
in other parts of the documentation about zero-alloc conversions to Box<[T]>.

Incorporate a constraint from `slice::from_raw_parts` that was missing
but needs to be fulfilled, since a `Vec` can be converted into a slice.

Fixes https://github.com/rust-lang/rust/issues/98780.
2022-10-03 20:58:53 +02:00
Matthias Krüger
098e8b7357
Rollup merge of #98218 - kpreid:nostdarc, r=joshtriplett
Document the conditional existence of `alloc::sync` and `alloc::task`.

`alloc` declares

```rust
#[cfg(target_has_atomic = "ptr")]
pub mod sync;
```

but there is no public documentation of this condition. This PR fixes that, so that users of `alloc` can understand how to make their code compile everywhere `alloc` does, if they are writing a library with impls for `Arc`.

The wording is copied from `std::sync::atomic::AtomicPtr`, with additional advice on how to `#[cfg]` for it.

I feel quite uncertain about whether the paragraph I added to `Arc`'s documentation should actually be there, as it is a distraction for anyone using `std`. On the other hand, maybe more reminders that no_std exists would benefit the ecosystem.

Note: `target_has_atomic` is [stabilized](https://github.com/rust-lang/rust/issues/32976) but [not yet documented in the reference](https://github.com/rust-lang/reference/pull/1171).
2022-10-03 20:58:53 +02:00
bors
0922559768 Auto merge of #102627 - matthiaskrgr:rollup-2xtrqkw, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #102439 (rustdoc: re-sugar more cross-crate trait bounds)
 - #102569 (Improve `FromStr` example)
 - #102597 (Avoid ICE in printing RPITIT type)
 - #102607 (Improve documentation of `slice::{from_ptr_range, from_ptr_range_mut}`)
 - #102613 (Fix ICE #101739)
 - #102615 (Cleanup some error code explanations)
 - #102617 (`HirId` for `deferred_transmute_checks`)
 - #102620 (Migrate `.stab` elements style to CSS variables)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-03 17:31:45 +00:00
pierwill
b9c0467e0c Add diagnostic struct for const eval error in rustc_middle
Co-authored-by: Michael Goulet <michael@errs.io>
2022-10-03 12:29:49 -05:00
Matthias Krüger
d32921340c
Rollup merge of #102620 - GuillaumeGomez:css-stab-migration, r=notriddle
Migrate `.stab` elements style to CSS variables

Part of https://github.com/rust-lang/rust/pull/98460.

There should be no UI changes.

r? `@notriddle`
2022-10-03 19:12:20 +02:00
Matthias Krüger
f50b72ffc5
Rollup merge of #102617 - lcnr:deferred_transmute_checks, r=compiler-errors
`HirId` for `deferred_transmute_checks`

directly interacting with spans is annoying 
2022-10-03 19:12:19 +02:00
Matthias Krüger
e64177c3f8
Rollup merge of #102615 - Nilstrieb:there-are-many-error-codes, r=compiler-errors
Cleanup some error code explanations

E0045: Use a stable non-C ABI instead
E0092: Use an atomic intrinsic that actually exists
E0161: Don't use box_syntax
E0579: Format ranges in the rustfmt style
E0622: Use the rustfmt style
E0743: Remove feature gate as it's not needed
2022-10-03 19:12:19 +02:00
Matthias Krüger
aa076d6144
Rollup merge of #102613 - TaKO8Ki:fix-part-of-101739, r=compiler-errors
Fix ICE #101739

Fixes a part of #101739

This cannot cover the following case. It causes `too many args provided` error and obligation does not have references error. I want your advice to solve the following cases as well in this pull request or a follow-up.

```rust
#![crate_type = "lib"]
#![feature(transmutability)]
#![allow(dead_code, incomplete_features, non_camel_case_types)]

mod assert {
    use std::mem::BikeshedIntrinsicFrom;

    pub fn is_transmutable<
        Src,
        Dst,
        Context,
        const ASSUME_ALIGNMENT: bool,
        const ASSUME_LIFETIMES: bool,
        const ASSUME_VALIDITY: bool,
        const ASSUME_VISIBILITY: bool,
    >()
    where
        Dst: BikeshedIntrinsicFrom<
            Src,
            Context,
            ASSUME_ALIGNMENT,
            ASSUME_LIFETIMES,
            ASSUME_VALIDITY,
            ASSUME_VISIBILITY,
        >,
    {}
}

fn via_const() {
    struct Context;
    #[repr(C)] struct Src;
    #[repr(C)] struct Dst;

    const FALSE: bool = false;

    assert::is_transmutable::<Src, Dst, Context, FALSE, FALSE, FALSE, FALSE>();
}
```
2022-10-03 19:12:19 +02:00
Matthias Krüger
3374a7d6f8
Rollup merge of #102607 - WaffleLapkin:docky_docky_slice_from_ptr_range, r=joshtriplett
Improve documentation of `slice::{from_ptr_range, from_ptr_range_mut}`

Document panic conditions (`T` is a ZST) and sync docs of shared/unique version.

cc `@wx-csy`
2022-10-03 19:12:18 +02:00
Matthias Krüger
8ede2340b7
Rollup merge of #102597 - compiler-errors:issue-102571, r=davidtwco
Avoid ICE in printing RPITIT type

Fixes #102571
2022-10-03 19:12:18 +02:00
Matthias Krüger
cdd0ba8f41
Rollup merge of #102569 - eduardosm:from_str-example, r=joshtriplett
Improve `FromStr` example

The `from_str` implementation from the example had an `unwrap` that would make it panic on invalid input strings. Instead of panicking, it nows returns an error to better reflect the intented behavior of the `FromStr` trait.
2022-10-03 19:12:17 +02:00
Matthias Krüger
2e7e17a84a
Rollup merge of #102439 - fmease:rustdoc-simplify-cross-crate-trait-bounds, r=GuillaumeGomez
rustdoc: re-sugar more cross-crate trait bounds

Previously, we would only ever re-sugar cross-crate predicates like `Type: Trait, <Type as Trait>::Name == Rhs` to `Type: Trait<Name = Rhs>` if the `Type` was a generic parameter like `Self` or `T`. With this PR, `Type` can be any type.

Most notably, this means that we now re-sugar predicates involving associated types (where `Type` is of the form `Self::Name`) which are then picked up by the pre-existing logic that re-sugars them into bounds. As a result of that, the associated type `IntoIter` of `std`'s `IntoIterator` trait (re-exported from `core`) is no longer rendered as:

```rust
type IntoIter: Iterator
where
    <Self::IntoIter as Iterator>::Item == Self::Item;
```

but as one would expect: `type IntoIter: Iterator<Item = Self::Item>;`.

Cross-crate closure bounds like `F: Fn(i32) -> bool` are now also rendered properly (previously, the return type (`Self::Output`) would not be rendered and we would show the underlying equality predicate).

Fixes #77763.
Fixes #84579.
Fixes #102142.

`@rustbot` label T-rustdoc A-cross-crate-reexports
r? rustdoc
2022-10-03 19:12:17 +02:00
bors
33d351972a Auto merge of #102610 - dawnofmidnight:git-commit-hash, r=Mark-Simulacrum
re-add git-commit-hash file to tarballs

rust-lang/rust#100557 removed the `git-commit-hash` file and replaced it with `git-commit-info`. However, build-manifest relies on the `git-commit-hash` file being present, so this adds it back.

r? `@Mark-Simulacrum`
2022-10-03 14:20:32 +00:00
Guillaume Gomez
c0c7597eea Migrate stab elements style to CSS variables 2022-10-03 15:31:59 +02:00
David Wood
c4418e1940 errors: rename typeck.ftl to hir_analysis.ftl
In #102306, `rustc_typeck` was renamed to `rustc_hir_analysis` but the
diagnostic resources were not renamed - which is what this commit
changes.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-03 13:52:17 +01:00
lcnr
550715d74d HirId for deferred_transmute_checks 2022-10-03 13:53:17 +02:00
bors
f47e9af824 Auto merge of #102551 - bjorn3:cg_ssa_cleanup, r=davidtwco
Some more cleanup for rustc_codegen_ssa

With the aim to make non-LLVM like backends, like Cranelift, easier to support using cg_ssa.
2022-10-03 11:02:58 +00:00
Takayuki Maeda
0e615caa8d check if const is ADT or not 2022-10-03 17:51:18 +09:00
bors
6b139c5b3e Auto merge of #102614 - matthiaskrgr:rollup-fjyu7oo, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #102550 (rustdoc: remove no-op CSS on `.impl, .method` etc)
 - #102591 (Fix duplicate usage of `a` article.)
 - #102592 (Remove a couple lifetimes that can be infered)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-03 07:30:34 +00:00
nils
1df0a1890a Cleanup some error code explanations
E0045: Use a stable non-C ABI instead
E0092: Use an atomic intrinsic that actually exists
E0161: Don't use box_syntax
E0579: Format ranges in the rustfmt style
E0622: Use the rustfmt style
E0743: Remove feature gate as it's not needed
2022-10-03 08:53:06 +02:00
Takayuki Maeda
b8b30ae6ba add a ui test for #101739 2022-10-03 15:02:38 +09:00
Matthias Krüger
d5fb8d2aef
Rollup merge of #102592 - WaffleLapkin:less_lifetimes, r=cjgillot
Remove a couple lifetimes that can be infered

From the review: https://github.com/rust-lang/rust/pull/101986#discussion_r974497497

r? `@cjgillot`
2022-10-03 08:00:48 +02:00
Matthias Krüger
d679ec5e2f
Rollup merge of #102591 - JarvisCraft:fix-double-a-article, r=compiler-errors
Fix duplicate usage of `a` article.

This fixes a typo first appearing in #94624 in which test-macro diagnostic uses "a" article twice.

Since I searched the sources for " a a " sequences, I also fixed the same issue in a few files where I found it.
2022-10-03 08:00:47 +02:00
Matthias Krüger
c3053309c5
Rollup merge of #102550 - notriddle:notriddle/impl, r=GuillaumeGomez
rustdoc: remove no-op CSS on `.impl, .method` etc

Preview: http://notriddle.com/notriddle-rustdoc-demos/impl/index.html

# `flex-basis: 100%`

When `.impl-items { flex-basis: 100% }` and `h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant` were added in 34bd2b845b, it seems like it was a mistake even then. According to MDN, [flex-basis] does nothing unless the box it's applied to is a flex *item*, a child of a flex container. However, when this was added, these elements were flex containers themselves.

[flex-basis]: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis

# `position: relative`

This property was added to help with positioning the `[+]/[-]` toggle. It is no longer necessary, because `details.rustdoc-toggle` already has `position:relative` set on it.
2022-10-03 08:00:47 +02:00
Takayuki Maeda
82510b90c6 return when obligation has references_error 2022-10-03 14:17:42 +09:00
bors
dbaf3e67aa Auto merge of #102508 - nnethercote:even-more-lexer-improvements, r=matklad
Even more lexer improvements

These are just about code clarity, rather than performance.

r? `@matklad`
2022-10-03 04:49:46 +00:00
dawnofmidnight
5c908c642b re-add git-commit-hash file to tarballs
rust-lang/rust#100557 removed the `git-commit-hash` file and replaced it
with `git-commit-info`. However, build-manifest relies on the
`git-commit-hash` file being present, so this adds it back.
2022-10-02 23:58:40 -04:00
León Orell Valerian Liehr
a5402343f6
rustdoc: re-sugar more cross-crate trait bounds 2022-10-03 04:36:39 +02:00
bors
607b8296e0 Auto merge of #102503 - cuviper:x86-stack-probes, r=nagisa
Enable inline stack probes on X86 with LLVM 16

The known problems with x86 inline-asm stack probes have been solved on LLVM main (16), so this flips the switch. Anyone using bleeding-edge LLVM with rustc can start testing this, as I have done locally. We'll get more direct rust-ci when LLVM 16 branches and we start our upgrade, and we can always patch or disable it then if we find new problems.

The previous attempt was #77885, reverted in #84708.
2022-10-03 02:09:05 +00:00
Maybe Waffle
2cd5fafd25 Sync docs of slice::{from_ptr_range, from_ptr_range_mut} 2022-10-03 00:44:50 +00:00
Nicholas Nethercote
4e5ddf1adf Invert is_top_level to avoid negation. 2022-10-03 11:42:29 +11:00
Nicholas Nethercote
a822d08bd1 Remove TokenStreamBuilder.
It's now only used in one function. Also, the "should we glue the
tokens?" check is only necessary when pushing a `TokenTree::Token`, not
when pushing a `TokenTree::Delimited`.

As part of this, we now do the "should we glue the tokens?" check
immediately, which avoids having look back at the previous token. It
also puts all the logic dealing with token gluing in a single place.
2022-10-03 11:42:29 +11:00
Nicholas Nethercote
8d0754d602 Inline and remove parse_token_tree_non_delim_non_eof.
It has a single call site.
2022-10-03 11:42:29 +11:00
Nicholas Nethercote
ce7676829e Merge parse_token_trees_until_close_delim and parse_all_token_trees.
Because they're very similar, and this will allow some follow-up
changes.
2022-10-03 11:42:29 +11:00
Nicholas Nethercote
9de9cf19d7 Add comments to TokenCursor::desugar.
It took me some time to work out what this code was doing.
2022-10-03 11:42:29 +11:00
Nicholas Nethercote
40e4827fd2 Rewrite Token::is_op.
An exhaustive match is more readable and more future-proof.
2022-10-03 11:42:29 +11:00
Nicholas Nethercote
bbb53bf772 Add comments to Spacing. 2022-10-03 11:42:21 +11:00
Maybe Waffle
bc1216e046 Document when slice::from_ptr_range[_mut] panic 2022-10-03 00:41:54 +00:00
Nicholas Nethercote
3be86e6528 Clarify operator splitting.
I found this code hard to read.
2022-10-03 11:41:36 +11:00
bors
573fd5a8c5 Auto merge of #102305 - flba-eb:remove_exclude_list, r=Mark-Simulacrum
Get rid of exclude-list for Windows-only tests

Main purpose of this change is to get rid of a quite long (and growing) list of excluded targets, while this test should only be useful on Windows (as far as I understand it). The `// only-windows` header seams to implement exactly what we need here.

I don't know why there are some whitespace changes, but `x.py fmt` and `.git/hooks/pre-push` are happy.
2022-10-02 23:47:48 +00:00