Skip to content

Commit

Permalink
Auto merge of rust-lang#135396 - matthiaskrgr:rollup-zublg1c, r=matth…
Browse files Browse the repository at this point in the history
…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
bors committed Jan 12, 2025
2 parents 13f3924 + 1380549 commit 1b41e84
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 24 deletions.
3 changes: 1 addition & 2 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ Compatibility Notes
- 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.
- [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)
- [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)
- 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.
- [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)
- [The next-generation trait solver is now enabled for coherence, fixing multiple soundness issues](https://github.com/rust-lang/rust/pull/130654)

Expand Down Expand Up @@ -2184,7 +2183,7 @@ Language
--------

- [Stabilize default_alloc_error_handler](https://github.com/rust-lang/rust/pull/102318/)
This allows usage of `alloc` on stable without requiring the
This allows usage of `alloc` on stable without requiring the
definition of a handler for allocation failure. Defining custom handlers is still unstable.
- [Stabilize `efiapi` calling convention.](https://github.com/rust-lang/rust/pull/105795/)
- [Remove implicit promotion for types with drop glue](https://github.com/rust-lang/rust/pull/105085/)
Expand Down
23 changes: 10 additions & 13 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2680,22 +2680,19 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
return;
}

let mut sugg = vec![];
let sm = self.infcx.tcx.sess.source_map();

if let Some(span) = finder.closure_arg_span {
sugg.push((sm.next_point(span.shrink_to_lo()).shrink_to_hi(), finder.suggest_arg));
}
for span in finder.closure_change_spans {
sugg.push((span, "this".to_string()));
}

for (span, suggest) in finder.closure_call_changes {
sugg.push((span, suggest));
}
let sugg = finder
.closure_arg_span
.map(|span| (sm.next_point(span.shrink_to_lo()).shrink_to_hi(), finder.suggest_arg))
.into_iter()
.chain(
finder.closure_change_spans.into_iter().map(|span| (span, "this".to_string())),
)
.chain(finder.closure_call_changes)
.collect();

err.multipart_suggestion_verbose(
"try explicitly pass `&Self` into the Closure as an argument",
"try explicitly passing `&Self` into the closure as an argument",
sugg,
Applicability::MachineApplicable,
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
)
} }

/// Show a suggestion that has multiple parts to it, always as it's own subdiagnostic.
/// Show a suggestion that has multiple parts to it, always as its own subdiagnostic.
/// In other words, multiple changes need to be applied as part of this suggestion.
#[rustc_lint_diagnostics]
pub fn multipart_suggestion_verbose(
Expand Down
8 changes: 6 additions & 2 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3708,7 +3708,11 @@ pub struct UniqueRc<
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
> {
ptr: NonNull<RcInner<T>>,
phantom: PhantomData<RcInner<T>>,
// Define the ownership of `RcInner<T>` for drop-check
_marker: PhantomData<RcInner<T>>,
// Invariance is necessary for soundness: once other `Weak`
// references exist, we already have a form of shared mutability!
_marker2: PhantomData<*mut T>,
alloc: A,
}

Expand Down Expand Up @@ -3994,7 +3998,7 @@ impl<T, A: Allocator> UniqueRc<T, A> {
},
alloc,
));
Self { ptr: ptr.into(), phantom: PhantomData, alloc }
Self { ptr: ptr.into(), _marker: PhantomData, _marker2: PhantomData, alloc }
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,10 @@ impl Step for Compiletest {
return;
}

if builder.top_stage == 0 && env::var("COMPILETEST_FORCE_STAGE0").is_err() {
if builder.top_stage == 0
&& env::var("COMPILETEST_FORCE_STAGE0").is_err()
&& self.mode != "js-doc-test"
{
eprintln!("\
ERROR: `--stage 0` runs compiletest on the beta compiler, not your local changes, and will almost always cause tests to fail
HELP: to test the compiler, use `--stage 1` instead
Expand Down
11 changes: 10 additions & 1 deletion src/tools/compiletest/src/runtest/run_make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ impl TestCx<'_> {
// to work correctly.
//
// See <https://github.com/rust-lang/rust/pull/122248> for more background.
let stage0_sysroot = build_root.join("stage0-sysroot");
if std::env::var_os("COMPILETEST_FORCE_STAGE0").is_some() {
let stage0_sysroot = build_root.join("stage0-sysroot");
rustc.arg("--sysroot").arg(&stage0_sysroot);
}

Expand All @@ -373,6 +373,15 @@ impl TestCx<'_> {
// Compute dynamic library search paths for recipes.
let recipe_dylib_search_paths = {
let mut paths = base_dylib_search_paths.clone();

// For stage 0, we need to explicitly include the stage0-sysroot libstd dylib.
// See <https://github.com/rust-lang/rust/issues/135373>.
if std::env::var_os("COMPILETEST_FORCE_STAGE0").is_some() {
paths.push(
stage0_sysroot.join("lib").join("rustlib").join(&self.config.host).join("lib"),
);
}

paths.push(support_lib_path.parent().unwrap().to_path_buf());
paths.push(stage_std_path.join("rustlib").join(&self.config.host).join("lib"));
paths
Expand Down
3 changes: 1 addition & 2 deletions src/tools/run-make-support/src/external_deps/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ impl Rustdoc {
#[track_caller]
pub fn new() -> Self {
let mut cmd = setup_common();
let target_rpath_dir = env_var_os("TARGET_RPATH_DIR");
cmd.arg(format!("-L{}", target_rpath_dir.to_string_lossy()));
cmd.arg("-L").arg(env_var_os("TARGET_RPATH_DIR"));
Self { cmd }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | self.qux();
LL | x(1);
| - immutable borrow later used here
|
help: try explicitly pass `&Self` into the Closure as an argument
help: try explicitly passing `&Self` into the closure as an argument
|
LL ~ let x = |this: &Self, v: i32| {
LL ~ this.bar();
Expand All @@ -35,7 +35,7 @@ LL | self.qux();
LL | y();
| - immutable borrow later used here
|
help: try explicitly pass `&Self` into the Closure as an argument
help: try explicitly passing `&Self` into the closure as an argument
|
LL ~ let y = |this: &Self| {
LL ~ this.bar();
Expand Down
27 changes: 27 additions & 0 deletions tests/ui/variance/variance-uniquerc.rs
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}");
}
15 changes: 15 additions & 0 deletions tests/ui/variance/variance-uniquerc.stderr
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

0 comments on commit 1b41e84

Please sign in to comment.