Skip to content

Commit 268be96

Browse files
committed
Auto merge of rust-lang#99112 - matthiaskrgr:rollup-uv2zk4d, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#99045 (improve print styles) - rust-lang#99086 (Fix display of search result crate filter dropdown) - rust-lang#99100 (Fix binary name in help message for test binaries) - rust-lang#99103 (Avoid some `&str` to `String` conversions) - rust-lang#99109 (fill new tracking issue for `feature(strict_provenance_atomic_ptr)`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4ec97d9 + 509a56f commit 268be96

File tree

17 files changed

+73
-44
lines changed

17 files changed

+73
-44
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -597,16 +597,16 @@ impl UseSpans<'_> {
597597
}
598598

599599
/// Describe the span associated with a use of a place.
600-
pub(super) fn describe(&self) -> String {
600+
pub(super) fn describe(&self) -> &str {
601601
match *self {
602602
UseSpans::ClosureUse { generator_kind, .. } => {
603603
if generator_kind.is_some() {
604-
" in generator".to_string()
604+
" in generator"
605605
} else {
606-
" in closure".to_string()
606+
" in closure"
607607
}
608608
}
609-
_ => String::new(),
609+
_ => "",
610610
}
611611
}
612612

compiler/rustc_middle/src/mir/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1824,12 +1824,10 @@ impl BorrowKind {
18241824
}
18251825
}
18261826

1827-
pub fn describe_mutability(&self) -> String {
1827+
pub fn describe_mutability(&self) -> &str {
18281828
match *self {
1829-
BorrowKind::Shared | BorrowKind::Shallow | BorrowKind::Unique => {
1830-
"immutable".to_string()
1831-
}
1832-
BorrowKind::Mut { .. } => "mutable".to_string(),
1829+
BorrowKind::Shared | BorrowKind::Shallow | BorrowKind::Unique => "immutable",
1830+
BorrowKind::Mut { .. } => "mutable",
18331831
}
18341832
}
18351833
}

compiler/rustc_mir_transform/src/check_packed_ref.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ fn unsafe_derive_on_repr_packed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
3939
let message = if tcx.generics_of(def_id).own_requires_monomorphization() {
4040
"`#[derive]` can't be used on a `#[repr(packed)]` struct with \
4141
type or const parameters (error E0133)"
42-
.to_string()
4342
} else {
4443
"`#[derive]` can't be used on a `#[repr(packed)]` struct that \
4544
does not derive Copy (error E0133)"
46-
.to_string()
4745
};
48-
lint.build(&message).emit();
46+
lint.build(message).emit();
4947
});
5048
}
5149

