about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2023-01-15Rollup merge of #106906 - matthiaskrgr:clone, r=NilstriebMatthias Krüger-3/+3
remove redundant clones
2023-01-15Rollup merge of #106900 - clubby789:unused-braces-regression, r=estebankMatthias Krüger-5/+29
Fix regression in `unused_braces` with macros Fixes #106899
2023-01-15Rollup merge of #106896 - Ezrashaw:str-cast-bool-emptyness, r=compiler-errorsMatthias Krüger-4/+142
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-15Rollup merge of #106888 - GuillaumeGomez:tidy-gui-test, r=notriddleMatthias Krüger-0/+37
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-15Auto merge of #106742 - compiler-errors:new-solver-make-it-not-ice, r=lcnrbors-41/+186
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-15remove redundant clonesMatthias Krüger-3/+3
2023-01-15Auto merge of #106171 - compiler-errors:consolidate-extract_callable_info, ↵bors-185/+183
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-15Add small description to GUI testGuillaume Gomez-0/+2
2023-01-15Add tidy check to ensure that rustdoc GUI tests start with a small descriptionGuillaume Gomez-0/+35
2023-01-15suggest `is_empty` for collections when casting to `bool`Ezra Shaw-4/+142
2023-01-15Auto merge of #105851 - dtolnay:peekmutleak, r=Mark-Simulacrumbors-10/+75
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-15Fix regression in `unused_braces` with macrosclubby789-5/+29
2023-01-15Auto merge of #106892 - matthiaskrgr:rollup-ohneu8o, r=matthiaskrgrbors-15/+205
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-15Rollup merge of #106880 - tspiteri:borrowing-sub-typo, r=cuviperMatthias Krüger-1/+1
doc: fix typo
2023-01-15Rollup merge of #106879 - JohnTitor:issue-42114, r=compiler-errorsMatthias Krüger-0/+20
Add regression test for #42114 Closes #42114 r? compiler-errors Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-01-15Rollup merge of #106878 - JohnTitor:issue-92157, r=compiler-errorsMatthias Krüger-0/+51
Add regression test for #92157 Closes #92157 r? compiler-errors Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-01-15Rollup merge of #106867 - sunfishcode:sunfishcode/std-os-fd-stable-version, ↵Matthias Krüger-3/+3
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-15Rollup merge of #106865 - GuillaumeGomez:add-gui-test-explanation, r=notriddleMatthias Krüger-0/+2
Add explanation comment for GUI test r? `@notriddle`
2023-01-15Rollup merge of #106863 - anden3:compiler-double-spaces, r=NilstriebMatthias Krüger-10/+10
Remove various double spaces in compiler source comments. Was asked to do it by `@Nilstrieb`
2023-01-15Rollup merge of #106859 - tialaramex:master, r=NilstriebMatthias Krüger-0/+76
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.
2023-01-15Rollup merge of #106072 - eopb:dyn-derive, r=estebankMatthias Krüger-1/+42
fix: misleading "add dyn keyword before derive macro" suggestion Fixes #106071
2023-01-14Document guarantees about BinaryHeap invariantDavid Tolnay-1/+9
2023-01-14Leak amplification for peek_mut() to ensure BinaryHeap's invariant is always metDavid Tolnay-9/+46
2023-01-14Add test of leaking a binary_heap PeekMutDavid Tolnay-0/+20
2023-01-14Improve E0308: suggest user meant to use byte literal, w/ tests and fixNick Lamb-0/+76
suggested by Nilstrieb Co-authored-by: nils <48135649+Nilstrieb@users.noreply.github.com>
2023-01-14doc: fix typoTrevor Spiteri-1/+1
2023-01-14Auto merge of #106866 - matthiaskrgr:rollup-r063s44, r=matthiaskrgrbors-161/+221
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
2023-01-15Add regression test for #42114Yuki Okushi-0/+20
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-01-15Add regression test for #92157Yuki Okushi-0/+51
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-01-14Fix the stability attributes for `std::os::fd`.Dan Gohman-3/+3
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-14Rollup merge of #106860 - anden3:doc-double-spaces, r=Dylan-DPCMatthias Krüger-71/+71
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.
2023-01-14Rollup merge of #106855 - klensy:rd-s, r=notriddleMatthias Krüger-28/+33
rustdoc: few small cleanups
2023-01-14Rollup merge of #106849 - WaffleLapkin:unvec, r=NilstriebMatthias Krüger-3/+2
Allocate one less vec while parsing arrays Probably does not matter, but imo a little bit nicer.
2023-01-14Rollup merge of #106828 - notriddle:notriddle/notable-trait-docblock, ↵Matthias Krüger-9/+13
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
2023-01-14Rollup merge of #106820 - m-ou-se:macro-type-error-thing, r=estebankMatthias Krüger-16/+23
Deprioritize fulfillment errors that come from expansions. Fixes (part of?) #69455
2023-01-14Rollup merge of #106661 - mjguzik:linux_statx, r=Mark-SimulacrumMatthias Krüger-29/+44
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.
2023-01-14Rollup merge of #106563 - clubby789:gce-macro-braces, r=TaKO8KiMatthias Krüger-1/+16
Fix `unused_braces` on generic const expr macro call Fixes #106545 `@rustbot` label +A-const-generics +A-lint
2023-01-14Rollup merge of #105526 - Xiretza:iter-from-generator-derive, r=scottmcmMatthias Krüger-4/+19
libcore: make result of iter::from_generator Clone `@rustbot` label +A-generators
2023-01-14Auto merge of #106696 - kylematsuda:early-binder, r=lcnrbors-112/+145
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`
2023-01-14Add explanation for GUI testGuillaume Gomez-0/+2
2023-01-14Fix some missed double spaces.André Vennberg-5/+5
2023-01-14Fix some missed double spaces.André Vennberg-4/+4
2023-01-14Removed various double spaces in compiler source comments.André Vennberg-6/+6
2023-01-14Remove various double spaces in source comments.André Vennberg-66/+66
2023-01-14Fix `unused_braces` on generic const expr macro callclubby789-1/+16
2023-01-14Auto merge of #106851 - matthiaskrgr:rollup-d9dz3yp, r=matthiaskrgrbors-307/+1082
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
2023-01-14Deprioritize fulfillment errors that come from expansions.Mara Bos-16/+23
2023-01-14fix: misleading add `dyn` to derive macro suggestionEthan Brierley-1/+42
2023-01-14Rollup merge of #106848 - BoxyUwU:correct_triagebot_path, r=WaffleLapkinMatthias Krüger-1/+1
Fix wrong path in triage bot autolabel for wg-trait-solver-refactor
2023-01-14Rollup merge of #106846 - WaffleLapkin:pico_parse_ref, r=TaKO8KiMatthias Krüger-15/+25
Improve some comments and names in parser Just a tiny drive-by cleanup.