8000 Rollup of 13 pull requests by Dylan-DPC-zz · Pull Request #76350 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 13 pull requests #76350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
18ad5a5
Add a regression test for issue-72793
JohnTitor Aug 19, 2020
e5f9d7f
BTreeMap: introduce marker::ValMut and reserve marker::Mut for unique…
ssomers Jul 23, 2020
aa40c02
Unstable Book: add links to tracking issues for FFI features
ArekPiekarz Aug 26, 2020
f03d0b3
`impl Rc::new_cyclic`
mental32 Aug 27, 2020
42fb270
typo
mental32 Aug 29, 2020
bb5e79c
Link vec doc to & reference
pickfire Aug 29, 2020
1b19354
[WIP] Fix intra-doc links on pub re-exports
jyn514 Aug 29, 2020
20a6866
Try removing [prim@reference]
pickfire Aug 30, 2020
e885f00
Comment out test for generated docs until rustdoc changes its behavio…
jyn514 Aug 30, 2020
d715015
Improve tests
jyn514 Aug 30, 2020
81e85ce
Move to Arc::clone(&x) over x.clone() in library/std
poliorcetics Aug 30, 2020
6b75e3d
Move to Arc::clone(&x) over x.clone() in library/core
poliorcetics Aug 30, 2020
864f2dc
Refactor byteorder to std in rustc_middle
workingjubilee Aug 20, 2020
fd959c1
Remove reference to byteorder limits
workingjubilee Aug 20, 2020
28d3100
Be explicit that we're handling bytes
workingjubilee Aug 20, 2020
91c9351
Explain contract of {read, write}_target_uint
workingjubilee Aug 21, 2020
b688314
Fix big endian read/write
workingjubilee Aug 22, 2020
ec0924f
do not apply DerefMut on union field
RalfJung Aug 16, 2020
44defae
also detect DerefMut in nested union fields
RalfJung Aug 16, 2020
97974e3
only emit error for ManuallyDrop derefs
RalfJung Aug 16, 2020
66b340f
test more ways of mutably accessing a place
RalfJung Aug 30, 2020
0f301e8
Removed [inline] and copied over comments from Arc::new_cyclic
mental32 Sep 1, 2020
8783c62
Add missing link in README
camelid Sep 2, 2020
89ae59a
Remove needless .to_owned() for link
jyn514 Jul 6, 2020
d5495e2
Refactor `ItemLink` into its own struct
jyn514 Jul 6, 2020
31a7b6e
Refactor RenderedLink into its own type
jyn514 Jul 6, 2020
9815010
Remove disambiguators from link text
jyn514 Jul 6, 2020
9d7e797
display_for -> suggestion_for
jyn514 Aug 29, 2020
4df6490
Link & primitive using relative link
pickfire Sep 3, 2020
6e43ff5
Add check for doc alias on associated const in trait impls
GuillaumeGomez Aug 24, 2020
b61eab5
Add test for doc alias on associated const in trait impls
GuillaumeGomez Aug 24, 2020
85146b9
Add slice primitive link to vec
pickfire Sep 4, 2020
18c14fd
Misc cleanup
jyn514 Aug 29, 2020
ed3950b
Enable profiler tests on Windows-gnu
mati865 Aug 5, 2020
1ea121c
Fix warning whe building profiler_builtins crate
mati865 Aug 24, 2020
03fd825
Ignore failing PGO/coverage tests on MinGW
mati865 Aug 24, 2020
e8fc38d
Update llvm submodule
mati865 Aug 31, 2020
57672a2
Rollup merge of #75200 - ssomers:btree_valmut, r=Mark-Simulacrum
Dylan-DPC Sep 4, 2020
eb2aca7
Rollup merge of #75584 - RalfJung:union-no-deref, r=matthewjasper
Dylan-DPC Sep 4, 2020
0ad0fee
Rollup merge of #75695 - JohnTitor:regression-test, r=Dylan-DPC
Dylan-DPC Sep 4, 2020
e818838
Rollup merge of #75741 - workingjubilee:refactor-byteorder, r=matthew…
Dylan-DPC Sep 4, 2020
9178eb0
Rollup merge of #75872 - mati865:pgo-tests, r=petrochenkov
Dylan-DPC Sep 4, 2020
6920100
Rollup merge of #75888 - GuillaumeGomez:trait-impl-assoc-const-doc-al…
Dylan-DPC Sep 4, 2020
8528e20
Rollup merge of #75954 - ArekPiekarz:unstable_book_ffi_tracking_issue…
Dylan-DPC Sep 4, 2020
e3e4705
Rollup merge of #75994 - mental32:impl-rc-new-cyclic, r=KodrAus
Dylan-DPC Sep 4, 2020
aeaecbe
Rollup merge of #76060 - pickfire:patch-12, r=jyn514
Dylan-DPC Sep 4, 2020
07a6c2c
Rollup merge of #76078 - jyn514:no-disambiguator, r=manishearth
Dylan-DPC Sep 4, 2020
aa6f881
Rollup merge of #76082 - jyn514:top-level-links, r=ollie27,GuillaumeG…
Dylan-DPC Sep 4, 2020
b3850fa
Rollup merge of #76128 - poliorcetics:doc-use-arc-clone, r=KodrAus
Dylan-DPC Sep 4, 2020
62ffaad
Rollup merge of #76229 - camelid:patch-3, r=jonas-schievink
Dylan-DPC Sep 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
only emit error for ManuallyDrop derefs
  • Loading branch information
