Commit Graph

215166 Commits

Author SHA1 Message Date
Matthias Krüger
9bcc46ee90
Rollup merge of #106949 - compiler-errors:is-poly, r=BoxyUwU
ConstBlocks are poly if their substs are poly

r? `@BoxyUwU`

fixes #106926
2023-01-17 05:25:23 +01:00
Matthias Krüger
b90f62988d
Rollup merge of #106869 - notriddle:notriddle/item-decl-pre-rust, r=GuillaumeGomez
rustdoc: remove redundant item kind class from `.item-decl > pre`

This class originated in the very first commit of `rustdoc_ng`, and was used to add a color border around the item decl based on its kind.

4fd061c426/src/rustdoc_ng/html/static/main.css (L102-L106)

The item decl no longer has a border, and there aren't any kind-specific styles in modern rustdoc's rendering of this UI item.

Most of this PR is updating test cases so that they use `item-decl` to find the `<pre>` tag instead of relying on the fact that the class name had `rust {kind}` in it while other `<pre>` tags only had class `rust`.
2023-01-17 05:25:22 +01:00
Matthias Krüger
6b49435480
Rollup merge of #106829 - compiler-errors:more-alias-combine, r=spastorino
Unify `Opaque`/`Projection` handling in region outlives code

They share basically identical paths in most places which are even easier to unify now that they're both `ty::Alias`

r? types
2023-01-17 05:25:22 +01:00
Matthias Krüger
9cda9e0ab6
Rollup merge of #106712 - Ezrashaw:impl-ref-trait, r=estebank
make error emitted on `impl &Trait` nicer

Fixes #106694

Turned out to be simpler than I thought, also added UI test.

