Skip to content

Commit 4c9ac1e

Browse files
committed
Auto merge of #114236 - fee1-dead-contrib:rollup-m92j7q1, r=fee1-dead
Rollup of 3 pull requests Successful merges: - #112151 (Clarify behavior of inclusive bounds in BTreeMap::{lower,upper}_bound) - #113512 (Updated lines doc to include trailing carriage return note) - #114203 (Effects: don't print `host` param in diagnostics) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2e0136a + 7b4bfd6 commit 4c9ac1e

File tree

5 files changed

+52
-13
lines changed

5 files changed

+52
-13
lines changed

Diff for: compiler/rustc_middle/src/ty/print/pretty.rs

+29-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use rustc_hir::LangItem;
1717
use rustc_session::config::TrimmedDefPaths;
1818
use rustc_session::cstore::{ExternCrate, ExternCrateSource};
1919
use rustc_session::Limit;
20+
use rustc_span::sym;
2021
use rustc_span::symbol::{kw, Ident, Symbol};
2122
use rustc_span::FileNameDisplayPreference;
2223
use rustc_target::abi::Size;
@@ -2017,11 +2018,37 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
20172018
) -> Result<Self::Path, Self::Error> {
20182019
self = print_prefix(self)?;
20192020

2020-
if args.first().is_some() {
2021+
let tcx = self.tcx;
2022+
2023+
let args = args.iter().copied();
2024+
2025+
let args: Vec<_> = if !tcx.sess.verbose() {
2026+
// skip host param as those are printed as `~const`
2027+
args.filter(|arg| match arg.unpack() {
2028+
// FIXME(effects) there should be a better way than just matching the name
2029+
GenericArgKind::Const(c)
2030+
if tcx.features().effects
2031+
&& matches!(
2032+
c.kind(),
2033+
ty::ConstKind::Param(ty::ParamConst { name: sym::host, .. })
2034+
) =>
2035+
{
2036+
false
2037+
}
2038+
_ => true,
2039+
})
2040+
.collect()
2041+
} else {
2042+
// If -Zverbose is passed, we should print the host parameter instead
2043+
// of eating it.
2044+
args.collect()
2045+
};
2046+
2047+
if !args.is_empty() {
20212048
if self.in_value {
20222049
write!(self, "::")?;
20232050
}
2024-
self.generic_delimiters(|cx| cx.comma_sep(args.iter().cloned()))
2051+
self.generic_delimiters(|cx| cx.comma_sep(args.into_iter()))
20252052
} else {
20262053
Ok(self)
20272054
}

Diff for: library/alloc/src/collections/btree/map.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2543,6 +2543,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
25432543
/// a.insert(2, "b");
25442544
/// a.insert(3, "c");
25452545
/// a.insert(4, "c");
2546+
/// let cursor = a.lower_bound(Bound::Included(&2));
2547+
/// assert_eq!(cursor.key(), Some(&2));
25462548
/// let cursor = a.lower_bound(Bound::Excluded(&2));
25472549
/// assert_eq!(cursor.key(), Some(&3));
25482550
/// ```
@@ -2582,6 +2584,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
25822584
/// a.insert(2, "b");
25832585
/// a.insert(3, "c");
25842586
/// a.insert(4, "c");
2587+
/// let cursor = a.lower_bound_mut(Bound::Included(&2));
2588+
/// assert_eq!(cursor.key(), Some(&2));
25852589
/// let cursor = a.lower_bound_mut(Bound::Excluded(&2));
25862590
/// assert_eq!(cursor.key(), Some(&3));
25872591
/// ```
@@ -2634,6 +2638,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
26342638
/// a.insert(2, "b");
26352639
/// a.insert(3, "c");
26362640
/// a.insert(4, "c");
2641+
/// let cursor = a.upper_bound(Bound::Included(&3));
2642+
/// assert_eq!(cursor.key(), Some(&3));
26372643
/// let cursor = a.upper_bound(Bound::Excluded(&3));
26382644
/// assert_eq!(cursor.key(), Some(&2));
26392645
/// ```
@@ -2673,6 +2679,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
26732679
/// a.insert(2, "b");
26742680
/// a.insert(3, "c");
26752681
/// a.insert(4, "c");
2682+
/// let cursor = a.upper_bound_mut(Bound::Included(&3));
2683+
/// assert_eq!(cursor.key(), Some(&3));
26762684
/// let cursor = a.upper_bound_mut(Bound::Excluded(&3));
26772685
/// assert_eq!(cursor.key(), Some(&2));
26782686
/// ```

Diff for: library/core/src/str/mod.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,10 @@ impl str {
952952
///
953953
/// Line terminators are not included in the lines returned by the iterator.
954954
///
955+
/// Note that any carriage return (`\r`) not immediately followed by a
956+
/// line feed (`\n`) does not split a line. These carriage returns are
957+
/// thereby included in the produced lines.
958+
///
955959
/// The final line ending is optional. A string that ends with a final line
956960
/// ending will return the same lines as an otherwise identical string
957961
/// without a final line ending.
@@ -961,18 +965,19 @@ impl str {
961965
/// Basic usage:
962966
///
963967
/// ```
964-
/// let text = "foo\r\nbar\n\nbaz\n";
968+
/// let text = "foo\r\nbar\n\nbaz\r";
965969
/// let mut lines = text.lines();
966970
///
967971
/// assert_eq!(Some("foo"), lines.next());
968972
/// assert_eq!(Some("bar"), lines.next());
969973
/// assert_eq!(Some(""), lines.next());
970-
/// assert_eq!(Some("baz"), lines.next());
974+
/// // Trailing carriage return is included in the last line
975+
/// assert_eq!(Some("baz\r"), lines.next());
971976
///
972977
/// assert_eq!(None, lines.next());
973978
/// ```
974979
///
975-
/// The final line ending isn't required:
980+
/// The final line does not require any ending:
976981
///
977982
/// ```
978983
/// let text = "foo\nbar\n\r\nbaz";

Diff for: tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
// known-bug: #110395
2-
#![feature(const_trait_impl)]
1+
#![feature(const_trait_impl, effects)]
32

43
#[const_trait]
54
pub trait Tr {
65
fn a(&self) {}
76

87
fn b(&self) {
98
().a()
10-
//FIXME ~^ ERROR the trait bound
9+
//~^ ERROR the trait bound
1110
}
1211
}
1312

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0015]: cannot call non-const fn `<() as Tr>::a` in constant functions
2-
--> $DIR/default-method-body-is-const-same-trait-ck.rs:9:12
1+
error[E0277]: the trait bound `(): ~const Tr` is not satisfied
2+
--> $DIR/default-method-body-is-const-same-trait-ck.rs:8:12
33
|
44
LL | ().a()
5-
| ^^^
5+
| ^ the trait `~const Tr` is not implemented for `()`
66
|
7-
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
7+
= help: the trait `Tr` is implemented for `()`
88

99
error: aborting due to previous error
1010

11-
For more information about this error, try `rustc --explain E0015`.
11+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)