8000 Rollup of 9 pull requests by Centril · Pull Request #70335 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 9 pull requests #70335

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 39 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2daaf2b
replace some adhoc logic with article_and_descr
mark-i-m Mar 16, 2020
1661a0a
convert a couple more errors
mark-i-m Mar 22, 2020
cdb2c3c
use static strs
mark-i-m Mar 22, 2020
1e5d81d
Fix invalid suggestion on `&mut` iterators yielding `&` references
tirr-c Mar 22, 2020
82f4a1a
get rid of ConstPropUnsupported; use ZST marker structs instead
RalfJung Mar 22, 2020
12607ef
Add lint when no doc is present at the crate-level
GuillaumeGomez Dec 1, 2019
f767f54
rename NO_CRATE_LEVEL_DOC lint into MISSING_CRATE_LEVEL_DOC
GuillaumeGomez Feb 11, 2020
a8b0e40
Improve code readability
GuillaumeGomez Feb 11, 2020
ffe1289
Update tests
GuillaumeGomez Feb 11, 2020
9664002
Update to new diagnostic
GuillaumeGomez Feb 12, 2020
be97eb4
Update lint name to follow convention
GuillaumeGomez Mar 22, 2020
d40dff9
the crate and tests
mark-i-m Mar 22, 2020
cda81da
avoid unsafe code, use upcasting-trait instead (trick by oli)
RalfJung Mar 22, 2020
5e8b795
fix one more test
mark-i-m Mar 22, 2020
410385d
add macro to reduce boilerplate and keep readable messages
RalfJung Mar 23, 2020
e619b85
make sure we are checking the size of the right thing
RalfJung Mar 23, 2020
19e6935
Clean up E0452 explanation
GuillaumeGomez Mar 23, 2020
799b15e
Evaluate repeat expression lengths as late as possible
oli-obk Mar 14, 2020
fa5a15c
Document most methods on `ty::Const`
oli-obk Mar 14, 2020
3f89c38
Inline `const_param_def_id` at its only use site
oli-obk Mar 14, 2020
770be24
Use `DefId`s to identify anon consts when converting from HIR to ty::…
oli-obk Mar 17, 2020
c3b9881
Remove `ReClosureBound`
matthewjasper Mar 11, 2020
9bcd9fe
Address review comments
oli-obk Mar 23, 2020
c7c2fa1
Make `needs_drop` less pessimistic on generators
jonas-schievink Mar 14, 2020
9ebc72f
Adjust mir-opt test and make it drop something
jonas-schievink Mar 15, 2020
124ab20
Limit `from_anon_const` to `AnonConst`s.
oli-obk Mar 23, 2020
1df7641
Fix rebase fallout
jonas-schievink Mar 23, 2020
e75158d
Account for bad placeholder types in where clauses
estebank Mar 23, 2020
5aa15bf
Remove leftover mentions of `from_anon_const`
oli-obk Mar 23, 2020
4f513b5
Split out some impls from rustc::mir into a separate submodule
oli-obk Mar 23, 2020
ccedc15
Rollup merge of #66938 - GuillaumeGomez:lint-for-no-crate-level-doc, …
Centril Mar 23, 2020
093602e
Rollup merge of #69740 - mark-i-m:describe-it-3, r=eddyb
Centril Mar 23, 2020
32b6b1e
Rollup merge of #69981 - oli-obk:const_blocks, r=eddyb
Centril Mar 23, 2020
c8fb14e
Rollup merge of #70015 - jonas-schievink:gen-needs-drop, r=matthewjasper
Centril Mar 23, 2020
a897944
Rollup merge of #70264 - tirr-c:issue-69789-mut-suggestion, r=estebank
Centril Mar 23, 2020
c213d76
Rollup merge of #70267 - RalfJung:const-prop-unsup, r=oli-obk,wesleyw…
Centril Mar 23, 2020
4c53bfe
Rollup merge of #70277 - matthewjasper:remove-closurebound, r=nikomat…
Centril Mar 23, 2020
de1b094
Rollup merge of #70294 - estebank:bad-placeholder-in-where, r=Centril
Centril Mar 23, 2020
c98c56e
Rollup merge of #70309 - GuillaumeGomez:cleanup-e0452, r=Dylan-DPC
Centril Mar 23, 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
8 changes: 3 additions & 5 deletions src/librustc/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1047,10 +1047,7 @@ pub fn needs_drop_components(
// Foreign types can never have destructors.
ty::Foreign(..) => Ok(SmallVec::new()),

// Pessimistically assume that all generators will require destructors
// as we don't know if a destructor is a noop or not until after the MIR
// state transformation pass.
ty::Generator(..) | ty::Dynamic(..) | ty::Error => Err(AlwaysRequiresDrop),
ty::Dynamic(..) | ty::Error => Err(AlwaysRequiresDrop),

ty::Slice(ty) => needs_drop_components(ty, target_layout),
ty::Array(elem_ty, size) => {
Expand Down Expand Up @@ -1083,7 +1080,8 @@ pub fn needs_drop_components(
| ty::Placeholder(..)
| ty::Opaque(..)
| ty::Infer(_)
| ty::Closure(..) => Ok(smallvec![ty]),
| ty::Closure(..)
| ty::Generator(..) => Ok(smallvec![ty]),
}
}

Expand Down
17 changes: 17 additions & 0 deletions src/librustc_ty/needs_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ where
}
}

