Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2de99ec
Reformat `struct_span_code_err!`.
nnethercote Jan 12, 2024
d71f535
Rework how diagnostic lints are stored.
nnethercote Jan 13, 2024
7df054b
Change return type of unstable `Waker::noop()` from `Waker` to `&Waker`.
kpreid Jan 15, 2024
219b00d
Remove unnecessary `let`s and borrowing from `Waker::noop()` usage.
kpreid Jan 15, 2024
9a8f117
Don't create the array type twice
oli-obk Jan 15, 2024
7052188
Document why `Waker::noop()`'s implementation is the shape it is.
kpreid Jan 15, 2024
290651b
don't store const var origins for known vars
lcnr Jan 16, 2024
3599c18
Skip dead code checks on items that failed typeck
oli-obk Jan 16, 2024
8bb1eae
Introduce helper that deals with moving async args into the coroutine
compiler-errors Jan 14, 2024
f56a4c0
Deny braced macro invocations in let-else
compiler-errors Dec 18, 2023
fd02369
Suggest wrapping mac args in parens rather than the whole expression
compiler-errors Dec 18, 2023
f1ee076
Async closures will move params into the future always
compiler-errors Jan 14, 2024
f4e35c6
Fix async closure call suggestion
compiler-errors Jan 15, 2024
04a5ee6
Deal with additional wrapping of async closure body in clippy
compiler-errors Jan 15, 2024
98a789c
Rollup merge of #119062 - compiler-errors:asm-in-let-else, r=davidtwc…
matthiaskrgr Jan 16, 2024
f990e22
Rollup merge of #119922 - nnethercote:fix-Diag-code-is_lint, r=oli-obk
matthiaskrgr Jan 16, 2024
3ef303b
Rollup merge of #119978 - compiler-errors:async-closure-captures, r=o…
matthiaskrgr Jan 16, 2024
3c7cca7
Rollup merge of #119984 - kpreid:waker-noop, r=dtolnay
matthiaskrgr Jan 16, 2024
c21fcd4
Rollup merge of #120020 - oli-obk:long_const_eval_err_taint, r=compil…
matthiaskrgr Jan 16, 2024
1a329e4
Rollup merge of #120021 - lcnr:const-var-value, r=compiler-errors
matthiaskrgr Jan 16, 2024
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
Remove unnecessary lets and borrowing from Waker::noop() usage.
`Waker::noop()` now returns a `&'static Waker` reference, so it can be
passed directly to `Context` creation with no temporary lifetime issue.
  • Loading branch information
