about summary refs log tree commit diff
path: root/tests/ui/hygiene
AgeCommit message (Collapse)AuthorLines
2023-12-20Auto merge of #106790 - the8472:rawvec-niche, r=scottmcmbors-1/+1
add more niches to rawvec Previously RawVec only had a single niche in its `NonNull` pointer. With this change it now has `isize::MAX` niches since half the value-space of the capacity field is never needed, we can't have a capacity larger than isize::MAX.
2023-12-15Rollup merge of #118234 - tgross35:type_name_of_value, r=dtolnayMatthias Krüger-1/+0
Stabilize `type_name_of_val` Make the following API stable: ```rust // in core::any pub fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str ``` This is a convenience method to get the type name of a value, as opposed to `type_name` that takes a type as a generic. Const stability is not added because this relies on `type_name` which is also not const. That has a blocking issue https://github.com/rust-lang/rust/issues/97156. Wording was also changed to direct most of the details to `type_name` so we don't have as much duplicated documentation. Fixes tracking issue #66359. There were two main concerns in the tracking issue: 1. Naming: `type_name_of` and `type_name_of_val` seem like the only mentioned options. Differences in opinion here come from `std::mem::{size_of, align_of, size_of_val, align_of_val}`. This PR leaves the name as `type_name_of_val`, but I can change if desired since it is pretty verbose. 2. What this displays for `&dyn`: I don't think that having `type_name_of_val` function resolve those is worth the headache it would be, see https://github.com/rust-lang/rust/issues/66359#issuecomment-1718480774 for some workarounds. I also amended the docs wording to leave it open-ended, in case we have means to change that behavior in the future. ``@rustbot`` label -T-libs +T-libs-api +needs-fcp r? libs-api
2023-12-11add more niches to rawvecThe 8472-1/+1
2023-12-11Improve `print_tts` by changing `tokenstream::Spacing`.Nicholas Nethercote-1/+1
`tokenstream::Spacing` appears on all `TokenTree::Token` instances, both punct and non-punct. Its current usage: - `Joint` means "can join with the next token *and* that token is a punct". - `Alone` means "cannot join with the next token *or* can join with the next token but that token is not a punct". The fact that `Alone` is used for two different cases is awkward. This commit augments `tokenstream::Spacing` with a new variant `JointHidden`, resulting in: - `Joint` means "can join with the next token *and* that token is a punct". - `JointHidden` means "can join with the next token *and* that token is a not a punct". - `Alone` means "cannot join with the next token". This *drastically* improves the output of `print_tts`. For example, this: ``` stringify!(let a: Vec<u32> = vec![];) ``` currently produces this string: ``` let a : Vec < u32 > = vec! [] ; ``` With this PR, it now produces this string: ``` let a: Vec<u32> = vec![] ; ``` (The space after the `]` is because `TokenTree::Delimited` currently doesn't have spacing information. The subsequent commit fixes this.) The new `print_tts` doesn't replicate original code perfectly. E.g. multiple space characters will be condensed into a single space character. But it's much improved. `print_tts` still produces the old, uglier output for code produced by proc macros. Because we have to translate the generated code from `proc_macro::Spacing` to the more expressive `token::Spacing`, which results in too much `proc_macro::Along` usage and no `proc_macro::JointHidden` usage. So `space_between` still exists and is used by `print_tts` in conjunction with the `Spacing` field. This change will also help with the removal of `Token::Interpolated`. Currently interpolated tokens are pretty-printed nicely via AST pretty printing. `Token::Interpolated` removal will mean they get printed with `print_tts`. Without this change, that would result in much uglier output for code produced by decl macro expansions. With this change, AST pretty printing and `print_tts` produce similar results. The commit also tweaks the comments on `proc_macro::Spacing`. In particular, it refers to "compound tokens" rather than "multi-char operators" because lifetimes aren't operators.
2023-12-05Stabilize `type_name_of_val`Trevor Gross-1/+0
Make the following API stable: // in core::any pub fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str Const stability is not added because this relies on `type_name` which is also not const. That has a blocking issue. Fixes #66359
2023-11-24Show number in error message even for one errorNilstrieb-23/+23
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-19When encountering struct fn call literal with private fields, suggest all ↵Esteban Küber-1/+1
builders When encountering code like `Box(42)`, suggest `Box::new(42)` and *all* other associated functions that return `-> Box<T>`.
2023-11-02Hint optimizer about reserved capacityKornel-1/+1
2023-10-17Automatically enable cross-crate inlining for small functionsBen Kimock-1/+1
2023-07-29Change default panic handler message format.Mara Bos-1/+2
2023-07-14Auto merge of #113113 - Amanieu:box-vec-zst, r=Mark-Simulacrumbors-1/+1
Eliminate ZST allocations in `Box` and `Vec` This PR fixes 2 issues with `Box` and `RawVec` related to ZST allocations. Specifically, the `Allocator` trait requires that: - If you allocate a zero-sized layout then you must later deallocate it, otherwise the allocator may leak memory. - You cannot pass a ZST pointer to the allocator that you haven't previously allocated. These restrictions exist because an allocator implementation is allowed to allocate non-zero amounts of memory for a zero-sized allocation. For example, `malloc` in libc does this. Currently, ZSTs are handled differently in `Box` and `Vec`: - `Vec` never allocates when `T` is a ZST or if the vector capacity is 0. - `Box` just blindly passes everything on to the allocator, including ZSTs. This causes problems due to the free conversions between `Box<[T]>` and `Vec<T>`, specifically that ZST allocations could get leaked or a dangling pointer could be passed to `deallocate`. This PR fixes this by changing `Box` to not allocate for zero-sized values and slices. It also fixes a bug in `RawVec::shrink` where shrinking to a size of zero did not actually free the backing memory.
2023-07-13Eliminate ZST allocations in `Box` and `Vec`Amanieu d'Antras-1/+1
2023-07-10Do not set up wrong span for adjustmentsMichael Goulet-1/+1
2023-07-07adjust smart_resolve_partial_mod_path_errorsyukang-0/+27
2023-07-07Add filter with next segment while lookup typo for pathyukang-4/+72
2023-06-10Make "consider importing" consistent for macrosMu001999-2/+4
2023-05-21Rename `drop_copy` lint to `dropping_copy_types`Urgau-1/+1
2023-05-10Adjust tests for new drop and forget lintsUrgau-0/+1
2023-04-14Rollup merge of #110244 - kadiwa4:unnecessary_imports, r=JohnTitorMatthias Krüger-1/+1
Remove some unneeded imports / qualified paths Continuation of #105537.
2023-04-12Special-case item attributes in the suggestion outputEsteban Küber-5/+0
2023-04-12Tweak output for 'add line' suggestionEsteban Küber-5/+10
2023-04-12remove some unneeded importsKaDiWa-1/+1
2023-04-03remove invalid ignore-prettyPietro Albini-32/+9
2023-01-22simplify layout calculations in rawvecThe 8472-1/+1
2023-01-17note -> helpMichael Goulet-3/+3
2023-01-11Move /src/test to /testsAlbert Larsan-0/+3138