Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 061ee95

Browse files
committed
Auto merge of #135978 - matthiaskrgr:rollup-ni16gqr, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #133605 (Add extensive set of drop order tests) - #135489 (remove pointless allowed_through_unstable_modules on TryFromSliceError) - #135757 (Add NuttX support for AArch64 and ARMv7-A targets) - #135799 (rustdoc-json: Rename `Path::name` to `path`, and give it the path again.) - #135865 (For E0223, suggest associated functions that are similar to the path, even if the base type has multiple inherent impl blocks.) - #135890 (Implement `VecDeque::pop_front_if` & `VecDeque::pop_back_if`) - #135914 (Remove usages of `QueryNormalizer` in the compiler) - #135936 (fix reify-intrinsic test) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 48ef38d + 109def5 commit 061ee95

File tree

41 files changed

+2317
-173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2317
-173
lines changed

‎compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_hir as hir;
99
use rustc_hir::def::{DefKind, Res};
1010
use rustc_hir::def_id::DefId;
1111
use rustc_middle::bug;
12+
use rustc_middle::ty::fast_reject::{TreatParams, simplify_type};
1213
use rustc_middle::ty::print::{PrintPolyTraitRefExt as _, PrintTraitRefExt as _};
1314
use rustc_middle::ty::{
1415
self, AdtDef, GenericParamDefKind, Ty, TyCtxt, TypeVisitableExt,
@@ -998,12 +999,19 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
998999
)),
9991000
..
10001001
}) = node
1001-
&& let Some(adt_def) = qself_ty.ty_adt_def()
1002-
&& let [inherent_impl] = tcx.inherent_impls(adt_def.did())
1003-
&& let name = format!("{ident2}_{ident3}")
1004-
&& let Some(ty::AssocItem { kind: ty::AssocKind::Fn, .. }) = tcx
1005-
.associated_items(inherent_impl)
1006-
.filter_by_name_unhygienic(Symbol::intern(&name))
1002+
&& let Some(inherent_impls) = qself_ty
1003+
.ty_adt_def()
1004+
.map(|adt_def| tcx.inherent_impls(adt_def.did()))
1005+
.or_else(|| {
1006+
simplify_type(tcx, qself_ty, TreatParams::InstantiateWithInfer)
1007+
.map(|simple_ty| tcx.incoherent_impls(simple_ty))
1008+
})
1009+
&& let name = Symbol::intern(&format!("{ident2}_{ident3}"))
1010+
&& let Some(ty::AssocItem { kind: ty::AssocKind::Fn, .. }) = inherent_impls
1011+
.iter()
1012+
.flat_map(|inherent_impl| {
1013+
tcx.associated_items(inherent_impl).filter_by_name_unhygienic(name)
1014+
})
10071015
.next()
10081016
{
10091017
Err(struct_span_code_err!(self.dcx(), span, E0223, "ambiguous associated type")

‎compiler/rustc_target/src/spec/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,8 @@ supported_targets! {
18531853

18541854
("armv7a-none-eabi", armv7a_none_eabi),
18551855
("armv7a-none-eabihf", armv7a_none_eabihf),
1856+
("armv7a-nuttx-eabi", armv7a_nuttx_eabi),
1857+
("armv7a-nuttx-eabihf", armv7a_nuttx_eabihf),
18561858

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

@@ -1896,6 +1898,7 @@ supported_targets! {
18961898

18971899
("aarch64-unknown-none", aarch64_unknown_none),
18981900
("aarch64-unknown-none-softfloat", aarch64_unknown_none_softfloat),
1901+
("aarch64-unknown-nuttx", aarch64_unknown_nuttx),
18991902

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

@@ -1971,6 +1974,8 @@ supported_targets! {
19711974
("x86_64-unknown-linux-none", x86_64_unknown_linux_none),
19721975

19731976
("thumbv6m-nuttx-eabi", thumbv6m_nuttx_eabi),
1977+
("thumbv7a-nuttx-eabi", thumbv7a_nuttx_eabi),
1978+
("thumbv7a-nuttx-eabihf", thumbv7a_nuttx_eabihf),
19741979
("thumbv7m-nuttx-eabi", thumbv7m_nuttx_eabi),
19751980
("thumbv7em-nuttx-eabi", thumbv7em_nuttx_eabi),
19761981
("thumbv7em-nuttx-eabihf", thumbv7em_nuttx_eabihf),
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Generic AArch64 target for NuttX OS
2+
//
3+
// Can be used in conjunction with the `target-feature` and
4+
// `target-cpu` compiler flags to opt-in more hardware-specific
5+
// features.
6+
//
7+
// For example, `-C target-cpu=cortex-a53`.
8+
9+
use crate::spec::{
10+
Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target,
11+
TargetOptions, cvs,
12+
};
13+
14+
pub(crate) fn target() -> Target {
15+
let opts = TargetOptions {
16+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
17+
linker: Some("rust-lld".into()),
18+
// Enable the Cortex-A53 errata 843419 mitigation by default
19+
pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[
20+
"--fix-cortex-a53-843419",
21+
]),
22+
features: "+v8a,+strict-align,+neon,+fp-armv8".into(),
23+
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
24+
relocation_model: RelocModel::Static,
25+
disable_redzone: true,
26+
max_atomic_width: Some(128),
27+
stack_probes: StackProbeType::Inline,
28+
panic_strategy: PanicStrategy::Abort,
29+
families: cvs!["unix"],
30+
os: "nuttx".into(),
31+
..Default::default()
32+
};
33+
Target {
34+
llvm_target: "aarch64-unknown-none".into(),
35+
metadata: crate::spec::TargetMetadata {
36+
description: Some("AArch64 NuttX".into()),
37+
tier: Some(3),
38+
host_tools: Some(false),
39+
std: Some(false),
40+
},
41+
pointer_width: 64,
42+
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(),
43+
arch: "aarch64".into(),
44+
options: opts,
45+
}
46+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Targets Cortex-A7/A8/A9 processors (ARMv7-A) running NuttX
2+
//
3+
// This target assumes that the device does NOT have a FPU (Floating Point Unit)
4+
// and will use software floating point operations. This matches the NuttX EABI
5+
// configuration without hardware floating point support.
6+
7+
use crate::spec::{
8+
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs,
9+
};
10+
11+
pub(crate) fn target() -> Target {
12+
let opts = TargetOptions {
13+
abi: "eabi".into(),
14+
llvm_floatabi: Some(FloatAbi::Soft),
15+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
16+
linker: Some("rust-lld".into()),
17+
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".into(),
18+
relocation_model: RelocModel::Static,
19+
disable_redzone: true,
20+
max_atomic_width: Some(64),
21+
panic_strategy: PanicStrategy::Abort,
22+
emit_debug_gdb_scripts: false,
23+
c_enum_min_bits: Some(8),
24+
families: cvs!["unix"],
25+
os: "nuttx".into(),
26+
..Default::default()
27+
};
28+
Target {
29+
llvm_target: "armv7a-none-eabi".into(),
30+
metadata: crate::spec::TargetMetadata {
31+
description: Some("ARMv7-A Cortex-A with NuttX".into()),
32+
tier: Some(3),
33+
host_tools: Some(false),
34+
std: Some(false),
35+
},
36+
pointer_width: 32,
37+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
38+
arch: "arm".into(),
39+
options: opts,
40+
}
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Targets Cortex-A7/A8/A9 processors (ARMv7-A) running NuttX with hardware floating point
2+
//
3+
// This target assumes that the device has a FPU (Floating Point Unit)
4+
// and will use hardware floating point operations. This matches the NuttX EABI
5+
// configuration with hardware floating point support.
6+
7+
use crate::spec::{
8+
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs,
9+
};
10+
11+
pub(crate) fn target() -> Target {
12+
let opts = TargetOptions {
13+
abi: "eabihf".into(),
14+
llvm_floatabi: Some(FloatAbi::Hard),
15+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
16+
linker: Some("rust-lld".into()),
17+
features: "+v7,+thumb2,+vfp3,+neon,+strict-align".into(),
18+
relocation_model: RelocModel::Static,
19+
disable_redzone: true,
20+
max_atomic_width: Some(64),
21+
panic_strategy: PanicStrategy::Abort,
22+
emit_debug_gdb_scripts: false,
23+
c_enum_min_bits: Some(8),
24+
families: cvs!["unix"],
25+
os: "nuttx".into(),
26+
..Default::default()
27+
};
28+
Target {
29+
llvm_target: "armv7a-none-eabihf".into(),
30+
metadata: crate::spec::TargetMetadata {
31+
description: Some("ARMv7-A Cortex-A with NuttX (hard float)".into()),
32+
tier: Some(3),
33+
host_tools: Some(false),
34+
std: Some(false),
35+
},
36+
pointer_width: 32,
37+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
38+
arch: "arm".into(),
39+
options: opts,
40+
}
41+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Targets Cortex-A7/A8/A9 processors (ARMv7-A)
2+
//
3+
// This target assumes that the device does NOT have a FPU (Floating Point Unit)
4+
// and will use software floating point operations. This matches the NuttX EABI
5+
// configuration without hardware floating point support.
6+
7+
use crate::spec::{FloatAbi, Target, TargetOptions, base, cvs};
8+
9+
pub(crate) fn target() -> Target {
10+
Target {
11+
llvm_target: "thumbv7a-none-eabi".into(),
12+
metadata: crate::spec::TargetMetadata {
13+
description: None,
14+
tier: None,
15+
host_tools: None,
16+
std: None,
17+
},
18+
pointer_width: 32,
19+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
20+
arch: "arm".into(),
21+
22+
options: TargetOptions {
23+
families: cvs!["unix"],
24+
os: "nuttx".into(),
25+
abi: "eabi".into(),
26+
llvm_floatabi: Some(FloatAbi::Soft),
27+
// Cortex-A7/A8/A9 with software floating point
28+
features: "+soft-float,-neon".into(),
29+
max_atomic_width: Some(64),
30+
..base::thumb::opts()
31+
},
32+
}
33+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Targets Cortex-A7/A8/A9 processors (ARMv7-A)
2+
//
3+
// This target assumes that the device has a FPU (Floating Point Unit) and lowers all (single
4+
// precision) floating point operations to hardware instructions. Cortex-A7/A8/A9 processors
5+
// support VFPv3-D32 or VFPv4-D32 floating point units with optional double-precision support.
6+
//
7+
// This target uses the "hard" floating convention (ABI) where floating point values
8+
// are passed to/from subroutines via FPU registers (S0, S1, D0, D1, etc.).
9+
10+
use crate::spec::{FloatAbi, Target, TargetOptions, base, cvs};
11+
12+
pub(crate) fn target() -> Target {
13+
Target {
14+
llvm_target: "thumbv7a-none-eabihf".into(),
15+
metadata: crate::spec::TargetMetadata {
16+
description: None,
17+
tier: None,
18+
host_tools: None,
19+
std: None,
20+
},
21+
pointer_width: 32,
22+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
23+
arch: "arm".into(),
24+
25+
options: TargetOptions {
26+
families: cvs!["unix"],
27+
os: "nuttx".into(),
28+
abi: "eabihf".into(),
29+
llvm_floatabi: Some(FloatAbi::Hard),
30+
// Cortex-A7/A8/A9 support VFPv3-D32/VFPv4-D32 with optional double-precision
31+
// and NEON SIMD instructions
32+
features: "+vfp3,+neon".into(),
33+
max_atomic_width: Some(64),
34+
..base::thumb::opts()
35+
},
36+
}
37+
}

‎compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use rustc_span::{DUMMY_SP, Span};
66
use tracing::{debug, instrument};
77

88
use crate::traits::query::NoSolution;
9-
use crate::traits::query::normalize::QueryNormalizeExt;
10-
use crate::traits::{Normalized, ObligationCause, ObligationCtxt};
9+
use crate::traits::{ObligationCause, ObligationCtxt};
1110

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

179-
debug!("dropck_outlives: ty from dtorck_types = {:?}", ty);
176+
let errors = ocx.select_where_possible();
177+
if !errors.is_empty() {
178+
debug!("failed to normalize dtorck type: {ty} ~> {errors:#?}");
179+
return Err(NoSolution);
180+
}
181+
182+
let normalized_ty = ocx.infcx.resolve_vars_if_possible(normalized_ty);
183+
debug!("dropck_outlives: ty from dtorck_types = {:?}", normalized_ty);
180184

181-
match ty.kind() {
185+
match normalized_ty.kind() {
182186
// All parameters live for the duration of the
183187
// function.
184188
ty::Param(..) => {}
185189

186190
// A projection that we couldn't resolve - it
187191
// might have a destructor.
188192
ty::Alias(..) => {
189-
result.kinds.push(ty.into());
193+
result.kinds.push(normalized_ty.into());
190194
}
191195

192196
_ => {
193-
if ty_set.insert(ty) {
194-
ty_stack.push((ty, depth + 1));
197+
if ty_set.insert(normalized_ty) {
198+
ty_stack.push((normalized_ty, depth + 1));
195199
}
196200
}
197201
}

‎compiler/rustc_traits/src/type_op.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ use rustc_middle::query::Providers;
66
use rustc_middle::traits::query::NoSolution;
77
use rustc_middle::ty::{Clause, FnSig, ParamEnvAnd, PolyFnSig, Ty, TyCtxt, TypeFoldable};
88
use rustc_trait_selection::infer::InferCtxtBuilderExt;
9-
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
109
use rustc_trait_selection::traits::query::type_op::ascribe_user_type::{
1110
AscribeUserType, type_op_ascribe_user_type_with_span,
1211
};
1312
use rustc_trait_selection::traits::query::type_op::normalize::Normalize;
1413
use rustc_trait_selection::traits::query::type_op::prove_predicate::ProvePredicate;
15-
use rustc_trait_selection::traits::{Normalized,Obligation, ObligationCause, ObligationCtxt};
14+
use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};
1615

1716
pub(crate) fn provide(p: &mut Providers) {
1817
*p = Providers {
@@ -43,10 +42,7 @@ where
4342
T: fmt::Debug + TypeFoldable<TyCtxt<'tcx>>,
4443
{
4544
let (param_env, Normalize { value }) = key.into_parts();
46-
let Normalized { value, obligations } =
47-
ocx.infcx.at(&ObligationCause::dummy(), param_env).query_normalize(value)?;
48-
ocx.register_obligations(obligations);
49-
Ok(value)
45+
Ok(ocx.normalize(&ObligationCause::dummy(), param_env, value))
5046
}
5147

5248
fn type_op_normalize_ty<'tcx>(

‎library/alloc/src/collections/vec_deque/mod.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,52 @@ impl<T, A: Allocator> VecDeque<T, A> {
17351735
}
17361736
}
17371737

1738+
/// Removes and returns the first element from the deque if the predicate
1739+
/// returns `true`, or [`None`] if the predicate returns false or the deque
1740+
/// is empty (the predicate will not be called in that case).
1741+
///
1742+
/// # Examples
1743+
///
1744+
/// ```
1745+
/// #![feature(vec_deque_pop_if)]
1746+
/// use std::collections::VecDeque;
1747+
///
1748+
/// let mut deque: VecDeque<i32> = vec![0, 1, 2, 3, 4].into();
1749+
/// let pred = |x: &mut i32| *x % 2 == 0;
1750+
///
1751+
/// assert_eq!(deque.pop_front_if(pred), Some(0));
1752+
/// assert_eq!(deque, [1, 2, 3, 4]);
1753+
/// assert_eq!(deque.pop_front_if(pred), None);
1754+
/// ```
1755+
#[unstable(feature = "vec_deque_pop_if", issue = "135889")]
1756+
pub fn pop_front_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option<T> {
1757+
let first = self.front_mut()?;
1758+
if predicate(first) { self.pop_front() } else { None }
1759+
}
1760+
1761+
/// Removes and returns the last element from the deque if the predicate
1762+
/// returns `true`, or [`None`] if the predicate returns false or the deque
1763+
/// is empty (the predicate will not be called in that case).
1764+
///
1765+
/// # Examples
1766+
///
1767+
/// ```
1768+
/// #![feature(vec_deque_pop_if)]
1769+
/// use std::collections::VecDeque;
1770+
///
1771+
/// let mut deque: VecDeque<i32> = vec![0, 1, 2, 3, 4].into();
1772+
/// let pred = |x: &mut i32| *x % 2 == 0;
1773+
///
1774+
/// assert_eq!(deque.pop_back_if(pred), Some(4));
1775+
/// assert_eq!(deque, [0, 1, 2, 3]);
1776+
/// assert_eq!(deque.pop_back_if(pred), None);
1777+
/// ```
1778+
#[unstable(feature = "vec_deque_pop_if", issue = "135889")]
1779+
pub fn pop_back_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option<T> {
1780+
let first = self.back_mut()?;
1781+
if predicate(first) { self.pop_back() } else { None }
1782+
}
1783+
17381784
/// Prepends an element to the deque.
17391785
///
17401786
/// # Examples

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /