forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#137248 - matthiaskrgr:rollup-s18zjau, r=matth…
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#136936 (Use 'yes' instead of 'while-echo' in tests/ui/process/process-sigpipe.rs except 'nto') - rust-lang#137026 (Stabilize (and const-stabilize) `integer_sign_cast`) - rust-lang#137059 (fix: Alloc new errorcode E0803 for E0495) - rust-lang#137177 (Update `minifier-rs` version to `0.3.5`) - rust-lang#137210 (compiler: Stop reexporting stuff in cg_llvm::abi) - rust-lang#137213 (Remove `rustc_middle::mir::tcx` module.) - rust-lang#137216 (eval_outlives: bail out early if both regions are in the same SCC) - rust-lang#137228 (Fix typo in hidden internal docs of `TrustedRandomAccess`) - rust-lang#137242 (Add reference annotations for the `do_not_recommend` attribute) r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
64 changed files
with
585 additions
and
546 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
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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
A trait implementation returns a reference without an | ||
explicit lifetime linking it to `self`. | ||
It commonly arises in generic trait implementations | ||
requiring explicit lifetime bounds. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0803 | ||
trait DataAccess<T> { | ||
fn get_ref(&self) -> T; | ||
} | ||
struct Container<'a> { | ||
value: &'a f64, | ||
} | ||
// Attempting to implement reference return | ||
impl<'a> DataAccess<&f64> for Container<'a> { | ||
fn get_ref(&self) -> &f64 { // Error: Lifetime mismatch | ||
self.value | ||
} | ||
} | ||
``` | ||
|
||
The trait method returns &f64 requiring an independent lifetime | ||
The struct Container<'a> carries lifetime parameter 'a | ||
The compiler cannot verify if the returned reference satisfies 'a constraints | ||
Solution | ||
Explicitly bind lifetimes to clarify constraints: | ||
``` | ||
// Modified trait with explicit lifetime binding | ||
trait DataAccess<'a, T> { | ||
fn get_ref(&'a self) -> T; | ||
} | ||
struct Container<'a> { | ||
value: &'a f64, | ||
} | ||
// Correct implementation (bound lifetimes) | ||
impl<'a> DataAccess<'a, &'a f64> for Container<'a> { | ||
fn get_ref(&'a self) -> &'a f64 { | ||
self.value | ||
} | ||
} | ||
``` |
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 |
---|---|---|
|
@@ -546,6 +546,7 @@ E0799: 0799, | |
E0800: 0800, | ||
E0801: 0801, | ||
E0802: 0802, | ||
E0803: 0803, | ||
); | ||
) | ||
} | ||
|
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
Oops, something went wrong.