Skip to content

Commit 78865ca

Browse files
committed
Auto merge of #151897 - matthiaskrgr:rollup-eTQjYr5, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #151262 (Introducing clap on tidy) - #151896 (Revert enabling `outline-atomics` on various platforms) - #151849 (refactor: remove `Ty::pinned_ref` in favor of `Ty::maybe_pinned_ref`) - #151892 (Document enum types used as values for E0423)
2 parents 271951b + 72f163c commit 78865ca

20 files changed

Lines changed: 335 additions & 78 deletions

File tree

Cargo.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,9 @@ dependencies = [
580580

581581
[[package]]
582582
name = "clap"
583-
version = "4.5.51"
583+
version = "4.5.54"
584584
source = "registry+https://github.com/rust-lang/crates.io-index"
585-
checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5"
585+
checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394"
586586
dependencies = [
587587
"clap_builder",
588588
"clap_derive",
@@ -600,9 +600,9 @@ dependencies = [
600600

601601
[[package]]
602602
name = "clap_builder"
603-
version = "4.5.51"
603+
version = "4.5.54"
604604
source = "registry+https://github.com/rust-lang/crates.io-index"
605-
checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a"
605+
checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00"
606606
dependencies = [
607607
"anstream",
608608
"anstyle",
@@ -5623,6 +5623,7 @@ version = "0.1.0"
56235623
dependencies = [
56245624
"build_helper",
56255625
"cargo_metadata 0.21.0",
5626+
"clap",
56265627
"fluent-syntax",
56275628
"globset",
56285629
"ignore",

compiler/rustc_error_codes/src/error_codes/E0423.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,14 @@ fn h1() -> i32 {
4444
// did you mean `a::I`?
4545
}
4646
```
47+
48+
### Enum types used as values
49+
50+
Enums are types and cannot be used directly as values.
51+
52+
```compile_fail,E0423
53+
fn main(){
54+
let x = Option::<i32>;
55+
//~^ ERROR expected value,found enum `Option`
56+
}
57+
```

compiler/rustc_hir_typeck/src/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2841,7 +2841,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
28412841
// the bad interactions of the given hack detailed in (note_1).
28422842
debug!("check_pat_ref: expected={:?}", expected);
28432843
match expected.maybe_pinned_ref() {
2844-
Some((r_ty, r_pinned, r_mutbl))
2844+
Some((r_ty, r_pinned, r_mutbl, _))
28452845
if ((ref_pat_matches_mut_ref && r_mutbl >= pat_mutbl)
28462846
|| r_mutbl == pat_mutbl)
28472847
&& pat_pinned == r_pinned =>

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,25 +1336,17 @@ impl<'tcx> Ty<'tcx> {
13361336
}
13371337
}
13381338

1339-
pub fn pinned_ref(self) -> Option<(Ty<'tcx>, ty::Mutability)> {
1340-
if let Adt(def, args) = self.kind()
1341-
&& def.is_pin()
1342-
&& let &ty::Ref(_, ty, mutbl) = args.type_at(0).kind()
1343-
{
1344-
return Some((ty, mutbl));
1345-
}
1346-
None
1347-
}
1348-
1349-
pub fn maybe_pinned_ref(self) -> Option<(Ty<'tcx>, ty::Pinnedness, ty::Mutability)> {
1350-
match *self.kind() {
1339+
pub fn maybe_pinned_ref(
1340+
self,
1341+
) -> Option<(Ty<'tcx>, ty::Pinnedness, ty::Mutability, Region<'tcx>)> {
1342+
match self.kind() {
13511343
Adt(def, args)
13521344
if def.is_pin()
1353-
&& let ty::Ref(_, ty, mutbl) = *args.type_at(0).kind() =>
1345+
&& let &ty::Ref(region, ty, mutbl) = args.type_at(0).kind() =>
13541346
{
1355-
Some((ty, ty::Pinnedness::Pinned, mutbl))
1347+
Some((ty, ty::Pinnedness::Pinned, mutbl, region))
13561348
}
1357-
ty::Ref(_, ty, mutbl) => Some((ty, ty::Pinnedness::Not, mutbl)),
1349+
&Ref(region, ty, mutbl) => Some((ty, ty::Pinnedness::Not, mutbl, region)),
13581350
_ => None,
13591351
}
13601352
}

compiler/rustc_pattern_analysis/src/rustc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::iter::once;
44

55
use rustc_abi::{FIRST_VARIANT, FieldIdx, Integer, VariantIdx};
66
use rustc_arena::DroplessArena;
7+
use rustc_hir::HirId;
78
use rustc_hir::def_id::DefId;
8-
use rustc_hir::{self as hir, HirId};
99
use rustc_index::{Idx, IndexVec};
1010
use rustc_middle::middle::stability::EvalResult;
1111
use rustc_middle::thir::{self, Pat, PatKind, PatRange, PatRangeBoundary};
@@ -471,9 +471,9 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
471471
PatKind::Deref { pin, subpattern } => {
472472
fields = vec![self.lower_pat(subpattern).at_index(0)];
473473
arity = 1;
474-
ctor = match pin {
475-
hir::Pinnedness::Not if ty.is_ref() => Ref,
476-
hir::Pinnedness::Pinned if let Some((inner_ty, _)) = ty.pinned_ref() => {
474+
ctor = match (pin, ty.maybe_pinned_ref()) {
475+
(ty::Pinnedness::Not, Some((_, ty::Pinnedness::Not, _, _))) => Ref,
476+
(ty::Pinnedness::Pinned, Some((inner_ty, ty::Pinnedness::Pinned, _, _))) => {
477477
self.internal_state.has_lowered_deref_pat.set(true);
478478
DerefPattern(RevealedTy(inner_ty))
479479
}

compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(crate) fn target() -> Target {
2121
max_atomic_width: Some(128),
2222
// As documented in https://developer.android.com/ndk/guides/cpu-features.html
2323
// the neon (ASIMD) and FP must exist on all android aarch64 targets.
24-
features: "+v8a,+neon,+outline-atomics".into(),
24+
features: "+v8a,+neon".into(),
2525
// the AAPCS64 expects use of non-leaf frame pointers per
2626
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
2727
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not

compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::spec::{Arch, Cc, FramePointer, LinkerFlavor, Lld, Target, TargetMetad
33
pub(crate) fn target() -> Target {
44
let mut base = base::windows_gnullvm::opts();
55
base.max_atomic_width = Some(128);
6-
base.features = "+v8a,+neon,+outline-atomics".into();
6+
base.features = "+v8a,+neon".into();
77
base.linker = Some("aarch64-w64-mingw32-clang".into());
88
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &["-m", "arm64pe"]);
99

compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::spec::{Arch, FramePointer, Target, TargetMetadata, base};
33
pub(crate) fn target() -> Target {
44
let mut base = base::windows_msvc::opts();
55
base.max_atomic_width = Some(128);
6-
base.features = "+v8a,+neon,+outline-atomics".into();
6+
base.features = "+v8a,+neon".into();
77

88
// Microsoft recommends enabling frame pointers on Arm64 Windows.
99
// From https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers

compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
1515
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(),
1616
arch: Arch::AArch64,
1717
options: TargetOptions {
18-
features: "+v8a,+outline-atomics".into(),
18+
features: "+v8a".into(),
1919
max_atomic_width: Some(128),
2020
stack_probes: StackProbeType::Inline,
2121
supported_sanitizers: SanitizerSet::ADDRESS

compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::spec::{
55
pub(crate) fn target() -> Target {
66
let mut base = base::fuchsia::opts();
77
base.cpu = "generic".into();
8-
base.features = "+v8a,+crc,+aes,+sha2,+neon,+outline-atomics".into();
8+
base.features = "+v8a,+crc,+aes,+sha2,+neon".into();
99
base.max_atomic_width = Some(128);
1010
base.stack_probes = StackProbeType::Inline;
1111
base.supported_sanitizers = SanitizerSet::ADDRESS

0 commit comments

Comments
 (0)