diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 4c64e679b9571..5e5596f13c845 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -117,7 +117,6 @@ pub fn create_session( let mut check_cfg = config::to_crate_check_config(check_cfg); check_cfg.fill_well_known(); - check_cfg.fill_actual(&cfg); sess.parse_sess.config = cfg; sess.parse_sess.check_config = check_cfg; diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 833edd2280500..ad78d24e95465 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -232,6 +232,10 @@ fn sanity_check_layout<'tcx>( assert!(layout.abi.is_uninhabited()); } + if layout.size.bytes() % layout.align.abi.bytes() != 0 { + bug!("size is not a multiple of align, in the following layout:\n{layout:#?}"); + } + if cfg!(debug_assertions) { fn check_layout_abi<'tcx>(tcx: TyCtxt<'tcx>, layout: Layout<'tcx>) { match layout.abi() { diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 70f942a65089a..6a8298605a23b 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1159,20 +1159,6 @@ impl CrateCheckConfig { self.fill_well_known_names(); self.fill_well_known_values(); } - - /// Fills a `CrateCheckConfig` with configuration names and values that are actually active. - pub fn fill_actual(&mut self, cfg: &CrateConfig) { - for &(k, v) in cfg { - if let Some(names_valid) = &mut self.names_valid { - names_valid.insert(k); - } - if let Some(v) = v { - self.values_valid.entry(k).and_modify(|values| { - values.insert(v); - }); - } - } - } } pub fn build_configuration(sess: &Session, mut user_cfg: CrateConfig) -> CrateConfig { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 6495339eaf19c..1827f1c208de7 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -393,8 +393,7 @@ mod desc { "either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted"; pub const parse_linker_plugin_lto: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin"; - pub const parse_location_detail: &str = - "comma separated list of location details to track: `file`, `line`, or `column`"; + pub const parse_location_detail: &str = "either `none`, or a comma separated list of location details to track: `file`, `line`, or `column`"; pub const parse_switch_with_opt_path: &str = "an optional path to the profiling data output directory"; pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`"; @@ -551,6 +550,9 @@ mod parse { ld.line = false; ld.file = false; ld.column = false; + if v == "none" { + return true; + } for s in v.split(',') { match s { "file" => ld.file = true, @@ -1374,8 +1376,9 @@ options! { llvm_time_trace: bool = (false, parse_bool, [UNTRACKED], "generate JSON tracing data file from LLVM data (default: no)"), location_detail: LocationDetail = (LocationDetail::all(), parse_location_detail, [TRACKED], - "comma separated list of location details to be tracked when using caller_location \ - valid options are `file`, `line`, and `column` (default: all)"), + "what location details should be tracked when using caller_location, either \ + `none`, or a comma separated list of location details, for which \ + valid options are `file`, `line`, and `column` (default: `file,line,column`)"), ls: bool = (false, parse_bool, [UNTRACKED], "list the symbols defined by a library crate (default: no)"), macro_backtrace: bool = (false, parse_bool, [UNTRACKED], diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs index b35502d9ee42b..d4d5674e246d8 100644 --- a/compiler/rustc_target/src/abi/mod.rs +++ b/compiler/rustc_target/src/abi/mod.rs @@ -1279,13 +1279,14 @@ impl<'a> fmt::Debug for LayoutS<'a> { // This is how `Layout` used to print before it become // `Interned`. We print it like this to avoid having to update // expected output in a lot of tests. + let LayoutS { size, align, abi, fields, largest_niche, variants } = self; f.debug_struct("Layout") - .field("fields", &self.fields) - .field("variants", &self.variants) - .field("abi", &self.abi) - .field("largest_niche", &self.largest_niche) - .field("align", &self.align) - .field("size", &self.size) + .field("size", size) + .field("align", align) + .field("abi", abi) + .field("fields", fields) + .field("largest_niche", largest_niche) + .field("variants", variants) .finish() } } diff --git a/compiler/rustc_typeck/src/check/demand.rs b/compiler/rustc_typeck/src/check/demand.rs index 58b0399c5c927..f0110645551af 100644 --- a/compiler/rustc_typeck/src/check/demand.rs +++ b/compiler/rustc_typeck/src/check/demand.rs @@ -1,5 +1,6 @@ use crate::check::FnCtxt; use rustc_infer::infer::InferOk; +use rustc_middle::middle::stability::EvalResult; use rustc_trait_selection::infer::InferCtxtExt as _; use rustc_trait_selection::traits::ObligationCause; @@ -363,18 +364,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - let compatible_variants: Vec<(String, Option)> = expected_adt + let compatible_variants: Vec<(String, _, _, Option)> = expected_adt .variants() .iter() .filter(|variant| { - variant.fields.len() == 1 && variant.ctor_kind == hir::def::CtorKind::Fn + variant.fields.len() == 1 }) .filter_map(|variant| { let sole_field = &variant.fields[0]; let field_is_local = sole_field.did.is_local(); let field_is_accessible = - sole_field.vis.is_accessible_from(expr.hir_id.owner.to_def_id(), self.tcx); + sole_field.vis.is_accessible_from(expr.hir_id.owner.to_def_id(), self.tcx) + // Skip suggestions for unstable public fields (for example `Pin::pointer`) + && matches!(self.tcx.eval_stability(sole_field.did, None, expr.span, None), EvalResult::Allow | EvalResult::Unmarked); if !field_is_local && !field_is_accessible { return None; @@ -391,33 +394,45 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(path) = variant_path.strip_prefix("std::prelude::") && let Some((_, path)) = path.split_once("::") { - return Some((path.to_string(), note_about_variant_field_privacy)); + return Some((path.to_string(), variant.ctor_kind, sole_field.name, note_about_variant_field_privacy)); } - Some((variant_path, note_about_variant_field_privacy)) + Some((variant_path, variant.ctor_kind, sole_field.name, note_about_variant_field_privacy)) } else { None } }) .collect(); - let prefix = match self.maybe_get_struct_pattern_shorthand_field(expr) { - Some(ident) => format!("{ident}: "), - None => String::new(), + let suggestions_for = |variant: &_, ctor, field_name| { + let prefix = match self.maybe_get_struct_pattern_shorthand_field(expr) { + Some(ident) => format!("{ident}: "), + None => String::new(), + }; + + let (open, close) = match ctor { + hir::def::CtorKind::Fn => ("(".to_owned(), ")"), + hir::def::CtorKind::Fictive => (format!(" {{ {field_name}: "), " }"), + + // unit variants don't have fields + hir::def::CtorKind::Const => unreachable!(), + }; + + vec![ + (expr.span.shrink_to_lo(), format!("{prefix}{variant}{open}")), + (expr.span.shrink_to_hi(), close.to_owned()), + ] }; match &compatible_variants[..] { [] => { /* No variants to format */ } - [(variant, note)] => { + [(variant, ctor_kind, field_name, note)] => { // Just a single matching variant. err.multipart_suggestion_verbose( &format!( "try wrapping the expression in `{variant}`{note}", note = note.as_deref().unwrap_or("") ), - vec![ - (expr.span.shrink_to_lo(), format!("{prefix}{variant}(")), - (expr.span.shrink_to_hi(), ")".to_string()), - ], + suggestions_for(&**variant, *ctor_kind, *field_name), Applicability::MaybeIncorrect, ); } @@ -428,12 +443,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "try wrapping the expression in a variant of `{}`", self.tcx.def_path_str(expected_adt.did()) ), - compatible_variants.into_iter().map(|(variant, _)| { - vec![ - (expr.span.shrink_to_lo(), format!("{prefix}{variant}(")), - (expr.span.shrink_to_hi(), ")".to_string()), - ] - }), + compatible_variants.into_iter().map( + |(variant, ctor_kind, field_name, _)| { + suggestions_for(&variant, ctor_kind, field_name) + }, + ), Applicability::MaybeIncorrect, ); } diff --git a/library/panic_unwind/src/gcc.rs b/library/panic_unwind/src/gcc.rs index 057e47bfdd18a..a596592311a64 100644 --- a/library/panic_unwind/src/gcc.rs +++ b/library/panic_unwind/src/gcc.rs @@ -306,7 +306,9 @@ unsafe fn find_eh_action(context: *mut uw::_Unwind_Context) -> Result) -> F { unsafe { - static symbol_name: &CStr = ansi_str!(sym $symbol); - if let Some(f) = module.and_then(|m| m.proc_address(symbol_name)) { + static SYMBOL_NAME: &CStr = ansi_str!(sym $symbol); + if let Some(f) = module.and_then(|m| m.proc_address(SYMBOL_NAME)) { PTR.store(f.as_ptr(), Ordering::Relaxed); mem::transmute(f) } else { @@ -251,7 +251,7 @@ macro_rules! compat_fn_optional { pub fn option() -> Option { let mut func = NonNull::new(PTR.load(Ordering::Relaxed)); if func.is_none() { - Module::new($module).map(preload); + unsafe { Module::new($module).map(preload) }; func = NonNull::new(PTR.load(Ordering::Relaxed)); } unsafe { @@ -262,8 +262,8 @@ macro_rules! compat_fn_optional { #[allow(unused)] pub(in crate::sys) fn preload(module: Module) { unsafe { - let symbol_name = ansi_str!(sym $symbol); - if let Some(f) = module.proc_address(symbol_name) { + static SYMBOL_NAME: &CStr = ansi_str!(sym $symbol); + if let Some(f) = module.proc_address(SYMBOL_NAME) { PTR.store(f.as_ptr(), Ordering::Relaxed); } } diff --git a/src/doc/unstable-book/src/compiler-flags/check-cfg.md b/src/doc/unstable-book/src/compiler-flags/check-cfg.md index 486b3d4414f3a..bfa92e7d32a8e 100644 --- a/src/doc/unstable-book/src/compiler-flags/check-cfg.md +++ b/src/doc/unstable-book/src/compiler-flags/check-cfg.md @@ -18,6 +18,9 @@ check cfg specification is parsed using the Rust metadata syntax, just as the `- These two options are independent. `names` checks only the namespace of condition names while `values` checks only the namespace of the values of list-valued conditions. +NOTE: No implicit expectation is added when using `--cfg` for both forms. Users are expected to +pass all expected names and values using `names(...)` and `values(...)`. + ## The `names(...)` form The `names(...)` form enables checking the names. This form uses a named list: @@ -53,27 +56,6 @@ The first form enables checking condition names, while specifying that there are condition names (outside of the set of well-known names defined by `rustc`). Omitting the `--check-cfg 'names(...)'` option does not enable checking condition names. -Conditions that are enabled are implicitly valid; it is unnecessary (but legal) to specify a -condition name as both enabled and valid. For example, the following invocations are equivalent: - -```bash -# condition names will be checked, and 'has_time_travel' is valid -rustc --cfg 'has_time_travel' --check-cfg 'names()' - -# condition names will be checked, and 'has_time_travel' is valid -rustc --cfg 'has_time_travel' --check-cfg 'names(has_time_travel)' -``` - -In contrast, the following two invocations are _not_ equivalent: - -```bash -# condition names will not be checked (because there is no --check-cfg names(...)) -rustc --cfg 'has_time_travel' - -# condition names will be checked, and 'has_time_travel' is both valid and enabled. -rustc --cfg 'has_time_travel' --check-cfg 'names(has_time_travel)' -``` - ## The `values(...)` form The `values(...)` form enables checking the values within list-valued conditions. It has this @@ -149,7 +131,7 @@ fn tame_lion() {} ```bash # This turns on checking for condition names, but not values, such as 'feature' values. rustc --check-cfg 'names(is_embedded, has_feathers)' \ - --cfg has_feathers --cfg 'feature = "zapping"' -Z unstable-options + --cfg has_feathers -Z unstable-options ``` ```rust @@ -159,13 +141,14 @@ fn do_embedded() {} #[cfg(has_feathers)] // This is expected as "has_feathers" was provided in names() fn do_features() {} +#[cfg(has_feathers = "zapping")] // This is expected as "has_feathers" was provided in names() + // and because no value checking was enable for "has_feathers" + // no warning is emited for the value "zapping" +fn do_zapping() {} + #[cfg(has_mumble_frotz)] // This is UNEXPECTED because names checking is enable and // "has_mumble_frotz" was not provided in names() fn do_mumble_frotz() {} - -#[cfg(feature = "lasers")] // This doesn't raise a warning, because values checking for "feature" - // was never used -fn shoot_lasers() {} ``` ### Example: Checking feature values, but not condition names diff --git a/src/doc/unstable-book/src/compiler-flags/location-detail.md b/src/doc/unstable-book/src/compiler-flags/location-detail.md index 08d937cc28200..db07061996964 100644 --- a/src/doc/unstable-book/src/compiler-flags/location-detail.md +++ b/src/doc/unstable-book/src/compiler-flags/location-detail.md @@ -17,8 +17,9 @@ within this list are: - `line` - the source line of the panic will be included in the panic output - `column` - the source column of the panic will be included in the panic output -Any combination of these three options are supported. If this option is not specified, -all three are included by default. +Any combination of these three options are supported. Alternatively, you can pass +`none` to this option, which results in no location details being tracked. +If this option is not specified, all three are included by default. An example of a panic output when using `-Z location-detail=line`: ```text diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 4067cf8441b3d..5071581e5dc43 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1019,7 +1019,7 @@ impl<'tcx> Clean<'tcx, bool> for hir::IsAuto { impl<'tcx> Clean<'tcx, Path> for hir::TraitRef<'tcx> { fn clean(&self, cx: &mut DocContext<'tcx>) -> Path { - let path = self.path.clean(cx); + let path = clean_path(self.path, cx); register_res(cx, path.res); path } @@ -1344,7 +1344,7 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type if let Some(expanded) = maybe_expand_private_type_alias(cx, path) { expanded } else { - let path = path.clean(cx); + let path = clean_path(path, cx); resolve_type(cx, path) } } @@ -1380,7 +1380,7 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type ty::Error(_) => return Type::Infer, _ => bug!("clean: expected associated type, found `{:?}`", ty), }; - let trait_ = hir::Path { span, res, segments: &[] }.clean(cx); + let trait_ = clean_path(&hir::Path { span, res, segments: &[] }, cx); register_res(cx, trait_.res); let self_def_id = res.opt_def_id(); let self_type = clean_ty(qself, cx); @@ -1857,10 +1857,8 @@ fn clean_variant_data<'tcx>( } } -impl<'tcx> Clean<'tcx, Path> for hir::Path<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Path { - Path { res: self.res, segments: self.segments.iter().map(|x| x.clean(cx)).collect() } - } +fn clean_path<'tcx>(path: &hir::Path<'tcx>, cx: &mut DocContext<'tcx>) -> Path { + Path { res: path.res, segments: path.segments.iter().map(|x| x.clean(cx)).collect() } } impl<'tcx> Clean<'tcx, GenericArgs> for hir::GenericArgs<'tcx> { @@ -1886,7 +1884,8 @@ impl<'tcx> Clean<'tcx, GenericArgs> for hir::GenericArgs<'tcx> { }) .collect::>() .into(); - let bindings = self.bindings.iter().map(|x| x.clean(cx)).collect::>().into(); + let bindings = + self.bindings.iter().map(|x| clean_type_binding(x, cx)).collect::>().into(); GenericArgs::AngleBracketed { args, bindings } } } @@ -2172,7 +2171,7 @@ fn clean_use_statement<'tcx>( // Also check whether imports were asked to be inlined, in case we're trying to re-export a // crate in Rust 2018+ - let path = path.clean(cx); + let path = clean_path(path, cx); let inner = if kind == hir::UseKind::Glob { if !denied { let mut visited = FxHashSet::default(); @@ -2252,24 +2251,19 @@ fn clean_maybe_renamed_foreign_item<'tcx>( }) } -impl<'tcx> Clean<'tcx, TypeBinding> for hir::TypeBinding<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> TypeBinding { - TypeBinding { - assoc: PathSegment { name: self.ident.name, args: self.gen_args.clean(cx) }, - kind: self.kind.clean(cx), - } - } -} - -impl<'tcx> Clean<'tcx, TypeBindingKind> for hir::TypeBindingKind<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> TypeBindingKind { - match *self { +fn clean_type_binding<'tcx>( + type_binding: &hir::TypeBinding<'tcx>, + cx: &mut DocContext<'tcx>, +) -> TypeBinding { + TypeBinding { + assoc: PathSegment { name: type_binding.ident.name, args: type_binding.gen_args.clean(cx) }, + kind: match type_binding.kind { hir::TypeBindingKind::Equality { ref term } => { TypeBindingKind::Equality { term: clean_hir_term(term, cx) } } hir::TypeBindingKind::Constraint { bounds } => TypeBindingKind::Constraint { bounds: bounds.iter().filter_map(|b| b.clean(cx)).collect(), }, - } + }, } } diff --git a/src/test/rustdoc-ui/z-help.stdout b/src/test/rustdoc-ui/z-help.stdout index c8e5cac059412..6dc41231559c0 100644 --- a/src/test/rustdoc-ui/z-help.stdout +++ b/src/test/rustdoc-ui/z-help.stdout @@ -69,7 +69,7 @@ -Z link-only=val -- link the `.rlink` file generated by `-Z no-link` (default: no) -Z llvm-plugins=val -- a list LLVM plugins to enable (space separated) -Z llvm-time-trace=val -- generate JSON tracing data file from LLVM data (default: no) - -Z location-detail=val -- comma separated list of location details to be tracked when using caller_location valid options are `file`, `line`, and `column` (default: all) + -Z location-detail=val -- what location details should be tracked when using caller_location, either `none`, or a comma separated list of location details, for which valid options are `file`, `line`, and `column` (default: `file,line,column`) -Z ls=val -- list the symbols defined by a library crate (default: no) -Z macro-backtrace=val -- show macro backtraces (default: no) -Z merge-functions=val -- control the operation of the MergeFunctions LLVM pass, taking the same values as the target option of the same name diff --git a/src/test/ui/check-cfg/invalid-cfg-value.rs b/src/test/ui/check-cfg/invalid-cfg-value.rs index a60095a5aae9d..9e428d367fdf4 100644 --- a/src/test/ui/check-cfg/invalid-cfg-value.rs +++ b/src/test/ui/check-cfg/invalid-cfg-value.rs @@ -12,6 +12,7 @@ pub fn f() {} pub fn g() {} #[cfg(feature = "rand")] +//~^ WARNING unexpected `cfg` condition value pub fn h() {} pub fn main() {} diff --git a/src/test/ui/check-cfg/invalid-cfg-value.stderr b/src/test/ui/check-cfg/invalid-cfg-value.stderr index bc2c053fed65a..6cce31d339286 100644 --- a/src/test/ui/check-cfg/invalid-cfg-value.stderr +++ b/src/test/ui/check-cfg/invalid-cfg-value.stderr @@ -5,7 +5,15 @@ LL | #[cfg(feature = "sedre")] | ^^^^^^^^^^^^^^^^^ | = note: `#[warn(unexpected_cfgs)]` on by default - = note: expected values for `feature` are: full, rand, serde + = note: expected values for `feature` are: full, serde -warning: 1 warning emitted +warning: unexpected `cfg` condition value + --> $DIR/invalid-cfg-value.rs:14:7 + | +LL | #[cfg(feature = "rand")] + | ^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: full, serde + +warning: 2 warnings emitted diff --git a/src/test/ui/check-cfg/mix.rs b/src/test/ui/check-cfg/mix.rs index b51d356f61fdf..8e3d20d50458f 100644 --- a/src/test/ui/check-cfg/mix.rs +++ b/src/test/ui/check-cfg/mix.rs @@ -1,6 +1,6 @@ -// This test checks the combination of well known names, their activation via names(), the usage of -// partial values() with a --cfg and test that we also correctly lint on the `cfg!` macro and -// `cfg_attr` attribute. +// This test checks the combination of well known names, their activation via names(), +// the usage of values(), and that no implicit is done with --cfg while also testing that +// we correctly lint on the `cfg!` macro and `cfg_attr` attribute. // // check-pass // compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo") --cfg feature="bar" -Z unstable-options @@ -16,6 +16,7 @@ fn do_windows_stuff() {} fn use_foo() {} #[cfg(feature = "bar")] +//~^ WARNING unexpected `cfg` condition value fn use_bar() {} #[cfg(feature = "zebra")] @@ -35,6 +36,7 @@ fn test_cfg_macro() { //~^ WARNING unexpected `cfg` condition name cfg!(feature = "foo"); cfg!(feature = "bar"); + //~^ WARNING unexpected `cfg` condition value cfg!(feature = "zebra"); //~^ WARNING unexpected `cfg` condition value cfg!(xxx = "foo"); diff --git a/src/test/ui/check-cfg/mix.stderr b/src/test/ui/check-cfg/mix.stderr index 08a338da104d0..e51b75b3d4358 100644 --- a/src/test/ui/check-cfg/mix.stderr +++ b/src/test/ui/check-cfg/mix.stderr @@ -7,21 +7,29 @@ LL | #[cfg(widnows)] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value - --> $DIR/mix.rs:21:7 + --> $DIR/mix.rs:18:7 + | +LL | #[cfg(feature = "bar")] + | ^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: foo + +warning: unexpected `cfg` condition value + --> $DIR/mix.rs:22:7 | LL | #[cfg(feature = "zebra")] | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: bar, foo + = note: expected values for `feature` are: foo warning: unexpected `cfg` condition name - --> $DIR/mix.rs:25:12 + --> $DIR/mix.rs:26:12 | LL | #[cfg_attr(uu, test)] | ^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:34:10 + --> $DIR/mix.rs:35:10 | LL | cfg!(widnows); | ^^^^^^^ help: did you mean: `windows` @@ -29,132 +37,138 @@ LL | cfg!(widnows); warning: unexpected `cfg` condition value --> $DIR/mix.rs:38:10 | +LL | cfg!(feature = "bar"); + | ^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: foo + +warning: unexpected `cfg` condition value + --> $DIR/mix.rs:40:10 + | LL | cfg!(feature = "zebra"); | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: bar, foo + = note: expected values for `feature` are: foo warning: unexpected `cfg` condition name - --> $DIR/mix.rs:40:10 + --> $DIR/mix.rs:42:10 | LL | cfg!(xxx = "foo"); | ^^^^^^^^^^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:42:10 + --> $DIR/mix.rs:44:10 | LL | cfg!(xxx); | ^^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:44:14 + --> $DIR/mix.rs:46:14 | LL | cfg!(any(xxx, windows)); | ^^^ warning: unexpected `cfg` condition value - --> $DIR/mix.rs:46:14 + --> $DIR/mix.rs:48:14 | LL | cfg!(any(feature = "bad", windows)); - | ^^^^^^^^^^----- - | | - | help: did you mean: `"bar"` + | ^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: bar, foo + = note: expected values for `feature` are: foo warning: unexpected `cfg` condition name - --> $DIR/mix.rs:48:23 + --> $DIR/mix.rs:50:23 | LL | cfg!(any(windows, xxx)); | ^^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:50:20 + --> $DIR/mix.rs:52:20 | LL | cfg!(all(unix, xxx)); | ^^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:52:14 + --> $DIR/mix.rs:54:14 | LL | cfg!(all(aa, bb)); | ^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:52:18 + --> $DIR/mix.rs:54:18 | LL | cfg!(all(aa, bb)); | ^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:55:14 + --> $DIR/mix.rs:57:14 | LL | cfg!(any(aa, bb)); | ^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:55:18 + --> $DIR/mix.rs:57:18 | LL | cfg!(any(aa, bb)); | ^^ warning: unexpected `cfg` condition value - --> $DIR/mix.rs:58:20 + --> $DIR/mix.rs:60:20 | LL | cfg!(any(unix, feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: bar, foo + = note: expected values for `feature` are: foo warning: unexpected `cfg` condition name - --> $DIR/mix.rs:60:14 + --> $DIR/mix.rs:62:14 | LL | cfg!(any(xxx, feature = "zebra")); | ^^^ warning: unexpected `cfg` condition value - --> $DIR/mix.rs:60:19 + --> $DIR/mix.rs:62:19 | LL | cfg!(any(xxx, feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: bar, foo + = note: expected values for `feature` are: foo warning: unexpected `cfg` condition name - --> $DIR/mix.rs:63:14 + --> $DIR/mix.rs:65:14 | LL | cfg!(any(xxx, unix, xxx)); | ^^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:63:25 + --> $DIR/mix.rs:65:25 | LL | cfg!(any(xxx, unix, xxx)); | ^^^ warning: unexpected `cfg` condition value - --> $DIR/mix.rs:66:14 + --> $DIR/mix.rs:68:14 | LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: bar, foo + = note: expected values for `feature` are: foo warning: unexpected `cfg` condition value - --> $DIR/mix.rs:66:33 + --> $DIR/mix.rs:68:33 | LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: bar, foo + = note: expected values for `feature` are: foo warning: unexpected `cfg` condition value - --> $DIR/mix.rs:66:52 + --> $DIR/mix.rs:68:52 | LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: bar, foo + = note: expected values for `feature` are: foo -warning: 23 warnings emitted +warning: 25 warnings emitted diff --git a/src/test/ui/did_you_mean/compatible-variants.rs b/src/test/ui/did_you_mean/compatible-variants.rs index 5d7c611980f1c..b1c7dc2a7f672 100644 --- a/src/test/ui/did_you_mean/compatible-variants.rs +++ b/src/test/ui/did_you_mean/compatible-variants.rs @@ -66,7 +66,7 @@ fn main() { } enum A { - B { b: B}, + B { b: B }, } struct A2(B); @@ -77,13 +77,12 @@ enum B { } fn foo() { - // We don't want to suggest `A::B(B::Fst)` here. let a: A = B::Fst; //~^ ERROR mismatched types + //~| HELP try wrapping } fn bar() { - // But we _do_ want to suggest `A2(B::Fst)` here! let a: A2 = B::Fst; //~^ ERROR mismatched types //~| HELP try wrapping diff --git a/src/test/ui/did_you_mean/compatible-variants.stderr b/src/test/ui/did_you_mean/compatible-variants.stderr index a16cdee44623a..fe81da19833a7 100644 --- a/src/test/ui/did_you_mean/compatible-variants.stderr +++ b/src/test/ui/did_you_mean/compatible-variants.stderr @@ -191,15 +191,20 @@ LL | let _ = Foo { bar: Some(bar) }; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/compatible-variants.rs:81:16 + --> $DIR/compatible-variants.rs:80:16 | LL | let a: A = B::Fst; | - ^^^^^^ expected enum `A`, found enum `B` | | | expected due to this + | +help: try wrapping the expression in `A::B` + | +LL | let a: A = A::B { b: B::Fst }; + | +++++++++ + error[E0308]: mismatched types - --> $DIR/compatible-variants.rs:87:17 + --> $DIR/compatible-variants.rs:86:17 | LL | let a: A2 = B::Fst; | -- ^^^^^^ expected struct `A2`, found enum `B` diff --git a/src/test/ui/did_you_mean/issue-42764.rs b/src/test/ui/did_you_mean/issue-42764.rs index 6da640b2b7c76..eb96c2480630e 100644 --- a/src/test/ui/did_you_mean/issue-42764.rs +++ b/src/test/ui/did_you_mean/issue-42764.rs @@ -26,4 +26,5 @@ struct Context { wrapper: Wrapper } fn overton() { let _c = Context { wrapper: Payload{} }; //~^ ERROR mismatched types + //~| try wrapping the expression in `Wrapper` } diff --git a/src/test/ui/did_you_mean/issue-42764.stderr b/src/test/ui/did_you_mean/issue-42764.stderr index 95b572133c5f7..6a7fd8fe251dc 100644 --- a/src/test/ui/did_you_mean/issue-42764.stderr +++ b/src/test/ui/did_you_mean/issue-42764.stderr @@ -25,6 +25,11 @@ error[E0308]: mismatched types | LL | let _c = Context { wrapper: Payload{} }; | ^^^^^^^^^ expected struct `Wrapper`, found struct `Payload` + | +help: try wrapping the expression in `Wrapper` + | +LL | let _c = Context { wrapper: Wrapper { payload: Payload{} } }; + | ++++++++++++++++++ + error: aborting due to 2 previous errors diff --git a/src/test/ui/layout/debug.stderr b/src/test/ui/layout/debug.stderr index 7ba9657fcd6f1..c5e1c41d1304c 100644 --- a/src/test/ui/layout/debug.stderr +++ b/src/test/ui/layout/debug.stderr @@ -1,4 +1,12 @@ error: layout_of(E) = Layout { + size: Size(12 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -7,6 +15,16 @@ error: layout_of(E) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I32, + false, + ), + valid_range: 0..=0, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -19,24 +37,30 @@ error: layout_of(E) = Layout { tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(12 bytes), align: AbiAndPrefAlign { - abi: Align(1 bytes), + abi: Align(4 bytes), pref: $PREF_ALIGN, }, - size: Size(4 bytes), - }, - Layout { + abi: Uninhabited, fields: Arbitrary { offsets: [ Size(4 bytes), @@ -49,37 +73,13 @@ error: layout_of(E) = Layout { 2, ], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Uninhabited, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(12 bytes), }, ], }, - abi: Aggregate { - sized: true, - }, - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - false, - ), - valid_range: 0..=0, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(12 bytes), } --> $DIR/debug.rs:6:1 | @@ -87,20 +87,10 @@ LL | enum E { Foo, Bar(!, i32, i32) } | ^^^^^^ error: layout_of(S) = Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - Size(0 bytes), - Size(4 bytes), - ], - memory_index: [ - 1, - 0, - 2, - ], - }, - variants: Single { - index: 0, + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -118,12 +108,22 @@ error: layout_of(S) = Layout { valid_range: 0..=4294967295, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + Size(0 bytes), + Size(4 bytes), + ], + memory_index: [ + 1, + 0, + 2, + ], + }, largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 0, }, - size: Size(8 bytes), } --> $DIR/debug.rs:9:1 | @@ -131,21 +131,21 @@ LL | struct S { f1: i32, f2: (), f3: i32 } | ^^^^^^^^ error: layout_of(U) = Layout { - fields: Union( - 2, - ), - variants: Single { - index: 0, + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, }, abi: Aggregate { sized: true, }, + fields: Union( + 2, + ), largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 0, }, - size: Size(8 bytes), } --> $DIR/debug.rs:12:1 | @@ -153,6 +153,27 @@ LL | union U { f1: (i32, i32), f3: i32 } | ^^^^^^^ error: layout_of(std::result::Result) = Layout { + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: ScalarPair( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 0..=1, + }, + Initialized { + value: Int( + I32, + true, + ), + valid_range: 0..=4294967295, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -161,6 +182,16 @@ error: layout_of(std::result::Result) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I32, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -173,16 +204,10 @@ error: layout_of(std::result::Result) = Layout { tag_field: 0, variants: [ Layout { - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - memory_index: [ - 0, - ], - }, - variants: Single { - index: 0, + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -200,14 +225,6 @@ error: layout_of(std::result::Result) = Layout { valid_range: 0..=4294967295, }, ), - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(8 bytes), - }, - Layout { fields: Arbitrary { offsets: [ Size(4 bytes), @@ -216,8 +233,16 @@ error: layout_of(std::result::Result) = Layout { 0, ], }, + largest_niche: None, variants: Single { - index: 1, + index: 0, + }, + }, + Layout { + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -235,46 +260,21 @@ error: layout_of(std::result::Result) = Layout { valid_range: 0..=4294967295, }, ), + fields: Arbitrary { + offsets: [ + Size(4 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 1, }, - size: Size(8 bytes), }, ], }, - abi: ScalarPair( - Initialized { - value: Int( - I32, - false, - ), - valid_range: 0..=1, - }, - Initialized { - value: Int( - I32, - true, - ), - valid_range: 0..=4294967295, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - false, - ), - valid_range: 0..=1, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(8 bytes), } --> $DIR/debug.rs:15:1 | @@ -282,9 +282,10 @@ LL | type Test = Result; | ^^^^^^^^^ error: layout_of(i32) = Layout { - fields: Primitive, - variants: Single { - index: 0, + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, }, abi: Scalar( Initialized { @@ -295,12 +296,11 @@ error: layout_of(i32) = Layout { valid_range: 0..=4294967295, }, ), + fields: Primitive, largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 0, }, - size: Size(4 bytes), } --> $DIR/debug.rs:18:1 | diff --git a/src/test/ui/layout/hexagon-enum.stderr b/src/test/ui/layout/hexagon-enum.stderr index f3123cb0ad22e..d850dd69c96e3 100644 --- a/src/test/ui/layout/hexagon-enum.stderr +++ b/src/test/ui/layout/hexagon-enum.stderr @@ -1,4 +1,18 @@ error: layout_of(A) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(1 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -7,6 +21,16 @@ error: layout_of(A) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=0, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -19,34 +43,54 @@ error: layout_of(A) = Layout { tag_field: 0, variants: [ Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(1 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(1 bytes), - }, - size: Size(1 bytes), }, ], }, + } + --> $DIR/hexagon-enum.rs:16:1 + | +LL | enum A { Apple } + | ^^^^^^ + +error: layout_of(B) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(1 bytes), + }, abi: Scalar( Initialized { value: Int( I8, false, ), - valid_range: 0..=0, + valid_range: 255..=255, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -54,29 +98,9 @@ error: layout_of(A) = Layout { I8, false, ), - valid_range: 0..=0, + valid_range: 255..=255, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(1 bytes), - }, - size: Size(1 bytes), - } - --> $DIR/hexagon-enum.rs:16:1 - | -LL | enum A { Apple } - | ^^^^^^ - -error: layout_of(B) = Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - memory_index: [ - 0, - ], - }, variants: Multiple { tag: Initialized { value: Int( @@ -89,49 +113,25 @@ error: layout_of(B) = Layout { tag_field: 0, variants: [ Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(1 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(1 bytes), - }, - size: Size(1 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I8, - false, - ), - valid_range: 255..=255, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 255..=255, - }, - ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(1 bytes), - }, - size: Size(1 bytes), } --> $DIR/hexagon-enum.rs:20:1 | @@ -139,6 +139,20 @@ LL | enum B { Banana = 255, } | ^^^^^^ error: layout_of(C) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: Align(2 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I16, + false, + ), + valid_range: 256..=256, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -147,6 +161,16 @@ error: layout_of(C) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I16, + false, + ), + valid_range: 256..=256, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -159,49 +183,25 @@ error: layout_of(C) = Layout { tag_field: 0, variants: [ Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: Align(2 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(2 bytes), - pref: Align(2 bytes), - }, - size: Size(2 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I16, - false, - ), - valid_range: 256..=256, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I16, - false, - ), - valid_range: 256..=256, - }, - ), - align: AbiAndPrefAlign { - abi: Align(2 bytes), - pref: Align(2 bytes), - }, - size: Size(2 bytes), } --> $DIR/hexagon-enum.rs:24:1 | @@ -209,6 +209,20 @@ LL | enum C { Chaenomeles = 256, } | ^^^^^^ error: layout_of(P) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 268435456..=268435456, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -217,6 +231,16 @@ error: layout_of(P) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I32, + false, + ), + valid_range: 268435456..=268435456, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -229,49 +253,25 @@ error: layout_of(P) = Layout { tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I32, - false, - ), - valid_range: 268435456..=268435456, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - false, - ), - valid_range: 268435456..=268435456, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), } --> $DIR/hexagon-enum.rs:28:1 | @@ -279,6 +279,20 @@ LL | enum P { Peach = 0x1000_0000isize, } | ^^^^^^ error: layout_of(T) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I32, + true, + ), + valid_range: 2164260864..=2164260864, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -287,6 +301,16 @@ error: layout_of(T) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I32, + true, + ), + valid_range: 2164260864..=2164260864, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -299,49 +323,25 @@ error: layout_of(T) = Layout { tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I32, - true, - ), - valid_range: 2164260864..=2164260864, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - true, - ), - valid_range: 2164260864..=2164260864, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), } --> $DIR/hexagon-enum.rs:34:1 | diff --git a/src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index 84d8bc799b93f..6deb1f271a728 100644 --- a/src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -1,4 +1,24 @@ error: layout_of(MissingPayloadField) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, + abi: ScalarPair( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + Union { + value: Int( + I8, + false, + ), + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -7,6 +27,16 @@ error: layout_of(MissingPayloadField) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -19,16 +49,10 @@ error: layout_of(MissingPayloadField) = Layout { tag_field: 0, variants: [ Layout { - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - memory_index: [ - 0, - ], - }, - variants: Single { - index: 0, + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -45,33 +69,51 @@ error: layout_of(MissingPayloadField) = Layout { ), }, ), + fields: Arbitrary { + offsets: [ + Size(1 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: None, + variants: Single { + index: 0, + }, + }, + Layout { + size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(2 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(1 bytes), }, ], }, + } + --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:16:1 + | +LL | pub enum MissingPayloadField { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: layout_of(CommonPayloadField) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, abi: ScalarPair( Initialized { value: Int( @@ -80,13 +122,22 @@ error: layout_of(MissingPayloadField) = Layout { ), valid_range: 0..=1, }, - Union { + Initialized { value: Int( I8, false, ), + valid_range: 0..=255, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -97,26 +148,6 @@ error: layout_of(MissingPayloadField) = Layout { valid_range: 0..=1, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), - } - --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:16:1 - | -LL | pub enum MissingPayloadField { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: layout_of(CommonPayloadField) = Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - memory_index: [ - 0, - ], - }, variants: Multiple { tag: Initialized { value: Int( @@ -129,16 +160,10 @@ error: layout_of(CommonPayloadField) = Layout { tag_field: 0, variants: [ Layout { - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - memory_index: [ - 0, - ], - }, - variants: Single { - index: 0, + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -156,14 +181,6 @@ error: layout_of(CommonPayloadField) = Layout { valid_range: 0..=255, }, ), - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), - }, - Layout { fields: Arbitrary { offsets: [ Size(1 bytes), @@ -172,8 +189,16 @@ error: layout_of(CommonPayloadField) = Layout { 0, ], }, + largest_niche: None, variants: Single { - index: 1, + index: 0, + }, + }, + Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -191,15 +216,33 @@ error: layout_of(CommonPayloadField) = Layout { valid_range: 0..=255, }, ), + fields: Arbitrary { + offsets: [ + Size(1 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 1, }, - size: Size(2 bytes), }, ], }, + } + --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:25:1 + | +LL | pub enum CommonPayloadField { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, abi: ScalarPair( Initialized { value: Int( @@ -208,14 +251,21 @@ error: layout_of(CommonPayloadField) = Layout { ), valid_range: 0..=1, }, - Initialized { + Union { value: Int( I8, false, ), - valid_range: 0..=255, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -226,26 +276,6 @@ error: layout_of(CommonPayloadField) = Layout { valid_range: 0..=1, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), - } - --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:25:1 - | -LL | pub enum CommonPayloadField { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - memory_index: [ - 0, - ], - }, variants: Multiple { tag: Initialized { value: Int( @@ -258,16 +288,10 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { tag_field: 0, variants: [ Layout { - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - memory_index: [ - 0, - ], - }, - variants: Single { - index: 0, + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -284,14 +308,6 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { ), }, ), - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), - }, - Layout { fields: Arbitrary { offsets: [ Size(1 bytes), @@ -300,8 +316,16 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { 0, ], }, + largest_niche: None, variants: Single { - index: 1, + index: 0, + }, + }, + Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -318,22 +342,40 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { ), }, ), + fields: Arbitrary { + offsets: [ + Size(1 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 1, }, - size: Size(2 bytes), }, ], }, + } + --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:33:1 + | +LL | pub enum CommonPayloadFieldIsMaybeUninit { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: layout_of(NicheFirst) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, abi: ScalarPair( Initialized { value: Int( I8, false, ), - valid_range: 0..=1, + valid_range: 0..=4, }, Union { value: Int( @@ -342,6 +384,14 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { ), }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -349,29 +399,9 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { I8, false, ), - valid_range: 0..=1, + valid_range: 0..=4, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), - } - --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:33:1 - | -LL | pub enum CommonPayloadFieldIsMaybeUninit { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: layout_of(NicheFirst) = Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - memory_index: [ - 0, - ], - }, variants: Multiple { tag: Initialized { value: Int( @@ -388,18 +418,10 @@ error: layout_of(NicheFirst) = Layout { tag_field: 0, variants: [ Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - Size(1 bytes), - ], - memory_index: [ - 0, - 1, - ], - }, - variants: Single { - index: 0, + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -417,6 +439,16 @@ error: layout_of(NicheFirst) = Layout { valid_range: 0..=255, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + Size(1 bytes), + ], + memory_index: [ + 0, + 1, + ], + }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -427,68 +459,68 @@ error: layout_of(NicheFirst) = Layout { valid_range: 0..=2, }, ), + variants: Single { + index: 0, + }, + }, + Layout { + size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(2 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(0 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 2, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(0 bytes), }, ], }, + } + --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:41:1 + | +LL | pub enum NicheFirst { + | ^^^^^^^^^^^^^^^^^^^ + +error: layout_of(NicheSecond) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, abi: ScalarPair( - Initialized { - value: Int( - I8, - false, - ), - valid_range: 0..=4, - }, Union { value: Int( I8, false, ), }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), + Initialized { value: Int( I8, false, @@ -496,18 +528,6 @@ error: layout_of(NicheFirst) = Layout { valid_range: 0..=4, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), - } - --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:41:1 - | -LL | pub enum NicheFirst { - | ^^^^^^^^^^^^^^^^^^^ - -error: layout_of(NicheSecond) = Layout { fields: Arbitrary { offsets: [ Size(1 bytes), @@ -516,6 +536,16 @@ error: layout_of(NicheSecond) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(1 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=4, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -532,18 +562,10 @@ error: layout_of(NicheSecond) = Layout { tag_field: 0, variants: [ Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - Size(1 bytes), - ], - memory_index: [ - 0, - 1, - ], - }, - variants: Single { - index: 0, + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -561,6 +583,16 @@ error: layout_of(NicheSecond) = Layout { valid_range: 0..=2, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + Size(1 bytes), + ], + memory_index: [ + 0, + 1, + ], + }, largest_niche: Some( Niche { offset: Size(1 bytes), @@ -571,80 +603,48 @@ error: layout_of(NicheSecond) = Layout { valid_range: 0..=2, }, ), + variants: Single { + index: 0, + }, + }, + Layout { + size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(2 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(0 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 2, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(0 bytes), }, ], }, - abi: ScalarPair( - Union { - value: Int( - I8, - false, - ), - }, - Initialized { - value: Int( - I8, - false, - ), - valid_range: 0..=4, - }, - ), - largest_niche: Some( - Niche { - offset: Size(1 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=4, - }, - ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), } --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:50:1 | diff --git a/src/test/ui/layout/issue-96185-overaligned-enum.stderr b/src/test/ui/layout/issue-96185-overaligned-enum.stderr index 8dc364fa7c9bd..de6177c8dfc4d 100644 --- a/src/test/ui/layout/issue-96185-overaligned-enum.stderr +++ b/src/test/ui/layout/issue-96185-overaligned-enum.stderr @@ -1,4 +1,12 @@ error: layout_of(Aligned1) = Layout { + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(8 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -7,6 +15,16 @@ error: layout_of(Aligned1) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -19,49 +37,57 @@ error: layout_of(Aligned1) = Layout { tag_field: 0, variants: [ Layout { + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(8 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: $PREF_ALIGN, }, - size: Size(8 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(8 bytes), - pref: $PREF_ALIGN, - }, - size: Size(8 bytes), }, ], }, - abi: Aggregate { - sized: true, + } + --> $DIR/issue-96185-overaligned-enum.rs:8:1 + | +LL | pub enum Aligned1 { + | ^^^^^^^^^^^^^^^^^ + +error: layout_of(Aligned2) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, - largest_niche: Some( - Niche { - offset: Size(0 bytes), + abi: Scalar( + Initialized { value: Int( I8, false, @@ -69,18 +95,6 @@ error: layout_of(Aligned1) = Layout { valid_range: 0..=1, }, ), - align: AbiAndPrefAlign { - abi: Align(8 bytes), - pref: $PREF_ALIGN, - }, - size: Size(8 bytes), - } - --> $DIR/issue-96185-overaligned-enum.rs:8:1 - | -LL | pub enum Aligned1 { - | ^^^^^^^^^^^^^^^^^ - -error: layout_of(Aligned2) = Layout { fields: Arbitrary { offsets: [ Size(0 bytes), @@ -89,6 +103,16 @@ error: layout_of(Aligned2) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -101,67 +125,43 @@ error: layout_of(Aligned2) = Layout { tag_field: 0, variants: [ Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(1 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(1 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I8, - false, - ), - valid_range: 0..=1, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=1, - }, - ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(1 bytes), } --> $DIR/issue-96185-overaligned-enum.rs:16:1 | diff --git a/src/test/ui/layout/thumb-enum.stderr b/src/test/ui/layout/thumb-enum.stderr index e6ed626d5f1aa..227bd950b6666 100644 --- a/src/test/ui/layout/thumb-enum.stderr +++ b/src/test/ui/layout/thumb-enum.stderr @@ -1,4 +1,18 @@ error: layout_of(A) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(4 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -7,6 +21,16 @@ error: layout_of(A) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=0, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -19,34 +43,54 @@ error: layout_of(A) = Layout { tag_field: 0, variants: [ Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(4 bytes), - }, - size: Size(1 bytes), }, ], }, + } + --> $DIR/thumb-enum.rs:16:1 + | +LL | enum A { Apple } + | ^^^^^^ + +error: layout_of(B) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(4 bytes), + }, abi: Scalar( Initialized { value: Int( I8, false, ), - valid_range: 0..=0, + valid_range: 255..=255, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -54,29 +98,9 @@ error: layout_of(A) = Layout { I8, false, ), - valid_range: 0..=0, + valid_range: 255..=255, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(4 bytes), - }, - size: Size(1 bytes), - } - --> $DIR/thumb-enum.rs:16:1 - | -LL | enum A { Apple } - | ^^^^^^ - -error: layout_of(B) = Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - memory_index: [ - 0, - ], - }, variants: Multiple { tag: Initialized { value: Int( @@ -89,49 +113,25 @@ error: layout_of(B) = Layout { tag_field: 0, variants: [ Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(4 bytes), - }, - size: Size(1 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I8, - false, - ), - valid_range: 255..=255, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 255..=255, - }, - ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(4 bytes), - }, - size: Size(1 bytes), } --> $DIR/thumb-enum.rs:20:1 | @@ -139,6 +139,20 @@ LL | enum B { Banana = 255, } | ^^^^^^ error: layout_of(C) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: Align(4 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I16, + false, + ), + valid_range: 256..=256, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -147,6 +161,16 @@ error: layout_of(C) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I16, + false, + ), + valid_range: 256..=256, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -159,49 +183,25 @@ error: layout_of(C) = Layout { tag_field: 0, variants: [ Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(2 bytes), - pref: Align(4 bytes), - }, - size: Size(2 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I16, - false, - ), - valid_range: 256..=256, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I16, - false, - ), - valid_range: 256..=256, - }, - ), - align: AbiAndPrefAlign { - abi: Align(2 bytes), - pref: Align(4 bytes), - }, - size: Size(2 bytes), } --> $DIR/thumb-enum.rs:24:1 | @@ -209,6 +209,20 @@ LL | enum C { Chaenomeles = 256, } | ^^^^^^ error: layout_of(P) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 268435456..=268435456, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -217,6 +231,16 @@ error: layout_of(P) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I32, + false, + ), + valid_range: 268435456..=268435456, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -229,49 +253,25 @@ error: layout_of(P) = Layout { tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I32, - false, - ), - valid_range: 268435456..=268435456, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - false, - ), - valid_range: 268435456..=268435456, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), } --> $DIR/thumb-enum.rs:28:1 | @@ -279,6 +279,20 @@ LL | enum P { Peach = 0x1000_0000isize, } | ^^^^^^ error: layout_of(T) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I32, + true, + ), + valid_range: 2164260864..=2164260864, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -287,6 +301,16 @@ error: layout_of(T) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I32, + true, + ), + valid_range: 2164260864..=2164260864, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -299,49 +323,25 @@ error: layout_of(T) = Layout { tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I32, - true, - ), - valid_range: 2164260864..=2164260864, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - true, - ), - valid_range: 2164260864..=2164260864, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), } --> $DIR/thumb-enum.rs:34:1 | diff --git a/src/test/ui/layout/zero-sized-array-enum-niche.stderr b/src/test/ui/layout/zero-sized-array-enum-niche.stderr index 0dbecbe412b8d..56d3a52bb7ff9 100644 --- a/src/test/ui/layout/zero-sized-array-enum-niche.stderr +++ b/src/test/ui/layout/zero-sized-array-enum-niche.stderr @@ -1,4 +1,12 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -7,6 +15,16 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -19,6 +37,14 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(4 bytes), @@ -27,20 +53,20 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { 0, ], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(2 bytes), align: AbiAndPrefAlign { - abi: Align(4 bytes), + abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(4 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(1 bytes), @@ -49,12 +75,6 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { 0, ], }, - variants: Single { - index: 1, - }, - abi: Aggregate { - sized: true, - }, largest_niche: Some( Niche { offset: Size(1 bytes), @@ -65,32 +85,12 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { valid_range: 0..=1, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 1, }, - size: Size(2 bytes), }, ], }, - abi: Aggregate { - sized: true, - }, - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=1, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(4 bytes), } --> $DIR/zero-sized-array-enum-niche.rs:13:1 | @@ -98,6 +98,14 @@ LL | type AlignedResult = Result<[u32; 0], bool>; | ^^^^^^^^^^^^^^^^^^ error: layout_of(MultipleAlignments) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -106,6 +114,16 @@ error: layout_of(MultipleAlignments) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=2, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -118,6 +136,14 @@ error: layout_of(MultipleAlignments) = Layout { tag_field: 0, variants: [ Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(2 bytes), @@ -126,20 +152,20 @@ error: layout_of(MultipleAlignments) = Layout { 0, ], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(4 bytes), align: AbiAndPrefAlign { - abi: Align(2 bytes), + abi: Align(4 bytes), pref: $PREF_ALIGN, }, - size: Size(2 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(4 bytes), @@ -148,20 +174,20 @@ error: layout_of(MultipleAlignments) = Layout { 0, ], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(2 bytes), align: AbiAndPrefAlign { - abi: Align(4 bytes), + abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(4 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(1 bytes), @@ -170,12 +196,6 @@ error: layout_of(MultipleAlignments) = Layout { 0, ], }, - variants: Single { - index: 2, - }, - abi: Aggregate { - sized: true, - }, largest_niche: Some( Niche { offset: Size(1 bytes), @@ -186,32 +206,12 @@ error: layout_of(MultipleAlignments) = Layout { valid_range: 0..=1, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 2, }, - size: Size(2 bytes), }, ], }, - abi: Aggregate { - sized: true, - }, - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=2, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(4 bytes), } --> $DIR/zero-sized-array-enum-niche.rs:21:1 | @@ -219,6 +219,14 @@ LL | enum MultipleAlignments { | ^^^^^^^^^^^^^^^^^^^^^^^ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -227,6 +235,16 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -239,6 +257,14 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(4 bytes), @@ -247,20 +273,20 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = 0, ], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(3 bytes), align: AbiAndPrefAlign { - abi: Align(4 bytes), + abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(4 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(1 bytes), @@ -269,12 +295,6 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = 0, ], }, - variants: Single { - index: 1, - }, - abi: Aggregate { - sized: true, - }, largest_niche: Some( Niche { offset: Size(1 bytes), @@ -285,32 +305,12 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = valid_range: 1..=65535, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 1, }, - size: Size(3 bytes), }, ], }, - abi: Aggregate { - sized: true, - }, - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=1, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(4 bytes), } --> $DIR/zero-sized-array-enum-niche.rs:37:1 | @@ -318,6 +318,14 @@ LL | type NicheLosesToTagged = Result<[u32; 0], Packed>; | ^^^^^^^^^^^^^^^^^^^^^^^ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -326,6 +334,16 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I16, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -342,6 +360,14 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { tag_field: 0, variants: [ Layout { + size: Size(0 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -350,20 +376,20 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { 0, ], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(2 bytes), align: AbiAndPrefAlign { - abi: Align(4 bytes), + abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(0 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -372,12 +398,6 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { 0, ], }, - variants: Single { - index: 1, - }, - abi: Aggregate { - sized: true, - }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -388,32 +408,12 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { valid_range: 0..=0, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 1, }, - size: Size(2 bytes), }, ], }, - abi: Aggregate { - sized: true, - }, - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I16, - false, - ), - valid_range: 0..=1, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(4 bytes), } --> $DIR/zero-sized-array-enum-niche.rs:44:1 | diff --git a/src/test/ui/panics/location-detail-panic-no-location-info.rs b/src/test/ui/panics/location-detail-panic-no-location-info.rs new file mode 100644 index 0000000000000..7b609145bad72 --- /dev/null +++ b/src/test/ui/panics/location-detail-panic-no-location-info.rs @@ -0,0 +1,8 @@ +// run-fail +// check-run-results +// compile-flags: -Zlocation-detail=none +// exec-env:RUST_BACKTRACE=0 + +fn main() { + panic!("no location info"); +} diff --git a/src/test/ui/panics/location-detail-panic-no-location-info.run.stderr b/src/test/ui/panics/location-detail-panic-no-location-info.run.stderr new file mode 100644 index 0000000000000..d1c3108643c6c --- /dev/null +++ b/src/test/ui/panics/location-detail-panic-no-location-info.run.stderr @@ -0,0 +1,2 @@ +thread 'main' panicked at 'no location info', :0:0 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace