Skip to content

Commit f418859

Browse files
committed
Auto merge of #109690 - matthiaskrgr:rollup-6p5m0es, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #108548 (Clarify the 'use a constant in a pattern' error message) - #109565 (Improve documentation for E0223) - #109661 (Fix LVI test post LLVM 16 update) - #109667 (Always set `RUSTC_BOOTSTRAP` with `x doc`) - #109669 (Update books) - #109678 (Don't shadow the `dep_node` var in `incremental_verify_ich_failed`) - #109682 (Add `#[inline]` to CStr trait implementations) - #109685 (Make doc comment a little bit more accurate) - #109687 (Document the heuristics IsTerminal uses on Windows) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents cbc064b + a694960 commit f418859

Some content is hidden

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

44 files changed

+215
-41
lines changed

Diff for: compiler/rustc_error_codes/src/error_codes/E0223.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,33 @@ An attempt was made to retrieve an associated type, but the type was ambiguous.
33
Erroneous code example:
44

55
```compile_fail,E0223
6-
trait MyTrait {type X; }
6+
trait Trait { type X; }
77
88
fn main() {
9-
let foo: MyTrait::X;
9+
let foo: Trait::X;
1010
}
1111
```
1212

13-
The problem here is that we're attempting to take the type of X from MyTrait.
14-
Unfortunately, the type of X is not defined, because it's only made concrete in
15-
implementations of the trait. A working version of this code might look like:
13+
The problem here is that we're attempting to take the associated type of `X`
14+
from `Trait`. Unfortunately, the type of `X` is not defined, because it's only
15+
made concrete in implementations of the trait. A working version of this code
16+
might look like:
1617

1718
```
18-
trait MyTrait {type X; }
19-
struct MyStruct;
19+
trait Trait { type X; }
2020
21-
impl MyTrait for MyStruct {
21+
struct Struct;
22+
impl Trait for Struct {
2223
type X = u32;
2324
}
2425
2526
fn main() {
26-
let foo: <MyStruct as MyTrait>::X;
27+
let foo: <Struct as Trait>::X;
2728
}
2829
```
2930

30-
This syntax specifies that we want the X type from MyTrait, as made concrete in
31-
MyStruct. The reason that we cannot simply use `MyStruct::X` is that MyStruct
32-
might implement two different traits with identically-named associated types.
33-
This syntax allows disambiguation between the two.
31+
This syntax specifies that we want the associated type `X` from `Struct`'s
32+
implementation of `Trait`.
33+
34+
Due to internal limitations of the current compiler implementation we cannot
35+
simply use `Struct::X`.

Diff for: compiler/rustc_interface/src/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub type MakeBackendFn = fn() -> Box<dyn CodegenBackend>;
3434
/// specific features (SSE, NEON etc.).
3535
///
3636
/// This is performed by checking whether a set of permitted features
37-
/// is available on the target machine, by querying LLVM.
37+
/// is available on the target machine, by querying the codegen backend.
3838
pub fn add_configuration(
3939
cfg: &mut CrateConfig,
4040
sess: &mut Session,

Diff for: compiler/rustc_mir_build/messages.ftl

+4
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ mir_build_indirect_structural_match =
331331
mir_build_nontrivial_structural_match =
332332
to use a constant of type `{$non_sm_ty}` in a pattern, the constant's initializer must be trivial or `{$non_sm_ty}` must be annotated with `#[derive(PartialEq, Eq)]`
333333
334+
mir_build_type_not_structural_tip = the traits must be derived, manual `impl`s are not sufficient
335+
336+
mir_build_type_not_structural_more_info = see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
337+
334338
mir_build_overlapping_range_endpoints = multiple patterns overlap on their endpoints
335339
.range = ... with this range
336340
.note = you likely meant to write mutually exclusive ranges

Diff for: compiler/rustc_mir_build/src/errors.rs

+6
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,8 @@ pub struct UnionPattern {
663663

664664
#[derive(Diagnostic)]
665665
#[diag(mir_build_type_not_structural)]
666+
#[note(mir_build_type_not_structural_tip)]
667+
#[note(mir_build_type_not_structural_more_info)]
666668
pub struct TypeNotStructural<'tcx> {
667669
#[primary_span]
668670
pub span: Span,
@@ -695,12 +697,16 @@ pub struct PointerPattern;
695697

696698
#[derive(LintDiagnostic)]
697699
#[diag(mir_build_indirect_structural_match)]
700+
#[note(mir_build_type_not_structural_tip)]
701+
#[note(mir_build_type_not_structural_more_info)]
698702
pub struct IndirectStructuralMatch<'tcx> {
699703
pub non_sm_ty: Ty<'tcx>,
700704
}
701705

702706
#[derive(LintDiagnostic)]
703707
#[diag(mir_build_nontrivial_structural_match)]
708+
#[note(mir_build_type_not_structural_tip)]
709+
#[note(mir_build_type_not_structural_more_info)]
704710
pub struct NontrivialStructuralMatch<'tcx> {
705711
pub non_sm_ty: Ty<'tcx>,
706712
}

