Skip to content

Commit 5eccfc3

Browse files
committed
Auto merge of rust-lang#119256 - matthiaskrgr:rollup-q0q5c1d, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#119231 (Clairify `ast::PatKind::Struct` presese of `..` by using an enum instead of a bool) - rust-lang#119232 (Fix doc typos) - rust-lang#119245 (Improve documentation for using warning blocks in documentation) - rust-lang#119248 (remove dead inferred outlives testing code) - rust-lang#119249 (Add spastorino to users_on_vacation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents edcbcc7 + 2e09941 commit 5eccfc3

File tree

18 files changed

+74
-55
lines changed

18 files changed

+74
-55
lines changed

compiler/rustc_ast/src/ast.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,7 @@ pub enum PatKind {
754754
Ident(BindingAnnotation, Ident, Option<P<Pat>>),
755755

756756
/// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).
757-
/// The `bool` is `true` in the presence of a `..`.
758-
Struct(Option<P<QSelf>>, Path, ThinVec<PatField>, /* recovered */ bool),
757+
Struct(Option<P<QSelf>>, Path, ThinVec<PatField>, PatFieldsRest),
759758

760759
/// A tuple struct/variant pattern (`Variant(x, y, .., z)`).
761760
TupleStruct(Option<P<QSelf>>, Path, ThinVec<P<Pat>>),
@@ -812,6 +811,15 @@ pub enum PatKind {
812811
MacCall(P<MacCall>),
813812
}
814813

814+
/// Whether the `..` is present in a struct fields pattern.
815+
#[derive(Clone, Copy, Encodable, Decodable, Debug, PartialEq)]
816+
pub enum PatFieldsRest {
817+
/// `module::StructName { field, ..}`
818+
Rest,
819+
/// `module::StructName { field }`
820+
None,
821+
}
822+
815823
/// The kind of borrow in an `AddrOf` expression,
816824
/// e.g., `&place` or `&raw const place`.
817825
#[derive(Clone, Copy, PartialEq, Eq, Debug)]

compiler/rustc_ast_lowering/src/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
8282
span: self.lower_span(f.span),
8383
}
8484
}));
85-
break hir::PatKind::Struct(qpath, fs, *etc);
85+
break hir::PatKind::Struct(qpath, fs, *etc == ast::PatFieldsRest::Rest);
8686
}
8787
PatKind::Tuple(pats) => {
8888
let (pats, ddpos) = self.lower_pat_tuple(pats, "tuple");

compiler/rustc_ast_pretty/src/pprust/state.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ impl<'a> State<'a> {
14271427
}
14281428
self.nbsp();
14291429
self.word("{");
1430-
let empty = fields.is_empty() && !etc;
1430+
let empty = fields.is_empty() && *etc == ast::PatFieldsRest::None;
14311431
if !empty {
14321432
self.space();
14331433
}
@@ -1445,7 +1445,7 @@ impl<'a> State<'a> {
14451445
},
14461446
|f| f.pat.span,
14471447
);
1448-
if *etc {
1448+
if *etc == ast::PatFieldsRest::Rest {
14491449
if !fields.is_empty() {
14501450
self.word_space(",");
14511451
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
#### This error code is internal to the compiler and will not be emitted with normal Rust code.
2+
#### Note: this error code is no longer emitted by the compiler.

compiler/rustc_expand/src/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ impl<'a> ExtCtxt<'a> {
491491
path: ast::Path,
492492
field_pats: ThinVec<ast::PatField>,
493493
) -> P<ast::Pat> {
494-
self.pat(span, PatKind::Struct(None, path, field_pats, false))
494+
self.pat(span, PatKind::Struct(None, path, field_pats, ast::PatFieldsRest::None))
495495
}
496496
pub fn pat_tuple(&self, span: Span, pats: ThinVec<P<ast::Pat>>) -> P<ast::Pat> {
497497
self.pat(span, PatKind::Tuple(pats))

compiler/rustc_hir_analysis/src/outlives/mod.rs

-20
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rustc_hir::def_id::LocalDefId;
44
use rustc_middle::query::Providers;
55
use rustc_middle::ty::GenericArgKind;
66
use rustc_middle::ty::{self, CratePredicatesMap, ToPredicate, TyCtxt};
7-
use rustc_span::symbol::sym;
87
use rustc_span::Span;
98

109
mod explicit;
@@ -49,25 +48,6 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clau
4948
let predicates =
5049
crate_map.predicates.get(&item_def_id.to_def_id()).copied().unwrap_or(&[]);
5150

52-
if tcx.has_attr(item_def_id, sym::rustc_outlives) {
53-
let mut pred: Vec<String> = predicates
54-
.iter()
55-
.map(|(out_pred, _)| match out_pred.kind().skip_binder() {
56-
ty::ClauseKind::RegionOutlives(p) => p.to_string(),
57-
ty::ClauseKind::TypeOutlives(p) => p.to_string(),
58-
err => bug!("unexpected clause {:?}", err),
59-
})
60-
.collect();
61-
pred.sort();
62-
63-
let span = tcx.def_span(item_def_id);
64-
let mut err = tcx.sess.struct_span_err(span, "rustc_outlives");
65-
for p in pred {
66-
err.note(p);
67-
}
68-
err.emit();
69-
}
70-
7151
debug!("inferred_outlives_of({:?}) = {:?}", item_def_id, predicates);
7252

7353
predicates
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
use rustc_errors::struct_span_err;
2-
use rustc_middle::ty::TyCtxt;
1+
use rustc_middle::ty::{self, TyCtxt};
32
use rustc_span::symbol::sym;
43

54
pub fn test_inferred_outlives(tcx: TyCtxt<'_>) {
65
for id in tcx.hir().items() {
76
// For unit testing: check for a special "rustc_outlives"
87
// attribute and report an error with various results if found.
98
if tcx.has_attr(id.owner_id, sym::rustc_outlives) {
10-
let inferred_outlives_of = tcx.inferred_outlives_of(id.owner_id);
11-
struct_span_err!(
12-
tcx.sess,
13-
tcx.def_span(id.owner_id),
14-
E0640,
15-
"{:?}",
16-
inferred_outlives_of
17-
)
18-
.emit();
9+
let predicates = tcx.inferred_outlives_of(id.owner_id);
10+
let mut pred: Vec<String> = predicates
11+
.iter()
12+
.map(|(out_pred, _)| match out_pred.kind().skip_binder() {
13+
ty::ClauseKind::RegionOutlives(p) => p.to_string(),
14+
ty::ClauseKind::TypeOutlives(p) => p.to_string(),
15+
err => bug!("unexpected clause {:?}", err),
16+
})
17+
.collect();
18+
pred.sort();
19+
20+
let span = tcx.def_span(id.owner_id);
21+
let mut err = tcx.sess.struct_span_err(span, "rustc_outlives");
22+
for p in pred {
23+
err.note(p);
24+
}
25+
err.emit();
1926
}
2027
}
2128
}

compiler/rustc_parse/src/parser/pat.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_ast::ptr::P;
1515
use rustc_ast::token::{self, Delimiter};
1616
use rustc_ast::{
1717
self as ast, AttrVec, BindingAnnotation, ByRef, Expr, ExprKind, MacCall, Mutability, Pat,
18-
PatField, PatKind, Path, QSelf, RangeEnd, RangeSyntax,
18+
PatField, PatFieldsRest, PatKind, Path, QSelf, RangeEnd, RangeSyntax,
1919
};
2020
use rustc_ast_pretty::pprust;
2121
use rustc_errors::{Applicability, DiagnosticBuilder, PResult};
@@ -891,7 +891,8 @@ impl<'a> Parser<'a> {
891891
e.span_label(path.span, "while parsing the fields for this pattern");
892892
e.emit();
893893
self.recover_stmt();
894-
(ThinVec::new(), true)
894+
// When recovering, pretend we had `Foo { .. }`, to avoid cascading errors.
895+
(ThinVec::new(), PatFieldsRest::Rest)
895896
});
896897
self.bump();
897898
Ok(PatKind::Struct(qself, path, fields, etc))
@@ -965,9 +966,9 @@ impl<'a> Parser<'a> {
965966
}
966967

967968
/// Parses the fields of a struct-like pattern.
968-
fn parse_pat_fields(&mut self) -> PResult<'a, (ThinVec<PatField>, bool)> {
969+
fn parse_pat_fields(&mut self) -> PResult<'a, (ThinVec<PatField>, PatFieldsRest)> {
969970
let mut fields = ThinVec::new();
970-
let mut etc = false;
971+
let mut etc = PatFieldsRest::None;
971972
let mut ate_comma = true;
972973
let mut delayed_err: Option<DiagnosticBuilder<'a>> = None;
973974
let mut first_etc_and_maybe_comma_span = None;
@@ -1001,7 +1002,7 @@ impl<'a> Parser<'a> {
10011002
|| self.check_noexpect(&token::DotDotDot)
10021003
|| self.check_keyword(kw::Underscore)
10031004
{
1004-
etc = true;
1005+
etc = PatFieldsRest::Rest;
10051006
let mut etc_sp = self.token.span;
10061007
if first_etc_and_maybe_comma_span.is_none() {
10071008
if let Some(comma_tok) = self

src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The target intends to match the corresponding Clang target for its `"C"` ABI.
9090
9191
## Platform requirements
9292

93-
The runtime should support the same set of APIs as any other supported wasi target for interacting with the host environment through the WASI standard. The runtime also should have implemetation of [wasi-threads proposal](https://github.com/WebAssembly/wasi-threads).
93+
The runtime should support the same set of APIs as any other supported wasi target for interacting with the host environment through the WASI standard. The runtime also should have implementation of [wasi-threads proposal](https://github.com/WebAssembly/wasi-threads).
9494

9595
This target is not a stable target. This means that there are a few engines
9696
which implement the `wasi-threads` feature and if they do they're likely behind a

src/doc/rustdoc/src/how-to-write-documentation.md

+16
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,22 @@ you can wrap it like this:
267267
/// more documentation
268268
```
269269

270+
Please note that if you want to put markdown in the HTML tag and for it to
271+
be interpreted as such, you need to have an empty line between the HTML tags
272+
and your markdown content. For example if you want to use a link:
273+
274+
```md
275+
/// documentation
276+
///
277+
/// <div class="warning">
278+
///
279+
/// Go to [this link](https://rust-lang.org)!
280+
///
281+
/// </div>
282+
///
283+
/// more documentation
284+
```
285+
270286
[`backtrace`]: https://docs.rs/backtrace/0.3.50/backtrace/
271287
[commonmark markdown specification]: https://commonmark.org/
272288
[commonmark quick reference]: https://commonmark.org/help/

src/doc/rustdoc/src/lints.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,9 @@ warning: 1 warning emitted
415415

416416
## `redundant_explicit_links`
417417

418-
This lint is **warned by default**. It detects explicit links that are same
418+
This lint is **warn-by-default**. It detects explicit links that are the same
419419
as computed automatic links.
420-
This usually means the explicit links is removeable. For example:
420+
This usually means the explicit links are removeable. For example:
421421

422422
```rust
423423
#![warn(rustdoc::redundant_explicit_links)] // note: unnecessary - warns by default.

src/doc/unstable-book/src/compiler-flags/check-cfg.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ fn poke_platypus() {}
107107
fn tame_lion() {}
108108

109109
// This is UNEXPECTED, because 'windows' is a well known condition name,
110-
// and because 'windows' doens't take any values,
110+
// and because 'windows' doesn't take any values,
111111
// and will cause a compiler warning (by default).
112112
#[cfg(windows = "unix")]
113113
fn tame_windows() {}

src/librustdoc/lint.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ declare_rustdoc_lint! {
186186
}
187187

188188
declare_rustdoc_lint! {
189-
/// This lint is **warned by default**. It detects explicit links that are same
190-
/// as computed automatic links. This usually means the explicit links is removeable.
189+
/// This lint is **warn-by-default**. It detects explicit links that are the same
190+
/// as computed automatic links. This usually means the explicit links are removeable.
191191
/// This is a `rustdoc` only lint, see the documentation in the [rustdoc book].
192192
///
193193
/// [rustdoc book]: ../../../rustdoc/lints.html#redundant_explicit_links

src/tools/clippy/clippy_lints/src/unnested_or_patterns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ fn extend_with_struct_pat(
293293
qself1: &Option<P<ast::QSelf>>,
294294
path1: &ast::Path,
295295
fps1: &mut [ast::PatField],
296-
rest1: bool,
296+
rest1: ast::PatFieldsRest,
297297
start: usize,
298298
alternatives: &mut ThinVec<P<Pat>>,
299299
) -> bool {

src/tools/rustfmt/src/patterns.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,15 @@ impl Rewrite for Pat {
259259
None,
260260
None,
261261
),
262-
PatKind::Struct(ref qself, ref path, ref fields, ellipsis) => {
263-
rewrite_struct_pat(qself, path, fields, ellipsis, self.span, context, shape)
264-
}
262+
PatKind::Struct(ref qself, ref path, ref fields, rest) => rewrite_struct_pat(
263+
qself,
264+
path,
265+
fields,
266+
rest == ast::PatFieldsRest::Rest,
267+
self.span,
268+
context,
269+
shape,
270+
),
265271
PatKind::MacCall(ref mac) => {
266272
rewrite_macro(mac, None, context, shape, MacroPosition::Pat)
267273
}

src/tools/tidy/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const ERROR_DOCS_PATH: &str = "compiler/rustc_error_codes/src/error_codes/";
2727
const ERROR_TESTS_PATH: &str = "tests/ui/error-codes/";
2828

2929
// Error codes that (for some reason) can't have a doctest in their explanation. Error codes are still expected to provide a code example, even if untested.
30-
const IGNORE_DOCTEST_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602", "E0640", "E0717"];
30+
const IGNORE_DOCTEST_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602", "E0717"];
3131

3232
// Error codes that don't yet have a UI test. This list will eventually be removed.
3333
const IGNORE_UI_TEST_CHECK: &[&str] =

src/tools/tidy/src/style.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ pub fn check(path: &Path, bad: &mut bool) {
494494
let mut err = |_| {
495495
tidy_error!(bad, "{}: leading newline", file.display());
496496
};
497-
suppressible_tidy_err!(err, skip_leading_newlines, "mising leading newline");
497+
suppressible_tidy_err!(err, skip_leading_newlines, "missing leading newline");
498498
}
499499
let mut err = |msg: &str| {
500500
tidy_error!(bad, "{}: {}", file.display(), msg);

triagebot.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ cc = ["@nnethercote"]
639639
[assign]
640640
warn_non_default_branch = true
641641
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
642-
users_on_vacation = ["jyn514", "oli-obk"]
642+
users_on_vacation = ["jyn514", "oli-obk", "spastorino"]
643643

644644
[assign.adhoc_groups]
645645
compiler-team = [

0 commit comments

Comments
 (0)