ty::Generator(_, substs, _) => {
let substs = substs.as_generator();
for upvar_ty in substs.upvar_tys() {
queue_type(self, upvar_ty);
}

let witness = substs.witness();
let interior_tys = match &witness.kind {
ty::GeneratorWitness(tys) => tcx.erase_late_bound_regions(tys),
_ => bug!(),
};

for interior_ty in interior_tys {
queue_type(self, interior_ty);
}
}

// Check for a `Drop` impl and whether this is a union or
// `ManuallyDrop`. If it's a struct or enum without a `Drop`
// impl then check whether the field types need `Drop`.
Expand Down
45 changes: 30 additions & 15 deletions src/test/mir-opt/generator-drop-cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

fn main() {
let gen = || {
let _s = String::new();
yield;
};
}
Expand All @@ -13,35 +14,49 @@ fn main() {

// START rustc.main-{{closure}}.generator_drop.0.mir
// bb0: {
// _7 = discriminant((*_1));
// switchInt(move _7) -> [0u32: bb4, 3u32: bb7, otherwise: bb8];
// _9 = discriminant((*_1));
// switchInt(move _9) -> [0u32: bb7, 3u32: bb11, otherwise: bb12];
// }
// bb1: {
// StorageDead(_4);
// StorageDead(_3);
// goto -> bb5;
// bb1 (cleanup): {
// resume;
// }
// bb2: {
// return;
// bb2 (cleanup): {
// nop;
// goto -> bb8;
// }
// bb3: {
// return;
// StorageDead(_5);
// StorageDead(_4);
// drop((((*_1) as variant#3).0: std::string::String)) -> [return: bb4, unwind: bb2];
// }
// bb4: {
// goto -> bb6;
// nop;
// goto -> bb9;
// }
// bb5: {
// goto -> bb2;
// return;
// }
// bb6: {
// goto -> bb3;
// return;
// }
// bb7: {
// StorageLive(_3);
// StorageLive(_4);
// goto -> bb10;
// }
// bb8 (cleanup): {
// goto -> bb1;
// }
// bb8: {
// bb9: {
// goto -> bb5;
// }
// bb10: {
// goto -> bb6;
// }
// bb11: {
// StorageLive(_4);
// StorageLive(_5);
// goto -> bb3;
// }
// bb12: {
// return;
// }
8000 // END rustc.main-{{closure}}.generator_drop.0.mir
15 changes: 6 additions & 9 deletions src/test/ui/generator/borrowing.stderr
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
error[E0597]: `a` does not live long enough
--> $DIR/borrowing.rs:9:33
|
LL | let _b = {
| -- borrow later stored here
LL | let a = 3;
LL | Pin::new(&mut || yield &a).resume(())
| ----------^
| | |
| | borrowed value does not live long enough
| -- ^ borrowed value does not live long enough
| |
| value captured here by generator
| a temporary with access to the borrow is created here ...
LL |
LL | };
| -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for generator
| |
| `a` dropped here while still borrowed
|
= note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block.
| - `a` dropped here while still borrowed

error[E0597]: `a` does not live long enough
--> $DIR/borrowing.rs:16:20
Expand Down
7 changes: 3 additions & 4 deletions src/test/ui/generator/retain-resume-ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ error[E0499]: cannot borrow `thing` as mutable more than once at a time
LL | gen.as_mut().resume(&mut thing);
| ---------- first mutable borrow occurs here
LL | gen.as_mut().resume(&mut thing);
| ^^^^^^^^^^ second mutable borrow occurs here
LL |
LL | }
| - first borrow might be used here, when `gen` is dropped and runs the destructor for generator
| ------ ^^^^^^^^^^ second mutable borrow occurs here
| |
| first borrow later used by call

error: aborting due to previous error

Expand Down
0