Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 104048f

Browse files
committed
Auto merge of rust-lang#2775 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 1812f60 + 072d5cd commit 104048f

File tree

80 files changed

+1700
-974
lines changed

Some content is hidden

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

80 files changed

+1700
-974
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ jobs:
325325
NO_DEBUG_ASSERTIONS: 1
326326
NO_OVERFLOW_CHECKS: 1
327327
DIST_REQUIRE_ALL_TOOLS: 1
328-
os: macos-12-xl
328+
os: macos-latest
329329
- name: dist-apple-various
330330
env:
331331
SCRIPT: "./x.py dist bootstrap --include-default-paths --host='' --target=aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim"
@@ -336,7 +336,7 @@ jobs:
336336
NO_LLVM_ASSERTIONS: 1
337337
NO_DEBUG_ASSERTIONS: 1
338338
NO_OVERFLOW_CHECKS: 1
339-
os: macos-12-xl
339+
os: macos-latest
340340
- name: dist-x86_64-apple-alt
341341
env:
342342
SCRIPT: "./x.py dist bootstrap --include-default-paths"
@@ -347,7 +347,7 @@ jobs:
347347
NO_LLVM_ASSERTIONS: 1
348348
NO_DEBUG_ASSERTIONS: 1
349349
NO_OVERFLOW_CHECKS: 1
350-
os: macos-12-xl
350+
os: macos-latest
351351
- name: x86_64-apple-1
352352
env:
353353
SCRIPT: "./x.py --stage 2 test --exclude tests/ui --exclude tests/rustdoc --exclude tests/run-make-fulldeps"
@@ -358,7 +358,7 @@ jobs:
358358
NO_LLVM_ASSERTIONS: 1
359359
NO_DEBUG_ASSERTIONS: 1
360360
NO_OVERFLOW_CHECKS: 1
361-
os: macos-12-xl
361+
os: macos-latest
362362
- name: x86_64-apple-2
363363
env:
364364
SCRIPT: "./x.py --stage 2 test tests/ui tests/rustdoc tests/run-make-fulldeps"
@@ -369,7 +369,7 @@ jobs:
369369
NO_LLVM_ASSERTIONS: 1
370370
NO_DEBUG_ASSERTIONS: 1
371371
NO_OVERFLOW_CHECKS: 1
372-
os: macos-12-xl
372+
os: macos-latest
373373
- name: dist-aarch64-apple
374374
env:
375375
SCRIPT: "./x.py dist bootstrap --include-default-paths --stage 2"
@@ -384,7 +384,7 @@ jobs:
384384
NO_OVERFLOW_CHECKS: 1
385385
DIST_REQUIRE_ALL_TOOLS: 1
386386
JEMALLOC_SYS_WITH_LG_PAGE: 14
387-
os: macos-12-xl
387+
os: macos-latest
388388
- name: x86_64-msvc-1
389389
env:
390390
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --enable-profiler"

compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,30 @@ pub fn expand_deriving_partial_eq(
2929
cx.span_bug(field.span, "not exactly 2 arguments in `derive(PartialEq)`");
3030
};
3131