compiler/rustc_resolve/src/diagnostics.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -943,10 +943,7 @@ impl<'a> Resolver<'a> {
943943
"generic parameters with a default cannot use \
944944
forward declared identifiers"
945945
);
946-
err.span_label(
947-
span,
948-
"defaulted generic parameters cannot be forward declared".to_string(),
949-
);
946+
err.span_label(span, "defaulted generic parameters cannot be forward declared");
950947
err
951948
}
952949
ResolutionError::ParamInTyOfConstParam(name) => {

compiler/rustc_resolve/src/late/diagnostics.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
349349

350350
err.code(rustc_errors::error_code!(E0424));
351351
err.span_label(span, match source {
352-
PathSource::Pat => "`self` value is a keyword and may not be bound to variables or shadowed"
353-
.to_string(),
354-
_ => "`self` value is a keyword only available in methods with a `self` parameter"
355-
.to_string(),
352+
PathSource::Pat => "`self` value is a keyword and may not be bound to variables or shadowed",
353+
_ => "`self` value is a keyword only available in methods with a `self` parameter",
356354
});
357355
if let Some((fn_kind, span)) = &self.diagnostic_metadata.current_function {
358356
// The current function has a `self' parameter, but we were unable to resolve

compiler/rustc_span/src/hygiene.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,7 @@ pub fn debug_hygiene_data(verbose: bool) -> String {
629629
if verbose {
630630
format!("{:#?}", data)
631631
} else {
632-
let mut s = String::from("");
633-
s.push_str("Expansions:");
632+
let mut s = String::from("Expansions:");
634633
let mut debug_expn_data = |(id, expn_data): (&ExpnId, &ExpnData)| {
635634
s.push_str(&format!(
636635
"\n{:?}: parent: {:?}, call_site_ctxt: {:?}, def_site_ctxt: {:?}, kind: {:?}",

compiler/rustc_trait_selection/src/traits/specialize/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ fn report_conflicting_impls(
406406
let mut err = err.build(&msg);
407407
match tcx.span_of_impl(overlap.with_impl) {
408408
Ok(span) => {
409-
err.span_label(span, "first implementation here".to_string());
409+
err.span_label(span, "first implementation here");
410410

411411
err.span_label(
412412
impl_span,

compiler/rustc_typeck/src/check/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
263263
} else if let ExprKind::Block(block, _) = &then_expr.kind
264264
&& let Some(expr) = &block.expr
265265
{
266-
err.span_label(expr.span, "found here".to_string());
266+
err.span_label(expr.span, "found here");
267267
}
268268
err.note("`if` expressions without `else` evaluate to `()`");
269269
err.help("consider adding an `else` block that evaluates to the expected type");

compiler/rustc_typeck/src/check/demand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
317317
.tcx
318318
.is_diagnostic_item(sym::Result, expected_adt.did())
319319
{
320-
vec!["Ok(())".to_string()]
320+
vec!["Ok(())"]
321321
} else if self.tcx.is_diagnostic_item(sym::Option, expected_adt.did()) {
322-
vec!["None".to_string(), "Some(())".to_string()]
322+
vec!["None", "Some(())"]
323323
} else {
324324
return;
325325
};

compiler/rustc_typeck/src/check/op.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
565565
.is_ok()
566566
{
567567
let (variable_snippet, applicability) = if !fn_sig.inputs().is_empty() {
568-
("( /* arguments */ )".to_string(), Applicability::HasPlaceholders)
568+
("( /* arguments */ )", Applicability::HasPlaceholders)
569569
} else {
570-
("()".to_string(), Applicability::MaybeIncorrect)
570+
("()", Applicability::MaybeIncorrect)
571571
};
572572

573573
err.span_suggestion_verbose(

compiler/rustc_typeck/src/hir_wf_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn diagnostic_hir_wf_check<'tcx>(
8686

8787
let errors = fulfill.select_all_or_error(&infcx);
8888
if !errors.is_empty() {
89-
tracing::debug!("Wf-check got errors for {:?}: {:?}", ty, errors);
89+
debug!("Wf-check got errors for {:?}: {:?}", ty, errors);
9090
for error in errors {
9191
if error.obligation.predicate == self.predicate {
9292
// Save the cause from the greatest depth - this corresponds

compiler/rustc_typeck/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
252252
let mut diag =
253253
struct_span_err!(tcx.sess, generics_param_span.unwrap_or(main_span), E0131, "{}", msg);
254254
if let Some(generics_param_span) = generics_param_span {
255-
let label = "`main` cannot have generic parameters".to_string();
255+
let label = "`main` cannot have generic parameters";
256256
diag.span_label(generics_param_span, label);
257257
}
258258
diag.emit();
@@ -307,8 +307,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
307307
let return_ty_span = main_fn_return_type_span(tcx, main_def_id).unwrap_or(main_span);
308308
if !return_ty.bound_vars().is_empty() {
309309
let msg = "`main` function return type is not allowed to have generic \
310-
parameters"
311-
.to_owned();
310+
parameters";
312311
struct_span_err!(tcx.sess, return_ty_span, E0131, "{}", msg).emit();
313312
error = true;
314313
}

compiler/rustc_typeck/src/structured_errors/wrong_number_of_generic_args.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
126126
}
127127
}
128128

129-
fn kind(&self) -> String {
130-
if self.missing_lifetimes() { "lifetime".to_string() } else { "generic".to_string() }
129+
fn kind(&self) -> &str {
130+
if self.missing_lifetimes() { "lifetime" } else { "generic" }
131131
}
132132

133133
fn num_provided_args(&self) -> usize {

library/core/src/sync/atomic.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ impl<T> AtomicPtr<T> {
14871487
/// ```
14881488
#[inline]
14891489
#[cfg(target_has_atomic = "ptr")]
1490-
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "95228")]
1490+
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "99108")]
14911491
pub fn fetch_ptr_add(&self, val: usize, order: Ordering) -> *mut T {
14921492
self.fetch_byte_add(val.wrapping_mul(core::mem::size_of::<T>()), order)
14931493
}
@@ -1531,7 +1531,7 @@ impl<T> AtomicPtr<T> {
15311531
/// ```
15321532
#[inline]
15331533
#[cfg(target_has_atomic = "ptr")]
1534-
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "95228")]
1534+
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "99108")]
15351535
pub fn fetch_ptr_sub(&self, val: usize, order: Ordering) -> *mut T {
15361536
self.fetch_byte_sub(val.wrapping_mul(core::mem::size_of::<T>()), order)
15371537
}
@@ -1566,7 +1566,7 @@ impl<T> AtomicPtr<T> {
15661566
/// ```
15671567
#[inline]
15681568
#[cfg(target_has_atomic = "ptr")]
1569-
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "95228")]
1569+
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "99108")]
15701570
pub fn fetch_byte_add(&self, val: usize, order: Ordering) -> *mut T {
15711571
#[cfg(not(bootstrap))]
15721572
// SAFETY: data races are prevented by atomic intrinsics.
@@ -1609,7 +1609,7 @@ impl<T> AtomicPtr<T> {
16091609
/// ```
16101610
#[inline]
16111611
#[cfg(target_has_atomic = "ptr")]
1612-
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "95228")]
1612+
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "99108")]
16131613
pub fn fetch_byte_sub(&self, val: usize, order: Ordering) -> *mut T {
16141614
#[cfg(not(bootstrap))]
16151615
// SAFETY: data races are prevented by atomic intrinsics.
@@ -1667,7 +1667,7 @@ impl<T> AtomicPtr<T> {
16671667
/// ```
16681668
#[inline]
16691669
#[cfg(target_has_atomic = "ptr")]
1670-
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "95228")]
1670+
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "99108")]
16711671
pub fn fetch_or(&self, val: usize, order: Ordering) -> *mut T {
16721672
#[cfg(not(bootstrap))]
16731673
// SAFETY: data races are prevented by atomic intrinsics.
@@ -1724,7 +1724,7 @@ impl<T> AtomicPtr<T> {
17241724
/// ```
17251725
#[inline]
17261726
#[cfg(target_has_atomic = "ptr")]
1727-
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "95228")]
1727+
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "99108")]
17281728
pub fn fetch_and(&self, val: usize, order: Ordering) -> *mut T {
17291729
#[cfg(not(bootstrap))]
17301730
// SAFETY: data races are prevented by atomic intrinsics.
@@ -1779,7 +1779,7 @@ impl<T> AtomicPtr<T> {
17791779
/// ```
17801780
#[inline]
17811781
#[cfg(target_has_atomic = "ptr")]
1782-
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "95228")]
1782+
#[unstable(feature = "strict_provenance_atomic_ptr", issue = "99108")]
17831783
pub fn fetch_xor(&self, val: usize, order: Ordering) -> *mut T {
17841784
#[cfg(not(bootstrap))]
17851785
// SAFETY: data races are prevented by atomic intrinsics.

library/test/src/cli.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ Test Attributes:
196196
pub fn parse_opts(args: &[String]) -> Option<OptRes> {
197197
// Parse matches.
198198
let opts = optgroups();
199+
let binary = args.get(0).map(|c| &**c).unwrap_or("...");
199200
let args = args.get(1..).unwrap_or(args);
200201
let matches = match opts.parse(args) {
201202
Ok(m) => m,
@@ -205,7 +206,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
205206
// Check if help was requested.
206207
if matches.opt_present("h") {
207208
// Show help and do nothing more.
208-
usage(&args[0], &opts);
209+
usage(binary, &opts);
209210
return None;
210211
}
211212

src/librustdoc/html/static/css/rustdoc.css

+13-2
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,6 @@ table,
924924
#crate-search {
925925
min-width: 115px;
926926
margin-top: 5px;
927-
margin-left: 0.25em;
928927
padding-left: 0.3125em;
929928
padding-right: 23px;
930929
border: 1px solid;
@@ -941,6 +940,8 @@ table,
941940
background-size: 20px;
942941
background-position: calc(100% - 1px) 56%;
943942
background-image: /* AUTOREPLACE: */url("down-arrow.svg");
943+
max-width: 100%;
944+
text-overflow: ellipsis;
944945
}
945946
.search-container {
946947
margin-top: 4px;
@@ -2056,9 +2057,19 @@ in storage.js plus the media query with (min-width: 701px)
20562057
}
20572058

20582059
@media print {
2059-
nav.sub, .content .out-of-band {
2060+
nav.sidebar, nav.sub, .content .out-of-band, a.srclink, #copy-path,
2061+
details.rustdoc-toggle[open] > summary::before, details.rustdoc-toggle > summary::before,
2062+
details.rustdoc-toggle.top-doc > summary {
20602063
display: none;
20612064
}
2065+
2066+
.docblock {
2067+
margin-left: 0;
2068+
}
2069+
2070+
main {
2071+
padding: 10px;
2072+
}
20622073
}
20632074

20642075
@media (max-width: 464px) {

src/test/rustdoc-gui/search-result-display.goml

+28
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,31 @@ size: (600, 100)
1010
// As counter-intuitive as it may seem, in this width, the width is "100%", which is why
1111
// when computed it's larger.
1212
assert-css: (".search-results div.desc", {"width": "570px"})
13+
14+
// Check that the crate filter `<select>` is correctly handled when it goes to next line.
15+
// To do so we need to update the length of one of its `<option>`.
16+
size: (900, 900)
17+
18+
// First we check the current width and position.
19+
assert-css: ("#crate-search", {"width": "222px"})
20+
compare-elements-position-near: (
21+
"#crate-search",
22+
"#search-settings .search-results-title",
23+
{"y": 5},
24+
)
25+
26+
// Then we update the text of one of the `<option>`.
27+
text: (
28+
"#crate-search option",
29+
"sdjfaksdjfaksjdbfkadsbfkjsadbfkdsbkfbsadkjfbkdsabfkadsfkjdsafa",
30+
)
31+
32+
// Then we compare again.
33+
assert-css: ("#crate-search", {"width": "640px"})
34+
compare-elements-position-near-false: (
35+
"#crate-search",
36+
"#search-settings .search-results-title",
37+
{"y": 5},
38+
)
39+
// And we check that the `<select>` isn't bigger than its container.
40+
assert-css: ("#search", {"width": "640px"})

0 commit comments

Comments
 (0)