]> git.lizzy.rs Git - rust.git/log
rust.git
17 months agoAuto merge of #106853 - TimNN:undo-remap, r=oli-obk
bors [Mon, 16 Jan 2023 15:11:28 +0000 (15:11 +0000)]
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").

17 months agoAuto merge of #106850 - cjgillot:issue-106141, r=oli-obk
bors [Mon, 16 Jan 2023 12:30:49 +0000 (12:30 +0000)]
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

17 months agoAuto merge of #106872 - dtolnay:nbsp, r=fee1-dead
bors [Mon, 16 Jan 2023 09:37:08 +0000 (09:37 +0000)]
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.

17 months agoAuto merge of #106395 - compiler-errors:rework-predicates, r=eholk
bors [Mon, 16 Jan 2023 05:55:59 +0000 (05:55 +0000)]
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.

17 months agoAuto merge of #106907 - matthiaskrgr:rustdoc_ref, r=GuillaumeGomez
bors [Mon, 16 Jan 2023 02:43:25 +0000 (02:43 +0000)]
Auto merge of #106907 - matthiaskrgr:rustdoc_ref, r=GuillaumeGomez

rustdoc: simplify some & ref erences

17 months agoAuto merge of #106914 - matthiaskrgr:rollup-yh0x4gq, r=matthiaskrgr
bors [Sun, 15 Jan 2023 21:35:50 +0000 (21:35 +0000)]
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

17 months agoRollup merge of #106909 - compiler-errors:only-types-can-be, r=estebank
Matthias Krüger [Sun, 15 Jan 2023 20:17:36 +0000 (21:17 +0100)]
Rollup merge of #106909 - compiler-errors:only-types-can-be, r=estebank

Only suggest adding type param if path being resolved was a type

17 months agoRollup merge of #106906 - matthiaskrgr:clone, r=Nilstrieb
Matthias Krüger [Sun, 15 Jan 2023 20:17:35 +0000 (21:17 +0100)]
Rollup merge of #106906 - matthiaskrgr:clone, r=Nilstrieb

remove redundant clones

17 months agoRollup merge of #106900 - clubby789:unused-braces-regression, r=estebank
Matthias Krüger [Sun, 15 Jan 2023 20:17:35 +0000 (21:17 +0100)]
Rollup merge of #106900 - clubby789:unused-braces-regression, r=estebank

Fix regression in `unused_braces` with macros

Fixes #106899

17 months agoRollup merge of #106896 - Ezrashaw:str-cast-bool-emptyness, r=compiler-errors
Matthias Krüger [Sun, 15 Jan 2023 20:17:34 +0000 (21:17 +0100)]
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.

17 months agoRollup merge of #106888 - GuillaumeGomez:tidy-gui-test, r=notriddle
Matthias Krüger [Sun, 15 Jan 2023 20:17:34 +0000 (21:17 +0100)]
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`

17 months agoAuto merge of #106393 - the8472:use-ptr-sub, r=scottmcm
bors [Sun, 15 Jan 2023 18:39:40 +0000 (18:39 +0000)]
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`

17 months agoreplace manual ptr arithmetic with ptr_sub
The 8472 [Tue, 3 Jan 2023 01:39:13 +0000 (02:39 +0100)]
replace manual ptr arithmetic with ptr_sub

17 months agoOnly suggest adding type param if path being resolved was a type
Michael Goulet [Sun, 15 Jan 2023 16:33:08 +0000 (16:33 +0000)]
Only suggest adding type param if path being resolved was a type

17 months agoRemove bound_{explicit,}_item_bounds
Michael Goulet [Tue, 3 Jan 2023 05:01:17 +0000 (05:01 +0000)]
Remove bound_{explicit,}_item_bounds

17 months agodrive-by: assert when iterating through InstantiatedPredicates
Michael Goulet [Tue, 3 Jan 2023 03:38:06 +0000 (03:38 +0000)]
drive-by: assert when iterating through InstantiatedPredicates

17 months agoMake InstantiatedPredicates impl IntoIterator
Michael Goulet [Tue, 3 Jan 2023 03:32:59 +0000 (03:32 +0000)]
Make InstantiatedPredicates impl IntoIterator

17 months agoinstantiate_own doesn't need to return a pair of vectors
Michael Goulet [Tue, 3 Jan 2023 02:49:31 +0000 (02:49 +0000)]
instantiate_own doesn't need to return a pair of vectors

