Skip to content
New issue

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

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

Already on GitHub? # to your account

Suggest adding Result return type for associated method in E0277. #128084

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

surechen
Copy link
Contributor

@surechen surechen commented Jul 23, 2024

Recommit #126515 because I messed up during rebase,

Suggest adding Result return type for associated method in E0277.

For following:

struct A;
impl A {
    fn test4(&self) {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method
    }

Suggest:

impl A {
    fn test4(&self) -> Result<(), Box<dyn std::error::Error>> {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method
    
    Ok(())
    }
}

For #125997

r? @cjgillot

For following:

```rust
struct A;
impl A {
    fn test4(&self) {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method
    }
```
Suggest:

```rust
impl A {
    fn test4(&self) -> Result<(), Box<dyn std::error::Error>> {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method

    Ok(())
    }
}
```

For rust-lang#125997
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 23, 2024
@surechen
Copy link
Contributor Author

Hello, I resubmitted this PR. You agreed to merge it before.
Please check again for me. Thank you.
Sorry. When I changed my computer and submitted #126515, I messed up the submission record, so I resubmitted it.

@cjgillot

@cjgillot
Copy link
Contributor

As a follow-up, do you mind fixing span manipulation and indentation of the suggestion?

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 18, 2024

📌 Commit b4b991e has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 18, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Aug 18, 2024
Suggest adding Result return type for associated method in E0277.

Recommit rust-lang#126515 because I messed up during rebase,

Suggest adding Result return type for associated method in E0277.

For following:

```rust
struct A;
impl A {
    fn test4(&self) {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method
    }
```

Suggest:

```rust
impl A {
    fn test4(&self) -> Result<(), Box<dyn std::error::Error>> {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method

    Ok(())
    }
}
```

For rust-lang#125997

r? `@cjgillot`
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 18, 2024
Rollup of 3 pull requests

Successful merges:

 - rust-lang#127679 (Stabilize `raw_ref_op` (RFC 2582))
 - rust-lang#128084 (Suggest adding Result return type for associated method in E0277.)
 - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation)

r? `@ghost`
`@rustbot` modify labels: rollup
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Aug 18, 2024
Suggest adding Result return type for associated method in E0277.

Recommit rust-lang#126515 because I messed up during rebase,

Suggest adding Result return type for associated method in E0277.

For following:

```rust
struct A;
impl A {
    fn test4(&self) {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method
    }
```

Suggest:

```rust
impl A {
    fn test4(&self) -> Result<(), Box<dyn std::error::Error>> {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method

    Ok(())
    }
}
```

For rust-lang#125997

r? ``@cjgillot``
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 18, 2024
Rollup of 4 pull requests

Successful merges:

 - rust-lang#128084 (Suggest adding Result return type for associated method in E0277.)
 - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation)
 - rust-lang#129208 (Fix order of normalization and recursion in const folding.)
 - rust-lang#129228 (crashes: more tests)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 18, 2024
Suggest adding Result return type for associated method in E0277.

Recommit rust-lang#126515 because I messed up during rebase,

Suggest adding Result return type for associated method in E0277.

For following:

```rust
struct A;
impl A {
    fn test4(&self) {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method
    }
```

Suggest:

```rust
impl A {
    fn test4(&self) -> Result<(), Box<dyn std::error::Error>> {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method

    Ok(())
    }
}
```

For rust-lang#125997

r? ```@cjgillot```
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 18, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#125854 (Move ZST ABI handling to `rustc_target`)
 - rust-lang#127623 (fix: fs::remove_dir_all: treat internal ENOENT as success)
 - rust-lang#128084 (Suggest adding Result return type for associated method in E0277.)
 - rust-lang#128902 (doc: std::env::var: Returns None for names with '=' or NUL byte)
 - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation)
 - rust-lang#129235 (Check that `#[may_dangle]` is properly applied)
 - rust-lang#129245 (Typo)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 18, 2024
Suggest adding Result return type for associated method in E0277.

Recommit rust-lang#126515 because I messed up during rebase,

Suggest adding Result return type for associated method in E0277.

For following:

```rust
struct A;
impl A {
    fn test4(&self) {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method
    }
```

Suggest:

