forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#131814 - Borgerr:misapplied-optimize-attrib…
…ute, r=jieyouxu `optimize` attribute applied to things other than methods/functions/c… …losures gives an error (rust-lang#128488) Duplicate of rust-lang#128943, which I had accidentally closed when rebasing. cc. `@jieyouxu` `@compiler-errors` `@nikomatsakis` `@traviscross` `@pnkfelix.`
- Loading branch information
Showing
8 changed files
with
115 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,36 @@ | ||
error: attribute should be applied to function or closure | ||
--> $DIR/optimize.rs:6:1 | ||
error: attribute applied to an invalid target | ||
--> $DIR/optimize.rs:8:1 | ||
| | ||
LL | #[optimize(speed)] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
LL | struct F; | ||
| --------- invalid target | ||
|
||
error: attribute applied to an invalid target | ||
--> $DIR/optimize.rs:12:5 | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/optimize.rs:3:9 | ||
LL | #[optimize(speed)] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
LL | / { | ||
LL | | 1 | ||
LL | | }; | ||
| |_____- invalid target | ||
|
||
error: attribute applied to an invalid target | ||
--> $DIR/optimize.rs:21:1 | ||
| | ||
LL | #![deny(unused_attributes)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
LL | #[optimize(speed)] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
LL | mod valid_module {} | ||
| ------------------- invalid target | ||
|
||
error: attribute should be applied to function or closure | ||
--> $DIR/optimize.rs:10:5 | ||
error: attribute applied to an invalid target | ||
--> $DIR/optimize.rs:24:1 | ||
| | ||
LL | #[optimize(speed)] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
LL | #[optimize(speed)] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
LL | impl F {} | ||
| --------- invalid target | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 4 previous errors | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//@ edition: 2024 | ||
//@ compile-flags: -Zunstable-options | ||
//@ run-pass | ||
#![feature(gen_blocks)] | ||
#![feature(optimize_attribute)] | ||
#![feature(stmt_expr_attributes)] | ||
#![feature(async_iterator)] | ||
#![allow(dead_code)] | ||
|
||
// make sure that other attributes e.g. `optimize` can be applied to gen blocks and functions | ||
|
||
fn main() { } | ||
|
||
fn optimize_gen_block() -> impl Iterator<Item = ()> { | ||
#[optimize(speed)] | ||
gen { yield (); } | ||
} | ||
|
||
#[optimize(speed)] | ||
gen fn optimize_gen_fn() -> i32 { | ||
yield 1; | ||
yield 2; | ||
yield 3; | ||
} | ||
|
||
#[optimize(speed)] | ||
async gen fn optimize_async_gen_fn() -> i32 { | ||
yield 1; | ||
yield 2; | ||
yield 3; | ||
} | ||
|
||
use std::async_iter::AsyncIterator; | ||
|
||
pub fn deduce() -> impl AsyncIterator<Item = ()> { | ||
#[optimize(size)] | ||
async gen { | ||
yield (); | ||
} | ||
} |
This file contains 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
This file contains 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