Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit de9022d

Browse files
committedJan 26, 2024
Auto merge of rust-lang#120359 - compiler-errors:rollup-3btckn2, r=compiler-errors
Rollup of 8 pull requests Successful merges: - rust-lang#118803 (Add the `min_exhaustive_patterns` feature gate) - rust-lang#119286 (show linker output even if the linker succeeds) - rust-lang#119616 (Add a new `wasm32-wasi-preview2` target) - rust-lang#120124 (Split assembly tests for ELF and MachO) - rust-lang#120201 (Bump some deps with syn 1.0 dependencies) - rust-lang#120204 (Builtin macros effectively have implicit #[collapse_debuginfo(yes)]) - rust-lang#120322 (Don't manually resolve async closures in `rustc_resolve`) - rust-lang#120356 (Fix broken markdown in csky-unknown-linux-gnuabiv2.md) r? `@ghost` `@rustbot` modify labels: rollup
2 parents dd2559e + 907936e commit de9022d

File tree

33 files changed

+1161
-430
lines changed

33 files changed

+1161
-430
lines changed
 

‎Cargo.lock

+16-36
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,9 @@ dependencies = [
382382

383383
[[package]]
384384
name = "byteorder"
385-
version = "1.4.3"
385+
version = "1.5.0"
386386
source = "registry+https://github.com/rust-lang/crates.io-index"
387-
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
387+
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
388388

389389
[[package]]
390390
name = "bytes"
@@ -2596,9 +2596,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
25962596

25972597
[[package]]
25982598
name = "object"
2599-
version = "0.32.1"
2599+
version = "0.32.2"
26002600
source = "registry+https://github.com/rust-lang/crates.io-index"
2601-
checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
2601+
checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
26022602
dependencies = [
26032603
"compiler_builtins",
26042604
"crc32fast",
@@ -4797,12 +4797,12 @@ checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06"
47974797

47984798
[[package]]
47994799
name = "ruzstd"
4800-
version = "0.4.0"
4800+
version = "0.5.0"
48014801
source = "registry+https://github.com/rust-lang/crates.io-index"
4802-
checksum = "ac3ffab8f9715a0d455df4bbb9d21e91135aab3cd3ca187af0cd0c3c3f868fdc"
4802+
checksum = "58c4eb8a81997cf040a091d1f7e1938aeab6749d3a0dfa73af43cdc32393483d"
48034803
dependencies = [
48044804
"byteorder",
4805-
"thiserror-core",
4805+
"derive_more",
48064806
"twox-hash",
48074807
]
48084808

@@ -5365,26 +5365,6 @@ dependencies = [
53655365
"thiserror-impl",
53665366
]
53675367

5368-
[[package]]
5369-
name = "thiserror-core"
5370-
version = "1.0.38"
5371-
source = "registry+https://github.com/rust-lang/crates.io-index"
5372-
checksum = "0d97345f6437bb2004cd58819d8a9ef8e36cdd7661c2abc4bbde0a7c40d9f497"
5373-
dependencies = [
5374-
"thiserror-core-impl",
5375-
]
5376-
5377-
[[package]]
5378-
name = "thiserror-core-impl"
5379-
version = "1.0.38"
5380-
source = "registry+https://github.com/rust-lang/crates.io-index"
5381-
checksum = "10ac1c5050e43014d16b2f94d0d2ce79e65ffdd8b38d8048f9c8f6a8a6da62ac"
5382-
dependencies = [
5383-
"proc-macro2",
5384-
"quote",
5385-
"syn 1.0.109",
5386-
]
5387-
53885368
[[package]]
53895369
name = "thiserror-impl"
53905370
version = "1.0.47"
@@ -5757,28 +5737,28 @@ dependencies = [
57575737

57585738
[[package]]
57595739
name = "unic-langid"
5760-
version = "0.9.1"
5740+
version = "0.9.4"
57615741
source = "registry+https://github.com/rust-lang/crates.io-index"
5762-
checksum = "398f9ad7239db44fd0f80fe068d12ff22d78354080332a5077dc6f52f14dcf2f"
5742+
checksum = "238722e6d794ed130f91f4ea33e01fcff4f188d92337a21297892521c72df516"
57635743
dependencies = [
57645744
"unic-langid-impl",
57655745
"unic-langid-macros",
57665746
]
57675747

57685748
[[package]]
57695749
name = "unic-langid-impl"
5770-
version = "0.9.1"
5750+
version = "0.9.4"
57715751
source = "registry+https://github.com/rust-lang/crates.io-index"
5772-
checksum = "e35bfd2f2b8796545b55d7d3fd3e89a0613f68a0d1c8bc28cb7ff96b411a35ff"
5752+
checksum = "4bd55a2063fdea4ef1f8633243a7b0524cbeef1905ae04c31a1c9b9775c55bc6"
57735753
dependencies = [
57745754
"tinystr",
57755755
]
57765756

57775757
[[package]]
57785758
name = "unic-langid-macros"
5779-
version = "0.9.1"
5759+
version = "0.9.4"
57805760
source = "registry+https://github.com/rust-lang/crates.io-index"
5781-
checksum = "055e618bf694161ffff0466d95cef3e1a5edc59f6ba1888e97801f2b4ebdc4fe"
5761+
checksum = "5c854cefb82ff2816410ce606acbad1b3af065140907b29be9229040752b83ec"
57825762
dependencies = [
57835763
"proc-macro-hack",
57845764
"tinystr",
@@ -5788,13 +5768,13 @@ dependencies = [
57885768

57895769
[[package]]
57905770
name = "unic-langid-macros-impl"
5791-
version = "0.9.1"
5771+
version = "0.9.4"
57925772
source = "registry+https://github.com/rust-lang/crates.io-index"
5793-
checksum = "1f5cdec05b907f4e2f6843f4354f4ce6a5bebe1a56df320a49134944477ce4d8"
5773+
checksum = "fea2a4c80deb4fb3ca51f66b5e2dd91e3642bbce52234bcf22e41668281208e4"
57945774
dependencies = [
57955775
"proc-macro-hack",
57965776
"quote",
5797-
"syn 1.0.109",
5777+
"syn 2.0.32",
57985778
"unic-langid-impl",
57995779
]
58005780

‎compiler/rustc_codegen_ssa/messages.ftl

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ codegen_ssa_linker_file_stem = couldn't extract file stem from specified linker
160160
codegen_ssa_linker_not_found = linker `{$linker_path}` not found
161161
.note = {$error}
162162
163+
codegen_ssa_linker_output = {$inner}
164+
163165
codegen_ssa_linker_unsupported_modifier = `as-needed` modifier not supported for current linker
164166
165167
codegen_ssa_linking_failed = linking with `{$linker_path}` failed: {$exit_status}

‎compiler/rustc_codegen_ssa/src/back/link.rs

+25-3
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,14 @@ fn link_dwarf_object<'a>(
730730
}
731731
}
732732

733+
#[derive(Diagnostic)]
734+
#[diag(codegen_ssa_linker_output)]
735+
/// Translating this is kind of useless. We don't pass translation flags to the linker, so we'd just
736+
/// end up with inconsistent languages within the same diagnostic.
737+
struct LinkerOutput {
738+
inner: String,
739+
}
740+
733741
/// Create a dynamic library or executable.
734742
///
735743
/// This will invoke the system linker/cc to create the resulting file. This links to all upstream
@@ -935,12 +943,12 @@ fn link_natively<'a>(
935943
let mut output = prog.stderr.clone();
936944
output.extend_from_slice(&prog.stdout);
937945
let escaped_output = escape_linker_output(&output, flavor);
938-
// FIXME: Add UI tests for this error.
939946
let err = errors::LinkingFailed {
940947
linker_path: &linker_path,
941948
exit_status: prog.status,
942949
command: &cmd,
943950
escaped_output,
951+
verbose: sess.opts.verbose,
944952
};
945953
sess.dcx().emit_err(err);
946954
// If MSVC's `link.exe` was expected but the return code
@@ -981,8 +989,22 @@ fn link_natively<'a>(
981989

982990
sess.dcx().abort_if_errors();
983991
}
984-
info!("linker stderr:\n{}", escape_string(&prog.stderr));
985-
info!("linker stdout:\n{}", escape_string(&prog.stdout));
992+
993+
if !prog.stderr.is_empty() {
994+
// We already print `warning:` at the start of the diagnostic. Remove it from the linker output if present.
995+
let stderr = escape_string(&prog.stderr);
996+
debug!("original stderr: {stderr}");
997+
let stderr = stderr
998+
.strip_prefix("warning: ")
999+
.unwrap_or(&stderr)
1000+
.replace(": warning: ", ": ");
1001+
sess.dcx().emit_warn(LinkerOutput { inner: format!("linker stderr: {stderr}") });
1002+
}
1003+
if !prog.stdout.is_empty() && sess.opts.verbose {
1004+
sess.dcx().emit_warn(LinkerOutput {
1005+
inner: format!("linker stdout: {}", escape_string(&prog.stdout)),
1006+
});
1007+
}
9861008
}
9871009
Err(e) => {
9881010
let linker_not_found = e.kind() == io::ErrorKind::NotFound;

‎compiler/rustc_codegen_ssa/src/errors.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ pub struct LinkingFailed<'a> {
340340
pub exit_status: ExitStatus,
341341
pub command: &'a Command,
342342
pub escaped_output: String,
343+
pub verbose: bool,
343344
}
344345

345346
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for LinkingFailed<'_> {
@@ -350,7 +351,13 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for LinkingFailed<'_> {
350351

351352
let contains_undefined_ref = self.escaped_output.contains("undefined reference to");
352353

353-
diag.note(format!("{:?}", self.command)).note(self.escaped_output);
354+
if self.verbose {
355+
diag.note(format!("{:?}", self.command));
356+
} else {
357+
diag.note("use `--verbose` to show all linker arguments");
358+
}
359+
360+
diag.note(self.escaped_output);
354361

355362
// Trying to match an error from OS linkers
356363
// which by now we have no way to translate.

‎compiler/rustc_expand/src/base.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -796,9 +796,15 @@ impl SyntaxExtension {
796796
/// | external | no | if-ext | if-ext | yes |
797797
/// | yes | yes | yes | yes | yes |
798798
fn get_collapse_debuginfo(sess: &Session, attrs: &[ast::Attribute], is_local: bool) -> bool {
799-
let collapse_debuginfo_attr = attr::find_by_name(attrs, sym::collapse_debuginfo)
799+
let mut collapse_debuginfo_attr = attr::find_by_name(attrs, sym::collapse_debuginfo)
800800
.map(|v| Self::collapse_debuginfo_by_name(sess, v))
801801
.unwrap_or(CollapseMacroDebuginfo::Unspecified);
802+
if collapse_debuginfo_attr == CollapseMacroDebuginfo::Unspecified
803+
&& attr::contains_name(attrs, sym::rustc_builtin_macro)
804+
{
805+
collapse_debuginfo_attr = CollapseMacroDebuginfo::Yes;
806+
}
807+
802808
let flag = sess.opts.unstable_opts.collapse_macro_debuginfo;
803809
let attr = collapse_debuginfo_attr;
804810
let ext = !is_local;

‎compiler/rustc_feature/src/unstable.rs

+3
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,9 @@ declare_features! (
516516
(unstable, macro_metavar_expr, "1.61.0", Some(83527)),
517517
/// Allows `#[marker]` on certain traits allowing overlapping implementations.
518518
(unstable, marker_trait_attr, "1.30.0", Some(29864)),
519+
/// Allows exhaustive pattern matching on types that contain uninhabited types in cases that are
520+
/// unambiguously sound.
521+
(incomplete, min_exhaustive_patterns, "CURRENT_RUSTC_VERSION", Some(119612)),
519522
/// A minimal, sound subset of specialization intended to be used by the
520523
/// standard library until the soundness issues with specialization
521524
/// are fixed.

‎compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,10 @@ impl DiagnosticDeriveVariantBuilder {
249249
let mut field_binding = binding_info.binding.clone();
250250
field_binding.set_span(field.ty.span());
251251

252-
let ident = field.ident.as_ref().unwrap();
252+
let Some(ident) = field.ident.as_ref() else {
253+
span_err(field.span().unwrap(), "tuple structs are not supported").emit();
254+
return TokenStream::new();
255+
};
253256
let ident = format_ident!("{}", ident); // strip `r#` prefix, if present
254257

255258
quote! {

‎compiler/rustc_macros/src/diagnostics/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn path_to_string(path: &syn::Path) -> String {
5555
/// Returns an error diagnostic on span `span` with msg `msg`.
5656
#[must_use]
5757
pub(crate) fn span_err<T: Into<String>>(span: impl MultiSpan, msg: T) -> Diagnostic {
58-
Diagnostic::spanned(span, Level::Error, msg)
58+
Diagnostic::spanned(span, Level::Error, format!("derive(Diagnostic): {}", msg.into()))
5959
}
6060

6161
/// Emit a diagnostic on span `$span` with msg `$msg` (optionally performing additional decoration

‎compiler/rustc_macros/src/diagnostics/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl<T> SetOnce<T> for SpannedOption<T> {
242242
*self = Some((value, span));
243243
}
244244
Some((_, prev_span)) => {
245-
span_err(span, "specified multiple times")
245+
span_err(span, "attribute specified multiple times")
246246
.span_note(*prev_span, "previously specified here")
247247
.emit();
248248
}

‎compiler/rustc_pattern_analysis/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pub trait TypeCx: Sized + fmt::Debug {
9595
type PatData: Clone;
9696

9797
fn is_exhaustive_patterns_feature_on(&self) -> bool;
98+
fn is_min_exhaustive_patterns_feature_on(&self) -> bool;
9899

99100
/// The number of fields for this constructor.
100101
fn ctor_arity(&self, ctor: &Constructor<Self>, ty: &Self::Ty) -> usize;

‎compiler/rustc_pattern_analysis/src/rustc.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
181181
// `field.ty()` doesn't normalize after substituting.
182182
let ty = cx.tcx.normalize_erasing_regions(cx.param_env, ty);
183183
let is_visible = adt.is_enum() || field.vis.is_accessible_from(cx.module, cx.tcx);
184-
let is_uninhabited = cx.tcx.features().exhaustive_patterns && cx.is_uninhabited(ty);
184+
let is_uninhabited = (cx.tcx.features().exhaustive_patterns
185+
|| cx.tcx.features().min_exhaustive_patterns)
186+
&& cx.is_uninhabited(ty);
185187

186188
if is_uninhabited && (!is_visible || is_non_exhaustive) {
187189
None
@@ -863,6 +865,9 @@ impl<'p, 'tcx> TypeCx for RustcMatchCheckCtxt<'p, 'tcx> {
863865
fn is_exhaustive_patterns_feature_on(&self) -> bool {
864866
self.tcx.features().exhaustive_patterns
865867
}
868+
fn is_min_exhaustive_patterns_feature_on(&self) -> bool {
869+
self.tcx.features().min_exhaustive_patterns
870+
}
866871

867872
fn ctor_arity(&self, ctor: &crate::constructor::Constructor<Self>, ty: &Self::Ty) -> usize {
868873
self.ctor_arity(ctor, *ty)

‎compiler/rustc_pattern_analysis/src/usefulness.rs

+17-9
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,12 @@
548548
//! [`ValidityConstraint::specialize`].
549549
//!
550550
//! Having said all that, in practice we don't fully follow what's been presented in this section.
551-
//! Under `exhaustive_patterns`, we allow omitting empty arms even in `!known_valid` places, for
552-
//! backwards-compatibility until we have a better alternative. Without `exhaustive_patterns`, we
553-
//! mostly treat empty types as inhabited, except specifically a non-nested `!` or empty enum. In
554-
//! this specific case we also allow the empty match regardless of place validity, for
555-
//! backwards-compatibility. Hopefully we can eventually deprecate this.
551+
//! Let's call "toplevel exception" the case where the match scrutinee itself has type `!` or
552+
//! `EmptyEnum`. First, on stable rust, we require `_` patterns for empty types in all cases apart
553+
//! from the toplevel exception. The `exhaustive_patterns` and `min_exaustive_patterns` allow
554+
//! omitting patterns in the cases described above. There's a final detail: in the toplevel
555+
//! exception or with the `exhaustive_patterns` feature, we ignore place validity when checking
556+
//! whether a pattern is required for exhaustiveness. I (Nadrieril) hope to deprecate this behavior.
556557
//!
557558
//!
558559
//!
@@ -1442,10 +1443,17 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
14421443
// We treat match scrutinees of type `!` or `EmptyEnum` differently.
14431444
let is_toplevel_exception =
14441445
is_top_level && matches!(ctors_for_ty, ConstructorSet::NoConstructors);
1445-
// Whether empty patterns can be omitted for exhaustiveness.
1446-
let can_omit_empty_arms = is_toplevel_exception || mcx.tycx.is_exhaustive_patterns_feature_on();
1447-
// Whether empty patterns are counted as useful or not.
1448-
let empty_arms_are_unreachable = place_validity.is_known_valid() && can_omit_empty_arms;
1446+
// Whether empty patterns are counted as useful or not. We only warn an empty arm unreachable if
1447+
// it is guaranteed unreachable by the opsem (i.e. if the place is `known_valid`).
1448+
let empty_arms_are_unreachable = place_validity.is_known_valid()
1449+
&& (is_toplevel_exception
1450+
|| mcx.tycx.is_exhaustive_patterns_feature_on()
1451+
|| mcx.tycx.is_min_exhaustive_patterns_feature_on());
1452+
// Whether empty patterns can be omitted for exhaustiveness. We ignore place validity in the
1453+
// toplevel exception and `exhaustive_patterns` cases for backwards compatibility.
1454+
let can_omit_empty_arms = empty_arms_are_unreachable
1455+
|| is_toplevel_exception
1456+
|| mcx.tycx.is_exhaustive_patterns_feature_on();
14491457

14501458
// Analyze the constructors present in this column.
14511459
let ctors = matrix.heads().map(|p| p.ctor());

‎compiler/rustc_resolve/src/late.rs

-29
Original file line numberDiff line numberDiff line change
@@ -4424,35 +4424,6 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
44244424
ExprKind::Type(ref _type_expr, ref _ty) => {
44254425
visit::walk_expr(self, expr);
44264426
}
4427-
// `async |x| ...` gets desugared to `|x| async {...}`, so we need to
4428-
// resolve the arguments within the proper scopes so that usages of them inside the
4429-
// closure are detected as upvars rather than normal closure arg usages.
4430-
//
4431-
// Similarly, `gen |x| ...` gets desugared to `|x| gen {...}`, so we handle that too.
4432-
ExprKind::Closure(box ast::Closure {
4433-
coroutine_kind: Some(_),
4434-
ref fn_decl,
4435-
ref body,
4436-
..
4437-
}) => {
4438-
self.with_rib(ValueNS, RibKind::Normal, |this| {
4439-
this.with_label_rib(RibKind::FnOrCoroutine, |this| {
4440-
// Resolve arguments:
4441-
this.resolve_params(&fn_decl.inputs);
4442-
// No need to resolve return type --
4443-
// the outer closure return type is `FnRetTy::Default`.
4444-
4445-
// Now resolve the inner closure
4446-
{
4447-
// No need to resolve arguments: the inner closure has none.
4448-
// Resolve the return type:
4449-
visit::walk_fn_ret_ty(this, &fn_decl.output);
4450-
// Resolve the body
4451-
this.visit_expr(body);
4452-
}
4453-
})
4454-
});
4455-
}
44564427
// For closures, RibKind::FnOrCoroutine is added in visit_fn
44574428
ExprKind::Closure(box ast::Closure {
44584429
binder: ClosureBinder::For { ref generic_params, span },

‎compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@ symbols! {
10291029
min_const_fn,
10301030
min_const_generics,
10311031
min_const_unsafe_fn,
1032+
min_exhaustive_patterns,
10321033
min_specialization,
10331034
min_type_alias_impl_trait,
10341035
minnumf32,

‎src/doc/rustc/src/platform-support/csky-unknown-linux-gnuabiv2.md

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ cc = "${TOOLCHAIN_PATH}/bin/csky-linux-gnuabiv2-gcc"
5050
[target.csky-unknown-linux-gnuabiv2hf]
5151
# ADJUST THIS PATH TO POINT AT YOUR TOOLCHAIN
5252
cc = "${TOOLCHAIN_PATH}/bin/csky-linux-gnuabiv2-gcc"
53+
```
5354

5455
### Build
5556

‎src/etc/cat-and-grep.sh

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ while getopts ':vieh' OPTION; do
3333
case "$OPTION" in
3434
v)
3535
INVERT=1
36-
ERROR_MSG='should not be found'
3736
;;
3837
i)
3938
GREPFLAGS="i$GREPFLAGS"

‎src/tools/tidy/src/deps.rs

-2
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
340340
"termize",
341341
"thin-vec",
342342
"thiserror",
343-
"thiserror-core",
344-
"thiserror-core-impl",
345343
"thiserror-impl",
346344
"thorin-dwp",
347345
"thread_local",

0 commit comments

Comments
 (0)
Please sign in to comment.