Skip to content

Commit 1b41e84

Browse files
committed
Auto merge of #135396 - matthiaskrgr:rollup-zublg1c, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #135266 (Remove emsdk version update from 1.84.0 relnotes) - #135364 (Cleanup `suggest_binding_for_closure_capture_self` diag in borrowck) - #135375 (allow rustdoc-js tests to be run at stage0) - #135379 (Make (unstable API) `UniqueRc` invariant for soundness) - #135389 (compiletest: include stage0-sysroot libstd dylib in recipe dylib search path) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 13f3924 + 1380549 commit 1b41e84

File tree

10 files changed

+77
-24
lines changed

10 files changed

+77
-24
lines changed

RELEASES.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ Compatibility Notes
111111
- Support for the target named `wasm32-wasi` has been removed as the target is now named `wasm32-wasip1`. This completes the [transition](https://github.com/rust-lang/compiler-team/issues/607) [plan](https://github.com/rust-lang/compiler-team/issues/695) for this target following [the introduction of `wasm32-wasip1`](https://github.com/rust-lang/rust/pull/120468) in Rust 1.78. Compiler warnings on [use of `wasm32-wasi`](https://github.com/rust-lang/rust/pull/126662) introduced in Rust 1.81 are now gone as well as the target is removed.
112112
- [The syntax `&pin (mut|const) T` is now parsed as a type which in theory could affect macro expansion results in some edge cases](https://github.com/rust-lang/rust/pull/130635#issuecomment-2375462821)
113113
- [Legacy syntax for calling `std::arch` functions is no longer permitted to declare items or bodies (such as closures, inline consts, or async blocks).](https://github.com/rust-lang/rust/pull/130443#issuecomment-2445678945)
114-
- The `wasm32-unknown-emscripten` target's binary release of the standard library is now [built with the latest emsdk 3.1.68](https://github.com/rust-lang/rust/pull/131533), which fixes an ABI-incompatibility with Emscripten >= 3.1.42. If you are locally using a version of emsdk with an incompatible ABI (e.g. before 3.1.42 or a future one), you should build your code with `-Zbuild-std` to ensure that `std` uses the correct ABI.
115114
- [Declaring functions with a calling convention not supported on the current target now triggers a hard error](https://github.com/rust-lang/rust/pull/129935)
116115
- [The next-generation trait solver is now enabled for coherence, fixing multiple soundness issues](https://github.com/rust-lang/rust/pull/130654)
117116

@@ -2184,7 +2183,7 @@ Language
21842183
--------
21852184

21862185
- [Stabilize default_alloc_error_handler](https://github.com/rust-lang/rust/pull/102318/)
2187-
This allows usage of `alloc` on stable without requiring the
2186+
This allows usage of `alloc` on stable without requiring the
21882187
definition of a handler for allocation failure. Defining custom handlers is still unstable.
21892188
- [Stabilize `efiapi` calling convention.](https://github.com/rust-lang/rust/pull/105795/)
21902189
- [Remove implicit promotion for types with drop glue](https://github.com/rust-lang/rust/pull/105085/)

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -2680,22 +2680,19 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
26802680
return;
26812681
}
26822682

2683-
let mut sugg = vec![];
26842683
let sm = self.infcx.tcx.sess.source_map();
2685-
2686-
if let Some(span) = finder.closure_arg_span {
2687-
sugg.push((sm.next_point(span.shrink_to_lo()).shrink_to_hi(), finder.suggest_arg));
2688-
}
2689-
for span in finder.closure_change_spans {
2690-
sugg.push((span, "this".to_string()));
2691-
}
2692-
2693-
for (span, suggest) in finder.closure_call_changes {
2694-
sugg.push((span, suggest));
2695-
}
2684+
let sugg = finder
2685+
.closure_arg_span
2686+
.map(|span| (sm.next_point(span.shrink_to_lo()).shrink_to_hi(), finder.suggest_arg))
2687+
.into_iter()
2688+
.chain(
2689+
finder.closure_change_spans.into_iter().map(|span| (span, "this".to_string())),
2690+
)
2691+
.chain(finder.closure_call_changes)
2692+
.collect();
26962693

26972694
err.multipart_suggestion_verbose(
2698-
"try explicitly pass `&Self` into the Closure as an argument",
2695+
"try explicitly passing `&Self` into the closure as an argument",
26992696
sugg,
27002697
Applicability::MachineApplicable,
27012698
);

compiler/rustc_errors/src/diagnostic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
880880
)
881881
} }
882882

883-
/// Show a suggestion that has multiple parts to it, always as it's own subdiagnostic.
883+
/// Show a suggestion that has multiple parts to it, always as its own subdiagnostic.
884884
/// In other words, multiple changes need to be applied as part of this suggestion.
885885
#[rustc_lint_diagnostics]
886886
pub fn multipart_suggestion_verbose(

library/alloc/src/rc.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -3708,7 +3708,11 @@ pub struct UniqueRc<
37083708
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
37093709
> {
37103710
ptr: NonNull<RcInner<T>>,
3711-
phantom: PhantomData<RcInner<T>>,
3711+
// Define the ownership of `RcInner<T>` for drop-check
3712+
_marker: PhantomData<RcInner<T>>,
3713+
// Invariance is necessary for soundness: once other `Weak`
3714+
// references exist, we already have a form of shared mutability!
3715+
_marker2: PhantomData<*mut T>,
37123716
alloc: A,
37133717
}
37143718

@@ -3994,7 +3998,7 @@ impl<T, A: Allocator> UniqueRc<T, A> {
39943998
},
39953999
alloc,
39964000
));
3997-
Self { ptr: ptr.into(), phantom: PhantomData, alloc }
4001+
Self { ptr: ptr.into(), _marker: PhantomData, _marker2: PhantomData, alloc }
39984002
}
39994003
}
40004004

src/bootstrap/src/core/build_steps/test.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,10 @@ impl Step for Compiletest {
16371637
return;
16381638
}
16391639

1640-
if builder.top_stage == 0 && env::var("COMPILETEST_FORCE_STAGE0").is_err() {
1640+
if builder.top_stage == 0
1641+
&& env::var("COMPILETEST_FORCE_STAGE0").is_err()
1642+
&& self.mode != "js-doc-test"
1643+
{
16411644
eprintln!("\
16421645
ERROR: `--stage 0` runs compiletest on the beta compiler, not your local changes, and will almost always cause tests to fail
16431646
HELP: to test the compiler, use `--stage 1` instead

src/tools/compiletest/src/runtest/run_make.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ impl TestCx<'_> {
353353
// to work correctly.
354354
//
355355
// See <https://github.com/rust-lang/rust/pull/122248> for more background.
356+
let stage0_sysroot = build_root.join("stage0-sysroot");
356357
if std::env::var_os("COMPILETEST_FORCE_STAGE0").is_some() {
357-
let stage0_sysroot = build_root.join("stage0-sysroot");
358358
rustc.arg("--sysroot").arg(&stage0_sysroot);
359359
}
360360

@@ -373,6 +373,15 @@ impl TestCx<'_> {
373373
// Compute dynamic library search paths for recipes.
374374
let recipe_dylib_search_paths = {
375375
let mut paths = base_dylib_search_paths.clone();
376+
377+
// For stage 0, we need to explicitly include the stage0-sysroot libstd dylib.
378+
// See <https://github.com/rust-lang/rust/issues/135373>.
379+
if std::env::var_os("COMPILETEST_FORCE_STAGE0").is_some() {
380+
paths.push(
381+
stage0_sysroot.join("lib").join("rustlib").join(&self.config.host).join("lib"),
382+
);
383+
}
384+
376385
paths.push(support_lib_path.parent().unwrap().to_path_buf());
377386
paths.push(stage_std_path.join("rustlib").join(&self.config.host).join("lib"));
378387
paths

src/tools/run-make-support/src/external_deps/rustdoc.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ impl Rustdoc {
4545
#[track_caller]
4646
pub fn new() -> Self {
4747
let mut cmd = setup_common();
48-
let target_rpath_dir = env_var_os("TARGET_RPATH_DIR");
49-
cmd.arg(format!("-L{}", target_rpath_dir.to_string_lossy()));
48+
cmd.arg("-L").arg(env_var_os("TARGET_RPATH_DIR"));
5049
Self { cmd }
5150
}
5251

tests/ui/suggestions/issue-105761-suggest-self-for-closure.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | self.qux();
1111
LL | x(1);
1212
| - immutable borrow later used here
1313
|
14-
help: try explicitly pass `&Self` into the Closure as an argument
14+
help: try explicitly passing `&Self` into the closure as an argument
1515
|
1616
LL ~ let x = |this: &Self, v: i32| {
1717
LL ~ this.bar();
@@ -35,7 +35,7 @@ LL | self.qux();
3535
LL | y();
3636
| - immutable borrow later used here
3737
|
38-
help: try explicitly pass `&Self` into the Closure as an argument
38+
help: try explicitly passing `&Self` into the closure as an argument
3939
|
4040
LL ~ let y = |this: &Self| {
4141
LL ~ this.bar();
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// regression test of https://github.com/rust-lang/rust/pull/133572#issuecomment-2543007164
2+
// we should also test UniqueArc once implemented
3+
//
4+
// inline comments explain how this code *would* compile if UniqueRc was still covariant
5+
6+
#![feature(unique_rc_arc)]
7+
8+
use std::rc::UniqueRc;
9+
10+
fn extend_lifetime<'a, 'b>(x: &'a str) -> &'b str {
11+
let r = UniqueRc::new(""); // UniqueRc<&'static str>
12+
let w = UniqueRc::downgrade(&r); // Weak<&'static str>
13+
let mut r = r; // [IF COVARIANT]: ==>> UniqueRc<&'a str>
14+
*r = x; // assign the &'a str
15+
let _r = UniqueRc::into_rc(r); // Rc<&'a str>, but we only care to activate the weak
16+
let r = w.upgrade().unwrap(); // Rc<&'static str>
17+
*r // &'static str, coerces to &'b str
18+
//~^ ERROR lifetime may not live long enough
19+
}
20+
21+
fn main() {
22+
let s = String::from("Hello World!");
23+
let r = extend_lifetime(&s);
24+
println!("{r}");
25+
drop(s);
26+
println!("{r}");
27+
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/variance-uniquerc.rs:17:5
3+
|
4+
LL | fn extend_lifetime<'a, 'b>(x: &'a str) -> &'b str {
5+
| -- -- lifetime `'b` defined here
6+
| |
7+
| lifetime `'a` defined here
8+
...
9+
LL | *r // &'static str, coerces to &'b str
10+
| ^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
11+
|
12+
= help: consider adding the following bound: `'a: 'b`
13+
14+
error: aborting due to 1 previous error
15+

0 commit comments

Comments
 (0)