forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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#135396 - matthiaskrgr:rollup-zublg1c, r=matth…
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#135266 (Remove emsdk version update from 1.84.0 relnotes) - rust-lang#135364 (Cleanup `suggest_binding_for_closure_capture_self` diag in borrowck) - rust-lang#135375 (allow rustdoc-js tests to be run at stage0) - rust-lang#135379 (Make (unstable API) `UniqueRc` invariant for soundness) - rust-lang#135389 (compiletest: include stage0-sysroot libstd dylib in recipe dylib search path) r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
10 changed files
with
77 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// regression test of https://github.com/rust-lang/rust/pull/133572#issuecomment-2543007164 | ||
// we should also test UniqueArc once implemented | ||
// | ||
// inline comments explain how this code *would* compile if UniqueRc was still covariant | ||
|
||
#![feature(unique_rc_arc)] | ||
|
||
use std::rc::UniqueRc; | ||
|
||
fn extend_lifetime<'a, 'b>(x: &'a str) -> &'b str { | ||
let r = UniqueRc::new(""); // UniqueRc<&'static str> | ||
let w = UniqueRc::downgrade(&r); // Weak<&'static str> | ||
let mut r = r; // [IF COVARIANT]: ==>> UniqueRc<&'a str> | ||
*r = x; // assign the &'a str | ||
let _r = UniqueRc::into_rc(r); // Rc<&'a str>, but we only care to activate the weak | ||
let r = w.upgrade().unwrap(); // Rc<&'static str> | ||
*r // &'static str, coerces to &'b str | ||
//~^ ERROR lifetime may not live long enough | ||
} | ||
|
||
fn main() { | ||
let s = String::from("Hello World!"); | ||
let r = extend_lifetime(&s); | ||
println!("{r}"); | ||
drop(s); | ||
println!("{r}"); | ||
} |
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,15 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/variance-uniquerc.rs:17:5 | ||
| | ||
LL | fn extend_lifetime<'a, 'b>(x: &'a str) -> &'b str { | ||
| -- -- lifetime `'b` defined here | ||
| | | ||
| lifetime `'a` defined here | ||
... | ||
LL | *r // &'static str, coerces to &'b str | ||
| ^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` | ||
| | ||
= help: consider adding the following bound: `'a: 'b` | ||
|
||
error: aborting due to 1 previous error | ||
|