Skip to content

Commit a50d721

Browse files
committed
Auto merge of #86127 - JohnTitor:rollup-0c6mp3j, r=JohnTitor
Rollup of 11 pull requests Successful merges: - #85906 (Use `Iterator::find` instead of open-coding it) - #85951 (Update the documentation of `-C force-unwind-tables` for #83482) - #85985 (Clarify documentation of slice sorting methods) - #85989 (Remove rustfmt tests from top-level .gitattributes) - #86074 (Default panic message should print Box<dyn Any>) - #86078 (Type page font weight) - #86090 (:arrow_up: rust-analyzer) - #86095 (Search description codeblock) - #86096 (Comment out unused error codes and add description for E0316) - #86101 (Correct type signature in doc for Bound::as_mut) - #86103 (Remove lifetime hack) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 376ec94 + b7fadfd commit a50d721

File tree

19 files changed

+88
-60
lines changed

19 files changed

+88
-60
lines changed

.gitattributes

-8
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,3 @@ config.toml.example linguist-language=TOML
1616
*.ico binary
1717
*.woff binary
1818
*.woff2 binary
19-
20-
# Needed as part of converting rustfmt to a subtree, can hopefully be removed later.
21-
src/tools/rustfmt/tests/source/issue-3494/crlf.rs -text
22-
src/tools/rustfmt/tests/source/comment_crlf_newline.rs -text
23-
src/tools/rustfmt/tests/source/configs/enum_discrim_align_threshold/40.rs -text
24-
src/tools/rustfmt/tests/target/issue-3494/crlf.rs -text
25-
src/tools/rustfmt/tests/target/comment_crlf_newline.rs -text
26-
src/tools/rustfmt/tests/target/configs/enum_discrim_align_threshold/40.rs -text

compiler/rustc_error_codes/src/error_codes.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ E0308: include_str!("./error_codes/E0308.md"),
157157
E0309: include_str!("./error_codes/E0309.md"),
158158
E0310: include_str!("./error_codes/E0310.md"),
159159
E0312: include_str!("./error_codes/E0312.md"),
160+
E0316: include_str!("./error_codes/E0316.md"),
160161
E0317: include_str!("./error_codes/E0317.md"),
161162
E0321: include_str!("./error_codes/E0321.md"),
162163
E0322: include_str!("./error_codes/E0322.md"),
@@ -553,9 +554,8 @@ E0783: include_str!("./error_codes/E0783.md"),
553554
E0311, // thing may not live long enough
554555
E0313, // lifetime of borrowed pointer outlives lifetime of captured
555556
// variable
556-
E0314, // closure outlives stack frame
557-
E0315, // cannot invoke closure outside of its lifetime
558-
E0316, // nested quantification of lifetimes
557+
// E0314, // closure outlives stack frame
558+
// E0315, // cannot invoke closure outside of its lifetime
559559
// E0319, // trait impls for defaulted traits allowed just for structs/enums
560560
E0320, // recursive overflow during dropck
561561
// E0372, // coherence not object safe
@@ -584,21 +584,21 @@ E0783: include_str!("./error_codes/E0783.md"),
584584
// E0470, removed
585585
// E0471, // constant evaluation error (in pattern)
586586
E0472, // llvm_asm! is unsupported on this target
587-
E0473, // dereference of reference outside its lifetime
588-
E0474, // captured variable `..` does not outlive the enclosing closure
589-
E0475, // index of slice outside its lifetime
587+
// E0473, // dereference of reference outside its lifetime
588+
// E0474, // captured variable `..` does not outlive the enclosing closure
589+
// E0475, // index of slice outside its lifetime
590590
E0476, // lifetime of the source pointer does not outlive lifetime bound...
591-
E0479, // the type `..` (provided as the value of a type parameter) is...
592-
E0480, // lifetime of method receiver does not outlive the method call
593-
E0481, // lifetime of function argument does not outlive the function call
591+
// E0479, // the type `..` (provided as the value of a type parameter) is...
592+
// E0480, // lifetime of method receiver does not outlive the method call
593+
// E0481, // lifetime of function argument does not outlive the function call
594594
E0482, // lifetime of return value does not outlive the function call
595-
E0483, // lifetime of operand does not outlive the operation
596-
E0484, // reference is not valid at the time of borrow
597-
E0485, // automatically reference is not valid at the time of borrow
598-
E0486, // type of expression contains references that are not valid during..
599-
E0487, // unsafe use of destructor: destructor might be called while...
600-
E0488, // lifetime of variable does not enclose its declaration
601-
E0489, // type/lifetime parameter not in scope here
595+
// E0483, // lifetime of operand does not outlive the operation
596+
// E0484, // reference is not valid at the time of borrow
597+
// E0485, // automatically reference is not valid at the time of borrow
598+
// E0486, // type of expression contains references that are not valid during..
599+
// E0487, // unsafe use of destructor: destructor might be called while...
600+
// E0488, // lifetime of variable does not enclose its declaration
601+
// E0489, // type/lifetime parameter not in scope here
602602
E0490, // a value of type `..` is borrowed for too long
603603
E0498, // malformed plugin attribute
604604
E0514, // metadata version mismatch
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
A `where` clause contains a nested quantification over lifetimes.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0316
6+
trait Tr<'a, 'b> {}
7+
8+
fn foo<T>(t: T)
9+
where
10+
for<'a> &'a T: for<'b> Tr<'a, 'b>, // error: nested quantification
11+
{
12+
}
13+
```
14+
15+
Rust syntax allows lifetime quantifications in two places within
16+
`where` clauses: Quantifying over the trait bound only (as in
17+
`Ty: for<'l> Trait<'l>`) and quantifying over the whole clause
18+
(as in `for<'l> &'l Ty: Trait<'l>`). Using both in the same clause
19+
leads to a nested lifetime quantification, which is not supported.
20+
21+
The following example compiles, because the clause with the nested
22+
quantification has been rewritten to use only one `for<>`:
23+
24+
```
25+
trait Tr<'a, 'b> {}
26+
27+
fn foo<T>(t: T)
28+
where
29+
for<'a, 'b> &'a T: Tr<'a, 'b>, // ok
30+
{
31+
}
32+
```

