Skip to content

Commit acabb52

Browse files
committed
Auto merge of rust-lang#133865 - matthiaskrgr:rollup-9v2f3w4, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#133737 (Include LLDB and GDB visualizers in MSVC distribution) - rust-lang#133774 (Make CoercePointee errors translatable) - rust-lang#133831 (Don't try and handle unfed `type_of` on anon consts) - rust-lang#133847 (Remove `-Zshow-span`.) - rust-lang#133849 (coverage: Use a separate counter type and simplification step during counter creation) - rust-lang#133850 (Avoid `opaque type not constrained` errors in the presence of other errors) - rust-lang#133851 (Stop git from merging generated files) - rust-lang#133856 (Update sysinfo version to 0.33.0) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 96e51d9 + 670affb commit acabb52

File tree

86 files changed

+1897
-2161
lines changed

Some content is hidden

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

86 files changed

+1897
-2161
lines changed

.gitattributes

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
*.cpp rust
55
*.h rust
66
*.rs rust diff=rust
7-
*.fixed linguist-language=Rust
8-
*.mir linguist-language=Rust
7+
*.fixed linguist-language=Rust -merge
8+
*.mir linguist-language=Rust -merge
9+
*.stderr -merge
10+
*.stdout -merge
911
src/etc/installer/gfx/* binary
1012
src/vendor/** -text
1113
Cargo.lock linguist-generated=false

compiler/rustc_ast_passes/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ ast_passes_precise_capturing_duplicated = duplicate `use<...>` precise capturing
207207
208208
ast_passes_precise_capturing_not_allowed_here = `use<...>` precise capturing syntax not allowed in {$loc}
209209
210-
ast_passes_show_span = {$msg}
211-
212210
ast_passes_stability_outside_std = stability attributes may not be used outside of the standard library
213211
214212
ast_passes_static_without_body =

compiler/rustc_ast_passes/src/errors.rs

-8
Original file line numberDiff line numberDiff line change
@@ -779,14 +779,6 @@ pub(crate) struct IncompatibleFeatures {
779779
pub f2: Symbol,
780780
}
781781

782-
#[derive(Diagnostic)]
783-
#[diag(ast_passes_show_span)]
784-
pub(crate) struct ShowSpan {
785-
#[primary_span]
786-
pub span: Span,
787-
pub msg: &'static str,
788-
}
789-
790782
#[derive(Diagnostic)]
791783
#[diag(ast_passes_negative_bound_not_supported)]
792784
pub(crate) struct NegativeBoundUnsupported {

compiler/rustc_ast_passes/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//! The `rustc_ast_passes` crate contains passes which validate the AST in `syntax`
22
//! parsed by `rustc_parse` and then lowered, after the passes in this crate,
33
//! by `rustc_ast_lowering`.
4-
//!
5-
//! The crate also contains other misc AST visitors, e.g. `node_count` and `show_span`.
64
75
// tidy-alphabetical-start
86
#![allow(internal_features)]
@@ -18,6 +16,5 @@
1816
pub mod ast_validation;
1917
mod errors;
2018
pub mod feature_gate;
21-
pub mod show_span;
2219

2320
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

compiler/rustc_ast_passes/src/show_span.rs

-68
This file was deleted.

compiler/rustc_builtin_macros/messages.ftl

+15
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,21 @@ builtin_macros_cfg_accessible_indeterminate = cannot determine whether the path
9494
builtin_macros_cfg_accessible_literal_path = `cfg_accessible` path cannot be a literal
9595
builtin_macros_cfg_accessible_multiple_paths = multiple `cfg_accessible` paths are specified
9696
builtin_macros_cfg_accessible_unspecified_path = `cfg_accessible` path is not specified
97+
98+
builtin_macros_coerce_pointee_requires_maybe_sized = `derive(CoercePointee)` requires `{$name}` to be marked `?Sized`
99+
100+
builtin_macros_coerce_pointee_requires_one_field = `CoercePointee` can only be derived on `struct`s with at least one field
101+
102+
builtin_macros_coerce_pointee_requires_one_generic = `CoercePointee` can only be derived on `struct`s that are generic over at least one type
103+
104+
builtin_macros_coerce_pointee_requires_one_pointee = exactly one generic type parameter must be marked as `#[pointee]` to derive `CoercePointee` traits
105+
106+
builtin_macros_coerce_pointee_requires_transparent = `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`
107+
108+
builtin_macros_coerce_pointee_too_many_pointees = only one type parameter can be marked as `#[pointee]` when deriving `CoercePointee` traits
109+
.label = here another type parameter is marked as `#[pointee]`
110+
111+
97112
builtin_macros_concat_bytes_array = cannot concatenate doubly nested array
98113
.note = byte strings are treated as arrays of bytes
99114
.help = try flattening the array

compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs

+56-41
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_ast::{
99
use rustc_attr as attr;
1010
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
1111
use rustc_expand::base::{Annotatable, ExtCtxt};
12+
use rustc_macros::Diagnostic;
1213
use rustc_span::symbol::{Ident, sym};
1314
use rustc_span::{Span, Symbol};
1415
use thin_vec::{ThinVec, thin_vec};
@@ -38,35 +39,20 @@ pub(crate) fn expand_deriving_coerce_pointee(
3839
.any(|r| matches!(r, attr::ReprTransparent))
3940
});
4041
if !is_transparent {
41-
cx.dcx()
42-
.struct_span_err(
43-
span,
44-
"`CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`",
45-
)
46-
.emit();
42+
cx.dcx().emit_err(RequireTransparent { span });
4743
return;
4844
}
4945
if !matches!(
5046
struct_data,
5147
VariantData::Struct { fields, recovered: _ } | VariantData::Tuple(fields, _)
5248
if !fields.is_empty())
5349
{
54-
cx.dcx()
55-
.struct_span_err(
56-
span,
57-
"`CoercePointee` can only be derived on `struct`s with at least one field",
58-
)
59-
.emit();
50+
cx.dcx().emit_err(RequireOneField { span });
6051
return;
6152
}
6253
(aitem.ident, g)
6354
} else {
64-
cx.dcx()
65-
.struct_span_err(
66-
span,
67-
"`CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`",
68-
)
69-
.emit();
55+
cx.dcx().emit_err(RequireTransparent { span });
7056
return;
7157
};
7258

@@ -95,10 +81,7 @@ pub(crate) fn expand_deriving_coerce_pointee(
9581

9682
let pointee_param_idx = if type_params.is_empty() {
9783
// `#[derive(CoercePointee)]` requires at least one generic type on the target `struct`
98-
cx.dcx().struct_span_err(
99-
span,
100-
"`CoercePointee` can only be derived on `struct`s that are generic over at least one type",
101-
).emit();
84+
cx.dcx().emit_err(RequireOneGeneric { span });
10285
return;
10386
} else if type_params.len() == 1 {
10487
// Regardless of the only type param being designed as `#[pointee]` or not, we can just use it as such
@@ -111,19 +94,11 @@ pub(crate) fn expand_deriving_coerce_pointee(
11194
match (pointees.next(), pointees.next()) {
11295
(Some((idx, _span)), None) => idx,
11396
(None, _) => {
114-
cx.dcx().struct_span_err(
115-
span,
116-
"exactly one generic type parameter must be marked as #[pointee] to derive CoercePointee traits",
117-
).emit();
97+
cx.dcx().emit_err(RequireOnePointee { span });
11898
return;
11999
}
120100
(Some((_, one)), Some((_, another))) => {
121-
cx.dcx()
122-
.struct_span_err(
123-
vec![one, another],
124-
"only one type parameter can be marked as `#[pointee]` when deriving CoercePointee traits",
125-
)
126-
.emit();
101+
cx.dcx().emit_err(TooManyPointees { one, another });
127102
return;
128103
}
129104
}
@@ -181,15 +156,10 @@ pub(crate) fn expand_deriving_coerce_pointee(
181156
pointee_ty_ident.name,
182157
)
183158
{
184-
cx.dcx()
185-
.struct_span_err(
186-
pointee_ty_ident.span,
187-
format!(
188-
"`derive(CoercePointee)` requires {} to be marked `?Sized`",
189-
pointee_ty_ident.name
190-
),
191-
)
192-
.emit();
159+
cx.dcx().emit_err(RequiresMaybeSized {
160+
span: pointee_ty_ident.span,
161+
name: pointee_ty_ident.name.to_ident_string(),
162+
});
193163
return;
194164
}
195165
let arg = GenericArg::Type(s_ty.clone());
@@ -459,3 +429,48 @@ impl<'a, 'b> rustc_ast::visit::Visitor<'a> for AlwaysErrorOnGenericParam<'a, 'b>
459429
}
460430
}
461431
}
432+
433+
#[derive(Diagnostic)]
434+
#[diag(builtin_macros_coerce_pointee_requires_transparent)]
435+
struct RequireTransparent {
436+
#[primary_span]
437+
span: Span,
438+
}
439+
440+
#[derive(Diagnostic)]
441+
#[diag(builtin_macros_coerce_pointee_requires_one_field)]
442+
struct RequireOneField {
443+
#[primary_span]
444+
span: Span,
445+
}
446+
447+
#[derive(Diagnostic)]
448+
#[diag(builtin_macros_coerce_pointee_requires_one_generic)]
449+
struct RequireOneGeneric {
450+
#[primary_span]
451+
span: Span,
452+
}
453+
454+
#[derive(Diagnostic)]
455+
#[diag(builtin_macros_coerce_pointee_requires_one_pointee)]
456+
struct RequireOnePointee {
457+
#[primary_span]
458+
span: Span,
459+
}
460+
461+
#[derive(Diagnostic)]
462+
#[diag(builtin_macros_coerce_pointee_too_many_pointees)]
463+
struct TooManyPointees {
464+
#[primary_span]
465+
one: Span,
466+
#[label]
467+
another: Span,
468+
}
469+
470+
#[derive(Diagnostic)]
471+
#[diag(builtin_macros_coerce_pointee_requires_maybe_sized)]
472+
struct RequiresMaybeSized {
473+
#[primary_span]
474+
span: Span,
475+
name: String,
476+
}

compiler/rustc_driver_impl/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,7 @@ fn run_compiler(
418418
return early_exit();
419419
}
420420

421-
if sess.opts.unstable_opts.parse_crate_root_only
422-
|| sess.opts.unstable_opts.show_span.is_some()
423-
{
421+
if sess.opts.unstable_opts.parse_crate_root_only {
424422
return early_exit();
425423
}
426424

compiler/rustc_hir_analysis/src/collect.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,10 @@ impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
309309
self.tcx.ensure().type_of(param.def_id);
310310
if let Some(default) = default {
311311
// need to store default and type of default
312+
self.tcx.ensure().const_param_default(param.def_id);
312313
if let hir::ConstArgKind::Anon(ac) = default.kind {
313314
self.tcx.ensure().type_of(ac.def_id);
314315
}
315-
self.tcx.ensure().const_param_default(param.def_id);
316316
}
317317
}
318318
}
@@ -1817,7 +1817,6 @@ fn const_param_default<'tcx>(
18171817
),
18181818
};
18191819
let icx = ItemCtxt::new(tcx, def_id);
1820-
// FIXME(const_generics): investigate which places do and don't need const ty feeding
1821-
let ct = icx.lowerer().lower_const_arg(default_ct, FeedConstTy::No);
1820+
let ct = icx.lowerer().lower_const_arg(default_ct, FeedConstTy::Param(def_id.to_def_id()));
18221821
ty::EarlyBinder::bind(ct)
18231822
}

0 commit comments

Comments
 (0)