about summary refs log tree commit diff
path: root/tests/ui/self
AgeCommit message (Collapse)AuthorLines
2023-03-11Rollup merge of #104363 - WaffleLapkin:bonk_box_new, r=NilstriebMatthias Krüger-2/+3
Make `unused_allocation` lint against `Box::new` too Previously it only linted against `box` syntax, which likely won't ever be stabilized, which is pretty useless. Even now I'm not sure if it's a meaningful lint, but it's at least something :shrug: This means that code like the following will be linted against: ```rust Box::new([1, 2, 3]).len(); f(&Box::new(1)); // where f : &i32 -> () ``` The lint works by checking if a `Box::new` (or `box`) expression has an a borrow adjustment, meaning that the code that first stores the box in a variable won't be linted against: ```rust let boxed = Box::new([1, 2, 3]); // no lint boxed.len(); ```
2023-03-03Add unuseless `#[allow(unused_allocation)]`Maybe Waffle-2/+3
2023-03-03Label opaque type for 'captures lifetime' error messageMichael Goulet-4/+6
2023-02-22diagnostics: update test cases to refer to assoc fn with `self` as methodMichael Howell-64/+64
2023-01-30Modify primary span label for E0308Esteban Küber-1/+1
The previous output was unintuitive to users.
2023-01-26Rollup merge of #97373 - dimpolo:cell_dispatch_from_dyn, r=dtolnayMatthias Krüger-0/+22
impl DispatchFromDyn for Cell and UnsafeCell After some fruitful discussion on [Internals](https://internals.rust-lang.org/t/impl-dispatchfromdyn-for-cell-2/16520) here's my first PR to rust-lang/rust 🎉 Please let me know if there's something I missed. This adds `DispatchFromDyn` impls for `Cell`, `UnsafeCell` and `SyncUnsafeCell`. An existing test is also expanded to test the `Cell` impl (which requires the `UnsafeCell` impl) The different `RefCell` types can not implement `DispatchFromDyn` since they have more than one (non ZST) field. &nbsp; **Edit:** ### What: These changes allow one to make types like `MyRc`(code below), to be object safe method receivers after implementing `DispatchFromDyn` and `Deref` for them. This allows for code like this: ```rust struct MyRc<T: ?Sized>(Cell<NonNull<RcBox<T>>>); /* impls for DispatchFromDyn, CoerceUnsized and Deref for MyRc*/ trait Trait { fn foo(self: MyRc<Self>); } let impls_trait = ...; let rc = MyRc::new(impls_trait) as MyRc<dyn Trait>; rc.foo(); ``` Note: `Cell` and `UnsafeCell` won't directly become valid method receivers since they don't implement `Deref`. Making use of these changes requires a wrapper type and nightly features. ### Why: A custom pointer type with interior mutability allows one to store extra information in the pointer itself. These changes allow for such a type to be a method receiver. ### Examples: My use case is a cycle aware custom `Rc` implementation that when dropping a cycle marks some references dangling. On the [forum](https://internals.rust-lang.org/t/impl-dispatchfromdyn-for-cell/14762/8) andersk mentioned that they track if a `Gc` reference is rooted with an extra bit in the reference itself.
2023-01-24impl DispatchFromDyn for Cell and UnsafeCelldimi-0/+22
2023-01-15Tweak E0597Esteban Küber-0/+2
CC #99430
2023-01-11When suggesting writing a fully qualified path probe for appropriate typesEsteban Küber-2/+2
Fix #46585.
2023-01-11Move /src/test to /testsAlbert Larsan-0/+4352