compiler/rustc_lint/src/types.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -679,16 +679,11 @@ pub fn transparent_newtype_field<'a, 'tcx>(
679679
variant: &'a ty::VariantDef,
680680
) -> Option<&'a ty::FieldDef> {
681681
let param_env = tcx.param_env(variant.def_id);
682-
for field in &variant.fields {
682+
variant.fields.iter().find(|field| {
683683
let field_ty = tcx.type_of(field.did);
684684
let is_zst = tcx.layout_of(param_env.and(field_ty)).map_or(false, |layout| layout.is_zst());
685-
686-
if !is_zst {
687-
return Some(field);
688-
}
689-
}
690-
691-
None
685+
!is_zst
686+
})
692687
}
693688

694689
/// Is type known to be non-null?

compiler/rustc_resolve/src/late/lifetimes.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -1841,14 +1841,6 @@ fn object_lifetime_defaults_for_item(
18411841
}
18421842

18431843
impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1844-
// FIXME(#37666) this works around a limitation in the region inferencer
1845-
fn hack<F>(&mut self, f: F)
1846-
where
1847-
F: for<'b> FnOnce(&mut LifetimeContext<'b, 'tcx>),
1848-
{
1849-
f(self)
1850-
}
1851-
18521844
fn with<F>(&mut self, wrap_scope: Scope<'_>, f: F)
18531845
where
18541846
F: for<'b> FnOnce(ScopeRef<'_>, &mut LifetimeContext<'b, 'tcx>),
@@ -2252,7 +2244,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
22522244
};
22532245
self.with(scope, move |old_scope, this| {
22542246
this.check_lifetime_params(old_scope, &generics.params);
2255-
this.hack(walk); // FIXME(#37666) workaround in place of `walk(this)`
2247+
walk(this);
22562248
});
22572249
}
22582250

library/core/src/ops/range.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ impl<T> Bound<T> {
686686
}
687687
}
688688