```rust
impl A {
    fn test4(&self) -> Result<(), Box<dyn std::error::Error>> {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method

    Ok(())
    }
}
```

For rust-lang#125997

r? ````@cjgillot````
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 19, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#128084 (Suggest adding Result return type for associated method in E0277.)
 - rust-lang#128902 (doc: std::env::var: Returns None for names with '=' or NUL byte)
 - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation)
 - rust-lang#129194 (Fix bootstrap test `detect_src_and_out` on Windows)
 - rust-lang#129231 (improve submodule updates)
 - rust-lang#129235 (Check that `#[may_dangle]` is properly applied)
 - rust-lang#129245 (Typo)

r? `@ghost`
`@rustbot` modify labels: rollup
@surechen
Copy link
Contributor Author

As a follow-up, do you mind fixing span manipulation and indentation of the suggestion?

@bors r+ rollup

OK, thank you!

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 19, 2024
Rollup of 7 pull requests

Successful merges:

 - rust-lang#127679 (Stabilize `raw_ref_op` (RFC 2582))
 - rust-lang#128084 (Suggest adding Result return type for associated method in E0277.)
 - rust-lang#128628 (When deduplicating unreachable blocks, erase the source information.)
 - rust-lang#128902 (doc: std::env::var: Returns None for names with '=' or NUL byte)
 - rust-lang#129048 (Update `crosstool-ng` for loongarch64)
 - rust-lang#129116 (Include a copy of `compiler-rt` source in the `download-ci-llvm` tarball)
 - rust-lang#129208 (Fix order of normalization and recursion in const folding.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d21b6f2 into rust-lang:master Aug 19, 2024
6 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 19, 2024
Rollup merge of rust-lang#128084 - surechen:fix_125997_v1, r=cjgillot

Suggest adding Result return type for associated method in E0277.

Recommit rust-lang#126515 because I messed up during rebase,

Suggest adding Result return type for associated method in E0277.

For following:

```rust
struct A;
impl A {
    fn test4(&self) {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method
    }
```

Suggest:

```rust
impl A {
    fn test4(&self) -> Result<(), Box<dyn std::error::Error>> {
        let mut _file = File::create("foo.txt")?;
        //~^ ERROR the `?` operator can only be used in a method

    Ok(())
    }
}
```

For rust-lang#125997

r? `@cjgillot`
surechen added a commit to surechen/rust that referenced this pull request Aug 22, 2024
… by rust-lang#126187

According to:
rust-lang#128084 (comment)
https://github.com/rust-lang/rust/pull/126187/files#r1634897691

I try to add a span field to `Block` which doesn't include brace '{' and '}', because I need to add a suggestion at the end of function's body, and this can help me find the right place. But this will make `Block` larger.

I don't want to break the original span field in `Block`, I'm worried that it will cause a lot of code failures and I think it may be more intuitive for span to include braces.
surechen added a commit to surechen/rust that referenced this pull request Aug 22, 2024
… by rust-lang#126187

According to:
rust-lang#128084 (comment)
https://github.com/rust-lang/rust/pull/126187/files#r1634897691

I try to add a span field to `Block` which doesn't include brace '{' and '}', because I need to add a suggestion at the end of function's body, and this can help me find the right place. But this will make `Block` larger.

I don't want to break the original span field in `Block`, I'm worried that it will cause a lot of code failures and I think it may be more intuitive for span to include braces.
surechen added a commit to surechen/rust that referenced this pull request Aug 23, 2024
… by rust-lang#126187

According to:
rust-lang#128084 (comment)
https://github.com/rust-lang/rust/pull/126187/files#r1634897691

I try to add a span field to `Block` which doesn't include brace '{' and '}', because I need to add a suggestion at the end of function's body, and this can help me find the right place. But this will make `Block` larger.

I don't want to break the original span field in `Block`, I'm worried that it will cause a lot of code failures and I think it may be more intuitive for span to include braces.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 25, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 25, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 26, 2024
Rollup merge of rust-lang#129405 - surechen:fix_span_x, r=cjgillot

Fixing span manipulation and indentation of the suggestion introduced by rust-lang#126187

According to comments:
rust-lang#128084 (comment)
https://github.com/rust-lang/rust/pull/126187/files#r1634897691
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants