Merged
Conversation
Contributor
|
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
Member
|
r? @RalfJung |
RalfJung
reviewed
Jun 29, 2020
RalfJung
reviewed
Jun 29, 2020
RalfJung
reviewed
Jun 29, 2020
Contributor
Author
|
Addressed the review comments (and in (I really need to figure out why format-on-save is not agreeing with |
dce66a3 to
b581b39
Compare
b581b39 to
aed88e1
Compare
RalfJung
reviewed
Jul 1, 2020
RalfJung
reviewed
Jul 1, 2020
Co-Authored-By: Ralf Jung <post@ralfj.de>
31f8489 to
98789ac
Compare
RalfJung
reviewed
Jul 1, 2020
RalfJung
reviewed
Jul 1, 2020
RalfJung
reviewed
Jul 2, 2020
0db0dcb to
1b5ac57
Compare
Member
|
Awesome, thanks a lot for enduring all these rounds of review. :) |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 4, 2020
…arth Rollup of 12 pull requests Successful merges: - rust-lang#73140 (Fallback to xml.etree.ElementTree) - rust-lang#73670 (Add `format_args_capture` feature) - rust-lang#73693 (Use exhaustive match in const_prop.rs) - rust-lang#73845 (Use &raw in A|Rc::as_ptr) - rust-lang#73861 (Create E0768) - rust-lang#73881 (Standardize bibliographic citations in rustc API docs) - rust-lang#73925 (Improve comments from rust-lang#72617, as suggested by RalfJung) - rust-lang#73949 ([mir-opt] Fix mis-optimization and other issues with the SimplifyArmIdentity pass) - rust-lang#73984 (Edit docs for rustc_data_structures::graph::scc) - rust-lang#73985 (Fix "getting started" link) - rust-lang#73997 (fix typo) - rust-lang#73999 (Bump mingw-check CI image from Ubuntu 16.04 to 18.04.) Failed merges: - rust-lang#74000 (add `lazy_normalization_consts` feature gate) r? @ghost
CAD97
added a commit
to CAD97/rust
that referenced
this pull request
Jul 4, 2020
....to allow use with unsized T. This is a follow-up to rust-lang#73845, which did the impl work required to be able to relax these bounds.
3 tasks
3 tasks
Dylan-DPC-zz
pushed a commit
to Dylan-DPC-zz/rust
that referenced
this pull request
Oct 3, 2020
Allow Weak::as_ptr and friends for unsized T Relaxes `impl<T> Weak<T>` to `impl<T: ?Sized> Weak<T>` for the methods `rc::Weak::as_ptr`, `into_raw`, and `from_raw`. Follow-up to rust-lang#73845, which did most of the impl work to make these functions work for `T: ?Sized`. We still have to adjust the implementation of `Weak::from_raw` here, however, because I missed a use of `ptr.is_null()` previously. This check was necessary when `into`/`from_raw` were first implemented, as `into_raw` returned `ptr::null()` for dangling weak. However, we now just (wrapping) offset dangling weaks' pointers the same as nondangling weak, so the null check is no longer necessary (or even hit). (I can submit just 17a928f as a separate PR if desired.) As a nice side effect, moves the `fn is_dangling` definition closer to `Weak::new`, which creates the dangling weak. This technically stabilizes that "something like `align_of_val_raw`" is possible to do. However, I believe the part of the functionality required by these methods here -- specifically, getting the alignment of a pointee from a pointer where it may be dangling iff the pointee is `Sized` -- is uncontroversial enough to stabilize these methods without a way to implement them on stable Rust. r? @RalfJung, who reviewed rust-lang#73845. ATTN: This changes (relaxes) the (input) generic bounds on stable fn!
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Oct 3, 2020
Allow Weak::as_ptr and friends for unsized T Relaxes `impl<T> Weak<T>` to `impl<T: ?Sized> Weak<T>` for the methods `rc::Weak::as_ptr`, `into_raw`, and `from_raw`. Follow-up to rust-lang#73845, which did most of the impl work to make these functions work for `T: ?Sized`. We still have to adjust the implementation of `Weak::from_raw` here, however, because I missed a use of `ptr.is_null()` previously. This check was necessary when `into`/`from_raw` were first implemented, as `into_raw` returned `ptr::null()` for dangling weak. However, we now just (wrapping) offset dangling weaks' pointers the same as nondangling weak, so the null check is no longer necessary (or even hit). (I can submit just 17a928f as a separate PR if desired.) As a nice side effect, moves the `fn is_dangling` definition closer to `Weak::new`, which creates the dangling weak. This technically stabilizes that "something like `align_of_val_raw`" is possible to do. However, I believe the part of the functionality required by these methods here -- specifically, getting the alignment of a pointee from a pointer where it may be dangling iff the pointee is `Sized` -- is uncontroversial enough to stabilize these methods without a way to implement them on stable Rust. r? `@RalfJung,` who reviewed rust-lang#73845. ATTN: This changes (relaxes) the (input) generic bounds on stable fn!
RalfJung
reviewed
Dec 26, 2020
| @@ -2279,13 +2292,6 @@ unsafe fn data_offset<T: ?Sized>(ptr: *const T) -> isize { | |||
| unsafe { data_offset_align(align_of_val(&*ptr)) } | |||
Member
There was a problem hiding this comment.
oops this line should have been align_of_val_raw now, right?
But I doubt that that's enough to fix #80365.
Contributor
Author
There was a problem hiding this comment.
Yes, it definitely should have been. I don't know how I missed this one 🙃
CAD97
added a commit
to CAD97/rust
that referenced
this pull request
Dec 26, 2020
This was missed in rust-lang#73845 when switching to use the raw operators. Fixes rust-lang#80365
m-ou-se
added a commit
to m-ou-se/rust
that referenced
this pull request
Dec 28, 2020
Use raw version of align_of in rc data_offset This was missed in rust-lang#73845 when switching to use the raw operators. Fixes rust-lang#80365
samueltardieu
pushed a commit
to samueltardieu/rust
that referenced
this pull request
Jun 26, 2025
It is currently possible to create a dangling `Weak` to a DST by calling `Weak::new()` for a sized type, then doing an unsized coercion. Therefore, the comments are wrong. These comments were added in <rust-lang#73845>. As far as I can tell, the guarantee in the comment was only previously used in the `as_ptr` method. However, the current implementation of `as_ptr` no longer relies on this guarantee.
samueltardieu
added a commit
to samueltardieu/rust
that referenced
this pull request
Jun 26, 2025
…ibraheemdev Remove incorrect comments in `Weak` It is currently possible to create a dangling `Weak` to a DST by calling `Weak::new()` for a sized type, then doing an unsized coercion. Therefore, the comments are wrong. These comments were added in <rust-lang#73845>. As far as I can tell, the guarantee in the comment was only previously used in the `as_ptr` method. However, the current implementation of `as_ptr` no longer relies on this guarantee.
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this pull request
Jun 26, 2025
…ibraheemdev Remove incorrect comments in `Weak` It is currently possible to create a dangling `Weak` to a DST by calling `Weak::new()` for a sized type, then doing an unsized coercion. Therefore, the comments are wrong. These comments were added in <rust-lang#73845>. As far as I can tell, the guarantee in the comment was only previously used in the `as_ptr` method. However, the current implementation of `as_ptr` no longer relies on this guarantee.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jun 26, 2025
…ibraheemdev Remove incorrect comments in `Weak` It is currently possible to create a dangling `Weak` to a DST by calling `Weak::new()` for a sized type, then doing an unsized coercion. Therefore, the comments are wrong. These comments were added in <rust-lang#73845>. As far as I can tell, the guarantee in the comment was only previously used in the `as_ptr` method. However, the current implementation of `as_ptr` no longer relies on this guarantee.
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this pull request
Jun 26, 2025
…ibraheemdev Remove incorrect comments in `Weak` It is currently possible to create a dangling `Weak` to a DST by calling `Weak::new()` for a sized type, then doing an unsized coercion. Therefore, the comments are wrong. These comments were added in <rust-lang#73845>. As far as I can tell, the guarantee in the comment was only previously used in the `as_ptr` method. However, the current implementation of `as_ptr` no longer relies on this guarantee.
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this pull request
Jun 27, 2025
…ibraheemdev Remove incorrect comments in `Weak` It is currently possible to create a dangling `Weak` to a DST by calling `Weak::new()` for a sized type, then doing an unsized coercion. Therefore, the comments are wrong. These comments were added in <rust-lang#73845>. As far as I can tell, the guarantee in the comment was only previously used in the `as_ptr` method. However, the current implementation of `as_ptr` no longer relies on this guarantee.
rust-timer
added a commit
that referenced
this pull request
Jun 27, 2025
Rollup merge of #142700 - theemathas:remove-weak-comment, r=ibraheemdev Remove incorrect comments in `Weak` It is currently possible to create a dangling `Weak` to a DST by calling `Weak::new()` for a sized type, then doing an unsized coercion. Therefore, the comments are wrong. These comments were added in <#73845>. As far as I can tell, the guarantee in the comment was only previously used in the `as_ptr` method. However, the current implementation of `as_ptr` no longer relies on this guarantee.
github-actions bot
pushed a commit
to model-checking/verify-rust-std
that referenced
this pull request
Jul 4, 2025
It is currently possible to create a dangling `Weak` to a DST by calling `Weak::new()` for a sized type, then doing an unsized coercion. Therefore, the comments are wrong. These comments were added in <rust-lang#73845>. As far as I can tell, the guarantee in the comment was only previously used in the `as_ptr` method. However, the current implementation of `as_ptr` no longer relies on this guarantee.
github-actions bot
pushed a commit
to model-checking/verify-rust-std
that referenced
this pull request
Jul 4, 2025
…ibraheemdev Remove incorrect comments in `Weak` It is currently possible to create a dangling `Weak` to a DST by calling `Weak::new()` for a sized type, then doing an unsized coercion. Therefore, the comments are wrong. These comments were added in <rust-lang#73845>. As far as I can tell, the guarantee in the comment was only previously used in the `as_ptr` method. However, the current implementation of `as_ptr` no longer relies on this guarantee.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR uses
&rawfor offsetting*mut [A]RcInner<T> -> *mut T.Additionally, this updates the implementation of
Weak::as_ptrto support unsizedT, though it does not yet relax the bounds ofWeak::as_ptr/into_raw/from_rawto accept unsizedT.