689-
/// Converts from `&mut Bound<T>` to `Bound<&T>`.
689+
/// Converts from `&mut Bound<T>` to `Bound<&mut T>`.
690690
#[inline]
691691
#[unstable(feature = "bound_as_ref", issue = "80996")]
692692
pub fn as_mut(&mut self) -> Bound<&mut T> {

library/core/src/slice/mod.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -2100,9 +2100,11 @@ impl<T> [T] {
21002100
///
21012101
/// If the value is found then [`Result::Ok`] is returned, containing the
21022102
/// index of the matching element. If there are multiple matches, then any
2103-
/// one of the matches could be returned. If the value is not found then
2104-
/// [`Result::Err`] is returned, containing the index where a matching
2105-
/// element could be inserted while maintaining sorted order.
2103+
/// one of the matches could be returned. The index is chosen
2104+
/// deterministically, but is subject to change in future versions of Rust.
2105+
/// If the value is not found then [`Result::Err`] is returned, containing
2106+
/// the index where a matching element could be inserted while maintaining
2107+
/// sorted order.
21062108
///
21072109
/// See also [`binary_search_by`], [`binary_search_by_key`], and [`partition_point`].
21082110
///
@@ -2153,9 +2155,11 @@ impl<T> [T] {
21532155
///
21542156
/// If the value is found then [`Result::Ok`] is returned, containing the
21552157
/// index of the matching element. If there are multiple matches, then any
2156-
/// one of the matches could be returned. If the value is not found then
2157-
/// [`Result::Err`] is returned, containing the index where a matching
2158-
/// element could be inserted while maintaining sorted order.
2158+
/// one of the matches could be returned. The index is chosen
2159+
/// deterministically, but is subject to change in future versions of Rust.
2160+
/// If the value is not found then [`Result::Err`] is returned, containing
2161+
/// the index where a matching element could be inserted while maintaining
2162+
/// sorted order.
21592163
///
21602164
/// See also [`binary_search`], [`binary_search_by_key`], and [`partition_point`].
21612165
///
@@ -2224,9 +2228,11 @@ impl<T> [T] {
22242228
///
22252229
/// If the value is found then [`Result::Ok`] is returned, containing the
22262230
/// index of the matching element. If there are multiple matches, then any
2227-
/// one of the matches could be returned. If the value is not found then
2228-
/// [`Result::Err`] is returned, containing the index where a matching
2229-
/// element could be inserted while maintaining sorted order.
2231+
/// one of the matches could be returned. The index is chosen
2232+
/// deterministically, but is subject to change in future versions of Rust.
2233+
/// If the value is not found then [`Result::Err`] is returned, containing
2234+
/// the index where a matching element could be inserted while maintaining
2235+
/// sorted order.
22302236
///
22312237
/// See also [`binary_search`], [`binary_search_by`], and [`partition_point`].
22322238
///

library/std/src/panicking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn default_hook(info: &PanicInfo<'_>) {
193193
Some(s) => *s,
194194
None => match info.payload().downcast_ref::<String>() {
195195
Some(s) => &s[..],
196-
None => "Box<Any>",
196+
None => "Box<dyn Any>",
197197
},
198198
};
199199
let thread = thread_info::current_thread();

src/doc/rustc/src/codegen-options/index.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ values:
149149

150150
* `y`, `yes`, `on`, or no value: Unwind tables are forced to be generated.
151151
* `n`, `no`, or `off`: Unwind tables are not forced to be generated. If unwind
152-
tables are required by the target or `-C panic=unwind`, an error will be
153-
emitted.
152+
tables are required by the target an error will be emitted.
154153

155154
The default if not specified depends on the target.
156155

src/librustdoc/html/static/rustdoc.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ h2, h3, h4 {
138138
border-bottom: 1px solid;
139139
}
140140
.impl, .method,
141-
.type, .associatedconstant,
141+
.type:not(.container-rustdoc), .associatedconstant,
142142
.associatedtype {
143143
flex-basis: 100%;
144144
font-weight: 600;

src/librustdoc/html/static/search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ window.initSearch = function(rawSearchIndex) {
10241024
var description = document.createElement("div");
10251025
description.className = "desc";
10261026
var spanDesc = document.createElement("span");
1027-
spanDesc.innerText = item.desc + "\u00A0";
1027+
spanDesc.insertAdjacentHTML("beforeend", item.desc);
10281028

10291029
description.appendChild(spanDesc);
10301030
wrapper.appendChild(description);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This test is to ensure that the codeblocks are correctly rendered in the search results.
2+
goto: file://|DOC_PATH|/test_docs/index.html?search=some_more_function
3+
// Waiting for the search results to appear...
4+
wait-for: "#titles"
5+
assert: (".search-results .desc code", "format!")

src/test/rustdoc-gui/sidebar.goml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ assert: (".sidebar-elems > .items > ul > li:nth-child(2)", "Structs")
1111
assert: (".sidebar-elems > .items > ul > li:nth-child(3)", "Enums")
1212
assert: (".sidebar-elems > .items > ul > li:nth-child(4)", "Traits")
1313
assert: (".sidebar-elems > .items > ul > li:nth-child(5)", "Functions")
14-
assert: (".sidebar-elems > .items > ul > li:nth-child(6)", "Keywords")
14+
assert: (".sidebar-elems > .items > ul > li:nth-child(6)", "Type Definitions")
15+
assert: (".sidebar-elems > .items > ul > li:nth-child(7)", "Keywords")
1516
assert: ("#structs + table td > a", "Foo")
1617
click: "#structs + table td > a"
1718

src/test/rustdoc-gui/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,6 @@ pub enum AnEnum {
9696

9797
#[doc(keyword = "CookieMonster")]
9898
pub mod keyword {}
99+
100+
/// Just some type alias.
101+
pub type SomeType = u32;

src/test/rustdoc-gui/type-weight.rs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
goto: file://|DOC_PATH|/test_docs/type.SomeType.html
2+
assert-all: (".top-block .docblock p", {"font-weight": "400"})

src/test/ui/panics/panic-macro-any-wrapped.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-fail
2-
// error-pattern:panicked at 'Box<Any>'
2+
// error-pattern:panicked at 'Box<dyn Any>'
33
// ignore-emscripten no processes
44

55
#![allow(non_fmt_panic)]

src/test/ui/panics/panic-macro-any.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-fail
2-
// error-pattern:panicked at 'Box<Any>'
2+
// error-pattern:panicked at 'Box<dyn Any>'
33
// ignore-emscripten no processes
44

55
#![feature(box_syntax)]

src/test/ui/where-clauses/where-for-self.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | where for<'a> &'a T: for<'b> Bar<'b>
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0316`.

src/tools/rust-analyzer

0 commit comments

Comments
 (0)