32-
// We received `&T` arguments. Convert them to `T` by
33-
// stripping `&` or adding `*`. This isn't necessary for
34-
// type checking, but it results in much better error
35-
// messages if something goes wrong.
32+
// We received arguments of type `&T`. Convert them to type `T` by stripping
33+
// any leading `&` or adding `*`. This isn't necessary for type checking, but
34+
// it results in better error messages if something goes wrong.
35+
//
36+
// Note: for arguments that look like `&{ x }`, which occur with packed
37+
// structs, this would cause expressions like `{ self.x } == { other.x }`,
38+
// which isn't valid Rust syntax. This wouldn't break compilation because these
39+
// AST nodes are constructed within the compiler. But it would mean that code
40+
// printed by `-Zunpretty=expanded` (or `cargo expand`) would have invalid
41+
// syntax, which would be suboptimal. So we wrap these in parens, giving
42+
// `({ self.x }) == ({ other.x })`, which is valid syntax.
3643
let convert = |expr: &P<Expr>| {
3744
if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) =
3845
&expr.kind
3946
{
40-
inner.clone()
47+
if let ExprKind::Block(..) = &inner.kind {
48+
// `&{ x }` form: remove the `&`, add parens.
49+
cx.expr_paren(field.span, inner.clone())
50+
} else {
51+
// `&x` form: remove the `&`.
52+
inner.clone()
53+
}
4154
} else {
55+
// No leading `&`: add a leading `*`.
4256
cx.expr_deref(field.span, expr.clone())
4357
}
4458
};

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -85,55 +85,11 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
8585
} else if attr.has_name(sym::rustc_allocator) {
8686
codegen_fn_attrs.flags |= CodegenFnAttrFlags::ALLOCATOR;
8787
} else if attr.has_name(sym::ffi_returns_twice) {
88-
if tcx.is_foreign_item(did) {
89-
codegen_fn_attrs.flags |= CodegenFnAttrFlags::FFI_RETURNS_TWICE;
90-
} else {
91-
// `#[ffi_returns_twice]` is only allowed `extern fn`s.
92-
struct_span_err!(
93-
tcx.sess,
94-
attr.span,
95-
E0724,
96-
"`#[ffi_returns_twice]` may only be used on foreign functions"
97-
)
98-
.emit();
99-
}
88+
codegen_fn_attrs.flags |= CodegenFnAttrFlags::FFI_RETURNS_TWICE;
10089
} else if attr.has_name(sym::ffi_pure) {
101-
if tcx.is_foreign_item(did) {
102-
if attrs.iter().any(|a| a.has_name(sym::ffi_const)) {
103-
// `#[ffi_const]` functions cannot be `#[ffi_pure]`
104-
struct_span_err!(
105-
tcx.sess,
106-
attr.span,
107-
E0757,
108-
"`#[ffi_const]` function cannot be `#[ffi_pure]`"
109-
)
110-
.emit();
111-
} else {
112-
codegen_fn_attrs.flags |= CodegenFnAttrFlags::FFI_PURE;
113-
}
114-
} else {
115-
// `#[ffi_pure]` is only allowed on foreign functions
116-
struct_span_err!(
117-
tcx.sess,
118-
attr.span,
119-
E0755,
120-
"`#[ffi_pure]` may only be used on foreign functions"
121-
)
122-
.emit();
123-
}
90+
codegen_fn_attrs.flags |= CodegenFnAttrFlags::FFI_PURE;
12491
} else if attr.has_name(sym::ffi_const) {
125-
if tcx.is_foreign_item(did) {
126-
codegen_fn_attrs.flags |= CodegenFnAttrFlags::FFI_CONST;
127-
} else {
128-
// `#[ffi_const]` is only allowed on foreign functions
129-
struct_span_err!(
130-
tcx.sess,
131-
attr.span,
132-
E0756,
133-
"`#[ffi_const]` may only be used on foreign functions"
134-
)
135-
.emit();
136-
}
92+
codegen_fn_attrs.flags |= CodegenFnAttrFlags::FFI_CONST;
13793
} else if attr.has_name(sym::rustc_nounwind) {
13894
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NEVER_UNWIND;
13995
} else if attr.has_name(sym::rustc_reallocator) {

compiler/rustc_error_messages/locales/en-US/hir_typeck.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ hir_typeck_lang_start_incorrect_param = parameter {$param_num} of the `start` la
5757
5858
hir_typeck_lang_start_incorrect_ret_ty = the return type of the `start` lang item is incorrect
5959
.suggestion = change the type from `{$found_ty}` to `{$expected_ty}`
60+
61+
hir_typeck_help_set_edition_cargo = set `edition = "{$edition}"` in `Cargo.toml`
62+
hir_typeck_help_set_edition_standalone = pass `--edition {$edition}` to `rustc`
63+
hir_typeck_note_edition_guide = for more on editions, read https://doc.rust-lang.org/edition-guide

compiler/rustc_error_messages/locales/en-US/parse.ftl

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,191 @@ parse_where_clause_before_tuple_struct_body = where clauses are not allowed befo
390390
.name_label = while parsing this tuple struct
391391
.body_label = the struct body
392392
.suggestion = move the body before the where clause
393+
394+
parse_async_fn_in_2015 = `async fn` is not permitted in Rust 2015
395+
.label = to use `async fn`, switch to Rust 2018 or later
396+
397+
parse_async_block_in_2015 = `async` blocks are only allowed in Rust 2018 or later
398+
399+
parse_self_argument_pointer = cannot pass `self` by raw pointer
400+
.label = cannot pass `self` by raw pointer
401+
402+
parse_visibility_not_followed_by_item = visibility `{$vis}` is not followed by an item
403+
.label = the visibility
404+
.help = you likely meant to define an item, e.g., `{$vis} fn foo() {"{}"}`
405+
406+
parse_default_not_followed_by_item = `default` is not followed by an item
407+
.label = the `default` qualifier
408+
.note = only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
409+
410+
parse_missing_struct_for_struct_definition = missing `struct` for struct definition
411+
.suggestion = add `struct` here to parse `{$ident}` as a public struct
412+
413+
parse_missing_fn_for_function_definition = missing `fn` for function definition
414+
.suggestion = add `fn` here to parse `{$ident}` as a public function
415+
416+
parse_missing_fn_for_method_definition = missing `fn` for method definition
417+
.suggestion = add `fn` here to parse `{$ident}` as a public method
418+
419+
parse_ambiguous_missing_keyword_for_item_definition = missing `fn` or `struct` for function or struct definition
420+
.suggestion = if you meant to call a macro, try
421+
.help = if you meant to call a macro, remove the `pub` and add a trailing `!` after the identifier
422+
423+
parse_missing_trait_in_trait_impl = missing trait in a trait impl
424+
.suggestion_add_trait = add a trait here
425+
.suggestion_remove_for = for an inherent impl, drop this `for`
426+
427+
parse_missing_for_in_trait_impl = missing `for` in a trait impl
428+
.suggestion = add `for` here
429+
430+
parse_expected_trait_in_trait_impl_found_type = expected a trait, found type
431+
432+
parse_non_item_in_item_list = non-item in item list
433+
.suggestion_use_const_not_let = consider using `const` instead of `let` for associated const
434+
.label_list_start = item list starts here
435+
.label_non_item = non-item starts here
436+
.label_list_end = item list ends here
437+
.suggestion_remove_semicolon = consider removing this semicolon
438+
439+
parse_bounds_not_allowed_on_trait_aliases = bounds are not allowed on trait aliases
440+
441+
parse_trait_alias_cannot_be_auto = trait aliases cannot be `auto`
442+
parse_trait_alias_cannot_be_unsafe = trait aliases cannot be `unsafe`
443+
444+
parse_associated_static_item_not_allowed = associated `static` items are not allowed
445+
446+
parse_extern_crate_name_with_dashes = crate name using dashes are not valid in `extern crate` statements
447+
.label = dash-separated idents are not valid
448+
.suggestion = if the original crate name uses dashes you need to use underscores in the code
449+
450+
parse_extern_item_cannot_be_const = extern items cannot be `const`
451+
.suggestion = try using a static value
452+
.note = for more information, visit https://doc.rust-lang.org/std/keyword.extern.html
453+
454+
parse_const_global_cannot_be_mutable = const globals cannot be mutable
455+
.label = cannot be mutable
456+
.suggestion = you might want to declare a static instead
457+
458+
parse_missing_const_type = missing type for `{$kind}` item
459+
.suggestion = provide a type for the item
460+
461+
parse_enum_struct_mutually_exclusive = `enum` and `struct` are mutually exclusive
462+
.suggestion = replace `enum struct` with
463+
464+
parse_unexpected_token_after_struct_name = expected `where`, `{"{"}`, `(`, or `;` after struct name
465+
parse_unexpected_token_after_struct_name_found_reserved_identifier = expected `where`, `{"{"}`, `(`, or `;` after struct name, found reserved identifier `{$token}`
466+
parse_unexpected_token_after_struct_name_found_keyword = expected `where`, `{"{"}`, `(`, or `;` after struct name, found keyword `{$token}`
467+
parse_unexpected_token_after_struct_name_found_reserved_keyword = expected `where`, `{"{"}`, `(`, or `;` after struct name, found reserved keyword `{$token}`
468+
parse_unexpected_token_after_struct_name_found_doc_comment = expected `where`, `{"{"}`, `(`, or `;` after struct name, found doc comment `{$token}`
469+
parse_unexpected_token_after_struct_name_found_other = expected `where`, `{"{"}`, `(`, or `;` after struct name, found `{$token}`
470+
471+
parse_unexpected_self_in_generic_parameters = unexpected keyword `Self` in generic parameters
472+
.note = you cannot use `Self` as a generic parameter because it is reserved for associated items
473+
474+
parse_multiple_where_clauses = cannot define duplicate `where` clauses on an item
475+
.label = previous `where` clause starts here
476+
.suggestion = consider joining the two `where` clauses into one
477+
478+
parse_nonterminal_expected_item_keyword = expected an item keyword
479+
parse_nonterminal_expected_statement = expected a statement
480+
parse_nonterminal_expected_ident = expected ident, found `{$token}`
481+
parse_nonterminal_expected_lifetime = expected a lifetime, found `{$token}`
482+
483+
parse_or_pattern_not_allowed_in_let_binding = top-level or-patterns are not allowed in `let` bindings
484+
parse_or_pattern_not_allowed_in_fn_parameters = top-level or-patterns are not allowed in function parameters
485+
parse_sugg_remove_leading_vert_in_pattern = remove the `|`
486+
parse_sugg_wrap_pattern_in_parens = wrap the pattern in parentheses
487+
488+
parse_note_pattern_alternatives_use_single_vert = alternatives in or-patterns are separated with `|`, not `||`
489+
490+
parse_unexpected_vert_vert_before_function_parameter = unexpected `||` before function parameter
491+
.suggestion = remove the `||`
492+
493+
parse_label_while_parsing_or_pattern_here = while parsing this or-pattern starting here
494+
495+
parse_unexpected_vert_vert_in_pattern = unexpected token `||` in pattern
496+
.suggestion = use a single `|` to separate multiple alternative patterns
497+
498+
parse_trailing_vert_not_allowed = a trailing `|` is not allowed in an or-pattern
499+
.suggestion = remove the `{$token}`
500+
501+
parse_dotdotdot_rest_pattern = unexpected `...`
502+
.label = not a valid pattern
503+
.suggestion = for a rest pattern, use `..` instead of `...`
504+
505+
parse_pattern_on_wrong_side_of_at = pattern on wrong side of `@`
506+
.label_pattern = pattern on the left, should be on the right
507+
.label_binding = binding on the right, should be on the left
508+
.suggestion = switch the order
509+
510+
parse_expected_binding_left_of_at = left-hand side of `@` must be a binding
511+
.label_lhs = interpreted as a pattern, not a binding
512+
.label_rhs = also a pattern
513+
.note = bindings are `x`, `mut x`, `ref x`, and `ref mut x`
514+
515+
parse_ambiguous_range_pattern = the range pattern here has ambiguous interpretation
516+
.suggestion = add parentheses to clarify the precedence
517+
518+
parse_unexpected_lifetime_in_pattern = unexpected lifetime `{$symbol}` in pattern
519+
.suggestion = remove the lifetime
520+
521+
parse_ref_mut_order_incorrect = the order of `mut` and `ref` is incorrect
522+
.suggestion = try switching the order
523+
524+
parse_mut_on_nested_ident_pattern = `mut` must be attached to each individual binding
525+
.suggestion = add `mut` to each binding
526+
parse_mut_on_non_ident_pattern = `mut` must be followed by a named binding
527+
.suggestion = remove the `mut` prefix
528+
parse_note_mut_pattern_usage = `mut` may be followed by `variable` and `variable @ pattern`
529+
530+
parse_repeated_mut_in_pattern = `mut` on a binding may not be repeated
531+
.suggestion = remove the additional `mut`s
532+
533+
parse_dot_dot_dot_range_to_pattern_not_allowed = range-to patterns with `...` are not allowed
534+
.suggestion = use `..=` instead
535+
536+
parse_enum_pattern_instead_of_identifier = expected identifier, found enum pattern
537+
538+
parse_dot_dot_dot_for_remaining_fields = expected field pattern, found `...`
539+
.suggestion = to omit remaining fields, use one fewer `.`
540+
541+
parse_expected_comma_after_pattern_field = expected `,`
542+
543+
parse_return_types_use_thin_arrow = return types are denoted using `->`
544+
.suggestion = use `->` instead
545+
546+
parse_need_plus_after_trait_object_lifetime = lifetime in trait object type must be followed by `+`
547+
548+
parse_expected_mut_or_const_in_raw_pointer_type = expected `mut` or `const` keyword in raw pointer type
549+
.suggestion = add `mut` or `const` here
550+
551+
parse_lifetime_after_mut = lifetime must precede `mut`
552+
.suggestion = place the lifetime before `mut`
553+
554+
parse_dyn_after_mut = `mut` must precede `dyn`
555+
.suggestion = place `mut` before `dyn`
556+
557+
parse_fn_pointer_cannot_be_const = an `fn` pointer type cannot be `const`
558+
.label = `const` because of this
559+
.suggestion = remove the `const` qualifier
560+
561+
parse_fn_pointer_cannot_be_async = an `fn` pointer type cannot be `async`
562+
.label = `async` because of this
563+
.suggestion = remove the `async` qualifier
564+
565+
parse_nested_c_variadic_type = C-variadic type `...` may not be nested inside another type
566+
567+
parse_invalid_dyn_keyword = invalid `dyn` keyword
568+
.help = `dyn` is only needed at the start of a trait `+`-separated list
569+
.suggestion = remove this keyword
570+
571+
parse_negative_bounds_not_supported = negative bounds are not supported
572+
.label = negative bounds are not supported
573+
.suggestion = {$num_bounds ->
574+
[one] remove the bound
575+
*[other] remove the bounds
576+
}
577+
578+
parse_help_set_edition_cargo = set `edition = "{$edition}"` in `Cargo.toml`
579+
parse_help_set_edition_standalone = pass `--edition {$edition}` to `rustc`
580+
parse_note_edition_guide = for more on editions, read https://doc.rust-lang.org/edition-guide

compiler/rustc_error_messages/locales/en-US/passes.ftl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,18 @@ passes_has_incoherent_inherent_impl =
182182
`rustc_has_incoherent_inherent_impls` attribute should be applied to types or traits.
183183
.label = only adts, extern types and traits are supported
184184
185+
passes_both_ffi_const_and_pure =
186+
`#[ffi_const]` function cannot be `#[ffi_pure]`
187+
188+
passes_ffi_pure_invalid_target =
189+
`#[ffi_pure]` may only be used on foreign functions
190+
191+
passes_ffi_const_invalid_target =
192+
`#[ffi_const]` may only be used on foreign functions
193+
194+
passes_ffi_returns_twice_invalid_target =
195+
`#[ffi_returns_twice]` may only be used on foreign functions
196+
185197
passes_must_use_async =
186198
`must_use` attribute on `async` functions applies to the anonymous `Future` returned by the function, not the value within
187199
.label = this attribute does nothing, the `Future`s returned by async functions are already `must_use`

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_data_structures::fx::FxHashMap;
77
use rustc_error_messages::fluent_value_from_str_list_sep_by_and;
88
use rustc_error_messages::FluentValue;
99
use rustc_lint_defs::{Applicability, LintExpectationId};
10-
use rustc_span::edition::LATEST_STABLE_EDITION;
1110
use rustc_span::symbol::Symbol;
1211
use rustc_span::{Span, DUMMY_SP};
1312
use std::borrow::Cow;
@@ -555,18 +554,6 @@ impl Diagnostic {
555554
self
556555
}
557556

558-
/// Help the user upgrade to the latest edition.
559-
/// This is factored out to make sure it does the right thing with `Cargo.toml`.
560-
pub fn help_use_latest_edition(&mut self) -> &mut Self {
561-
if std::env::var_os("CARGO").is_some() {
562-
self.help(&format!("set `edition = \"{}\"` in `Cargo.toml`", LATEST_STABLE_EDITION));
563-
} else {
564-
self.help(&format!("pass `--edition {}` to `rustc`", LATEST_STABLE_EDITION));
565-
}
566-
self.note("for more on editions, read https://doc.rust-lang.org/edition-guide");
567-
self
568-
}
569-
570557
/// Disallow attaching suggestions this diagnostic.
571558
/// Any suggestions attached e.g. with the `span_suggestion_*` methods
572559
/// (before and after the call to `disable_suggestions`) will be ignored.

0 commit comments

Comments
 (0)