diff options
| author | bors <bors@rust-lang.org> | 2024-02-13 08:33:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-13 08:33:04 +0000 |
| commit | 41555ab4a39e18f59387a576bf1c19ef39093a60 (patch) | |
| tree | 5ed166021ffb0cc6a84667f2801a90486858a747 /src | |
| parent | d2e446d39e2390093042a7fd8676cc85f2b573d7 (diff) | |
| parent | 43e9411db839747f650e1125ed06266566c20b65 (diff) | |
| download | rust-41555ab4a39e18f59387a576bf1c19ef39093a60.tar.gz rust-41555ab4a39e18f59387a576bf1c19ef39093a60.zip | |
Auto merge of #3298 - rust-lang:rustup-2024-02-13, r=oli-obk
Automatic Rustup
Diffstat (limited to 'src')
25 files changed, 119 insertions, 47 deletions
diff --git a/src/ci/docker/host-x86_64/mingw-check/Dockerfile b/src/ci/docker/host-x86_64/mingw-check/Dockerfile index f8fcda5070f..30d3a52d82b 100644 --- a/src/ci/docker/host-x86_64/mingw-check/Dockerfile +++ b/src/ci/docker/host-x86_64/mingw-check/Dockerfile @@ -40,13 +40,9 @@ COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/ ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1 -# Run clippy just to make sure it doesn't error out; we don't actually want to gate on the warnings -# though. -# Ideally we'd use stage 1, but that ICEs: https://github.com/rust-lang/rust-clippy/issues/11230 - ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \ python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu && \ - python3 ../x.py clippy --stage 0 -Awarnings && \ + python3 ../x.py clippy compiler -Aclippy::all -Dclippy::correctness && \ python3 ../x.py build --stage 0 src/tools/build-manifest && \ python3 ../x.py test --stage 0 src/tools/compiletest && \ python3 ../x.py test --stage 0 core alloc std test proc_macro && \ diff --git a/src/doc/edition-guide b/src/doc/edition-guide -Subproject baafacc6d8701269dab1e1e333f3547fb54b5a5 +Subproject 76bd48a273a0e0413a3bf22c699112d41497b99 diff --git a/src/doc/reference b/src/doc/reference -Subproject a0b119535e7740f68494c4f0582f7ad008b00cc +Subproject 8227666de13f6e7bb32dea9dc42e841adb5ce4b diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example -Subproject 179256a445d6144f5f371fdefb993f48f33978b +Subproject e188d5d466f7f3ff9f1d518393235f4fe951be4 diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide -Subproject ec287e332777627185be4798ad22599ffe7b84a +Subproject 1f30cc7cca9a3433bc1872abdc98960b36c21ca diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 89977934cde..f4527d1e55e 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1796,7 +1796,7 @@ fn maybe_expand_private_type_alias<'tcx>( } else { Lifetime::elided() }; - args.insert(param.def_id.to_def_id(), SubstParam::Lifetime(cleaned)); + args.insert(param.def_id.to_def_id(), InstantiationParam::Lifetime(cleaned)); } indices.lifetimes += 1; } @@ -1813,9 +1813,15 @@ fn maybe_expand_private_type_alias<'tcx>( _ => None, }); if let Some(ty) = type_ { - args.insert(param.def_id.to_def_id(), SubstParam::Type(clean_ty(ty, cx))); + args.insert( + param.def_id.to_def_id(), + InstantiationParam::Type(clean_ty(ty, cx)), + ); } else if let Some(default) = *default { - args.insert(param.def_id.to_def_id(), SubstParam::Type(clean_ty(default, cx))); + args.insert( + param.def_id.to_def_id(), + InstantiationParam::Type(clean_ty(default, cx)), + ); } indices.types += 1; } @@ -1832,7 +1838,7 @@ fn maybe_expand_private_type_alias<'tcx>( _ => None, }); if let Some(_) = const_ { - args.insert(param.def_id.to_def_id(), SubstParam::Constant); + args.insert(param.def_id.to_def_id(), InstantiationParam::Constant); } // FIXME(const_generics_defaults) indices.consts += 1; @@ -1840,7 +1846,9 @@ fn maybe_expand_private_type_alias<'tcx>( } } - Some(cx.enter_alias(args, def_id.to_def_id(), |cx| clean_ty(&ty, cx))) + Some(cx.enter_alias(args, def_id.to_def_id(), |cx| { + cx.with_param_env(def_id.to_def_id(), |cx| clean_ty(&ty, cx)) + })) } pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type { @@ -1892,6 +1900,9 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T TyKind::BareFn(barefn) => BareFunction(Box::new(clean_bare_fn_ty(barefn, cx))), // Rustdoc handles `TyKind::Err`s by turning them into `Type::Infer`s. TyKind::Infer | TyKind::Err(_) | TyKind::Typeof(..) | TyKind::InferDelegation(..) => Infer, + TyKind::AnonAdt(..) => { + unimplemented!("Anonymous structs or unions are not supported yet") + } } } diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 6710193f961..96b4d1a45f6 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -2542,14 +2542,14 @@ pub(crate) enum TypeBindingKind { /// ``` /// /// `public_fn`'s docs will show it as returning `Vec<i32>`, since `PrivAlias` is private. -/// [`SubstParam`] is used to record that `T` should be mapped to `i32`. -pub(crate) enum SubstParam { +/// [`InstantiationParam`] is used to record that `T` should be mapped to `i32`. +pub(crate) enum InstantiationParam { Type(Type), Lifetime(Lifetime), Constant, } -impl SubstParam { +impl InstantiationParam { pub(crate) fn as_ty(&self) -> Option<&Type> { if let Self::Type(ty) = self { Some(ty) } else { None } } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 9eb62c25892..28ccda39e4d 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -44,10 +44,10 @@ pub(crate) struct DocContext<'tcx> { /// Used while populating `external_traits` to ensure we don't process the same trait twice at /// the same time. pub(crate) active_extern_traits: DefIdSet, - // The current set of parameter substitutions, + // The current set of parameter instantiations, // for expanding type aliases at the HIR level: - /// Table `DefId` of type, lifetime, or const parameter -> substituted type, lifetime, or const - pub(crate) args: DefIdMap<clean::SubstParam>, + /// Table `DefId` of type, lifetime, or const parameter -> instantiated type, lifetime, or const + pub(crate) args: DefIdMap<clean::InstantiationParam>, pub(crate) current_type_aliases: DefIdMap<usize>, /// Table synthetic type parameter for `impl Trait` in argument position -> bounds pub(crate) impl_trait_bounds: FxHashMap<ImplTraitParam, Vec<clean::GenericBound>>, @@ -84,10 +84,10 @@ impl<'tcx> DocContext<'tcx> { } /// Call the closure with the given parameters set as - /// the substitutions for a type alias' RHS. + /// the generic parameters for a type alias' RHS. pub(crate) fn enter_alias<F, R>( &mut self, - args: DefIdMap<clean::SubstParam>, + args: DefIdMap<clean::InstantiationParam>, def_id: DefId, f: F, ) -> R diff --git a/src/tools/clippy/clippy_lints/src/dereference.rs b/src/tools/clippy/clippy_lints/src/dereference.rs index cdbb52f497b..0ddfeaa0ae0 100644 --- a/src/tools/clippy/clippy_lints/src/dereference.rs +++ b/src/tools/clippy/clippy_lints/src/dereference.rs @@ -831,6 +831,7 @@ impl TyCoercionStability { | TyKind::Typeof(..) | TyKind::TraitObject(..) | TyKind::InferDelegation(..) + | TyKind::AnonAdt(..) | TyKind::Err(_) => Self::Reborrow, }; } diff --git a/src/tools/clippy/clippy_lints/src/redundant_locals.rs b/src/tools/clippy/clippy_lints/src/redundant_locals.rs index 700a5dd4a85..6528a7b369f 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_locals.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_locals.rs @@ -101,7 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals { fn is_by_value_closure_capture(cx: &LateContext<'_>, redefinition: HirId, root_variable: HirId) -> bool { let closure_def_id = cx.tcx.hir().enclosing_body_owner(redefinition); - cx.tcx.is_closure_or_coroutine(closure_def_id.to_def_id()) + cx.tcx.is_closure_like(closure_def_id.to_def_id()) && cx.tcx.closure_captures(closure_def_id).iter().any(|c| { matches!(c.info.capture_kind, UpvarCapture::ByValue) && matches!(c.place.base, PlaceBase::Upvar(upvar) if upvar.var_path.hir_id == root_variable) diff --git a/src/tools/clippy/clippy_utils/src/hir_utils.rs b/src/tools/clippy/clippy_utils/src/hir_utils.rs index 4fa93ad23c3..d50332e82da 100644 --- a/src/tools/clippy/clippy_utils/src/hir_utils.rs +++ b/src/tools/clippy/clippy_utils/src/hir_utils.rs @@ -515,6 +515,7 @@ impl HirEqInterExpr<'_, '_, '_> { (TyKind::Path(l), TyKind::Path(r)) => self.eq_qpath(l, r), (&TyKind::Tup(l), &TyKind::Tup(r)) => over(l, r, |l, r| self.eq_ty(l, r)), (&TyKind::Infer, &TyKind::Infer) => true, + (TyKind::AnonAdt(l_item_id), TyKind::AnonAdt(r_item_id)) => l_item_id == r_item_id, _ => false, } } @@ -1108,7 +1109,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { TyKind::Typeof(anon_const) => { self.hash_body(anon_const.body); }, - TyKind::Err(_) | TyKind::Infer | TyKind::Never | TyKind::InferDelegation(..) => {}, + TyKind::Err(_) | TyKind::Infer | TyKind::Never | TyKind::InferDelegation(..) | TyKind::AnonAdt(_) => {}, } } diff --git a/src/tools/clippy/tests/integration.rs b/src/tools/clippy/tests/integration.rs index 267f095f9c2..7f4500826ff 100644 --- a/src/tools/clippy/tests/integration.rs +++ b/src/tools/clippy/tests/integration.rs @@ -77,7 +77,7 @@ fn integration_test() { // the repo basically just contains a span_delayed_bug that forces rustc/clippy to panic: /* #![feature(rustc_attrs)] - #[rustc_error(span_delayed_bug_from_inside_query)] + #[rustc_error(delayed_bug_from_inside_query)] fn main() {} */ diff --git a/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.fixed b/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.fixed index 4e145693c55..696def08f14 100644 --- a/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.fixed +++ b/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.fixed @@ -35,7 +35,7 @@ fn transmute_ptr_to_ptr() { // ref-ref transmutes; bad let _: &f32 = &*(&1u32 as *const u32 as *const f32); //~^ ERROR: transmute from a reference to a reference - let _: &f64 = &*(&1f32 as *const f32 as *const f64); + let _: &f32 = &*(&1f64 as *const f64 as *const f32); //~^ ERROR: transmute from a reference to a reference //:^ this test is here because both f32 and f64 are the same TypeVariant, but they are not // the same type @@ -43,8 +43,8 @@ fn transmute_ptr_to_ptr() { //~^ ERROR: transmute from a reference to a reference let _: &GenericParam<f32> = &*(&GenericParam { t: 1u32 } as *const GenericParam<u32> as *const GenericParam<f32>); //~^ ERROR: transmute from a reference to a reference - let u8_ref: &u8 = &0u8; - let u64_ref: &u64 = unsafe { &*(u8_ref as *const u8 as *const u64) }; + let u64_ref: &u64 = &0u64; + let u8_ref: &u8 = unsafe { &*(u64_ref as *const u64 as *const u8) }; //~^ ERROR: transmute from a reference to a reference } diff --git a/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.rs b/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.rs index 086aadc3647..0700d8c1957 100644 --- a/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.rs +++ b/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.rs @@ -35,7 +35,7 @@ fn transmute_ptr_to_ptr() { // ref-ref transmutes; bad let _: &f32 = std::mem::transmute(&1u32); //~^ ERROR: transmute from a reference to a reference - let _: &f64 = std::mem::transmute(&1f32); + let _: &f32 = std::mem::transmute(&1f64); //~^ ERROR: transmute from a reference to a reference //:^ this test is here because both f32 and f64 are the same TypeVariant, but they are not // the same type @@ -43,8 +43,8 @@ fn transmute_ptr_to_ptr() { //~^ ERROR: transmute from a reference to a reference let _: &GenericParam<f32> = std::mem::transmute(&GenericParam { t: 1u32 }); //~^ ERROR: transmute from a reference to a reference - let u8_ref: &u8 = &0u8; - let u64_ref: &u64 = unsafe { std::mem::transmute(u8_ref) }; + let u64_ref: &u64 = &0u64; + let u8_ref: &u8 = unsafe { std::mem::transmute(u64_ref) }; //~^ ERROR: transmute from a reference to a reference } diff --git a/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.stderr b/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.stderr index 9f8599921ec..6e3af1f7337 100644 --- a/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.stderr +++ b/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.stderr @@ -22,8 +22,8 @@ LL | let _: &f32 = std::mem::transmute(&1u32); error: transmute from a reference to a reference --> $DIR/transmute_ptr_to_ptr.rs:38:23 | -LL | let _: &f64 = std::mem::transmute(&1f32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f32 as *const f32 as *const f64)` +LL | let _: &f32 = std::mem::transmute(&1f64); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f64 as *const f64 as *const f32)` error: transmute from a reference to a reference --> $DIR/transmute_ptr_to_ptr.rs:42:27 @@ -38,10 +38,10 @@ LL | let _: &GenericParam<f32> = std::mem::transmute(&GenericParam { t: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam<u32> as *const GenericParam<f32>)` error: transmute from a reference to a reference - --> $DIR/transmute_ptr_to_ptr.rs:47:38 + --> $DIR/transmute_ptr_to_ptr.rs:47:36 | -LL | let u64_ref: &u64 = unsafe { std::mem::transmute(u8_ref) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(u8_ref as *const u8 as *const u64)` +LL | let u8_ref: &u8 = unsafe { std::mem::transmute(u64_ref) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(u64_ref as *const u64 as *const u8)` error: aborting due to 7 previous errors diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index ff907152ca9..daec3914145 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -650,7 +650,7 @@ fn iter_header_extra( let comment = if testfile.extension().is_some_and(|e| e == "rs") { "//" } else { "#" }; - let mut rdr = BufReader::new(rdr); + let mut rdr = BufReader::with_capacity(1024, rdr); let mut ln = String::new(); let mut line_number = 0; diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 60dd15841b7..667358b1a6e 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -25,7 +25,7 @@ use build_helper::git::{get_git_modified_files, get_git_untracked_files}; use core::panic; use getopts::Options; use lazycell::AtomicLazyCell; -use std::collections::BTreeSet; +use std::collections::HashSet; use std::ffi::OsString; use std::fs; use std::io::{self, ErrorKind}; @@ -415,7 +415,7 @@ pub fn run_tests(config: Arc<Config>) { let mut tests = Vec::new(); for c in configs { - let mut found_paths = BTreeSet::new(); + let mut found_paths = HashSet::new(); make_tests(c, &mut tests, &mut found_paths); check_overlapping_tests(&found_paths); } @@ -550,7 +550,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts { pub fn make_tests( config: Arc<Config>, tests: &mut Vec<test::TestDescAndFn>, - found_paths: &mut BTreeSet<PathBuf>, + found_paths: &mut HashSet<PathBuf>, ) { debug!("making tests from {:?}", config.src_base.display()); let inputs = common_inputs_stamp(&config); @@ -646,7 +646,7 @@ fn collect_tests_from_dir( relative_dir_path: &Path, inputs: &Stamp, tests: &mut Vec<test::TestDescAndFn>, - found_paths: &mut BTreeSet<PathBuf>, + found_paths: &mut HashSet<PathBuf>, modified_tests: &Vec<PathBuf>, poisoned: &mut bool, ) -> io::Result<()> { @@ -675,6 +675,8 @@ fn collect_tests_from_dir( // Add each `.rs` file as a test, and recurse further on any // subdirectories we find, except for `aux` directories. + // FIXME: this walks full tests tree, even if we have something to ignore + // use walkdir/ignore like in tidy? for file in fs::read_dir(dir)? { let file = file?; let file_path = file.path(); @@ -1128,7 +1130,7 @@ fn not_a_digit(c: char) -> bool { !c.is_digit(10) } -fn check_overlapping_tests(found_paths: &BTreeSet<PathBuf>) { +fn check_overlapping_tests(found_paths: &HashSet<PathBuf>) { let mut collisions = Vec::new(); for path in found_paths { for ancestor in path.ancestors().skip(1) { @@ -1138,6 +1140,7 @@ fn check_overlapping_tests(found_paths: &BTreeSet<PathBuf>) { } } if !collisions.is_empty() { + collisions.sort(); let collisions: String = collisions .into_iter() .map(|(path, check_parent)| format!("test {path:?} clashes with {check_parent:?}\n")) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index ed1c559e1f6..f3a0e87d43a 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -4316,10 +4316,11 @@ impl<'test> TestCx<'test> { let mut seen_allocs = indexmap::IndexSet::new(); // The alloc-id appears in pretty-printed allocations. - let re = + static ALLOC_ID_PP_RE: Lazy<Regex> = Lazy::new(|| { Regex::new(r"╾─*a(lloc)?([0-9]+)(\+0x[0-9]+)?(<imm>)?( \([0-9]+ ptr bytes\))?─*╼") - .unwrap(); - normalized = re + .unwrap() + }); + normalized = ALLOC_ID_PP_RE .replace_all(&normalized, |caps: &Captures<'_>| { // Renumber the captured index. let index = caps.get(2).unwrap().as_str().to_string(); @@ -4332,8 +4333,9 @@ impl<'test> TestCx<'test> { .into_owned(); // The alloc-id appears in a sentence. - let re = Regex::new(r"\balloc([0-9]+)\b").unwrap(); - normalized = re + static ALLOC_ID_RE: Lazy<Regex> = + Lazy::new(|| Regex::new(r"\balloc([0-9]+)\b").unwrap()); + normalized = ALLOC_ID_RE .replace_all(&normalized, |caps: &Captures<'_>| { let index = caps.get(1).unwrap().as_str().to_string(); let (index, _) = seen_allocs.insert_full(index); diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 2c98082bc1e..eca1a2335c8 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -b17491c8f6d555386104dfd82004c01bfef09c95 +d26b41711282042c4ea0c5733e7332b07cfa4933 diff --git a/src/tools/miri/tests/fail/unaligned_pointers/unaligned_ref_addr_of.rs b/src/tools/miri/tests/fail/unaligned_pointers/unaligned_ref_addr_of.rs index 470420acd50..225feef7281 100644 --- a/src/tools/miri/tests/fail/unaligned_pointers/unaligned_ref_addr_of.rs +++ b/src/tools/miri/tests/fail/unaligned_pointers/unaligned_ref_addr_of.rs @@ -1,6 +1,8 @@ // This should fail even without Stacked Borrows. //@compile-flags: -Zmiri-disable-stacked-borrows -Cdebug-assertions=no +#![allow(invalid_reference_casting)] // for u16 -> u32 + fn main() { // Try many times as this might work by chance. for _ in 0..20 { diff --git a/src/tools/miri/tests/pass/async-closure.rs b/src/tools/miri/tests/pass/async-closure.rs new file mode 100644 index 00000000000..e04acfc39cf --- /dev/null +++ b/src/tools/miri/tests/pass/async-closure.rs @@ -0,0 +1,41 @@ +#![feature(async_closure, noop_waker, async_fn_traits)] + +use std::future::Future; +use std::pin::pin; +use std::task::*; + +pub fn block_on<T>(fut: impl Future<Output = T>) -> T { + let mut fut = pin!(fut); + let ctx = &mut Context::from_waker(Waker::noop()); + + loop { + match fut.as_mut().poll(ctx) { + Poll::Pending => {} + Poll::Ready(t) => break t, + } + } +} + +#[rustfmt::skip] +async fn call_once(f: impl async FnOnce(DropMe)) { + f(DropMe("world")).await; +} + +#[derive(Debug)] +struct DropMe(&'static str); + +impl Drop for DropMe { + fn drop(&mut self) { + println!("{}", self.0); + } +} + +pub fn main() { + block_on(async { + let b = DropMe("hello"); + let async_closure = async move |a: DropMe| { + println!("{a:?} {b:?}"); + }; + call_once(async_closure).await; + }); +} diff --git a/src/tools/miri/tests/pass/async-closure.stdout b/src/tools/miri/tests/pass/async-closure.stdout new file mode 100644 index 00000000000..34cfdedc44a --- /dev/null +++ b/src/tools/miri/tests/pass/async-closure.stdout @@ -0,0 +1,3 @@ +DropMe("world") DropMe("hello") +world +hello diff --git a/src/tools/rust-analyzer/crates/hir-def/src/attr/builtin.rs b/src/tools/rust-analyzer/crates/hir-def/src/attr/builtin.rs index b20ee9e5bf6..55b9a1dfdcb 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/attr/builtin.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/attr/builtin.rs @@ -650,7 +650,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[ rustc_attr!(TEST, rustc_regions, Normal, template!(Word), WarnFollowing), rustc_attr!( TEST, rustc_error, Normal, - template!(Word, List: "span_delayed_bug_from_inside_query"), WarnFollowingWordOnly + template!(Word, List: "delayed_bug_from_inside_query"), WarnFollowingWordOnly ), rustc_attr!(TEST, rustc_dump_user_args, Normal, template!(Word), WarnFollowing), rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing), diff --git a/src/tools/rustfmt/src/types.rs b/src/tools/rustfmt/src/types.rs index cd2582e66be..aaef80f4aef 100644 --- a/src/tools/rustfmt/src/types.rs +++ b/src/tools/rustfmt/src/types.rs @@ -806,8 +806,8 @@ impl Rewrite for ast::Ty { ast::TyKind::Tup(ref items) => { rewrite_tuple(context, items.iter(), self.span, shape, items.len() == 1) } - ast::TyKind::AnonStruct(_) => Some(context.snippet(self.span).to_owned()), - ast::TyKind::AnonUnion(_) => Some(context.snippet(self.span).to_owned()), + ast::TyKind::AnonStruct(..) => Some(context.snippet(self.span).to_owned()), + ast::TyKind::AnonUnion(..) => Some(context.snippet(self.span).to_owned()), ast::TyKind::Path(ref q_self, ref path) => { rewrite_path(context, PathContext::Type, q_self, path, shape) } diff --git a/src/tools/rustfmt/tests/target/anonymous-types.rs b/src/tools/rustfmt/tests/target/anonymous-types.rs index 8e08c314ed1..e8c2d83878c 100644 --- a/src/tools/rustfmt/tests/target/anonymous-types.rs +++ b/src/tools/rustfmt/tests/target/anonymous-types.rs @@ -16,4 +16,16 @@ struct Foo { e: f32, } +// Test for https://github.com/rust-lang/rust/issues/117942 +struct Foo { + _: union { + #[rustfmt::skip] + f: String, + }, + #[rustfmt::skip] + _: struct { + g: i32, + }, +} + fn main() {} |
