Skip to content

Rollup of 8 pull requests #135978

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

Merged
merged 21 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5c2006b
remove pointless allowed_through_unstable_modules on TryFromSliceError
RalfJung Jan 14, 2025
6103896
rustc-dev-guide: add note about not adding rustc_allowed_through_unst…
RalfJung Jan 14, 2025
0fe555a
Add NuttX support for AArch64 and ARMv7-A targets
no1wudi Jan 7, 2025
6702df1
For E0223, suggest associated functions that are similar to the path,…
zachs18 Jan 22, 2025
221b621
Add test that multiple impls works with E0223 similar-name suggestion.
zachs18 Jan 22, 2025
7e1a8bd
Also check for associated fns on primitives in E0223 similar-path check.
zachs18 Jan 22, 2025
ed7cc34
Implement `VecDeque::pop_front_if` & `VecDeque::pop_back_if`
GrigorenkoPV Jan 22, 2025
9c0e32b
rustdoc-json: Rename `Path::name` to `path`, and give it path (again).
aDotInTheVoid Jan 20, 2025
11067c4
Remove query normalize from normalize type op
compiler-errors Jan 23, 2025
00a0ef4
Remove query normalize from dropck outlives type op
compiler-errors Jan 23, 2025
b88dea2
fix reify-intrinsic test
RalfJung Jan 23, 2025
2c58212
Give E0223 similar-item suggestion test more descriptive name.
zachs18 Jan 23, 2025
c27a6bf
Add extensive set of drop order tests
traviscross Nov 29, 2024
a7922db
Rollup merge of #133605 - traviscross:TC/add-2024-drop-order-tests, r…
matthiaskrgr Jan 24, 2025
a3fb2a0
Rollup merge of #135489 - RalfJung:TryFromSliceError, r=tgross35
matthiaskrgr Jan 24, 2025
042da35
Rollup merge of #135757 - no1wudi:master, r=compiler-errors
matthiaskrgr Jan 24, 2025
40e2858
Rollup merge of #135799 - aDotInTheVoid:skrrt-skrrt-revrrt, r=Guillau…
matthiaskrgr Jan 24, 2025
efb8084
Rollup merge of #135865 - zachs18:maybe_report_similar_assoc_fn_more,…
matthiaskrgr Jan 24, 2025
be15391
Rollup merge of #135890 - GrigorenkoPV:deque-pop-if, r=thomcc
matthiaskrgr Jan 24, 2025
556d901
Rollup merge of #135914 - compiler-errors:vanquish-query-norm, r=jack…
matthiaskrgr Jan 24, 2025
109def5
Rollup merge of #135936 - RalfJung:reify-intrinsic, r=oli-obk
matthiaskrgr Jan 24, 2025
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
20 changes: 14 additions & 6 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_middle::bug;
use rustc_middle::ty::fast_reject::{TreatParams, simplify_type};
use rustc_middle::ty::print::{PrintPolyTraitRefExt as _, PrintTraitRefExt as _};
use rustc_middle::ty::{
self, AdtDef, GenericParamDefKind, Ty, TyCtxt, TypeVisitableExt,
Expand Down Expand Up @@ -998,12 +999,19 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
)),
..
}) = node
&& let Some(adt_def) = qself_ty.ty_adt_def()
&& let [inherent_impl] = tcx.inherent_impls(adt_def.did())
&& let name = format!("{ident2}_{ident3}")
&& let Some(ty::AssocItem { kind: ty::AssocKind::Fn, .. }) = tcx
.associated_items(inherent_impl)
.filter_by_name_unhygienic(Symbol::intern(&name))
&& let Some(inherent_impls) = qself_ty
.ty_adt_def()
.map(|adt_def| tcx.inherent_impls(adt_def.did()))
.or_else(|| {
simplify_type(tcx, qself_ty, TreatParams::InstantiateWithInfer)
.map(|simple_ty| tcx.incoherent_impls(simple_ty))
})
&& let name = Symbol::intern(&format!("{ident2}_{ident3}"))
&& let Some(ty::AssocItem { kind: ty::AssocKind::Fn, .. }) = inherent_impls
.iter()
.flat_map(|inherent_impl| {
tcx.associated_items(inherent_impl).filter_by_name_unhygienic(name)
})
.next()
{
Err(struct_span_code_err!(self.dcx(), span, E0223, "ambiguous associated type")
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,8 @@ supported_targets! {

("armv7a-none-eabi", armv7a_none_eabi),
("armv7a-none-eabihf", armv7a_none_eabihf),
("armv7a-nuttx-eabi", armv7a_nuttx_eabi),
("armv7a-nuttx-eabihf", armv7a_nuttx_eabihf),

("msp430-none-elf", msp430_none_elf),

Expand Down Expand Up @@ -1896,6 +1898,7 @@ supported_targets! {

("aarch64-unknown-none", aarch64_unknown_none),
("aarch64-unknown-none-softfloat", aarch64_unknown_none_softfloat),
("aarch64-unknown-nuttx", aarch64_unknown_nuttx),

("x86_64-fortanix-unknown-sgx", x86_64_fortanix_unknown_sgx),

Expand Down Expand Up @@ -1971,6 +1974,8 @@ supported_targets! {
("x86_64-unknown-linux-none", x86_64_unknown_linux_none),

("thumbv6m-nuttx-eabi", thumbv6m_nuttx_eabi),
("thumbv7a-nuttx-eabi", thumbv7a_nuttx_eabi),
("thumbv7a-nuttx-eabihf", thumbv7a_nuttx_eabihf),
("thumbv7m-nuttx-eabi", thumbv7m_nuttx_eabi),
("thumbv7em-nuttx-eabi", thumbv7em_nuttx_eabi),
("thumbv7em-nuttx-eabihf", thumbv7em_nuttx_eabihf),
Expand Down
46 changes: 46 additions & 0 deletions compiler/rustc_target/src/spec/targets/aarch64_unknown_nuttx.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Generic AArch64 target for NuttX OS
//
// Can be used in conjunction with the `target-feature` and
// `target-cpu` compiler flags to opt-in more hardware-specific
// features.
//
// For example, `-C target-cpu=cortex-a53`.

use crate::spec::{
Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target,
TargetOptions, cvs,
};

pub(crate) fn target() -> Target {
let opts = TargetOptions {
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
// Enable the Cortex-A53 errata 843419 mitigation by default
pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[
"--fix-cortex-a53-843419",
]),
features: "+v8a,+strict-align,+neon,+fp-armv8".into(),
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
panic_strategy: PanicStrategy::Abort,
families: cvs!["unix"],
os: "nuttx".into(),
..Default::default()
};
Target {
llvm_target: "aarch64-unknown-none".into(),
metadata: crate::spec::TargetMetadata {
description: Some("AArch64 NuttX".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(false),
},
pointer_width: 64,
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
arch: "aarch64".into(),
options: opts,
}
}
41 changes: 41 additions & 0 deletions compiler/rustc_target/src/spec/targets/armv7a_nuttx_eabi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Targets Cortex-A7/A8/A9 processors (ARMv7-A) running NuttX
//
// This target assumes that the device does NOT have a FPU (Floating Point Unit)
// and will use software floating point operations. This matches the NuttX EABI
// configuration without hardware floating point support.

use crate::spec::{
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs,
};

pub(crate) fn target() -> Target {
let opts = TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".into(),
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(64),
panic_strategy: PanicStrategy::Abort,
emit_debug_gdb_scripts: false,
c_enum_min_bits: Some(8),
families: cvs!["unix"],
os: "nuttx".into(),
..Default::default()
};
Target {
llvm_target: "armv7a-none-eabi".into(),
metadata: crate::spec::TargetMetadata {
description: Some("ARMv7-A Cortex-A with NuttX".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(false),
},
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
options: opts,
}
}
41 changes: 41 additions & 0 deletions compiler/rustc_target/src/spec/targets/armv7a_nuttx_eabihf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Targets Cortex-A7/A8/A9 processors (ARMv7-A) running NuttX with hardware floating point
//
// This target assumes that the device has a FPU (Floating Point Unit)
// and will use hardware floating point operations. This matches the NuttX EABI
// configuration with hardware floating point support.

use crate::spec::{
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs,
};

pub(crate) fn target() -> Target {
let opts = TargetOptions {
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
features: "+v7,+thumb2,+vfp3,+neon,+strict-align".into(),
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(64),
panic_strategy: PanicStrategy::Abort,
emit_debug_gdb_scripts: false,
c_enum_min_bits: Some(8),
families: cvs!["unix"],
os: "nuttx".into(),
..Default::default()
};
Target {
llvm_target: "armv7a-none-eabihf".into(),
metadata: crate::spec::TargetMetadata {
description: Some("ARMv7-A Cortex-A with NuttX (hard float)".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(false),
},
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
options: opts,
}
}
33 changes: 33 additions & 0 deletions compiler/rustc_target/src/spec/targets/thumbv7a_nuttx_eabi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Targets Cortex-A7/A8/A9 processors (ARMv7-A)
//
// This target assumes that the device does NOT have a FPU (Floating Point Unit)
// and will use software floating point operations. This matches the NuttX EABI
// configuration without hardware floating point support.

use crate::spec::{FloatAbi, Target, TargetOptions, base, cvs};

pub(crate) fn target() -> Target {
Target {
llvm_target: "thumbv7a-none-eabi".into(),
metadata: crate::spec::TargetMetadata {
description: None,
tier: None,
host_tools: None,
std: None,
},
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),

options: TargetOptions {
families: cvs!["unix"],
os: "nuttx".into(),
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
// Cortex-A7/A8/A9 with software floating point
features: "+soft-float,-neon".into(),
max_atomic_width: Some(64),
..base::thumb::opts()
},
}
}
37 changes: 37 additions & 0 deletions compiler/rustc_target/src/spec/targets/thumbv7a_nuttx_eabihf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Targets Cortex-A7/A8/A9 processors (ARMv7-A)
//
// This target assumes that the device has a FPU (Floating Point Unit) and lowers all (single
// precision) floating point operations to hardware instructions. Cortex-A7/A8/A9 processors
// support VFPv3-D32 or VFPv4-D32 floating point units with optional double-precision support.
//
// This target uses the "hard" floating convention (ABI) where floating point values
// are passed to/from subroutines via FPU registers (S0, S1, D0, D1, etc.).

use crate::spec::{FloatAbi, Target, TargetOptions, base, cvs};

pub(crate) fn target() -> Target {
Target {
llvm_target: "thumbv7a-none-eabihf".into(),
metadata: crate::spec::TargetMetadata {
description: None,
tier: None,
host_tools: None,
std: None,
},
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),

options: TargetOptions {
families: cvs!["unix"],
os: "nuttx".into(),
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
// Cortex-A7/A8/A9 support VFPv3-D32/VFPv4-D32 with optional double-precision
// and NEON SIMD instructions
features: "+vfp3,+neon".into(),
max_atomic_width: Some(64),
..base::thumb::opts()
},
}
}
24 changes: 14 additions & 10 deletions compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use rustc_span::{DUMMY_SP, Span};
use tracing::{debug, instrument};

use crate::traits::query::NoSolution;
use crate::traits::query::normalize::QueryNormalizeExt;
use crate::traits::{Normalized, ObligationCause, ObligationCtxt};
use crate::traits::{ObligationCause, ObligationCtxt};

/// This returns true if the type `ty` is "trivial" for
/// dropck-outlives -- that is, if it doesn't require any types to
Expand Down Expand Up @@ -172,26 +171,31 @@ pub fn compute_dropck_outlives_inner<'tcx>(
// do not themselves define a destructor", more or less. We have
// to push them onto the stack to be expanded.
for ty in constraints.dtorck_types.drain(..) {
let Normalized { value: ty, obligations } =
ocx.infcx.at(&cause, param_env).query_normalize(ty)?;
ocx.register_obligations(obligations);
let normalized_ty = ocx.normalize(&cause, param_env, ty);

debug!("dropck_outlives: ty from dtorck_types = {:?}", ty);
let errors = ocx.select_where_possible();
if !errors.is_empty() {
debug!("failed to normalize dtorck type: {ty} ~> {errors:#?}");
return Err(NoSolution);
}

let normalized_ty = ocx.infcx.resolve_vars_if_possible(normalized_ty);
debug!("dropck_outlives: ty from dtorck_types = {:?}", normalized_ty);

match ty.kind() {
match normalized_ty.kind() {
// All parameters live for the duration of the
// function.
ty::Param(..) => {}

// A projection that we couldn't resolve - it
// might have a destructor.
ty::Alias(..) => {
result.kinds.push(ty.into());
result.kinds.push(normalized_ty.into());
}

_ => {
if ty_set.insert(ty) {
ty_stack.push((ty, depth + 1));
if ty_set.insert(normalized_ty) {
ty_stack.push((normalized_ty, depth + 1));
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_traits/src/type_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ use rustc_middle::query::Providers;
use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::{Clause, FnSig, ParamEnvAnd, PolyFnSig, Ty, TyCtxt, TypeFoldable};
use rustc_trait_selection::infer::InferCtxtBuilderExt;
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
use rustc_trait_selection::traits::query::type_op::ascribe_user_type::{
AscribeUserType, type_op_ascribe_user_type_with_span,
};
use rustc_trait_selection::traits::query::type_op::normalize::Normalize;
use rustc_trait_selection::traits::query::type_op::prove_predicate::ProvePredicate;
use rustc_trait_selection::traits::{Normalized, Obligation, ObligationCause, ObligationCtxt};
use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};

pub(crate) fn provide(p: &mut Providers) {
*p = Providers {
Expand Down Expand Up @@ -43,10 +42,7 @@ where
T: fmt::Debug + TypeFoldable<TyCtxt<'tcx>>,
{
let (param_env, Normalize { value }) = key.into_parts();
let Normalized { value, obligations } =
ocx.infcx.at(&ObligationCause::dummy(), param_env).query_normalize(value)?;
ocx.register_obligations(obligations);
Ok(value)
Ok(ocx.normalize(&ObligationCause::dummy(), param_env, value))
}

fn type_op_normalize_ty<'tcx>(
Expand Down
46 changes: 46 additions & 0 deletions library/alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,52 @@ impl<T, A: Allocator> VecDeque<T, A> {
}
}

/// Removes and returns the first element from the deque if the predicate
/// returns `true`, or [`None`] if the predicate returns false or the deque
/// is empty (the predicate will not be called in that case).
///
/// # Examples
///
/// ```
/// #![feature(vec_deque_pop_if)]
/// use std::collections::VecDeque;
///
/// let mut deque: VecDeque<i32> = vec![0, 1, 2, 3, 4].into();
/// let pred = |x: &mut i32| *x % 2 == 0;
///
/// assert_eq!(deque.pop_front_if(pred), Some(0));
/// assert_eq!(deque, [1, 2, 3, 4]);
/// assert_eq!(deque.pop_front_if(pred), None);
/// ```
#[unstable(feature = "vec_deque_pop_if", issue = "135889")]
pub fn pop_front_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option<T> {
let first = self.front_mut()?;
if predicate(first) { self.pop_front() } else { None }
}

/// Removes and returns the last element from the deque if the predicate
/// returns `true`, or [`None`] if the predicate returns false or the deque
/// is empty (the predicate will not be called in that case).
///
/// # Examples
///
/// ```
/// #![feature(vec_deque_pop_if)]
/// use std::collections::VecDeque;
///
/// let mut deque: VecDeque<i32> = vec![0, 1, 2, 3, 4].into();
/// let pred = |x: &mut i32| *x % 2 == 0;
///
/// assert_eq!(deque.pop_back_if(pred), Some(4));
/// assert_eq!(deque, [0, 1, 2, 3]);
/// assert_eq!(deque.pop_back_if(pred), None);
/// ```
#[unstable(feature = "vec_deque_pop_if", issue = "135889")]
pub fn pop_back_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option<T> {
let first = self.back_mut()?;
if predicate(first) { self.pop_back() } else { None }
}

/// Prepends an element to the deque.
///
/// # Examples
Expand Down
Loading
Loading