Skip to content

Commit 5474218

Browse files
authored
Merge pull request #4952 from RalfJung/rustup
Rustup
2 parents a33321c + 4e6323b commit 5474218

250 files changed

Lines changed: 3659 additions & 2330 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/library_tracking_issue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ It's useful to link any relevant discussions and conclusions (whether on GitHub,
8383
Zulip, or the internals forum) here.
8484
-->
8585

86-
- None yet.
86+
- [ ] None yet.
8787

8888
[^1]: https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

.github/ISSUE_TEMPLATE/tracking_issue.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ for larger features an implementation could be broken up into multiple PRs.
5555
### Unresolved Questions
5656
<!--
5757
Include any open questions that need to be answered before the feature can be
58-
stabilised.
58+
stabilised. It is useful to link related discussions and conculsions as they
59+
develop.
5960
-->
6061

61-
XXX --- list all the "unresolved questions" found in the RFC to ensure they are
62-
not forgotten
62+
- [ ] list all the "unresolved questions" found in the RFC to ensure they are
63+
not forgotten.
6364

6465
### Implementation history
6566

Cargo.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ dependencies = [
6464

6565
[[package]]
6666
name = "annotate-snippets"
67-
version = "0.12.10"
67+
version = "0.12.15"
6868
source = "registry+https://github.com/rust-lang/crates.io-index"
69-
checksum = "15580ece6ea97cbf832d60ba19c021113469480852c6a2a6beb0db28f097bf1f"
69+
checksum = "92570a3f9c98e7e84df84b71d0965ac99b1871fcd75a3773a3bd1bad13f64cf7"
7070
dependencies = [
7171
"anstyle",
7272
"memchr",
@@ -2418,9 +2418,9 @@ dependencies = [
24182418

24192419
[[package]]
24202420
name = "memchr"
2421-
version = "2.7.6"
2421+
version = "2.8.0"
24222422
source = "registry+https://github.com/rust-lang/crates.io-index"
2423-
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
2423+
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
24242424

24252425
[[package]]
24262426
name = "memmap2"
@@ -3905,7 +3905,7 @@ dependencies = [
39053905
name = "rustc_errors"
39063906
version = "0.0.0"
39073907
dependencies = [
3908-
"annotate-snippets 0.12.10",
3908+
"annotate-snippets 0.12.15",
39093909
"anstream",
39103910
"anstyle",
39113911
"derive_setters",

compiler/rustc_ast/src/ast.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3338,7 +3338,7 @@ pub enum UseTreeKind {
33383338
/// ```
33393339
Nested { items: ThinVec<(UseTree, NodeId)>, span: Span },
33403340
/// `use prefix::*`
3341-
Glob,
3341+
Glob(Span),
33423342
}
33433343

33443344
/// A tree of paths sharing common prefixes.
@@ -3347,10 +3347,11 @@ pub enum UseTreeKind {
33473347
pub struct UseTree {
33483348
pub prefix: Path,
33493349
pub kind: UseTreeKind,
3350-
pub span: Span,
33513350
}
33523351

33533352
impl UseTree {
3353+
/// If the `UseTree` is just an identifier, return that.
3354+
/// Panics if it's a glob (`*`) or a nested use tree.
33543355
pub fn ident(&self) -> Ident {
33553356
match self.kind {
33563357
UseTreeKind::Simple(Some(rename)) => rename,
@@ -3360,6 +3361,27 @@ impl UseTree {
33603361
_ => panic!("`UseTree::ident` can only be used on a simple import"),
33613362
}
33623363
}
3364+
3365+
/// Returns the full span from the start of the path to the
3366+
/// closing `}` or nested spans, `*` of glob spans or the end of the
3367+
/// identifier of simple spans.
3368+
pub fn span(&self) -> Span {
3369+
self.prefix.span.to(self.hi_span())
3370+
}
3371+
3372+
/// Returns the trailing element's span. So for a nested
3373+
/// span you get the entire `{}`-block, for a glob you
3374+
/// get the span of the `*` itself, and for simple use trees
3375+
/// you get the identifier to rename the import to or the full
3376+
/// path if no rename is specified.
3377+
pub fn hi_span(&self) -> Span {
3378+
match self.kind {
3379+
UseTreeKind::Simple(None) => self.prefix.span,
3380+
UseTreeKind::Simple(Some(name)) => name.span,
3381+
UseTreeKind::Nested { span, .. } => span,
3382+
UseTreeKind::Glob(span) => span,
3383+
}
3384+
}
33633385
}
33643386

33653387
/// Distinguishes between `Attribute`s that decorate items and Attributes that

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
153153
self.lower_item_id_use_tree(nested, vec);
154154
}
155155
}
156-
UseTreeKind::Simple(..) | UseTreeKind::Glob => {}
156+
UseTreeKind::Simple(..) | UseTreeKind::Glob(_) => {}
157157
}
158158
}
159159

@@ -287,7 +287,11 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
287287
}
288288
ItemKind::Use(use_tree) => {
289289
// Start with an empty prefix.
290-
let prefix = Path { segments: ThinVec::new(), span: use_tree.span, tokens: None };
290+
let prefix = Path {
291+
segments: ThinVec::new(),
292+
span: use_tree.prefix.span.shrink_to_lo(),
293+
tokens: None,
294+
};
291295

292296
self.lower_use_tree(use_tree, &prefix, id, vis_span, attrs)
293297
}
@@ -659,7 +663,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
659663
let ident = self.lower_ident(ident);
660664
hir::ItemKind::Use(path, hir::UseKind::Single(ident))
661665
}
662-
UseTreeKind::Glob => {
666+
UseTreeKind::Glob(_) => {
663667
let res = self.expect_full_res(id);
664668
let res = self.lower_res(res);
665669
// Put the result in the appropriate namespace.
@@ -731,7 +735,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
731735
owner_id,
732736
kind,
733737
vis_span,
734-
span: this.lower_span(use_tree.span),
738+
span: this.lower_span(use_tree.span()),
735739
has_delayed_lints: !this.delayed_lints.is_empty(),
736740
eii: find_attr!(attrs, EiiImpls(..) | EiiDeclaration(..)),
737741
};

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,15 @@ impl<'a> State<'a> {
235235
// In order to call a named field, needs parens: `(self.fun)()`
236236
// But not for an unnamed field: `self.0()`
237237
ast::ExprKind::Field(_, name) => !name.is_numeric(),
238-
_ => func_fixup.precedence(func) < ExprPrecedence::Unambiguous,
238+
// Block-like expressions (block, match, if, loop, ...) never
239+
// parse as the callee of a call, regardless of context: the
240+
// closing brace ends the expression and `(args)` becomes a
241+
// separate tuple. Parenthesize them so the call survives a
242+
// pretty-print round trip.
243+
_ => {
244+
func_fixup.precedence(func) < ExprPrecedence::Unambiguous
245+
|| classify::expr_is_complete(func)
246+
}
239247
};
240248

241249
self.print_expr_cond_paren(func, needs_paren, func_fixup);
@@ -677,7 +685,8 @@ impl<'a> State<'a> {
677685
let expr_fixup = fixup.leftmost_subexpression_with_operator(true);
678686
self.print_expr_cond_paren(
679687
expr,
680-
expr_fixup.precedence(expr) < ExprPrecedence::Unambiguous,
688+
expr_fixup.precedence(expr) < ExprPrecedence::Unambiguous
689+
|| classify::expr_is_complete(expr),
681690
expr_fixup,
682691
);
683692
self.word("[");

compiler/rustc_ast_pretty/src/pprust/state/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ impl<'a> State<'a> {
867867
self.print_ident(rename);
868868
}
869869
}
870-
ast::UseTreeKind::Glob => {
870+
ast::UseTreeKind::Glob(_) => {
871871
if !tree.prefix.segments.is_empty() {
872872
self.print_path(&tree.prefix, false, 0);
873873
self.word("::");

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<S: Stage> SingleAttributeParser<S> for DeprecatedParser {
8383
ArgParser::List(list) => {
8484
for param in list.mixed() {
8585
let Some(param) = param.meta_item() else {
86-
cx.adcx().unexpected_literal(param.span());
86+
cx.adcx().expected_not_literal(param.span());
8787
return None;
8888
};
8989

compiler/rustc_attr_parsing/src/attributes/link_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
9393
let mut import_name_type = None;
9494
for item in items.mixed() {
9595
let Some(item) = item.meta_item() else {
96-
cx.adcx().unexpected_literal(item.span());
96+
cx.adcx().expected_not_literal(item.span());
9797
continue;
9898
};
9999

compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl<S: Stage> SingleAttributeParser<S> for CollapseDebugInfoParser {
185185
return None;
186186
};
187187
let Some(mi) = single.meta_item() else {
188-
cx.adcx().unexpected_literal(single.span());
188+
cx.adcx().expected_not_literal(single.span());
189189
return None;
190190
};
191191
if let Err(err) = mi.args().no_args() {

0 commit comments

Comments
 (0)