Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #135388

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ COPY scripts/cmake.sh /scripts/
RUN /scripts/cmake.sh

ENV \
AR_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-ar \
CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-clang \
CXX_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-clang++
AR_x86_64_unknown_freebsd=x86_64-unknown-freebsd13-ar \
CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd13-clang \
CXX_x86_64_unknown_freebsd=x86_64-unknown-freebsd13-clang++

ENV HOSTS=x86_64-unknown-freebsd

Expand Down
6 changes: 3 additions & 3 deletions src/ci/docker/scripts/freebsd-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -eux

arch=$1
binutils_version=2.40
freebsd_version=12.3
triple=$arch-unknown-freebsd12
freebsd_version=13.4
triple=$arch-unknown-freebsd13
sysroot=/usr/local/$triple

hide_output() {
Expand Down Expand Up @@ -59,7 +59,7 @@ done

# Originally downloaded from:
# URL=https://download.freebsd.org/ftp/releases/${freebsd_arch}/${freebsd_version}-RELEASE/base.txz
URL=https://ci-mirrors.rust-lang.org/rustc/2022-05-06-freebsd-${freebsd_version}-${freebsd_arch}-base.txz
URL=https://ci-mirrors.rust-lang.org/rustc/2024-09-13-freebsd-${freebsd_version}-${freebsd_arch}-base.txz
curl "$URL" | tar xJf - -C "$sysroot" --wildcards "${files_to_extract[@]}"

# Clang can do cross-builds out of the box, if we give it the right
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

Loading