Diff for: compiler/rustc_query_system/src/query/plumbing.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,7 @@ fn incremental_verify_ich_failed<Tcx>(
703703
};
704704

705705
let dep_node = tcx.dep_graph().data().unwrap().prev_node_of(prev_index);
706-
707-
let dep_node = tcx.sess().emit_err(crate::error::IncrementCompilation {
706+
tcx.sess().emit_err(crate::error::IncrementCompilation {
708707
run_cmd,
709708
dep_node: format!("{dep_node:?}"),
710709
});

Diff for: library/core/src/ffi/c_str.rs

+5
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ impl fmt::Debug for CStr {
172172

173173
#[stable(feature = "cstr_default", since = "1.10.0")]
174174
impl Default for &CStr {
175+
#[inline]
175176
fn default() -> Self {
176177
const SLICE: &[c_char] = &[0];
177178
// SAFETY: `SLICE` is indeed pointing to a valid nul-terminated string.
@@ -623,6 +624,7 @@ impl CStr {
623624

624625
#[stable(feature = "rust1", since = "1.0.0")]
625626
impl PartialEq for CStr {
627+
#[inline]
626628
fn eq(&self, other: &CStr) -> bool {
627629
self.to_bytes().eq(other.to_bytes())
628630
}
@@ -631,12 +633,14 @@ impl PartialEq for CStr {
631633
impl Eq for CStr {}
632634
#[stable(feature = "rust1", since = "1.0.0")]
633635
impl PartialOrd for CStr {
636+
#[inline]
634637
fn partial_cmp(&self, other: &CStr) -> Option<Ordering> {
635638
self.to_bytes().partial_cmp(&other.to_bytes())
636639
}
637640
}
638641
#[stable(feature = "rust1", since = "1.0.0")]
639642
impl Ord for CStr {
643+
#[inline]
640644
fn cmp(&self, other: &CStr) -> Ordering {
641645
self.to_bytes().cmp(&other.to_bytes())
642646
}
@@ -646,6 +650,7 @@ impl Ord for CStr {
646650
impl ops::Index<ops::RangeFrom<usize>> for CStr {
647651
type Output = CStr;
648652

653+
#[inline]
649654
fn index(&self, index: ops::RangeFrom<usize>) -> &CStr {
650655
let bytes = self.to_bytes_with_nul();
651656
// we need to manually check the starting index to account for the null

Diff for: library/std/src/io/stdio.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,15 @@ pub trait IsTerminal: crate::sealed::Sealed {
10541054
/// On platforms where Rust does not know how to detect a terminal yet, this will return
10551055
/// `false`. This will also return `false` if an unexpected error occurred, such as from
10561056
/// passing an invalid file descriptor.
1057+
///
1058+
/// # Platform-specific behavior
1059+
///
1060+
/// On Windows, in addition to detecting consoles, this currently uses some heuristics to
1061+
/// detect older msys/cygwin/mingw pseudo-terminals based on device name: devices with names
1062+
/// starting with `msys-` or `cygwin-` and ending in `-pty` will be considered terminals.
1063+
/// Note that this [may change in the future][changes].
1064+
///
1065+
/// [changes]: io#platform-specific-behavior
10571066
fn is_terminal(&self) -> bool;
10581067
}
10591068

Diff for: src/bootstrap/doc.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1027,10 +1027,11 @@ impl Step for RustcBook {
10271027
if self.validate {
10281028
cmd.arg("--validate");
10291029
}
1030-
if !builder.unstable_features() {
1031-
// We need to validate nightly features, even on the stable channel.
1032-
cmd.env("RUSTC_BOOTSTRAP", "1");
1033-
}
1030+
// We need to validate nightly features, even on the stable channel.
1031+
// Set this unconditionally as the stage0 compiler may be being used to
1032+
// document.
1033+
cmd.env("RUSTC_BOOTSTRAP", "1");
1034+
10341035
// If the lib directories are in an unusual location (changed in
10351036
// config.toml), then this needs to explicitly update the dylib search
10361037
// path.

Diff for: src/doc/nomicon

Diff for: src/tools/clippy/tests/ui/crashes/ice-6254.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ LL | FOO_REF_REF => {},
66
|
77
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
88
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
9+
= note: the traits must be derived, manual `impl`s are not sufficient
10+
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
911
= note: `-D indirect-structural-match` implied by `-D warnings`
1012

1113
error: aborting due to previous error

Diff for: tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_asm.checks

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ CHECK: cc_plus_one_asm
22
CHECK-NEXT: movl
33
CHECK-NEXT: lfence
44
CHECK-NEXT: incl
5-
CHECK-NEXT: shlq $0, (%rsp)
5+
CHECK-NEXT: shlq $0x0, (%rsp)
66
CHECK-NEXT: lfence
77
CHECK-NEXT: retq

Diff for: tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_c_asm.checks

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CHECK: lfence
66
CHECK: lfence
77
CHECK-NEXT: incl
88
CHECK-NEXT: jmp
9-
CHECK-NEXT: shlq $0, (%rsp)
9+
CHECK-NEXT: shlq $0x0, (%rsp)
1010
CHECK-NEXT: lfence
1111
CHECK-NEXT: retq
1212
CHECK: popq

Diff for: tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_cxx_asm.checks

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CHECK: lfence
77
CHECK: lfence
88
CHECK-NEXT: incl
99
CHECK-NEXT: jmp 0x{{[[:xdigit:]]+}} <cc_plus_one_cxx_asm+0x{{[[:xdigit:]]+}}>
10-
CHECK-NEXT: shlq $0, (%rsp)
10+
CHECK-NEXT: shlq $0x0, (%rsp)
1111
CHECK-NEXT: lfence
1212
CHECK-NEXT: retq
1313
CHECK: popq

Diff for: tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_asm.checks

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ CHECK: cmake_plus_one_asm
22
CHECK-NEXT: movl
33
CHECK-NEXT: lfence
44
CHECK-NEXT: incl
5-
CHECK-NEXT: shlq $0, (%rsp)
5+
CHECK-NEXT: shlq $0x0, (%rsp)
66
CHECK-NEXT: lfence
77
CHECK-NEXT: retq

Diff for: tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c_asm.checks

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CHECK: movl
77
CHECK: lfence
88
CHECK-NEXT: incl
99
CHECK-NEXT: jmp 0x{{[[:xdigit:]]+}} <cmake_plus_one_c_asm+0x{{[[:xdigit:]]+}}>
10-
CHECK-NEXT: shlq $0, (%rsp)
10+
CHECK-NEXT: shlq $0x0, (%rsp)
1111
CHECK-NEXT: lfence
1212
CHECK-NEXT: retq
1313
CHECK: popq

Diff for: tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx_asm.checks

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CHECK: movl
77
CHECK: lfence
88
CHECK-NEXT: incl
99
CHECK-NEXT: jmp 0x{{[[:xdigit:]]+}} <cmake_plus_one_cxx_asm+0x{{[[:xdigit:]]+}}>
10-
CHECK-NEXT: shlq $0, (%rsp)
10+
CHECK-NEXT: shlq $0x0, (%rsp)
1111
CHECK-NEXT: lfence
1212
CHECK-NEXT: retq
1313
CHECK: popq
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CHECK: unw_getcontext
22
CHECK: lfence
33
CHECK: lfence
4-
CHECK: shlq $0, (%rsp)
4+
CHECK: shlq $0x0, (%rsp)
55
CHECK-NEXT: lfence
66
CHECK-NEXT: retq

Diff for: tests/ui/consts/const_in_pattern/cross-crate-fail.stderr

+6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be ann
33
|
44
LL | consts::SOME => panic!(),
55
| ^^^^^^^^^^^^
6+
|
7+
= note: the traits must be derived, manual `impl`s are not sufficient
8+
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
69

710
error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
811
--> $DIR/cross-crate-fail.rs:20:9
912
|
1013
LL | <Defaulted as consts::AssocConst>::SOME => panic!(),
1114
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
|
16+
= note: the traits must be derived, manual `impl`s are not sufficient
17+
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
1218

1319
error: aborting due to 2 previous errors
1420

Diff for: tests/ui/consts/const_in_pattern/custom-eq-branch-warn.rs

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ fn main() {
2828
match Foo::Qux(CustomEq) {
2929
BAR_BAZ => panic!(),
3030
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
31+
//~| NOTE the traits must be derived
32+
//~| NOTE StructuralEq.html for details
3133
//~| WARN this was previously accepted
3234
//~| NOTE see issue #73448
3335
//~| NOTE `#[warn(nontrivial_structural_match)]` on by default

Diff for: tests/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ LL | BAR_BAZ => panic!(),
66
|
77
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
88
= note: for more information, see issue #73448 <https://github.com/rust-lang/rust/issues/73448>
9+
= note: the traits must be derived, manual `impl`s are not sufficient
10+
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
911
= note: `#[warn(nontrivial_structural_match)]` on by default
1012

1113
warning: 1 warning emitted

Diff for: tests/ui/consts/const_in_pattern/incomplete-slice.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ LL | E_SL => {}
66
|
77
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
88
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
9+
= note: the traits must be derived, manual `impl`s are not sufficient
10+
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
911
= note: `#[warn(indirect_structural_match)]` on by default
1012

1113
error[E0004]: non-exhaustive patterns: `&_` not covered

Diff for: tests/ui/consts/const_in_pattern/issue-78057.stderr

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ error: to use a constant of type `Opaque` in a pattern, `Opaque` must be annotat
33
|
44
LL | FOO => {},
55
| ^^^
6+
|
7+
= note: the traits must be derived, manual `impl`s are not sufficient
8+
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
69

710
error: unreachable pattern
811
--> $DIR/issue-78057.rs:14:9

Diff for: tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated wit
33
|
44
LL | BAR_BAZ => panic!(),
55
| ^^^^^^^
6+
|
7+
= note: the traits must be derived, manual `impl`s are not sufficient
8+
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
69

710
error: aborting due to previous error
811

Diff for: tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ error: to use a constant of type `NoPartialEq` in a pattern, `NoPartialEq` must
33
|
44
LL | NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
55
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: the traits must be derived, manual `impl`s are not sufficient
8+
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
69

710
error: aborting due to previous error
811

Diff for: tests/ui/consts/const_in_pattern/reject_non_structural.rs

+22
Original file line numberDiff line numberDiff line change
@@ -39,45 +39,67 @@ fn main() {
3939
const ENUM: Derive<NoDerive> = Derive::Some(NoDerive);
4040
match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
4141
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
42+
//~| NOTE the traits must be derived
43+
//~| NOTE StructuralEq.html for details
4244

4345
const FIELD: OND = TrivialEq(Some(NoDerive)).0;
4446
match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
4547
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
48+
//~| NOTE the traits must be derived
49+
//~| NOTE StructuralEq.html for details
4650

4751
const NO_DERIVE_SOME: OND = Some(NoDerive);
4852
const INDIRECT: OND = NO_DERIVE_SOME;
4953
match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
5054
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
55+
//~| NOTE the traits must be derived
56+
//~| NOTE StructuralEq.html for details
5157

5258
const TUPLE: (OND, OND) = (None, Some(NoDerive));
5359
match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
5460
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
61+
//~| NOTE the traits must be derived
62+
//~| NOTE StructuralEq.html for details
5563

5664
const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND);
5765
match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
5866
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
67+
//~| NOTE the traits must be derived
68+
//~| NOTE StructuralEq.html for details
5969

6070
const ARRAY: [OND; 2] = [None, Some(NoDerive)];
6171
match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
6272
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
73+
//~| NOTE the traits must be derived
74+
//~| NOTE StructuralEq.html for details
6375

6476
const REPEAT: [OND; 2] = [Some(NoDerive); 2];
6577
match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
6678
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
79+
//~| NOTE the traits must be derived
80+
//~| NOTE StructuralEq.html for details
6781
//~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
82+
//~| NOTE the traits must be derived
83+
//~| NOTE StructuralEq.html for details
6884

6985
trait Trait: Sized { const ASSOC: Option<Self>; }
7086
impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
7187
match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
7288
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
89+
//~| NOTE the traits must be derived
90+
//~| NOTE StructuralEq.html for details
7391

7492
const BLOCK: OND = { NoDerive; Some(NoDerive) };
7593
match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
7694
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
95+
//~| NOTE the traits must be derived
96+
//~| NOTE StructuralEq.html for details
7797

7898
const ADDR_OF: &OND = &Some(NoDerive);
7999
match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
80100
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
101+
//~| NOTE the traits must be derived
102+
//~| NOTE StructuralEq.html for details
81103
//~| WARN previously accepted by the compiler but is being phased out
82104
//~| NOTE for more information, see issue #62411
83105
}

0 commit comments

Comments
 (0)