kpreid committed Jan 15, 2024
commit 219b00df0b5fd68cd5abc4c553b9529066927f60
3 changes: 1 addition & 2 deletions library/core/tests/async_iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ fn into_async_iter() {
let async_iter = async_iter::from_iter(0..3);
let mut async_iter = pin!(async_iter.into_async_iter());

let waker = core::task::Waker::noop();
let mut cx = &mut core::task::Context::from_waker(&waker);
let mut cx = &mut core::task::Context::from_waker(core::task::Waker::noop());

assert_eq!(async_iter.as_mut().poll_next(&mut cx), Poll::Ready(Some(0)));
assert_eq!(async_iter.as_mut().poll_next(&mut cx), Poll::Ready(Some(1)));
Expand Down
3 changes: 1 addition & 2 deletions src/tools/miri/tests/pass/async-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ async fn uninhabited_variant() {
fn run_fut<T>(fut: impl Future<Output = T>) -> T {
use std::task::{Context, Poll, Waker};

let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
let mut context = Context::from_waker(Waker::noop());

let mut pinned = Box::pin(fut);
loop {
Expand Down
3 changes: 1 addition & 2 deletions src/tools/miri/tests/pass/dyn-star.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ fn dispatch_on_pin_mut() {
let mut fut = async_main();

// Poll loop, just to test the future...
let waker = Waker::noop();
let ctx = &mut Context::from_waker(&waker);
let ctx = &mut Context::from_waker(Waker::noop());

loop {
match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } {
Expand Down
6 changes: 2 additions & 4 deletions src/tools/miri/tests/pass/future-self-referential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ impl Future for DoStuff {
}

fn run_fut<T>(fut: impl Future<Output = T>) -> T {
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
let mut context = Context::from_waker(Waker::noop());

let mut pinned = pin!(fut);
loop {
Expand All @@ -90,8 +89,7 @@ fn run_fut<T>(fut: impl Future<Output = T>) -> T {
}

fn self_referential_box() {
let waker = Waker::noop();
let cx = &mut Context::from_waker(&waker);
let cx = &mut Context::from_waker(Waker::noop());

async fn my_fut() -> i32 {
let val = 10;
Expand Down
3 changes: 1 addition & 2 deletions src/tools/miri/tests/pass/issues/issue-miri-2068.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use std::task::{Context, Poll, Waker};

pub fn fuzzing_block_on<O, F: Future<Output = O>>(fut: F) -> O {
let mut fut = std::pin::pin!(fut);
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
let mut context = Context::from_waker(Waker::noop());
loop {
match fut.as_mut().poll(&mut context) {
Poll::Ready(v) => return v,
Expand Down
3 changes: 1 addition & 2 deletions src/tools/miri/tests/pass/move-data-across-await-point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ fn data_moved() {
fn run_fut<T>(fut: impl Future<Output = T>) -> T {
use std::task::{Context, Poll, Waker};

let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
let mut context = Context::from_waker(Waker::noop());

let mut pinned = Box::pin(fut);
loop {
Expand Down
3 changes: 1 addition & 2 deletions tests/coverage/async.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@
LL| | #[coverage(off)]
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
LL| | let mut future = pin!(future);
LL| | let waker = Waker::noop();
LL| | let mut context = Context::from_waker(&waker);
LL| | let mut context = Context::from_waker(Waker::noop());
LL| |
LL| | loop {
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
Expand Down
3 changes: 1 addition & 2 deletions tests/coverage/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ mod executor {
#[coverage(off)]
pub fn block_on<F: Future>(mut future: F) -> F::Output {
let mut future = pin!(future);
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
let mut context = Context::from_waker(Waker::noop());

loop {
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
Expand Down
3 changes: 1 addition & 2 deletions tests/coverage/async2.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
LL| | #[coverage(off)]
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
LL| | let mut future = pin!(future);
LL| | let waker = Waker::noop();
LL| | let mut context = Context::from_waker(&waker);
LL| | let mut context = Context::from_waker(Waker::noop());
LL| |
LL| | loop {
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
Expand Down
3 changes: 1 addition & 2 deletions tests/coverage/async2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ mod executor {
#[coverage(off)]
pub fn block_on<F: Future>(mut future: F) -> F::Output {
let mut future = pin!(future);
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
let mut context = Context::from_waker(Waker::noop());

loop {
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
Expand Down
3 changes: 1 addition & 2 deletions tests/coverage/async_block.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
LL| | #[coverage(off)]
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
LL| | let mut future = pin!(future);
LL| | let waker = Waker::noop();
LL| | let mut context = Context::from_waker(&waker);
LL| | let mut context = Context::from_waker(Waker::noop());
LL| |
LL| | loop {
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
Expand Down
3 changes: 1 addition & 2 deletions tests/coverage/async_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ mod executor {
#[coverage(off)]
pub fn block_on<F: Future>(mut future: F) -> F::Output {
let mut future = pin!(future);
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
let mut context = Context::from_waker(Waker::noop());

loop {
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
Expand Down
16 changes: 8 additions & 8 deletions tests/coverage/closure_macro_async.cov-map
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
Function name: closure_macro_async::load_configuration_files
Raw bytes (9): 0x[01, 01, 00, 01, 01, 1e, 01, 02, 02]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 1f, 01, 02, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 30, 1) to (start + 2, 2)
- Code(Counter(0)) at (prev + 31, 1) to (start + 2, 2)

Function name: closure_macro_async::test
Raw bytes (9): 0x[01, 01, 00, 01, 01, 22, 01, 00, 2b]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 23, 01, 00, 2b]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 34, 1) to (start + 0, 43)
- Code(Counter(0)) at (prev + 35, 1) to (start + 0, 43)

Function name: closure_macro_async::test::{closure#0}
Raw bytes (43): 0x[01, 01, 02, 01, 05, 05, 02, 07, 01, 22, 2b, 01, 21, 02, 02, 09, 00, 0f, 05, 00, 12, 00, 13, 02, 00, 12, 00, 13, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 07, 03, 01, 00, 02]
Raw bytes (43): 0x[01, 01, 02, 01, 05, 05, 02, 07, 01, 23, 2b, 01, 21, 02, 02, 09, 00, 0f, 05, 00, 12, 00, 13, 02, 00, 12, 00, 13, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 07, 03, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 2
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
Number of file 0 mappings: 7
- Code(Counter(0)) at (prev + 34, 43) to (start + 1, 33)
- Code(Counter(0)) at (prev + 35, 43) to (start + 1, 33)
- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15)
= (c0 - c1)
- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19)
Expand All @@ -35,10 +35,10 @@ Number of file 0 mappings: 7
= (c1 + (c0 - c1))

Function name: closure_macro_async::test::{closure#0}::{closure#0}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 24, 12, 00, 54]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 25, 12, 00, 54]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 36, 18) to (start + 0, 84)
- Code(Counter(0)) at (prev + 37, 18) to (start + 0, 84)

3 changes: 1 addition & 2 deletions tests/coverage/closure_macro_async.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@
LL| | #[coverage(off)]
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
LL| | let mut future = pin!(future);
LL| | let waker = Waker::noop();
LL| | let mut context = Context::from_waker(&waker);
LL| | let mut context = Context::from_waker(Waker::noop());
LL| |
LL| | loop {
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
Expand Down
6 changes: 3 additions & 3 deletions tests/coverage/closure_macro_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ macro_rules! bail {

macro_rules! on_error {
($value:expr, $error_message:expr) => {
$value.or_else(|e| { // FIXME(85000): no coverage in closure macros
$value.or_else(|e| {
// FIXME(85000): no coverage in closure macros
let message = format!($error_message, e);
if message.len() > 0 {
println!("{}", message);
Expand Down Expand Up @@ -53,8 +54,7 @@ mod executor {
#[coverage(off)]
pub fn block_on<F: Future>(mut future: F) -> F::Output {
let mut future = pin!(future);
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
let mut context = Context::from_waker(Waker::noop());

loop {
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/async-await/for-await-passthrough.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ async fn real_main() {

fn main() {
let future = real_main();
let waker = std::task::Waker::noop();
let mut cx = &mut core::task::Context::from_waker(&waker);
let mut cx = &mut core::task::Context::from_waker(std::task::Waker::noop());
let mut future = core::pin::pin!(future);
while let core::task::Poll::Pending = future.as_mut().poll(&mut cx) {}
}
3 changes: 1 addition & 2 deletions tests/ui/async-await/for-await.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ async fn real_main() {

fn main() {
let future = real_main();
let waker = std::task::Waker::noop();
let mut cx = &mut core::task::Context::from_waker(&waker);
let mut cx = &mut core::task::Context::from_waker(std::task::Waker::noop());
let mut future = core::pin::pin!(future);
while let core::task::Poll::Pending = future.as_mut().poll(&mut cx) {}
}
3 changes: 1 addition & 2 deletions tests/ui/async-await/in-trait/async-default-fn-overridden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ fn main() {
let mut fut = pin!(async_main());

// Poll loop, just to test the future...
let waker = Waker::noop();
let ctx = &mut Context::from_waker(&waker);
let ctx = &mut Context::from_waker(Waker::noop());

loop {
match fut.as_mut().poll(ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ fn main() {
let mut fut = pin!(async_main());

// Poll loop, just to test the future...
let waker = Waker::noop();
let ctx = &mut Context::from_waker(&waker);
let ctx = &mut Context::from_waker(Waker::noop());

loop {
match fut.as_mut().poll(ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LL | default async fn foo(_: T) -> &'static str {
= note: specialization behaves in inconsistent and surprising ways with async functions in traits, and for now is disallowed

error[E0599]: no method named `poll` found for struct `Pin<&mut impl Future<Output = ()>>` in the current scope
--> $DIR/dont-project-to-specializable-projection.rs:50:28
--> $DIR/dont-project-to-specializable-projection.rs:49:28
|
LL | match fut.as_mut().poll(ctx) {
| ^^^^ method not found in `Pin<&mut impl Future<Output = ()>>`
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/coroutine/async-gen-yield-ty-is-unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ async gen fn gen_fn() -> &'static str {

pub fn main() {
let async_iterator = pin!(gen_fn());
let waker = Waker::noop();
let ctx = &mut Context::from_waker(&waker);
let ctx = &mut Context::from_waker(Waker::noop());
async_iterator.poll_next(ctx);
}
3 changes: 1 addition & 2 deletions tests/ui/coroutine/async_gen_fn_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ fn main() {
let mut fut = pin!(async_main());

// Poll loop, just to test the future...
let waker = Waker::noop();
let ctx = &mut Context::from_waker(&waker);
let ctx = &mut Context::from_waker(Waker::noop());

loop {
match fut.as_mut().poll(ctx) {
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/dyn-star/dispatch-on-pin-mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ async fn async_main() {
// ------------------------------------------------------------------------- //
// Implementation Details Below...

use std::task::*;
use std::pin::pin;
use std::task::*;

fn main() {
let mut fut = pin!(async_main());

// Poll loop, just to test the future...
let waker = Waker::noop();
let ctx = &mut Context::from_waker(&waker);
let ctx = &mut Context::from_waker(Waker::noop());

loop {
match fut.as_mut().poll(ctx) {
Expand Down