about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2023-01-15Remove bound_{explicit,}_item_boundsMichael Goulet-64/+40
2023-01-15drive-by: assert when iterating through InstantiatedPredicatesMichael Goulet-0/+2
2023-01-15Make InstantiatedPredicates impl IntoIteratorMichael Goulet-65/+74
2023-01-15instantiate_own doesn't need to return a pair of vectorsMichael Goulet-27/+39
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-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-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.
2023-01-14Rollup merge of #106831 - estebank:tickets_yaml, r=Mark-SimulacrumMatthias Krüger-129/+185
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.
2023-01-14Rollup merge of #106788 - estebank:elaborate_pred_E0599, r=compiler-errorsMatthias Krüger-24/+296
Tweak E0599 and elaborate_predicates CC https://github.com/rust-lang/rust/issues/86377.
2023-01-14Rollup merge of #106752 - sulami:master, r=estebankMatthias Krüger-0/+338
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.
2023-01-14Rollup merge of #106665 - JulianKnodt:better_fn_trait_note, r=cjgillotMatthias Krüger-17/+111
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).
2023-01-14Rollup merge of #106644 - alexcrichton:update-wasi-toolchain, r=cuviperMatthias Krüger-1/+1
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.
2023-01-14Rollup merge of #106566 - clubby789:contiguous-weird-unicode, r=cjgillotMatthias Krüger-9/+49
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