Before: ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9bda53271ef3a8886793cf427b8cea91))
```text
error: expected one of `:`, ``@`,` or `|`, found `)`
 --> src/main.rs:2:22
  |
2 | fn foo(_: impl &Trait) {}
  |                      ^ expected one of `:`, ``@`,` or `|`
  |
  = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
help: if this is a parameter name, give it a type
  |
2 | fn foo(_: impl Trait: &TypeName) {}
  |                ~~~~~~~~~~~~~~~~
help: if this is a type, explicitly ignore the parameter name
  |
2 | fn foo(_: impl _: &Trait) {}
  |                ++

error: expected one of `!`, `(`, `)`, `,`, `?`, `for`, `~`, lifetime, or path, found `&`
 --> src/main.rs:2:16
  |
2 | fn foo(_: impl &Trait) {}
  |               -^ expected one of 9 possible tokens
  |               |
  |               help: missing `,`

error: expected one of `!`, `(`, `,`, `=`, `>`, `?`, `for`, `~`, lifetime, or path, found `&`
 --> src/main.rs:3:11
  |
3 | fn bar<T: &Trait>(_: T) {}
  |           ^ expected one of 10 possible tokens
```

After:
```text
error: expected a trait, found type
 --> <anon>:2:16
  |
2 | fn foo(_: impl &Trait) {}
  |                -^^^^^
  |                |
  |                help: consider removing the indirection

error: expected a trait, found type
 --> <anon>:3:11
  |
3 | fn bar<T: &Trait>(_: T) {}
  |           -^^^^^
  |           |
  |           help: consider removing the indirection
```
2023-01-17 05:25:21 +01:00
Matthias Krüger
f74044259a
Rollup merge of #106591 - Ezrashaw:attempted-integer-identifer, r=Estebank
suggestion for attempted integer identifier in patterns

Fixes #106552

Implemented a suggestion on `E0005` that occurs when no bindings are present and the pattern is a literal integer.
2023-01-17 05:25:21 +01:00
Michael Goulet
9f6fef9657 Properly pluralize 'generic constants' 2023-01-16 20:21:29 +00:00
Michael Goulet
fdaac4e48e ConstBlocks are poly if their substs are poly 2023-01-16 20:09:31 +00:00
bors
4781233a77 Auto merge of #106945 - matthiaskrgr:rollup-c5or8z3, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #105954 (Update instrument-coverage.md)
 - #106835 (new trait solver: rebase impl substs for gats correctly)
 - #106912 (check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736))
 - #106940 (Improve a TAIT error and add an error code plus documentation)
 - #106942 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-16 19:30:08 +00:00
Matthias Krüger
4fb9da1db5
Rollup merge of #106942 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/book

1 commits in 2bd5d42c9956369132228da6409f0e68da56c51a..2cd1b5593d26dc6a03c20f8619187ad4b2485552
2023-01-12 14:47:47 UTC to 2023-01-12 14:47:47 UTC

- Typo (rust-lang/book#3457)

## rust-lang/nomicon

2 commits in 8ca261268068d80c0969260fff15199bad87b587..960d610e7f33889a2577f5f17c26f0d5c82b30df
2023-01-06 11:51:41 UTC to 2023-01-05 10:20:31 UTC

- vec/raw: Simplify `RawVec::grow` (rust-lang/nomicon#392)
- borrow-splitting: Use `take` instead of `replace` (rust-lang/nomicon#391)

## rust-lang/reference

4 commits in 3ae62681ff236d5528ef7c8c28ba7c6b2ecc6731..2cb0ed9ba56360949f492f9866afe8c293f9f9da
2023-01-13 03:16:35 UTC to 2023-01-07 00:08:06 UTC

- Update field-expr.md (rust-lang/reference#1318)
- Update documentation for arbitrary_enum_discriminant feature (rust-lang/reference#1055)
- Add links to definitions of terminology ... (rust-lang/reference#1315)
- Enable triagebot shortcuts (rust-lang/reference#1314)

## rust-lang/rust-by-example

2 commits in 8888f9428fe9a48f31de6bd2cef9b9bf80791edc..a9fb7d13eadfcc5f457962731f105b97f9a7474a
2023-01-14 10:25:39 UTC to 2023-01-11 18:25:42 UTC

- get_or_insert example: print my_fruit as intended (rust-lang/rust-by-example#1664)
- Update print.md (rust-lang/rust-by-example#1663)

## rust-lang/rustc-dev-guide

8 commits in b3e2a6e6c8a3aae5b5d950c63046f23bae07096d..7352353ae91c48b136d2ca7d03822e1448165e1e
2023-01-14 20:34:23 UTC to 2023-01-02 23:35:09 UTC

- fix examples for rustc 1.68.0-nightly (935dc0721 2022-12-19) (#1556) (rust-lang/rustc-dev-guide#1557)
- Update incremental-compilation-in-detail.md (rust-lang/rustc-dev-guide#1553)
- Link to the youtube recording of my talk, not the summary (rust-lang/rustc-dev-guide#1554)
- Change `src/test` to `tests` (rust-lang/rustc-dev-guide#1547)
- add full name for ICE (rust-lang/rustc-dev-guide#1552)
- Fix incorrect links (rust-lang/rustc-dev-guide#1549)
- fix rebase link (rust-lang/rustc-dev-guide#1546)
- Add a section for how to review code more easily (rust-lang/rustc-dev-guide#1538)
2023-01-16 20:29:40 +01:00
Matthias Krüger
d2a8a9fb36
Rollup merge of #106940 - oli-obk:tait_error, r=compiler-errors
Improve a TAIT error and add an error code plus documentation

cc https://github.com/rust-lang/rust/issues/106858
2023-01-16 20:29:39 +01:00
Matthias Krüger
37378ee7da
Rollup merge of #106912 - gftea:pr-106736, r=Nilstrieb
check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736)

PR to solve #106736, r? `@cjgillot`
2023-01-16 20:29:39 +01:00
Matthias Krüger
8ea26ca17f
Rollup merge of #106835 - compiler-errors:new-solver-gat-rebase-oops, r=lcnr
new trait solver: rebase impl substs for gats correctly

you might've caught this while working on projection code, if so then you can close this pr

r? `@lcnr`
2023-01-16 20:29:38 +01:00
Matthias Krüger
cf533dd3d5
Rollup merge of #105954 - gftea:patch-1, r=ehuss
Update instrument-coverage.md

explicitly set environment variable LLVM_PROFILE_FILE="default_%m.profraw"  when starting cargo test, otherwise, only one `default.profraw ` is generated and will be overwritten if run unnittests and integration tests at the same time.
2023-01-16 20:29:37 +01:00
rustbot
db1ddef55e Update books 2023-01-16 12:01:00 -05:00
Oli Scherer
6b69b5e460 Improve a TAIT error and add an error code plus documentation 2023-01-16 16:54:14 +00:00
bors
481725984b Auto merge of #106853 - TimNN:undo-remap, r=oli-obk
Heuristically undo path prefix mappings.

Because the compiler produces better diagnostics if it can find the source of (potentially remapped) dependencies.

The new test fails without the other changes in this PR. Let me know if you have better suggestions for the test directory. I moved the existing remapping test to be in the same location as the new one.

Some more context: I'm exploring running UI tests with remapped paths by default in https://github.com/rust-lang/rust/pull/105924 and this was one of the issues discovered.

This may also be useful in the context of https://github.com/rust-lang/rfcs/pull/3127 ("New rustc and Cargo options to allow path sanitisation by default").
2023-01-16 15:11:28 +00:00
gftea
c1f1f60bcb Update instrument-coverage.md
Document the default for LLVM_PROFILE_FILE and add a recemmondation for setting
it for older versions of Rust which had a different default.
2023-01-16 06:27:29 -08:00
bors
af669c2684 Auto merge of #106850 - cjgillot:issue-106141, r=oli-obk
Make the inlining destination a Local.

Fixes https://github.com/rust-lang/rust/issues/106141
2023-01-16 12:30:49 +00:00
gftea
2c5583efbd check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736) 2023-01-16 11:09:53 +01:00
bors
a5bfc25c93 Auto merge of #106872 - dtolnay:nbsp, r=fee1-dead
Emit only one nbsp error per file

Fixes #106101.

See https://github.com/rust-lang/rust/issues/106098 for an explanation of how someone would end up with a large number of these nbsp characters in their source code, which is why I think rustc needs to handle this specific case in a friendlier way.
2023-01-16 09:37:08 +00:00
bors
d12412c90f Auto merge of #106395 - compiler-errors:rework-predicates, r=eholk
Rework some `predicates_of`/`{Generic,Instantiated}Predicates` code

1. Make `instantiate_own` return an iterator, since it's a bit more efficient and easier to work with
2. Remove `bound_{explicit,}_predicates_of` -- these `bound_` methods in particular were a bit awkward to work with since `ty::GenericPredicates` *already* acts kinda like an `EarlyBinder` with its own `instantiate_*` methods, and had only a few call sites anyways.
3. Implement `IntoIterator` for `InstantiatedPredicates`, since it's *very* commonly being `zip`'d together.
2023-01-16 05:55:59 +00:00
Ezra Shaw
fcd5ed21b7
fix dropping diagnostic without emit 2023-01-16 16:18:56 +13:00
bors
41edaac716 Auto merge of #106907 - matthiaskrgr:rustdoc_ref, r=GuillaumeGomez
rustdoc: simplify some & ref erences
2023-01-16 02:43:25 +00:00
bors
9a19e76044 Auto merge of #106914 - matthiaskrgr:rollup-yh0x4gq, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #106888 (Add tidy check to ensure that rustdoc GUI tests start with a small description)
 - #106896 (suggest `is_empty` for collections when casting to `bool`)
 - #106900 (Fix regression in `unused_braces` with macros)
 - #106906 (remove redundant clones)
 - #106909 (Only suggest adding type param if path being resolved was a type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-15 21:35:50 +00:00
Matthias Krüger
fc78b1e7f9
Rollup merge of #106909 - compiler-errors:only-types-can-be, r=estebank
Only suggest adding type param if path being resolved was a type
2023-01-15 21:17:36 +01:00
Matthias Krüger
8bd67dd12d
Rollup merge of #106906 - matthiaskrgr:clone, r=Nilstrieb
remove redundant clones
2023-01-15 21:17:35 +01:00
Matthias Krüger
5321ad574d
Rollup merge of #106900 - clubby789:unused-braces-regression, r=estebank
Fix regression in `unused_braces` with macros

Fixes #106899
2023-01-15 21:17:35 +01:00
Matthias Krüger
5610231454
Rollup merge of #106896 - Ezrashaw:str-cast-bool-emptyness, r=compiler-errors
suggest `is_empty` for collections when casting to `bool`

Fixes #106883

Matches on slices, `String` and `str`. It would be nice to do this with something like `Deref<Target=str>` as well, but AFAIK it's not possible in this part of the compiler.
2023-01-15 21:17:34 +01:00
Matthias Krüger
72180b348b
Rollup merge of #106888 - GuillaumeGomez:tidy-gui-test, r=notriddle
Add tidy check to ensure that rustdoc GUI tests start with a small description

The first commit comes from https://github.com/rust-lang/rust/pull/106865 to prevent CI to fail.

This PR adds a tidy check to enforce having a small description at the top of the GUI test. Although the format is made to be as easy as possible to read, it's not always obvious what a test is actually checking. I think enforcing this will make it easier for us to come back on these tests if needed.

r? `@notriddle`
2023-01-15 21:17:34 +01:00
bors
9e75dddf60 Auto merge of #106393 - the8472:use-ptr-sub, r=scottmcm
Simplify manual ptr arithmetic in slice::Iter with ptr_sub

The old code was introduced in #61885, which predates the ptr_sub method and underlying intrinsic. The codegen test still passes.

r? `@scottmcm`
2023-01-15 18:39:40 +00:00
The 8472
9db0134018 replace manual ptr arithmetic with ptr_sub 2023-01-15 17:38:05 +01:00
Michael Goulet
566202b975 Only suggest adding type param if path being resolved was a type 2023-01-15 16:33:08 +00:00
Michael Goulet
90df86f474 Remove bound_{explicit,}_item_bounds 2023-01-15 15:36:06 +00:00
Michael Goulet
e1533a26f7 drive-by: assert when iterating through InstantiatedPredicates 2023-01-15 15:36:06 +00:00
Michael Goulet
9b28edb6d7 Make InstantiatedPredicates impl IntoIterator 2023-01-15 15:36:06 +00:00
Michael Goulet
91fd862df0 instantiate_own doesn't need to return a pair of vectors 2023-01-15 15:29:53 +00:00
bors
ae4d89dfb5 Auto merge of #106742 - compiler-errors:new-solver-make-it-not-ice, r=lcnr
Implement some FIXME methods in the new trait solver

Implement just enough of the solver's response logic to make it not ICE.

Also, fix a bug with `no_bound_vars` call failing due to canonical bound vars.

r? `@lcnr`
2023-01-15 15:07:27 +00:00
Matthias Krüger
fdd6af14a1 rustdoc: simplify some & ref erences 2023-01-15 15:23:30 +01:00
Matthias Krüger
665d4ea98d remove redundant clones 2023-01-15 15:02:02 +01:00
bors
fc11ee02ee Auto merge of #106171 - compiler-errors:consolidate-extract_callable_info, r=estebank,lcnr
Consolidate two almost duplicated fn info extraction routines

Moves `extract_callable_info` up to trait selection, because it was being (almost) duplicated fully there for similar diagnostic purposes. This also generalizes the diagnostics we can give slightly (see UI test).
2023-01-15 12:10:36 +00:00
Guillaume Gomez
5376670323 Add small description to GUI test 2023-01-15 12:58:04 +01:00
Guillaume Gomez
98cfa68f16 Add tidy check to ensure that rustdoc GUI tests start with a small description 2023-01-15 12:58:04 +01:00
Ezra Shaw
92ced4a12e
suggest is_empty for collections when casting to bool 2023-01-15 22:17:54 +13:00
bors
bbb36fe545 Auto merge of #105851 - dtolnay:peekmutleak, r=Mark-Simulacrum
Leak amplification for peek_mut() to ensure BinaryHeap's invariant is always met

In the libs-api team's discussion around #104210, some of the team had hesitations around exposing malformed BinaryHeaps of an element type whose Ord and Drop impls are trusted, and which does not contain interior mutability.

For example in the context of this kind of code:

```rust
use std::collections::BinaryHeap;
use std::ops::Range;
use std::slice;

fn main() {
    let slice = &mut ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
    let cut_points = BinaryHeap::from(vec![4, 2, 7]);
    println!("{:?}", chop(slice, cut_points));
}

// This is a souped up slice::split_at_mut to split in arbitrary many places.
//
// usize's Ord impl is trusted, so 1 single bounds check guarantees all those
// output slices are non-overlapping and in-bounds
fn chop<T>(slice: &mut [T], mut cut_points: BinaryHeap<usize>) -> Vec<&mut [T]> {
    let mut vec = Vec::with_capacity(cut_points.len() + 1);
    let max = match cut_points.pop() {
        Some(max) => max,
        None => {
            vec.push(slice);
            return vec;
        }
    };

    assert!(max <= slice.len());

    let len = slice.len();
    let ptr: *mut T = slice.as_mut_ptr();
    let get_unchecked_mut = unsafe {
        |range: Range<usize>| &mut *slice::from_raw_parts_mut(ptr.add(range.start), range.len())
    };

    vec.push(get_unchecked_mut(max..len));
    let mut end = max;
    while let Some(start) = cut_points.pop() {
        vec.push(get_unchecked_mut(start..end));
        end = start;
    }
    vec.push(get_unchecked_mut(0..end));
    vec
}
```

```console
[['7', '8', '9'], ['4', '5', '6'], ['2', '3'], ['0', '1']]
```

In the current BinaryHeap API, `peek_mut()` is the only thing that makes the above function unsound.

```rust
let slice = &mut ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
let mut cut_points = BinaryHeap::from(vec![4, 2, 7]);
{
    let mut max = cut_points.peek_mut().unwrap();
    *max = 0;
    std::mem::forget(max);
}
println!("{:?}", chop(slice, cut_points));
```

```console
[['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], [], ['2', '3'], ['0', '1']]
```

Or worse:

```rust
let slice = &mut ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
let mut cut_points = BinaryHeap::from(vec![100, 100]);
{
    let mut max = cut_points.peek_mut().unwrap();
    *max = 0;
    std::mem::forget(max);
}
println!("{:?}", chop(slice, cut_points));
```

```console
[['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], [], ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '\u{1}', '\0', '?', '翾', '?', '翾', '\0', '\0', '?', '翾', '?', '翾', '?', '啿', '?', '啿', '?', '啿', '?', '啿', '?', '啿', '?', '翾', '\0', '\0', '񤬐', '啿', '\u{5}', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\u{8}', '\0', '`@',` '\0', '\u{1}', '\0', '?', '翾', '?', '翾', '?', '翾', '
thread 'main' panicked at 'index out of bounds: the len is 33 but the index is 33', library/core/src/unicode/unicode_data.rs:319:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

---

This PR makes `peek_mut()` use leak amplification (https://doc.rust-lang.org/1.66.0/nomicon/leaking.html#drain) to preserve the heap's invariant even in the situation that `PeekMut` gets leaked.

I'll also follow up in the tracking issue of unstable `drain_sorted()` (#59278) and `retain()` (#71503).
2023-01-15 08:59:55 +00:00
clubby789
295f5483fe Fix regression in unused_braces with macros 2023-01-15 05:08:30 +00:00
bors
754f6d4a8c Auto merge of #106892 - matthiaskrgr:rollup-ohneu8o, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #106072 (fix: misleading "add dyn keyword before derive macro" suggestion)
 - #106859 (Suggestion for type mismatch when we need a u8 but the programmer wrote a char literal)
 - #106863 (Remove various double spaces in compiler source comments.)
 - #106865 (Add explanation comment for GUI test)
 - #106867 (Fix the stability attributes for `std::os::fd`.)
 - #106878 (Add regression test for #92157)
 - #106879 (Add regression test for #42114)
 - #106880 (doc: fix typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-15 00:16:09 +00:00
Matthias Krüger
cdf462275a
Rollup merge of #106880 - tspiteri:borrowing-sub-typo, r=cuviper
doc: fix typo
2023-01-15 01:01:39 +01:00
Matthias Krüger
30b963c05c
Rollup merge of #106879 - JohnTitor:issue-42114, r=compiler-errors
Add regression test for #42114

Closes #42114
r? compiler-errors
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-01-15 01:01:39 +01:00
Matthias Krüger
08ef0ce056
Rollup merge of #106878 - JohnTitor:issue-92157, r=compiler-errors
Add regression test for #92157

Closes #92157
r? compiler-errors
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-01-15 01:01:38 +01:00
Matthias Krüger
445e3841da
Rollup merge of #106867 - sunfishcode:sunfishcode/std-os-fd-stable-version, r=m-ou-se
Fix the stability attributes for `std::os::fd`.

As `@bjorn3` pointed out [here], I used the wrong stability attribute in #98368 when making `std::os::fd` public. I set it to Rust 1.63, which was when io-safety was stabilized, but it should be Rust 1.66, which was when `std::os::fd` was stabilized.

[here]: https://github.com/rust-lang/rust/pull/98368#discussion_r1063721420
2023-01-15 01:01:38 +01:00