about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2022-05-28Rollup merge of #97034 - fee1-dead-contrib:layout-hash, r=dtolnayDylan DPC-2/+9
Implement `Hash` for `core::alloc::Layout` This was brought up on [reddit](https://www.reddit.com/r/rust/comments/uoypui/the_standard_library_types_are_good_except_when/), and I don't see why Layout shouldn't implement `Hash`. Feel free to comment if I am wrong though :)
2022-05-28Rollup merge of #94640 - Pointerbender:issue-71146-partial-stabilization, ↵Dylan DPC-3/+4
r=yaahc Partially stabilize `(const_)slice_ptr_len` feature by stabilizing `NonNull::len` This PR partially stabilizes features `const_slice_ptr_len` and `slice_ptr_len` by only stabilizing `NonNull::len`. This partial stabilization is tracked under features `slice_ptr_len_nonnull` and `const_slice_ptr_len_nonnull`, for which this PR can serve as the tracking issue. To summarize the discussion from #71146 leading up to this partial stabilization request: It's currently a bit footgunny to obtain the length of a raw slice pointer, stabilization of `NonNull:len` will help with removing these footguns. Some example footguns are: ```rust /// # Safety /// The caller must ensure that `ptr`: /// 1. does not point to memory that was previously allocated but is now deallocated; /// 2. is within the bounds of a single allocated object; /// 3. does not to point to a slice for which the length exceeds `isize::MAX` bytes; /// 4. points to a properly aligned address; /// 5. does not point to uninitialized memory; /// 6. does not point to a mutably borrowed memory location. pub unsafe fn ptr_len<T>(ptr: core::ptr::NonNull<[T]>) -> usize { (&*ptr.as_ptr()).len() } ``` A slightly less complicated version (but still more complicated than it needs to be): ```rust /// # Safety /// The caller must ensure that the start of `ptr`: /// 1. does not point to memory that was previously allocated but is now deallocated; /// 2. must be within the bounds of a single allocated object. pub unsafe fn ptr_len<T>(ptr: NonNull<[T]>) -> usize { (&*(ptr.as_ptr() as *const [()])).len() } ``` This PR does not stabilize `<*const [T]>::len` and `<*mut [T]>::len` because the tracking issue #71146 list a potential blocker for these methods, but this blocker [does not apply](https://github.com/rust-lang/rust/issues/71146#issuecomment-808735714) to `NonNull::len`. We should probably also ping the [Constant Evaluation WG](https://github.com/rust-lang/const-eval) since this PR includes a `#[rustc_allow_const_fn_unstable(const_slice_ptr_len)]`. My instinct here is that this will probably be okay because the pointer is not actually dereferenced and `len()` does not touch the address component of the pointer, but would be best to double check :) One potential down-side was raised that stabilizing `NonNull::len` could lead to encouragement of coding patterns like: ``` pub fn ptr_len<T>(ptr: *mut [T]) -> usize { NonNull::new(ptr).unwrap().len() } ``` which unnecessarily assert non-nullness. However, these are much less of a footgun than the above examples and this should be resolved when `slice_ptr_len` fully stabilizes eventually.
2022-05-28Auto merge of #97284 - b-naber:constraint-dyn-impl-suggestion, r=estebankbors-104/+368
Add suggestion for relaxing static lifetime bounds on dyn trait impls in NLL This PR introduces suggestions for relaxing static lifetime bounds on impls of dyn trait items for NLL similar to what is already available in lexical region diagnostics. Fixes https://github.com/rust-lang/rust/issues/95701 r? `@estebank`
2022-05-28Auto merge of #97433 - GuillaumeGomez:rm-refcell-context, r=notriddlebors-111/+128
Pass Context as a &mut to allow to remove RefCell fields Fixes #90323. r? `@notriddle`
2022-05-27Auto merge of #97468 - matthiaskrgr:rollup-8cu0hqr, r=matthiaskrgrbors-47/+109
Rollup of 6 pull requests Successful merges: - #95214 (Remove impossible panic note from `Vec::append`) - #97411 (Print stderr consistently) - #97453 (rename `TyKind` to `RegionKind` in comment in rustc_middle) - #97457 (Add regression test for #81899) - #97458 (Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error) - #97462 (Add more eslint rules) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-05-28Rollup merge of #97462 - GuillaumeGomez:more-eslint-rules, r=notriddleMatthias Krüger-6/+15
Add more eslint rules The last one is the most useful of this batch. :) Here are the links for the eslint rules: * [arrow-parens](https://eslint.org/docs/rules/arrow-parens) * [no-unused-vars](https://eslint.org/docs/rules/no-unused-vars) * [eqeqeq](https://eslint.org/docs/rules/eqeqeq) r? `@notriddle`
2022-05-28Rollup merge of #97458 - estebank:use-self-in-derive-macro, r=compiler-errorsMatthias Krüger-1/+24
Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error Reduce verbosity in #97343.
2022-05-28Rollup merge of #97457 - JohnTitor:issue-81899, r=compiler-errorsMatthias Krüger-0/+30
Add regression test for #81899 Closes #81899 r? `@compiler-errors`
2022-05-28Rollup merge of #97453 - lcnr:comment, r=jackh726Matthias Krüger-1/+1
rename `TyKind` to `RegionKind` in comment in rustc_middle
2022-05-28Rollup merge of #97411 - raiyansayeed:print-stderr-consistently, ↵Matthias Krüger-38/+38
r=Mark-Simulacrum Print stderr consistently Solves https://github.com/rust-lang/rust/issues/96712 I tried to follow what I perceived as the general consensus for error messages in boostrap i.e messages that were .. * resulting from an Err(...) => * literally called as "Error: ...." * by the end of the block scope forced to run a panic! or process::exit with a guaranteed non-zero error code.
2022-05-28Rollup merge of #95214 - tbu-:pr_vec_append_doc, r=Mark-SimulacrumMatthias Krüger-1/+1
Remove impossible panic note from `Vec::append` Neither the number of elements in a vector can overflow a `usize`, nor can the amount of elements in two vectors.
2022-05-27Add "eqeqeq" eslint ruleGuillaume Gomez-6/+7
2022-05-27Add "no-unused-vars" eslint ruleGuillaume Gomez-0/+7
2022-05-27Add "arrow-parens" eslint ruleGuillaume Gomez-0/+1
2022-05-27Pass Context as a &mut to allow to remove RefCell fieldsGuillaume Gomez-111/+128
2022-05-27Auto merge of #96790 - lqd:update_jemalloc, r=Mark-Simulacrumbors-21/+17
Update jemalloc to v5.3 Now that `jemalloc` version 5.3 has been released, this PR updates `tikv-jemalloc-sys` to the corresponding release. The crates.io publishing issue seems to have been resolved for the `jemalloc-sys` package, and version 5.3.0 is now also available under the historical name (and should become the preferred crate to be used). Therefore, this PR also switches back to using `jemalloc-sys` instead of `tikv-jemalloc-sys`.
2022-05-27Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant errorEsteban Küber-13/+6
#97343
2022-05-27Add test for #97343Esteban Küber-0/+30
2022-05-28Add regression test for #81899Yuki Okushi-0/+30
2022-05-27fix commentlcnr-1/+1
2022-05-27Auto merge of #96046 - oli-obk:const_typeck, r=cjgillotbors-518/+875
Move various checks to typeck so them failing causes the typeck result to get tainted Fixes #69487 fixes #79047 cc `@RalfJung` this gets rid of the `Transmute` invalid program error variant
2022-05-27Update tests on aarch64Oli Scherer-127/+183
2022-05-27Auto merge of #97442 - hafeoz:master, r=GuillaumeGomezbors-1/+20
Fix multiline attributes processing in doctest Fixes #97440. It seems like the call to `check_if_attr_is_complete` is not provided with the correct argument: the pending attribute should be passed, while the current line is actually being passed. This causes any attribute with more than 2 lines to fail and produces ICE when running through doctest.
2022-05-27Auto merge of #97004 - nnethercote:proc-macro-tweaks, r=eddybbors-148/+139
Proc macro tweaks Various improvements I spotted while looking through the proc macro code. r? `@eddyb`
2022-05-27Cut down `associated_item`.Nicholas Nethercote-20/+18
The part of it dealing with types obfuscates and makes the code less concise. This commit removes that part.
2022-05-27Remove unnecessary blank line.Nicholas Nethercote-1/+0
2022-05-27Rename `b` as `buf` in several places.Nicholas Nethercote-30/+30
Because it's easy to confuse with `bridge`.
2022-05-27Add some comments about `_marker` fields.Nicholas Nethercote-4/+14
There is some non-obvious information required to understand them.
2022-05-27Clarify a comment.Nicholas Nethercote-1/+1
`reverse_encode` isn't necessary to please the borrow checker, it's to match the ordering done by `reverse_decode`.
2022-05-27Rename `ProcMacroDerive` as `DeriveProcMacro`.Nicholas Nethercote-4/+4
So it matches the existing `AttrProcMacro` and `BangProcMacro` types.
2022-05-27Rename `ProcMacro` trait as `BangProcMacro`.Nicholas Nethercote-4/+4
Similar to the existing `AttrProcMacro` trait.
2022-05-27Simplify types in `proc_macro_harness.rs`.Nicholas Nethercote-27/+17
This gives the more obvious derive/attr/bang distinction, and reduces code size slightly.
2022-05-27Make `Buffer<T>` non-generic.Nicholas Nethercote-46/+46
`u8` is the only type that makes sense for `T`, as demonstrated by the fact that several impls and functions are hardwired to `Buffer<u8>`.
2022-05-27Improve formatting in `associated_item!` definition.Nicholas Nethercote-24/+15
2022-05-27Add some comments.Nicholas Nethercote-0/+3
2022-05-27Fix a typo in a comment.Nicholas Nethercote-1/+1
2022-05-27Auto merge of #97444 - compiler-errors:rollup-2gvdav6, r=compiler-errorsbors-141/+169
Rollup of 3 pull requests Successful merges: - #96051 (Use rounding in float to Duration conversion methods) - #97066 (rustdoc: Remove `ItemFragment(Kind)`) - #97436 (Update `triagebot.toml` for macos ping group) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-05-26Rollup merge of #97436 - compiler-errors:macos-ping-2, r=Mark-SimulacrumMichael Goulet-0/+7
Update `triagebot.toml` for macos ping group idk what i'm doing but i saw https://github.com/rust-lang/rust/pull/96392#issuecomment-1138893845 cc: `@thomcc`
2022-05-26Rollup merge of #97066 - petrochenkov:nofragkind, r=camelidMichael Goulet-114/+53
rustdoc: Remove `ItemFragment(Kind)` And stop using `write!` when rendering URL fragments to avoid impossible errors.
2022-05-26Rollup merge of #96051 - newpavlov:duration_rounding, r=nagisa,joshtriplettMichael Goulet-27/+109
Use rounding in float to Duration conversion methods Closes #96045
2022-05-27fmtАртём Павлов [Artyom Pavlov]-5/+1
2022-05-27fix nanos overflow for f64Артём Павлов [Artyom Pavlov]-9/+24
2022-05-27Auto merge of #96298 - petrochenkov:fromgen, r=estebankbors-34/+67
libcore: Add `iter::from_generator` which is like `iter::from_fn`, but for coroutines instead of functions An equally useful little helper. I didn't follow any of the async-wg work, so I don't know why something like this wasn't added before.
2022-05-27add debug assertsArtyom Pavlov-4/+8
2022-05-27libcore: Add `iter::from_generator` which is like `iter::from_fn`, but for ↵Vadim Petrochenkov-34/+67
coroutines instead of functions
2022-05-26Formattinghafeoz-1/+3
2022-05-26Remove few characters for tidy check to passhafeoz-1/+1
2022-05-26Auto merge of #97386 - nnethercote:optimize-pos-adjustments, r=bjorn3bors-30/+21
Optimize position adjustments A small improvement. r? `@bjorn3`
2022-05-26Add testshafeoz-0/+17
2022-05-26Use correct var for attribute completeness fnhafeoz-1/+1