17 months agoAuto merge of #106742 - compiler-errors:new-solver-make-it-not-ice, r=lcnr
bors [Sun, 15 Jan 2023 15:07:27 +0000 (15:07 +0000)]
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`

17 months agorustdoc: simplify some & ref erences
Matthias Krüger [Sun, 15 Jan 2023 14:23:30 +0000 (15:23 +0100)]
rustdoc: simplify some & ref erences

17 months agoremove redundant clones
Matthias Krüger [Sun, 15 Jan 2023 14:02:02 +0000 (15:02 +0100)]
remove redundant clones

17 months agoAuto merge of #106171 - compiler-errors:consolidate-extract_callable_info, r=estebank...
bors [Sun, 15 Jan 2023 12:10:36 +0000 (12:10 +0000)]
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).

17 months agoAdd small description to GUI test
Guillaume Gomez [Sat, 14 Jan 2023 21:18:56 +0000 (22:18 +0100)]
Add small description to GUI test

17 months agoAdd tidy check to ensure that rustdoc GUI tests start with a small description
Guillaume Gomez [Sat, 14 Jan 2023 21:17:06 +0000 (22:17 +0100)]
Add tidy check to ensure that rustdoc GUI tests start with a small description

17 months agosuggest `is_empty` for collections when casting to `bool`
Ezra Shaw [Sun, 15 Jan 2023 02:51:52 +0000 (15:51 +1300)]
suggest `is_empty` for collections when casting to `bool`

17 months agoAuto merge of #105851 - dtolnay:peekmutleak, r=Mark-Simulacrum
bors [Sun, 15 Jan 2023 08:59:55 +0000 (08:59 +0000)]
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).

17 months agoFix regression in `unused_braces` with macros
clubby789 [Sun, 15 Jan 2023 05:06:33 +0000 (05:06 +0000)]
Fix regression in `unused_braces` with macros

17 months agoAuto merge of #106892 - matthiaskrgr:rollup-ohneu8o, r=matthiaskrgr
bors [Sun, 15 Jan 2023 00:16:09 +0000 (00:16 +0000)]
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

17 months agoRollup merge of #106880 - tspiteri:borrowing-sub-typo, r=cuviper
Matthias Krüger [Sun, 15 Jan 2023 00:01:39 +0000 (01:01 +0100)]
Rollup merge of #106880 - tspiteri:borrowing-sub-typo, r=cuviper

doc: fix typo

17 months agoRollup merge of #106879 - JohnTitor:issue-42114, r=compiler-errors
Matthias Krüger [Sun, 15 Jan 2023 00:01:39 +0000 (01:01 +0100)]
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>
17 months agoRollup merge of #106878 - JohnTitor:issue-92157, r=compiler-errors
Matthias Krüger [Sun, 15 Jan 2023 00:01:38 +0000 (01:01 +0100)]
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>
17 months agoRollup merge of #106867 - sunfishcode:sunfishcode/std-os-fd-stable-version, r=m-ou-se
Matthias Krüger [Sun, 15 Jan 2023 00:01:38 +0000 (01:01 +0100)]
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

17 months agoRollup merge of #106865 - GuillaumeGomez:add-gui-test-explanation, r=notriddle
Matthias Krüger [Sun, 15 Jan 2023 00:01:37 +0000 (01:01 +0100)]
Rollup merge of #106865 - GuillaumeGomez:add-gui-test-explanation, r=notriddle

Add explanation comment for GUI test

r? `@notriddle`

17 months agoRollup merge of #106863 - anden3:compiler-double-spaces, r=Nilstrieb
Matthias Krüger [Sun, 15 Jan 2023 00:01:37 +0000 (01:01 +0100)]
Rollup merge of #106863 - anden3:compiler-double-spaces, r=Nilstrieb

Remove various double spaces in compiler source comments.

Was asked to do it by `@Nilstrieb`

17 months agoRollup merge of #106859 - tialaramex:master, r=Nilstrieb
Matthias Krüger [Sun, 15 Jan 2023 00:01:36 +0000 (01:01 +0100)]
Rollup merge of #106859 - tialaramex:master, r=Nilstrieb

Suggestion for type mismatch when we need a u8 but the programmer wrote a char literal

Today Rust just points out that we have a char and we need a u8, but if I wrote 'A' then I could fix this by just writing b'A' instead. This code should detect the case where we're about to report a type mismatch of this kind, and the programmer wrote a char literal, and the char they wrote is ASCII, so therefore just prefixing b to make a byte literal will do what they meant.

I have definitely written this mistake more than once, it's not difficult to figure out what to do, but the compiler might as well tell us anyway.

I provided a test with two simple examples where the suggestion is appropriate, and one where it is not because the char literal is not ASCII, showing that the suggestion is only triggered in the former cases.

I have contributed only a small typo doc fix before, so this is my first substantive rustc change.

17 months agoRollup merge of #106072 - eopb:dyn-derive, r=estebank
Matthias Krüger [Sun, 15 Jan 2023 00:01:36 +0000 (01:01 +0100)]
Rollup merge of #106072 - eopb:dyn-derive, r=estebank

fix: misleading "add dyn keyword before derive macro" suggestion

Fixes #106071

17 months agoDocument guarantees about BinaryHeap invariant
David Tolnay [Thu, 5 Jan 2023 08:04:59 +0000 (00:04 -0800)]
Document guarantees about BinaryHeap invariant

17 months agoLeak amplification for peek_mut() to ensure BinaryHeap's invariant is always met
David Tolnay [Sun, 18 Dec 2022 17:40:36 +0000 (09:40 -0800)]
Leak amplification for peek_mut() to ensure BinaryHeap's invariant is always met

17 months agoAdd test of leaking a binary_heap PeekMut
David Tolnay [Sun, 18 Dec 2022 17:40:23 +0000 (09:40 -0800)]
Add test of leaking a binary_heap PeekMut

17 months agoImprove E0308: suggest user meant to use byte literal, w/ tests and fix
Nick Lamb [Sat, 14 Jan 2023 14:51:17 +0000 (14:51 +0000)]
Improve E0308: suggest user meant to use byte literal, w/ tests and fix
suggested by Nilstrieb

Co-authored-by: nils <48135649+Nilstrieb@users.noreply.github.com>
17 months agodoc: fix typo
Trevor Spiteri [Sat, 14 Jan 2023 21:09:14 +0000 (22:09 +0100)]
doc: fix typo

17 months agoAuto merge of #106866 - matthiaskrgr:rollup-r063s44, r=matthiaskrgr
bors [Sat, 14 Jan 2023 20:53:37 +0000 (20:53 +0000)]
Auto merge of #106866 - matthiaskrgr:rollup-r063s44, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #105526 (libcore: make result of iter::from_generator Clone)
 - #106563 (Fix `unused_braces` on generic const expr macro call)
 - #106661 (Stop probing for statx unless necessary)
 - #106820 (Deprioritize fulfillment errors that come from expansions.)
 - #106828 (rustdoc: remove `docblock` class from notable trait popover)
 - #106849 (Allocate one less vec while parsing arrays)
 - #106855 (rustdoc: few small cleanups)
 - #106860 (Remove various double spaces in the libraries.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

17 months agoAdd regression test for #42114
Yuki Okushi [Sat, 14 Jan 2023 20:52:22 +0000 (05:52 +0900)]
Add regression test for #42114

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
17 months agoAdd regression test for #92157
Yuki Okushi [Sat, 14 Jan 2023 20:47:24 +0000 (05:47 +0900)]
Add regression test for #92157

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
17 months agoEmit only one nbsp error per file
David Tolnay [Sat, 14 Jan 2023 18:34:06 +0000 (10:34 -0800)]
Emit only one nbsp error per file

17 months agoAdd more nbsp to unicode-chars test
David Tolnay [Sat, 14 Jan 2023 19:02:14 +0000 (11:02 -0800)]
Add more nbsp to unicode-chars test

17 months agoFix the stability attributes for `std::os::fd`.
Dan Gohman [Sat, 14 Jan 2023 17:35:42 +0000 (09:35 -0800)]
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

17 months agoRollup merge of #106860 - anden3:doc-double-spaces, r=Dylan-DPC
Matthias Krüger [Sat, 14 Jan 2023 17:45:29 +0000 (18:45 +0100)]
Rollup merge of #106860 - anden3:doc-double-spaces, r=Dylan-DPC

Remove various double spaces in the libraries.

I was just pretty bothered by this when reading the source for a function, and was suggested to check if this happened elsewhere.

17 months agoRollup merge of #106855 - klensy:rd-s, r=notriddle
Matthias Krüger [Sat, 14 Jan 2023 17:45:28 +0000 (18:45 +0100)]
Rollup merge of #106855 - klensy:rd-s, r=notriddle

rustdoc: few small cleanups

17 months agoRollup merge of #106849 - WaffleLapkin:unvec, r=Nilstrieb
Matthias Krüger [Sat, 14 Jan 2023 17:45:28 +0000 (18:45 +0100)]
Rollup merge of #106849 - WaffleLapkin:unvec, r=Nilstrieb

Allocate one less vec while parsing arrays

Probably does not matter, but imo a little bit nicer.

17 months agoRollup merge of #106828 - notriddle:notriddle/notable-trait-docblock, r=GuillaumeGomez
Matthias Krüger [Sat, 14 Jan 2023 17:45:27 +0000 (18:45 +0100)]
Rollup merge of #106828 - notriddle:notriddle/notable-trait-docblock, r=GuillaumeGomez

rustdoc: remove `docblock` class from notable trait popover

This commit builds on b72de9be74dd5ac1d8b23d5ece03a7690274a14c, which removes the `docblock` class from the All Items page, and 9457380ac902db3febf92077c5b645db55998ad4, which removes the `docblock` class from the item decl.

Fixes #92974

17 months agoRollup merge of #106820 - m-ou-se:macro-type-error-thing, r=estebank
Matthias Krüger [Sat, 14 Jan 2023 17:45:27 +0000 (18:45 +0100)]
Rollup merge of #106820 - m-ou-se:macro-type-error-thing, r=estebank

Deprioritize fulfillment errors that come from expansions.

Fixes (part of?) #69455

17 months agoRollup merge of #106661 - mjguzik:linux_statx, r=Mark-Simulacrum
Matthias Krüger [Sat, 14 Jan 2023 17:45:26 +0000 (18:45 +0100)]
Rollup merge of #106661 - mjguzik:linux_statx, r=Mark-Simulacrum

Stop probing for statx unless necessary

As is the current toy program:
fn main() -> std::io::Result<()> {
    use std::fs;

    let metadata = fs::metadata("foo.txt")?;

    assert!(!metadata.is_dir());
    Ok(())
}

... observed under strace will issue:
[snip]
statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address) statx(AT_FDCWD, "foo.txt", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0

While statx is not necessarily always present, checking for it can be delayed to the first error condition. Said condition may very well never happen, in which case the check got avoided altogether.

Note this is still suboptimal as there still will be programs issuing it, but bulk of the problem is removed.

Tested by forbidding the syscall for the binary and observing it correctly falls back to newfstatat.

While here tidy up the commentary, in particular by denoting some problems with the current approach.

17 months agoRollup merge of #106563 - clubby789:gce-macro-braces, r=TaKO8Ki
Matthias Krüger [Sat, 14 Jan 2023 17:45:26 +0000 (18:45 +0100)]
Rollup merge of #106563 - clubby789:gce-macro-braces, r=TaKO8Ki

Fix `unused_braces` on generic const expr macro call

Fixes #106545

`@rustbot` label +A-const-generics +A-lint

17 months agoRollup merge of #105526 - Xiretza:iter-from-generator-derive, r=scottmcm
Matthias Krüger [Sat, 14 Jan 2023 17:45:25 +0000 (18:45 +0100)]
Rollup merge of #105526 - Xiretza:iter-from-generator-derive, r=scottmcm

libcore: make result of iter::from_generator Clone

`@rustbot` label +A-generators

17 months agoAuto merge of #106696 - kylematsuda:early-binder, r=lcnr
bors [Sat, 14 Jan 2023 17:44:30 +0000 (17:44 +0000)]
Auto merge of #106696 - kylematsuda:early-binder, r=lcnr

Switch to `EarlyBinder` for `const_param_default` and `impl_trait_ref` queries

Part of the work to close #105779 and implement https://github.com/rust-lang/types-team/issues/78.

Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This PR adds `EarlyBinder` to the return type of  `const_param_default` and `impl_trait_ref`, and removes their `bound_X` variants.

r? `@lcnr`

17 months agoAdd explanation for GUI test
Guillaume Gomez [Sat, 14 Jan 2023 17:30:33 +0000 (18:30 +0100)]
Add explanation for GUI test

17 months agoFix some missed double spaces.
André Vennberg [Sat, 14 Jan 2023 17:26:38 +0000 (18:26 +0100)]
Fix some missed double spaces.

17 months agoFix some missed double spaces.
André Vennberg [Sat, 14 Jan 2023 17:23:40 +0000 (18:23 +0100)]
Fix some missed double spaces.

17 months agoRemove visit_place.
Camille GILLOT [Sat, 14 Jan 2023 17:04:02 +0000 (17:04 +0000)]
Remove visit_place.

17 months agoRemoved various double spaces in compiler source comments.
André Vennberg [Sat, 14 Jan 2023 16:34:59 +0000 (17:34 +0100)]
Removed various double spaces in compiler source comments.

17 months agoRemove various double spaces in source comments.
André Vennberg [Sat, 14 Jan 2023 15:33:11 +0000 (16:33 +0100)]
Remove various double spaces in source comments.

17 months agoFix `unused_braces` on generic const expr macro call
clubby789 [Sat, 7 Jan 2023 15:41:32 +0000 (15:41 +0000)]
Fix `unused_braces` on generic const expr macro call

17 months agoAuto merge of #106851 - matthiaskrgr:rollup-d9dz3yp, r=matthiaskrgr
bors [Sat, 14 Jan 2023 14:50:53 +0000 (14:50 +0000)]
Auto merge of #106851 - matthiaskrgr:rollup-d9dz3yp, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #106046 (Fix mir-opt tests for big-endian platforms)
 - #106470 (tidy: Don't include wasm32 in compiler dependency check)
 - #106566 (Emit a single error for contiguous sequences of unknown tokens)
 - #106644 (Update the wasi-libc used for the wasm32-wasi target)
 - #106665 (Add note when `FnPtr` vs. `FnDef` impl trait)
 - #106752 (Emit a hint for bad call return types due to generic arguments)
 - #106788 (Tweak E0599 and elaborate_predicates)
 - #106831 (Use GitHub yaml templates for ICE, Docs and Diagnostics tickets)
 - #106846 (Improve some comments and names in parser)
 - #106848 (Fix wrong path in triage bot autolabel for wg-trait-solver-refactor)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

17 months agoDeprioritize fulfillment errors that come from expansions.
Mara Bos [Fri, 13 Jan 2023 00:27:58 +0000 (01:27 +0100)]
Deprioritize fulfillment errors that come from expansions.

17 months agoHeuristically undo path prefix mappings.
Tim Neumann [Fri, 6 Jan 2023 11:28:05 +0000 (11:28 +0000)]
Heuristically undo path prefix mappings.

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

17 months agofix: misleading add `dyn` to derive macro suggestion
Ethan Brierley [Fri, 23 Dec 2022 00:13:47 +0000 (00:13 +0000)]
fix: misleading add `dyn` to derive macro suggestion

17 months agoMake the inlining destination a `Local`.
Camille GILLOT [Sat, 14 Jan 2023 12:01:27 +0000 (12:01 +0000)]
Make the inlining destination a `Local`.

17 months agoRollup merge of #106848 - BoxyUwU:correct_triagebot_path, r=WaffleLapkin
Matthias Krüger [Sat, 14 Jan 2023 12:04:28 +0000 (13:04 +0100)]
Rollup merge of #106848 - BoxyUwU:correct_triagebot_path, r=WaffleLapkin

Fix wrong path in triage bot autolabel for wg-trait-solver-refactor

17 months agoRollup merge of #106846 - WaffleLapkin:pico_parse_ref, r=TaKO8Ki
Matthias Krüger [Sat, 14 Jan 2023 12:04:27 +0000 (13:04 +0100)]
Rollup merge of #106846 - WaffleLapkin:pico_parse_ref, r=TaKO8Ki

Improve some comments and names in parser

Just a tiny drive-by cleanup.

17 months agoRollup merge of #106831 - estebank:tickets_yaml, r=Mark-Simulacrum
Matthias Krüger [Sat, 14 Jan 2023 12:04:27 +0000 (13:04 +0100)]
Rollup merge of #106831 - estebank:tickets_yaml, r=Mark-Simulacrum

Use GitHub yaml templates for ICE, Docs and Diagnostics tickets

The GitHub yaml templates allow us to define HTML forms with validation for issue templates, instead of the current markdown based templates which only let us introduce text into the user editable text area. The form lets us make some fields mandatory, as well as add text that won't pollute the user's text and titles that won't be interfered with by enterprising users.

17 months agoRollup merge of #106788 - estebank:elaborate_pred_E0599, r=compiler-errors
Matthias Krüger [Sat, 14 Jan 2023 12:04:26 +0000 (13:04 +0100)]
Rollup merge of #106788 - estebank:elaborate_pred_E0599, r=compiler-errors

Tweak E0599 and elaborate_predicates

CC https://github.com/rust-lang/rust/issues/86377.

17 months agoRollup merge of #106752 - sulami:master, r=estebank
Matthias Krüger [Sat, 14 Jan 2023 12:04:26 +0000 (13:04 +0100)]
Rollup merge of #106752 - sulami:master, r=estebank

Emit a hint for bad call return types due to generic arguments

When the return type of a function call depends on the type of an argument, e.g.

```
fn foo<T>(x: T) -> T {
    x
}
```

and the expected type is set due to either an explicitly typed binding, or because the call to the function is in a tail position without semicolon, the current error implies that the argument in the call has the wrong type.

This new hint highlights that the expected type doesn't match the returned type, which matches the argument type, and that that's why we're flagging the argument type.

Fixes #43608.

17 months agoRollup merge of #106665 - JulianKnodt:better_fn_trait_note, r=cjgillot
Matthias Krüger [Sat, 14 Jan 2023 12:04:25 +0000 (13:04 +0100)]
Rollup merge of #106665 - JulianKnodt:better_fn_trait_note, r=cjgillot

Add note when `FnPtr` vs. `FnDef` impl trait

I encountered an instance where an `FnPtr` implemented a trait, but I was passing an `FnDef`. I was confused for an hour and to examine the source code of the trait's crate's tests in order to understand how to cast it properly (it didn't help that it was behind a reference). To the end user, it might not be immediately obvious that they are different and how to convert from an `FnDef` to an `FnPtr`, but it is necessary to cast to the generic function in order to compile. It is thus useful to suggest `as` in the help note, (even if the `Fn` output implements the trait).

17 months agoRollup merge of #106644 - alexcrichton:update-wasi-toolchain, r=cuviper
Matthias Krüger [Sat, 14 Jan 2023 12:04:25 +0000 (13:04 +0100)]
Rollup merge of #106644 - alexcrichton:update-wasi-toolchain, r=cuviper

Update the wasi-libc used for the wasm32-wasi target

This commit updates the wasi-libc revision used to build with the wasm32-wasi target. This notably pulls in WebAssembly/wasi-libc#377 which is needed to fix a use case I've been working on recently. This should be a relatively small update hopefully and is not expected to have any user impact.

17 months agoRollup merge of #106566 - clubby789:contiguous-weird-unicode, r=cjgillot
Matthias Krüger [Sat, 14 Jan 2023 12:04:24 +0000 (13:04 +0100)]
Rollup merge of #106566 - clubby789:contiguous-weird-unicode, r=cjgillot

Emit a single error for contiguous sequences of unknown tokens

Closes #106101

On encountering a sequence of identical source characters which are unknown tokens, note the amount of subsequent characters and advance past them silently. The old behavior was to emit an error and 'help' note for every single one.

`@rustbot` label +A-diagnostics +A-parser

17 months agoRollup merge of #106470 - ehuss:tidy-no-wasm, r=Mark-Simulacrum
Matthias Krüger [Sat, 14 Jan 2023 12:04:24 +0000 (13:04 +0100)]
Rollup merge of #106470 - ehuss:tidy-no-wasm, r=Mark-Simulacrum

tidy: Don't include wasm32 in compiler dependency check

This changes the tidy compiler dependency check so that it does not include wasm32-unknown-unknown dependencies in the PERMITTED_RUSTC_DEPENDENCIES. This just helps keep the list cleaner under the assumption that the compiler will never work on wasm32-unknown-unknown.

This also fixes a bug in the check to verify there are no unused dependencies in the PERMITTED_RUSTC_DEPENDENCIES. Previously the check was verifying that the dependency was used *anywhere* in the workspace, when it should have been checking if it was used for the compiler.

There's also just a little general cleanup here. For example, the old `normal_deps_of_r` function was changed a while ago to return *all* dependencies, but the function name and description wasn't updated to remove `normal_`.

17 months agoRollup merge of #106046 - uweigand:s390x-test-bigendian-mir, r=Mark-Simulacrum
Matthias Krüger [Sat, 14 Jan 2023 12:04:23 +0000 (13:04 +0100)]
Rollup merge of #106046 - uweigand:s390x-test-bigendian-mir, r=Mark-Simulacrum

Fix mir-opt tests for big-endian platforms

The test cases src/test/mir-opt/building/custom/consts.rs and src/test/mir-opt/const_prop/mutable_variable_no_prop.rs are currently failing on big-endian platforms as the binary encoding of some constants is hard-coded in the MIR test files.  Fix this by choosing constant values that have the same encoding on big- and little-endian platforms.

The test case src/test/mir-opt/issues/issue_75439.rs is failing as well, but since the purpose of the test is to validate handling of big-endian integer encodings on a little-endian platform, it does not make much sense to run it on big-endian platforms in the first place - we can just ignore it there.

Fixed part of https://github.com/rust-lang/rust/issues/105383.

17 months agoa
Boxy [Sat, 14 Jan 2023 11:44:37 +0000 (11:44 +0000)]
a

17 months agoAllocate one less vec in `parser/expr.rs`
Maybe Waffle [Sat, 14 Jan 2023 11:44:25 +0000 (11:44 +0000)]
Allocate one less vec in `parser/expr.rs`

17 months agoAdd test.
Camille GILLOT [Sat, 14 Jan 2023 11:40:52 +0000 (11:40 +0000)]
Add test.

17 months agoImprove comments in `parser/expr.rs`
Maybe Waffle [Sat, 14 Jan 2023 11:29:22 +0000 (11:29 +0000)]
Improve comments in `parser/expr.rs`

17 months agoMake `LhsExpr::AlreadyParsed` a named struct
Maybe Waffle [Sat, 14 Jan 2023 11:28:14 +0000 (11:28 +0000)]
Make `LhsExpr::AlreadyParsed` a named struct

17 months agoAdd note when `FnPtr` vs. `FnDef` impl trait
kadmin [Tue, 10 Jan 2023 06:08:18 +0000 (06:08 +0000)]
Add note when `FnPtr` vs. `FnDef` impl trait

I encountered an instance where an `FnPtr` implemented a trait, but I was passing an `FnDef`. To
the end user, there is really no way to differentiate each of them, but it is necessary to cast
to the generic function in order to compile. It is thus useful to suggest `as` in the help note,
(even if the Fn output implements the trait).

17 months agoAuto merge of #106646 - Amanieu:ilp32-object, r=Mark-Simulacrum
bors [Sat, 14 Jan 2023 08:33:09 +0000 (08:33 +0000)]
Auto merge of #106646 - Amanieu:ilp32-object, r=Mark-Simulacrum

Fix aarch64-unknown-linux-gnu_ilp32 target

This was broken because the synthetic object files produced by rustc were for 64-bit AArch64, which caused link failures when combined with 32-bit ILP32 object files.

This PR updates the object crate to 0.30.1 which adds support for generating ILP32 AArch64 object files.

17 months agofix various subst_identity vs skip_binder
Kyle Matsuda [Wed, 11 Jan 2023 18:32:33 +0000 (11:32 -0700)]
fix  various subst_identity vs skip_binder

17 months agochange impl_trait_ref query to return EarlyBinder; remove bound_impl_trait_ref query...
Kyle Matsuda [Tue, 10 Jan 2023 21:57:22 +0000 (14:57 -0700)]
change impl_trait_ref query to return EarlyBinder; remove bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata

17 months agochange usages of impl_trait_ref to bound_impl_trait_ref
Kyle Matsuda [Tue, 10 Jan 2023 21:22:52 +0000 (14:22 -0700)]
change usages of impl_trait_ref to bound_impl_trait_ref

17 months agochange const_param_default query to return EarlyBinder; remove bound_const_param_defa...
Kyle Matsuda [Tue, 10 Jan 2023 19:27:41 +0000 (12:27 -0700)]
change const_param_default query to return EarlyBinder; remove bound_const_param_default query; add EarlyBinder to const_param_default in metadata

17 months agochange usages of const_param_default query to bound_const_param_default
Kyle Matsuda [Tue, 10 Jan 2023 19:20:15 +0000 (12:20 -0700)]
change usages of const_param_default query to bound_const_param_default

17 months agoadd EarlyBinder::subst_identity; impl ParameterizedOverTcx (needed for rustc_metadat...
Kyle Matsuda [Tue, 10 Jan 2023 18:53:35 +0000 (11:53 -0700)]
add EarlyBinder::subst_identity; impl  ParameterizedOverTcx (needed for rustc_metadata) and Value for EarlyBinder

17 months agoAuto merge of #106833 - JohnTitor:rollup-z8398jk, r=JohnTitor
bors [Sat, 14 Jan 2023 05:51:55 +0000 (05:51 +0000)]
Auto merge of #106833 - JohnTitor:rollup-z8398jk, r=JohnTitor

Rollup of 13 pull requests

Successful merges:

 - #104965 (reword Option::as_ref and Option::map examples)
 - #105172 (Added error documentation for write_fmt)
 - #106605 (rustdoc: fix outdated lint section of the book)
 - #106670 (Check compiler docs in PR CI)
 - #106692 (mv binary_heap.rs binary_heap/mod.rs)
 - #106693 (rustdoc: rename CSS rustdoc-toggle -> toggle and toggle -> settings-toggle)
 - #106707 (Remove duplicate sha-1 dependency)
 - #106762 (Add `AtomicPtr::as_mut_ptr`)
 - #106766 (Remove dead code in rustdoc stripper)
 - #106775 (Remove stale reference to the test suite location)
 - #106799 (Stop having unused lifetimes on some `impl`s)
 - #106816 (Update `rental` hack to work with remapped paths.)
 - #106819 (rustdoc: remove unnecessary DOM class `h1.fqn`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

17 months agoAuto merge of #106520 - ehuss:update-mdbook, r=Mark-Simulacrum
bors [Sat, 14 Jan 2023 03:04:40 +0000 (03:04 +0000)]
Auto merge of #106520 - ehuss:update-mdbook, r=Mark-Simulacrum

Update mdbook

This updates mdbook from 0.4.21 to 0.4.25. The list of changes is [here](https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0425). The only user-visible changes are some changes around the theme picker, and change to the copy-to-clipboard ignoring hidden lines.

Internally there were some dependency updates and small fixes.

This also updates `clap` from 4.0.15 to 4.0.32 whose changelog is [here](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md#4032---2022-12-22). This impacts tools like cargo. I don't see anything particularly noteworthy there, though there are some small user-visible changes.

Unfortunately this required adding a hack for building `rustix` with a bootstrap tool. The comment explains why. I am unable to think of some other workaround (or even a cleaner way to set the rustflag). Ideas are welcome if you can think of alternatives. I'm struggling to even think of a long-term solution, other than asking projects not to do auto-nightly feature detection.

One medium-term solution is to avoid the clap dependency for the mdbook library (which is how rustix gets pulled in). That is one of my goals for the 0.5 release of mdbook, but that probably won't happen until later this year. It would also require dropping clap from `rustbook` and using some other means to parse arguments (there's only two options, so it can probably be done manually).

17 months agoRollup merge of #106819 - notriddle:notriddle/rm-h1-fqn, r=GuillaumeGomez
Yuki Okushi [Sat, 14 Jan 2023 03:04:37 +0000 (12:04 +0900)]
Rollup merge of #106819 - notriddle:notriddle/rm-h1-fqn, r=GuillaumeGomez

rustdoc: remove unnecessary DOM class `h1.fqn`

It's misleading. The main heading sometimes isn't an fully qualified name at all.

It's also redundant. It's always a child of `div.main-heading`, so just use that.

17 months agoRollup merge of #106816 - TimNN:rental-remap, r=oli-obj
Yuki Okushi [Sat, 14 Jan 2023 03:04:37 +0000 (12:04 +0900)]
Rollup merge of #106816 - TimNN:rental-remap, r=oli-obj

Update `rental` hack to work with remapped paths.

This PR simply switches to an already-existing helper instead of hard-coding a specific enum variant. The new revision of the test fails without the other changes in this PR.

Context: I'm exploring running UI tests with remapped paths by default in #105924 and the rental test was one of the ones that failed.

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").

17 months agoRollup merge of #106799 - scottmcm:remove-unused-generics, r=cuviper
Yuki Okushi [Sat, 14 Jan 2023 03:04:36 +0000 (12:04 +0900)]
Rollup merge of #106799 - scottmcm:remove-unused-generics, r=cuviper

Stop having unused lifetimes on some `impl`s

See <https://doc.rust-lang.org/nightly/std/cmp/trait.PartialOrd.html#impl-PartialOrd%3COsStr%3E-for-PathBuf>, where these lifetimes show up even though they're not needed:
![image](https://user-images.githubusercontent.com/18526288/212257802-da275167-38f9-4e2c-aafc-d44f0fc6a7c6.png)

With this PR, the unneeded lifetimes are no longer there:
![image](https://user-images.githubusercontent.com/18526288/212257938-0097c4bf-1247-4c91-8445-5bf0dde1b501.png)

17 months agoRollup merge of #106775 - albertlarsan68:patch-1, r=Mark-Simulacrum
Yuki Okushi [Sat, 14 Jan 2023 03:04:36 +0000 (12:04 +0900)]
Rollup merge of #106775 - albertlarsan68:patch-1, r=Mark-Simulacrum

Remove stale reference to the test suite location

17 months agoRollup merge of #106766 - GuillaumeGomez:rm-stripper-dead-code, r=notriddle
Yuki Okushi [Sat, 14 Jan 2023 03:04:35 +0000 (12:04 +0900)]
Rollup merge of #106766 - GuillaumeGomez:rm-stripper-dead-code, r=notriddle

Remove dead code in rustdoc stripper

No changes when this code is removed.

cc `@aDotInTheVoid`
r? `@notriddle`

17 months agoRollup merge of #106762 - WaffleLapkin:atomicptr+as_mut_ptr, r=m-ou-se
Yuki Okushi [Sat, 14 Jan 2023 03:04:35 +0000 (12:04 +0900)]
Rollup merge of #106762 - WaffleLapkin:atomicptr+as_mut_ptr, r=m-ou-se

Add `AtomicPtr::as_mut_ptr`

See https://github.com/rust-lang/rust/issues/66893#issuecomment-720125447

r? thomcc

17 months agoRollup merge of #106707 - ehuss:remove-dupe-sha-1, r=Mark-Simulacrum
Yuki Okushi [Sat, 14 Jan 2023 03:04:34 +0000 (12:04 +0900)]
Rollup merge of #106707 - ehuss:remove-dupe-sha-1, r=Mark-Simulacrum

Remove duplicate sha-1 dependency

[`sha-1`](https://crates.io/crates/sha-1) is more or less a duplicate of [`sha1`](https://crates.io/crates/sha1). The `sha-1` is deprecated and no longer updated. This updates the dependencies to use the new name.

Some other dependencies that got updated as a consequence:
* The updated pest dependencies are currently only used by mdbook, and shouldn't have any issues.
* ucd-trie 0.1.3 to 0.1.5: No changelog, but looks like some tables were updated for new unicode versions: https://github.com/BurntSushi/ucd-generate/commits/master/ucd-trie. This is only used by pest (and thus mdbook).
* thiserror 1.33 to 1.38: Nothing significant in the notes at https://github.com/dtolnay/thiserror/releases.