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

File tree

44 files changed

+215
-41
lines changed

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

compiler/rustc_error_codes/src/error_codes/E0223.md

Lines changed: 15 additions & 13 deletions
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`.

compiler/rustc_interface/src/util.rs

Lines changed: 1 addition & 1 deletion
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,

compiler/rustc_mir_build/messages.ftl

Lines changed: 4 additions & 0 deletions
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

compiler/rustc_mir_build/src/errors.rs

Lines changed: 6 additions & 0 deletions
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
}

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 1 addition & 2 deletions
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
});

library/core/src/ffi/c_str.rs

Lines changed: 5 additions & 0 deletions
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

library/std/src/io/stdio.rs

Lines changed: 9 additions & 0 deletions
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

src/bootstrap/doc.rs

Lines changed: 5 additions & 4 deletions
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.

src/doc/nomicon

0 commit comments

Comments
 (0)