RalfJung committed Aug 31, 2020
commit 97974e3cabefe725b6bea24c20e5fb9709e08a02
14 changes: 9 additions & 5 deletions compiler/rustc_typeck/src/check/place_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let ty::Ref(region, _, mutbl) = method.sig.output().kind {
*deref = OverloadedDeref { region, mutbl };
}
// If this is a union field, also throw an error.
// Union fields should not get mutable auto-deref'd (see RFC 2514).
if inside_union {
// If this is a union field, also throw an error for `DerefMut` of `ManuallyDrop` (see RFC 2514).
// This helps avoid accidental drops.
if inside_union
&& source.ty_adt_def().map_or(false, |adt| adt.is_manually_drop())
{
let mut err = self.tcx.sess.struct_span_err(
expr.span,
"not automatically applying `DerefMut` on union field",
"not automatically applying `DerefMut` on `ManuallyDrop` union field",
);
err.help(
"writing to this reference calls the destructor for the old value",
);
err.help("writing to this field calls the destructor for the old value");
err.help("add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor");
err.emit();
}
Expand Down
5 changes: 3 additions & 2 deletions src/test/ui/union/union-deref.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore-tidy-linelength
//! Test the part of RFC 2514 that is about not applying `DerefMut` coercions
//! of union fields.
#![feature(untagged_unions)]
Expand All @@ -11,9 +12,9 @@ union U2<T> { x:(), f: (ManuallyDrop<(T,)>,) }
fn main() {
let mut u : U1<Vec<i32>> = U1 { x: () };
unsafe { (*u.f).0 = Vec::new() }; // explicit deref, this compiles
unsafe { u.f.0 = Vec::new() }; //~ERROR not automatically applying `DerefMut` on union field
unsafe { u.f.0 = Vec::new() }; //~ERROR not automatically applying `DerefMut` on `ManuallyDrop` union field

let mut u : U2<Vec<i32>> = U2 { x: () };
unsafe { (*u.f.0).0 = Vec::new() }; // explicit deref, this compiles
unsafe { u.f.0.0 = Vec::new() }; //~ERROR not automatically applying `DerefMut` on union field
unsafe { u.f.0.0 = Vec::new() }; //~ERROR not automatically applying `DerefMut` on `ManuallyDrop` union field
}
12 changes: 6 additions & 6 deletions src/test/ui/union/union-deref.stderr
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
error: not automatically applying `DerefMut` on union field
--> $DIR/union-deref.rs:14:14
error: not automatically applying `DerefMut` on `ManuallyDrop` union field
--> $DIR/union-deref.rs:15:14
|
LL | unsafe { u.f.0 = Vec::new() };
| ^^^
|
= help: writing to this field calls the destructor for the old value
= help: writing to this reference calls the destructor for the old value
= help: add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor

error: not automatically applying `DerefMut` on union field
--> $DIR/union-deref.rs:18:14
error: not automatically applying `DerefMut` on `ManuallyDrop` union field
--> $DIR/union-deref.rs:19:14
|
LL | unsafe { u.f.0.0 = Vec::new() };
| ^^^^^^^
|
= help: writing to this field calls the destructor for the old value
= help: writing to this reference calls the destructor for the old value
= help: add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor

error: aborting due to 2 previous errors
Expand Down
0