diff options
Diffstat (limited to 'src')
77 files changed, 918 insertions, 331 deletions
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 9b77e38a847..354be109cf2 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1183,7 +1183,11 @@ impl Step for PlainSourceTarball { // characters and on `C:\` paths, so normalize both of them away. pub fn sanitize_sh(path: &Path) -> String { let path = path.to_str().unwrap().replace("\\", "/"); - return change_drive(&path).unwrap_or(path); + return change_drive(unc_to_lfs(&path)).unwrap_or(path); + + fn unc_to_lfs(s: &str) -> &str { + if s.starts_with("//?/") { &s[4..] } else { s } + } fn change_drive(s: &str) -> Option<String> { let mut ch = s.chars(); diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 8eb4821396d..99e0a2b177f 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -152,6 +152,7 @@ not available. target | std | host | notes -------|-----|------|------- +`aarch64-apple-ios-macabi` | ? | | Apple Catalyst on ARM64 `aarch64-apple-tvos` | * | | ARM64 tvOS `aarch64-unknown-freebsd` | ✓ | ✓ | ARM64 FreeBSD `aarch64-unknown-hermit` | ? | | @@ -207,7 +208,7 @@ target | std | host | notes `thumbv7a-uwp-windows-msvc` | ✓ | | `thumbv7neon-unknown-linux-musleabihf` | ? | | Thumb2-mode ARMv7a Linux with NEON, MUSL `thumbv4t-none-eabi` | * | | ARMv4T T32 -`x86_64-apple-ios-macabi` | ✓ | | Apple Catalyst +`x86_64-apple-ios-macabi` | ✓ | | Apple Catalyst on x86_64 `x86_64-apple-tvos` | * | | x86 64-bit tvOS `x86_64-linux-kernel` | * | | Linux kernel modules `x86_64-pc-solaris` | ? | | diff --git a/src/etc/gdb_providers.py b/src/etc/gdb_providers.py index b74d47a8002..cabf5dccbfe 100644 --- a/src/etc/gdb_providers.py +++ b/src/etc/gdb_providers.py @@ -352,7 +352,7 @@ class StdHashMapProvider: ctrl = table["ctrl"]["pointer"] self.size = int(table["items"]) - self.pair_type = table.type.template_argument(0) + self.pair_type = table.type.template_argument(0).strip_typedefs() self.new_layout = not table.type.has_key("data") if self.new_layout: diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 64cb9837943..9c7b07efbaa 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -531,7 +531,7 @@ class StdHashMapSyntheticProvider: ctrl = table.GetChildMemberWithName("ctrl").GetChildAtIndex(0) self.size = table.GetChildMemberWithName("items").GetValueAsUnsigned() - self.pair_type = table.type.template_args[0] + self.pair_type = table.type.template_args[0].GetTypedefedType() self.pair_type_size = self.pair_type.GetByteSize() self.new_layout = not table.GetChildMemberWithName("data").IsValid() diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index cc3e8707e52..61121c776f4 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -124,7 +124,7 @@ crate fn try_inline( let attrs = merge_attrs(cx, Some(parent_module), target_attrs, attrs_clone); cx.renderinfo.borrow_mut().inlined.insert(did); - let what_rustc_thinks = clean::Item::from_def_id_and_parts(did, Some(name), kind, cx); + let what_rustc_thinks = clean::Item::from_def_id_and_parts(did, Some(name.clean(cx)), kind, cx); ret.push(clean::Item { attrs, ..what_rustc_thinks }); Some(ret) } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ea34085823f..13643fbf3d3 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -122,7 +122,7 @@ impl Clean<ExternalCrate> for CrateNum { } } } - return prim.map(|p| (def_id, p, attrs)); + return prim.map(|p| (def_id, p)); } None }; @@ -144,9 +144,9 @@ impl Clean<ExternalCrate> for CrateNum { hir::ItemKind::Use(ref path, hir::UseKind::Single) if item.vis.node.is_pub() => { - as_primitive(path.res).map(|(_, prim, attrs)| { + as_primitive(path.res).map(|(_, prim)| { // Pretend the primitive is local. - (cx.tcx.hir().local_def_id(id.id).to_def_id(), prim, attrs) + (cx.tcx.hir().local_def_id(id.id).to_def_id(), prim) }) } _ => None, @@ -177,7 +177,7 @@ impl Clean<ExternalCrate> for CrateNum { } } } - return keyword.map(|p| (def_id, p, attrs)); + return keyword.map(|p| (def_id, p)); } None }; @@ -199,8 +199,8 @@ impl Clean<ExternalCrate> for CrateNum { hir::ItemKind::Use(ref path, hir::UseKind::Single) if item.vis.node.is_pub() => { - as_keyword(path.res).map(|(_, prim, attrs)| { - (cx.tcx.hir().local_def_id(id.id).to_def_id(), prim, attrs) + as_keyword(path.res).map(|(_, prim)| { + (cx.tcx.hir().local_def_id(id.id).to_def_id(), prim) }) } _ => None, @@ -1099,7 +1099,7 @@ impl Clean<Item> for hir::TraitItem<'_> { AssocTypeItem(bounds.clean(cx), default.clean(cx)) } }; - Item::from_def_id_and_parts(local_did, Some(self.ident.name), inner, cx) + Item::from_def_id_and_parts(local_did, Some(self.ident.name.clean(cx)), inner, cx) }) } } @@ -1127,7 +1127,7 @@ impl Clean<Item> for hir::ImplItem<'_> { TypedefItem(Typedef { type_, generics: Generics::default(), item_type }, true) } }; - Item::from_def_id_and_parts(local_did, Some(self.ident.name), inner, cx) + Item::from_def_id_and_parts(local_did, Some(self.ident.name.clean(cx)), inner, cx) }) } } @@ -1284,7 +1284,7 @@ impl Clean<Item> for ty::AssocItem { } }; - Item::from_def_id_and_parts(self.def_id, Some(self.ident.name), kind, cx) + Item::from_def_id_and_parts(self.def_id, Some(self.ident.name.clean(cx)), kind, cx) } } @@ -1503,7 +1503,9 @@ impl Clean<Type> for hir::Ty<'_> { } /// Returns `None` if the type could not be normalized +#[allow(unreachable_code, unused_variables)] fn normalize(cx: &DocContext<'tcx>, ty: Ty<'_>) -> Option<Ty<'tcx>> { + return None; // HACK: low-churn fix for #79459 while we wait for a trait normalization fix use crate::rustc_trait_selection::infer::TyCtxtInferExt; use crate::rustc_trait_selection::traits::query::normalize::AtExt; use rustc_middle::traits::ObligationCause; @@ -1769,7 +1771,7 @@ impl Clean<Item> for ty::FieldDef { fn clean(&self, cx: &DocContext<'_>) -> Item { let what_rustc_thinks = Item::from_def_id_and_parts( self.did, - Some(self.ident.name), + Some(self.ident.name.clean(cx)), StructFieldItem(cx.tcx.type_of(self.did).clean(cx)), cx, ); @@ -1844,22 +1846,20 @@ impl Clean<Item> for ty::VariantDef { fields: self .fields .iter() - .map(|field| Item { - source: cx.tcx.def_span(field.did).clean(cx), - name: Some(field.ident.name.clean(cx)), - attrs: cx.tcx.get_attrs(field.did).clean(cx), - visibility: Visibility::Inherited, - def_id: field.did, - stability: get_stability(cx, field.did), - deprecation: get_deprecation(cx, field.did), - kind: StructFieldItem(cx.tcx.type_of(field.did).clean(cx)), + .map(|field| { + let name = Some(field.ident.name.clean(cx)); + let kind = StructFieldItem(cx.tcx.type_of(field.did).clean(cx)); + let what_rustc_thinks = + Item::from_def_id_and_parts(field.did, name, kind, cx); + // don't show `pub` for fields, which are always public + Item { visibility: Visibility::Inherited, ..what_rustc_thinks } }) .collect(), }), }; let what_rustc_thinks = Item::from_def_id_and_parts( self.def_id, - Some(self.ident.name), + Some(self.ident.name.clean(cx)), VariantItem(Variant { kind }), cx, ); @@ -2057,7 +2057,7 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Ident>) { _ => unreachable!("not yet converted"), }; - vec![Item::from_def_id_and_parts(def_id, Some(name), kind, cx)] + vec![Item::from_def_id_and_parts(def_id, Some(name.clean(cx)), kind, cx)] }) } } @@ -2319,7 +2319,7 @@ impl Clean<Item> for doctree::Macro { fn clean(&self, cx: &DocContext<'_>) -> Item { Item::from_def_id_and_parts( self.def_id, - Some(self.name), + Some(self.name.clean(cx)), MacroItem(Macro { source: format!( "macro_rules! {} {{\n{}}}", diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 43b986aae1c..2283b71a94f 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -34,6 +34,7 @@ use crate::clean::cfg::Cfg; use crate::clean::external_path; use crate::clean::inline; use crate::clean::types::Type::{QPath, ResolvedPath}; +use crate::clean::Clean; use crate::core::DocContext; use crate::doctree; use crate::formats::cache::cache; @@ -54,7 +55,7 @@ crate struct Crate { crate src: FileName, crate module: Option<Item>, crate externs: Vec<(CrateNum, ExternalCrate)>, - crate primitives: Vec<(DefId, PrimitiveType, Attributes)>, + crate primitives: Vec<(DefId, PrimitiveType)>, // These are later on moved into `CACHEKEY`, leaving the map empty. // Only here so that they can be filtered through the rustdoc passes. crate external_traits: Rc<RefCell<FxHashMap<DefId, Trait>>>, @@ -67,8 +68,8 @@ crate struct ExternalCrate { crate name: String, crate src: FileName, crate attrs: Attributes, - crate primitives: Vec<(DefId, PrimitiveType, Attributes)>, - crate keywords: Vec<(DefId, String, Attributes)>, + crate primitives: Vec<(DefId, PrimitiveType)>, + crate keywords: Vec<(DefId, String)>, } /// Anything with a source location and set of attributes and, optionally, a @@ -120,17 +121,20 @@ impl Item { kind: ItemKind, cx: &DocContext<'_>, ) -> Item { - Item::from_def_id_and_parts(cx.tcx.hir().local_def_id(hir_id).to_def_id(), name, kind, cx) + Item::from_def_id_and_parts( + cx.tcx.hir().local_def_id(hir_id).to_def_id(), + name.clean(cx), + kind, + cx, + ) } pub fn from_def_id_and_parts( def_id: DefId, - name: Option<Symbol>, + name: Option<String>, kind: ItemKind, cx: &DocContext<'_>, ) -> Item { - use super::Clean; - debug!("name={:?}, def_id={:?}", name, def_id); // `span_if_local()` lies about functions and only gives the span of the function signature @@ -145,7 +149,7 @@ impl Item { Item { def_id, kind, - name: name.clean(cx), + name, source: source.clean(cx), attrs: cx.tcx.get_attrs(def_id).clean(cx), visibility: cx.tcx.visibility(def_id).clean(cx), diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 22917fbceb4..1b22d26f49b 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -1,15 +1,14 @@ use crate::clean::auto_trait::AutoTraitFinder; use crate::clean::blanket_impl::BlanketImplFinder; use crate::clean::{ - inline, Clean, Crate, Deprecation, ExternalCrate, FnDecl, FnRetTy, Generic, GenericArg, - GenericArgs, GenericBound, Generics, GetDefId, ImportSource, Item, ItemKind, Lifetime, - MacroKind, Path, PathSegment, Primitive, PrimitiveType, ResolvedPath, Span, Type, TypeBinding, - TypeKind, Visibility, WherePredicate, + inline, Clean, Crate, ExternalCrate, FnDecl, FnRetTy, Generic, GenericArg, GenericArgs, + GenericBound, Generics, GetDefId, ImportSource, Item, ItemKind, Lifetime, MacroKind, Path, + PathSegment, Primitive, PrimitiveType, ResolvedPath, Type, TypeBinding, TypeKind, + WherePredicate, }; use crate::core::DocContext; use itertools::Itertools; -use rustc_attr::Stability; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; @@ -66,25 +65,16 @@ crate fn krate(mut cx: &mut DocContext<'_>) -> Crate { ItemKind::ModuleItem(ref mut m) => m, _ => unreachable!(), }; - m.items.extend(primitives.iter().map(|&(def_id, prim, ref attrs)| Item { - source: Span::empty(), - name: Some(prim.to_url_str().to_string()), - attrs: attrs.clone(), - visibility: Visibility::Public, - stability: get_stability(cx, def_id), - deprecation: get_deprecation(cx, def_id), - def_id, - kind: ItemKind::PrimitiveItem(prim), + m.items.extend(primitives.iter().map(|&(def_id, prim)| { + Item::from_def_id_and_parts( + def_id, + Some(prim.to_url_str().to_owned()), + ItemKind::PrimitiveItem(prim), + cx, + ) })); - m.items.extend(keywords.into_iter().map(|(def_id, kw, attrs)| Item { - source: Span::empty(), - name: Some(kw.clone()), - attrs, - visibility: Visibility::Public, - stability: get_stability(cx, def_id), - deprecation: get_deprecation(cx, def_id), - def_id, - kind: ItemKind::KeywordItem(kw), + m.items.extend(keywords.into_iter().map(|(def_id, kw)| { + Item::from_def_id_and_parts(def_id, Some(kw.clone()), ItemKind::KeywordItem(kw), cx) })); } @@ -101,15 +91,6 @@ crate fn krate(mut cx: &mut DocContext<'_>) -> Crate { } } -// extract the stability index for a node from tcx, if possible -crate fn get_stability(cx: &DocContext<'_>, def_id: DefId) -> Option<Stability> { - cx.tcx.lookup_stability(def_id).cloned() -} - -crate fn get_deprecation(cx: &DocContext<'_>, def_id: DefId) -> Option<Deprecation> { - cx.tcx.lookup_deprecation(def_id).clean(cx) -} - fn external_generic_args( cx: &DocContext<'_>, trait_did: Option<DefId>, diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 39b750279ac..c3153f2d4b6 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -187,11 +187,11 @@ impl Cache { // Favor linking to as local extern as possible, so iterate all crates in // reverse topological order. for &(_, ref e) in krate.externs.iter().rev() { - for &(def_id, prim, _) in &e.primitives { + for &(def_id, prim) in &e.primitives { cache.primitive_locations.insert(prim, def_id); } } - for &(def_id, prim, _) in &krate.primitives { + for &(def_id, prim) in &krate.primitives { cache.primitive_locations.insert(prim, def_id); } diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index e57717dab76..02152edbbc2 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -240,8 +240,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { } match item.kind { - hir::ItemKind::ForeignMod(ref fm) => { - for item in fm.items { + hir::ItemKind::ForeignMod { items, .. } => { + for item in items { + let item = self.cx.tcx.hir().foreign_item(item.id); self.visit_foreign_item(item, None, om); } } diff --git a/src/test/incremental/hashes/extern_mods.rs b/src/test/incremental/hashes/extern_mods.rs index 0b9a0fd7945..dd775167757 100644 --- a/src/test/incremental/hashes/extern_mods.rs +++ b/src/test/incremental/hashes/extern_mods.rs @@ -13,114 +13,99 @@ #![feature(rustc_attrs)] #![feature(unboxed_closures)] #![feature(link_args)] -#![crate_type="rlib"] - +#![crate_type = "rlib"] // Change function name -------------------------------------------------------- #[cfg(cfail1)] -extern { +extern "C" { pub fn change_function_name1(c: i64) -> i32; } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] -#[rustc_clean(cfg="cfail3")] -extern { +#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] +#[rustc_clean(cfg = "cfail3")] +extern "C" { pub fn change_function_name2(c: i64) -> i32; } - - // Change parameter name ------------------------------------------------------- #[cfg(cfail1)] -extern { +extern "C" { pub fn change_parameter_name(c: i64) -> i32; } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] -#[rustc_clean(cfg="cfail3")] -extern { +#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail3")] +extern "C" { pub fn change_parameter_name(d: i64) -> i32; } - - // Change parameter type ------------------------------------------------------- #[cfg(cfail1)] -extern { +extern "C" { pub fn change_parameter_type(c: i64) -> i32; } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] -#[rustc_clean(cfg="cfail3")] -extern { +#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail3")] +extern "C" { pub fn change_parameter_type(c: i32) -> i32; } - - // Change return type ---------------------------------------------------------- #[cfg(cfail1)] -extern { +extern "C" { pub fn change_return_type(c: i32) -> i32; } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] -#[rustc_clean(cfg="cfail3")] -extern { +#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail3")] +extern "C" { pub fn change_return_type(c: i32) -> i8; } - - // Add parameter --------------------------------------------------------------- #[cfg(cfail1)] -extern { +extern "C" { pub fn add_parameter(c: i32) -> i32; } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] -#[rustc_clean(cfg="cfail3")] -extern { +#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail3")] +extern "C" { pub fn add_parameter(c: i32, d: i32) -> i32; } - - // Add return type ------------------------------------------------------------- #[cfg(cfail1)] -extern { +extern "C" { pub fn add_return_type(c: i32); } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] -#[rustc_clean(cfg="cfail3")] -extern { +#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail3")] +extern "C" { pub fn add_return_type(c: i32) -> i32; } - - // Make function variadic ------------------------------------------------------ #[cfg(cfail1)] -extern { +extern "C" { pub fn make_function_variadic(c: i32); } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] -#[rustc_clean(cfg="cfail3")] -extern { +#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail3")] +extern "C" { pub fn make_function_variadic(c: i32, ...); } - - // Change calling convention --------------------------------------------------- #[cfg(cfail1)] extern "C" { @@ -128,74 +113,66 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] -#[rustc_clean(cfg="cfail3")] +#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] +#[rustc_clean(cfg = "cfail3")] extern "rust-call" { pub fn change_calling_convention(c: i32); } - - // Make function public -------------------------------------------------------- #[cfg(cfail1)] -extern { +extern "C" { fn make_function_public(c: i32); } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] -#[rustc_clean(cfg="cfail3")] -extern { +#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] +#[rustc_clean(cfg = "cfail3")] +extern "C" { pub fn make_function_public(c: i32); } - - // Add function ---------------------------------------------------------------- #[cfg(cfail1)] -extern { +extern "C" { pub fn add_function1(c: i32); } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] -#[rustc_clean(cfg="cfail3")] -extern { +#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] +#[rustc_clean(cfg = "cfail3")] +extern "C" { pub fn add_function1(c: i32); pub fn add_function2(); } - - // Change link-args ------------------------------------------------------------ #[cfg(cfail1)] #[link_args = "-foo -bar"] -extern { +extern "C" { pub fn change_link_args(c: i32); } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] -#[rustc_clean(cfg="cfail3")] +#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] +#[rustc_clean(cfg = "cfail3")] #[link_args = "-foo -bar -baz"] -extern { +extern "C" { pub fn change_link_args(c: i32); } - - // Change link-name ------------------------------------------------------------ #[cfg(cfail1)] #[link(name = "foo")] -extern { +extern "C" { pub fn change_link_name(c: i32); } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] -#[rustc_clean(cfg="cfail3")] +#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] +#[rustc_clean(cfg = "cfail3")] #[link(name = "bar")] -extern { +extern "C" { pub fn change_link_name(c: i32); } @@ -209,15 +186,13 @@ mod indirectly_change_parameter_type { #[cfg(not(cfail1))] use super::c_i64 as c_int; - #[rustc_dirty(cfg="cfail2")] - #[rustc_clean(cfg="cfail3")] - extern { + #[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] + #[rustc_clean(cfg = "cfail3")] + extern "C" { pub fn indirectly_change_parameter_type(c: c_int); } } - - // Indirectly change return type -------------------------------------------- mod indirectly_change_return_type { #[cfg(cfail1)] @@ -225,9 +200,9 @@ mod indirectly_change_return_type { #[cfg(not(cfail1))] use super::c_i64 as c_int; - #[rustc_dirty(cfg="cfail2")] - #[rustc_clean(cfg="cfail3")] - extern { + #[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] + #[rustc_clean(cfg = "cfail3")] + extern "C" { pub fn indirectly_change_return_type() -> c_int; } } diff --git a/src/test/rustdoc-ui/coverage/exotic.stdout b/src/test/rustdoc-ui/coverage/exotic.stdout index e282ff12843..27798b81310 100644 --- a/src/test/rustdoc-ui/coverage/exotic.stdout +++ b/src/test/rustdoc-ui/coverage/exotic.stdout @@ -1,8 +1,7 @@ +-------------------------------------+------------+------------+------------+------------+ | File | Documented | Percentage | Examples | Percentage | +-------------------------------------+------------+------------+------------+------------+ -| ...st/rustdoc-ui/coverage/exotic.rs | 1 | 100.0% | 0 | 0.0% | -| <anon> | 2 | 100.0% | 0 | 0.0% | +| ...st/rustdoc-ui/coverage/exotic.rs | 3 | 100.0% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ | Total | 3 | 100.0% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc/normalize-assoc-item.rs b/src/test/rustdoc/normalize-assoc-item.rs index 137fd354a87..70b3c66fd2b 100644 --- a/src/test/rustdoc/normalize-assoc-item.rs +++ b/src/test/rustdoc/normalize-assoc-item.rs @@ -1,6 +1,7 @@ // ignore-tidy-linelength // aux-build:normalize-assoc-item.rs // build-aux-docs +// ignore-test pub trait Trait { type X; diff --git a/src/test/ui/asm/naked-invalid-attr.stderr b/src/test/ui/asm/naked-invalid-attr.stderr index beaa34140c9..565c2986a66 100644 --- a/src/test/ui/asm/naked-invalid-attr.stderr +++ b/src/test/ui/asm/naked-invalid-attr.stderr @@ -1,12 +1,4 @@ error: attribute should be applied to a function definition - --> $DIR/naked-invalid-attr.rs:9:5 - | -LL | #[naked] - | ^^^^^^^^ -LL | fn f(); - | ------- not a function definition - -error: attribute should be applied to a function definition --> $DIR/naked-invalid-attr.rs:13:1 | LL | #[naked] @@ -33,6 +25,14 @@ LL | extern "C" fn invoke(&self); | ---------------------------- not a function definition error: attribute should be applied to a function definition + --> $DIR/naked-invalid-attr.rs:9:5 + | +LL | #[naked] + | ^^^^^^^^ +LL | fn f(); + | ------- not a function definition + +error: attribute should be applied to a function definition --> $DIR/naked-invalid-attr.rs:6:1 | LL | #![naked] diff --git a/src/test/ui/associated-type-bounds/dyn-impl-trait-type.rs b/src/test/ui/associated-type-bounds/dyn-impl-trait-type.rs index fd9e52a6ff2..a8d00803a53 100644 --- a/src/test/ui/associated-type-bounds/dyn-impl-trait-type.rs +++ b/src/test/ui/associated-type-bounds/dyn-impl-trait-type.rs @@ -30,7 +30,7 @@ fn def_et3() -> Et3 { impl Tr1 for A { type As1 = core::ops::Range<u8>; fn mk(&self) -> Self::As1 { 0..10 } - }; + } Box::new(A) } pub fn use_et3() { diff --git a/src/test/ui/associated-type-bounds/dyn-lcsit.rs b/src/test/ui/associated-type-bounds/dyn-lcsit.rs index c936fe0550a..b7869e22b4a 100644 --- a/src/test/ui/associated-type-bounds/dyn-lcsit.rs +++ b/src/test/ui/associated-type-bounds/dyn-lcsit.rs @@ -33,7 +33,7 @@ const cdef_et3: &dyn Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>> impl Tr1 for A { type As1 = core::ops::Range<u8>; fn mk(&self) -> Self::As1 { 0..10 } - }; + } &A }; pub fn use_et3() { diff --git a/src/test/ui/associated-type-bounds/dyn-rpit-and-let.rs b/src/test/ui/associated-type-bounds/dyn-rpit-and-let.rs index f22a6c44cb8..08f965452ef 100644 --- a/src/test/ui/associated-type-bounds/dyn-rpit-and-let.rs +++ b/src/test/ui/associated-type-bounds/dyn-rpit-and-let.rs @@ -35,7 +35,7 @@ fn def_et3() -> Box<dyn Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8> impl Tr1 for A { type As1 = core::ops::Range<u8>; fn mk(&self) -> Self::As1 { 0..10 } - }; + } let x /* : Box<dyn Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>>> */ = Box::new(A); x diff --git a/src/test/ui/associated-type-bounds/lcsit.rs b/src/test/ui/associated-type-bounds/lcsit.rs index 497205f9f18..5364f25f89a 100644 --- a/src/test/ui/associated-type-bounds/lcsit.rs +++ b/src/test/ui/associated-type-bounds/lcsit.rs @@ -39,7 +39,7 @@ const cdef_et3: impl Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>> impl Tr1 for A { type As1 = core::ops::Range<u8>; fn mk(&self) -> Self::As1 { 0..10 } - }; + } let x: impl Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>> = A; x }; diff --git a/src/test/ui/associated-type-bounds/rpit.rs b/src/test/ui/associated-type-bounds/rpit.rs index 7b640d5a457..47cadf3310b 100644 --- a/src/test/ui/associated-type-bounds/rpit.rs +++ b/src/test/ui/associated-type-bounds/rpit.rs @@ -27,7 +27,7 @@ fn def_et3() -> impl Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>> impl Tr1 for A { type As1 = core::ops::Range<u8>; fn mk(self) -> Self::As1 { 0..10 } - }; + } A } diff --git a/src/test/ui/associated-type-bounds/trait-alias-impl-trait.rs b/src/test/ui/associated-type-bounds/trait-alias-impl-trait.rs index 9ee33e4149a..025540ce200 100644 --- a/src/test/ui/associated-type-bounds/trait-alias-impl-trait.rs +++ b/src/test/ui/associated-type-bounds/trait-alias-impl-trait.rs @@ -31,7 +31,7 @@ fn def_et3() -> Et3 { impl Tr1 for A { type As1 = core::ops::Range<u8>; fn mk(self) -> Self::As1 { 0..10 } - }; + } A } pub fn use_et3() { diff --git a/src/test/ui/const-generics/min_const_generics/macro.rs b/src/test/ui/const-generics/min_const_generics/macro.rs index 85ecce551d4..575fbd33572 100644 --- a/src/test/ui/const-generics/min_const_generics/macro.rs +++ b/src/test/ui/const-generics/min_const_generics/macro.rs @@ -15,14 +15,14 @@ impl<const N: usize> Marker<N> for Example<N> {} fn make_marker() -> impl Marker<{ #[macro_export] - macro_rules! const_macro { () => {{ 3 }} }; inline!() + macro_rules! const_macro { () => {{ 3 }} } inline!() }> { Example::<{ const_macro!() }> } fn from_marker(_: impl Marker<{ #[macro_export] - macro_rules! inline { () => {{ 3 }} }; inline!() + macro_rules! inline { () => {{ 3 }} } inline!() }>) {} fn main() { @@ -30,7 +30,7 @@ fn main() { #[macro_export] macro_rules! gimme_a_const { ($rusty: ident) => {{ let $rusty = 3; *&$rusty }} - }; + } gimme_a_const!(run) }>; @@ -42,13 +42,13 @@ fn main() { let _ok: [u8; { #[macro_export] - macro_rules! const_two { () => {{ 2 }} }; + macro_rules! const_two { () => {{ 2 }} } const_two!() }]; let _ok = [0; { #[macro_export] - macro_rules! const_three { () => {{ 3 }} }; + macro_rules! const_three { () => {{ 3 }} } const_three!() }]; let _ok = [0; const_three!()]; diff --git a/src/test/ui/generic-associated-types/parse/trait-path-expected-token.rs b/src/test/ui/generic-associated-types/parse/trait-path-expected-token.rs new file mode 100644 index 00000000000..b10bfea9feb --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-expected-token.rs @@ -0,0 +1,11 @@ +#![feature(generic_associated_types)] +//~^ WARNING: the feature `generic_associated_types` is incomplete + +trait X { + type Y<'a>; +} + +fn f1<'a>(arg : Box<dyn X<Y = B = &'a ()>>) {} + //~^ ERROR: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=` + +fn main() {} diff --git a/src/test/ui/generic-associated-types/parse/trait-path-expected-token.stderr b/src/test/ui/generic-associated-types/parse/trait-path-expected-token.stderr new file mode 100644 index 00000000000..051253cadc6 --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-expected-token.stderr @@ -0,0 +1,17 @@ +error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=` + --> $DIR/trait-path-expected-token.rs:8:33 + | +LL | fn f1<'a>(arg : Box<dyn X<Y = B = &'a ()>>) {} + | ^ expected one of 7 possible tokens + +warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/trait-path-expected-token.rs:1:12 + | +LL | #![feature(generic_associated_types)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information + +error: aborting due to previous error; 1 warning emitted + diff --git a/src/test/ui/generic-associated-types/parse/trait-path-expressions.rs b/src/test/ui/generic-associated-types/parse/trait-path-expressions.rs new file mode 100644 index 00000000000..de61cfa1cf7 --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-expressions.rs @@ -0,0 +1,23 @@ +#![feature(generic_associated_types)] +//~^ WARNING: the feature `generic_associated_types` is incomplete + +mod error1 { + trait X { + type Y<'a>; + } + + fn f1<'a>(arg : Box<dyn X< 1 = 32 >>) {} + //~^ ERROR: expected expression, found `)` +} + +mod error2 { + + trait X { + type Y<'a>; + } + + fn f2<'a>(arg : Box<dyn X< { 1 } = 32 >>) {} + //~^ ERROR: only types can be used in associated type constraints +} + +fn main() {} diff --git a/src/test/ui/generic-associated-types/parse/trait-path-expressions.stderr b/src/test/ui/generic-associated-types/parse/trait-path-expressions.stderr new file mode 100644 index 00000000000..a9ba8adcaba --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-expressions.stderr @@ -0,0 +1,25 @@ +error: expected expression, found `)` + --> $DIR/trait-path-expressions.rs:9:39 + | +LL | fn f1<'a>(arg : Box<dyn X< 1 = 32 >>) {} + | - ^ expected expression + | | + | while parsing a const generic argument starting here + +error: only types can be used in associated type constraints + --> $DIR/trait-path-expressions.rs:19:30 + | +LL | fn f2<'a>(arg : Box<dyn X< { 1 } = 32 >>) {} + | ^^^^^ + +warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/trait-path-expressions.rs:1:12 + | +LL | #![feature(generic_associated_types)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information + +error: aborting due to 2 previous errors; 1 warning emitted + diff --git a/src/test/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs b/src/test/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs new file mode 100644 index 00000000000..dad8c2a2909 --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs @@ -0,0 +1,21 @@ +#![feature(generic_associated_types)] +//~^ WARNING: the feature `generic_associated_types` is incomplete + +trait X { + type Y<'a>; +} + +const _: () = { + fn f1<'a>(arg : Box<dyn X< : 32 >>) {} + //~^ ERROR: expected one of `>`, const, lifetime, or type, found `:` + //~| ERROR: expected parameter name, found `>` + //~| ERROR: expected one of `!`, `)`, `+`, `,`, or `::`, found `>` + //~| ERROR: constant provided when a type was expected +}; + +const _: () = { + fn f1<'a>(arg : Box<dyn X< = 32 >>) {} + //~^ ERROR: expected one of `>`, const, lifetime, or type, found `=` +}; + +fn main() {} diff --git a/src/test/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr b/src/test/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr new file mode 100644 index 00000000000..583697f0b67 --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr @@ -0,0 +1,50 @@ +error: expected one of `>`, const, lifetime, or type, found `:` + --> $DIR/trait-path-missing-gen_arg.rs:9:30 + | +LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {} + | ^ expected one of `>`, const, lifetime, or type + | +help: expressions must be enclosed in braces to be used as const generic arguments + | +LL | fn f1<'a>(arg : Box<{ dyn X< : 32 } >>) {} + | ^ ^ + +error: expected parameter name, found `>` + --> $DIR/trait-path-missing-gen_arg.rs:9:36 + | +LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {} + | ^ expected parameter name + +error: expected one of `!`, `)`, `+`, `,`, or `::`, found `>` + --> $DIR/trait-path-missing-gen_arg.rs:9:36 + | +LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {} + | ^ + | | + | expected one of `!`, `)`, `+`, `,`, or `::` + | help: missing `,` + +error: expected one of `>`, const, lifetime, or type, found `=` + --> $DIR/trait-path-missing-gen_arg.rs:17:30 + | +LL | fn f1<'a>(arg : Box<dyn X< = 32 >>) {} + | ^ expected one of `>`, const, lifetime, or type + +warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/trait-path-missing-gen_arg.rs:1:12 + | +LL | #![feature(generic_associated_types)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information + +error[E0747]: constant provided when a type was expected + --> $DIR/trait-path-missing-gen_arg.rs:9:23 + | +LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {} + | ^^^^^^^^^^^ + +error: aborting due to 5 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0747`. diff --git a/src/test/ui/generic-associated-types/parse/trait-path-segments.rs b/src/test/ui/generic-associated-types/parse/trait-path-segments.rs new file mode 100644 index 00000000000..0bf48b1f418 --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-segments.rs @@ -0,0 +1,35 @@ +#![feature(generic_associated_types)] +//~^ WARNING: the feature `generic_associated_types` is incomplete + +const _: () = { + trait X { + type Y<'a>; + } + + fn f1<'a>(arg : Box<dyn X<X::Y = u32>>) {} + //~^ ERROR: paths with multiple segments cannot be used in associated type constraints + }; + +const _: () = { + trait X { + type Y<'a>; + } + + trait Z {} + + impl<T : X<<Self as X>::Y<'a> = &'a u32>> Z for T {} + //~^ ERROR: qualified paths cannot be used in associated type constraints +}; + +const _: () = { + trait X { + type Y<'a>; + } + + trait Z {} + + impl<T : X<X::Y<'a> = &'a u32>> Z for T {} + //~^ ERROR: paths with multiple segments cannot be used in associated type constraints +}; + +fn main() {} diff --git a/src/test/ui/generic-associated-types/parse/trait-path-segments.stderr b/src/test/ui/generic-associated-types/parse/trait-path-segments.stderr new file mode 100644 index 00000000000..4e2b84d0182 --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-segments.stderr @@ -0,0 +1,31 @@ +error: paths with multiple segments cannot be used in associated type constraints + --> $DIR/trait-path-segments.rs:9:31 + | +LL | fn f1<'a>(arg : Box<dyn X<X::Y = u32>>) {} + | ^^^^ + +error: qualified paths cannot be used in associated type constraints + --> $DIR/trait-path-segments.rs:20:16 + | +LL | impl<T : X<<Self as X>::Y<'a> = &'a u32>> Z for T {} + | ^^^^^^^^^-^^^^^^^^ + | | + | not allowed in associated type constraints + +error: paths with multiple segments cannot be used in associated type constraints + --> $DIR/trait-path-segments.rs:31:16 + | +LL | impl<T : X<X::Y<'a> = &'a u32>> Z for T {} + | ^^^^^^^^ + +warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/trait-path-segments.rs:1:12 + | +LL | #![feature(generic_associated_types)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information + +error: aborting due to 3 previous errors; 1 warning emitted + diff --git a/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs b/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs new file mode 100644 index 00000000000..e203a5e0d2d --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs @@ -0,0 +1,10 @@ +#![feature(generic_associated_types)] + +trait X { + type Y<'a>; +} + +const _: () = { + fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {} + //~^ ERROR: generic associated types in trait paths are currently not implemented +}; diff --git a/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr b/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr new file mode 100644 index 00000000000..e59a72a99ee --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr @@ -0,0 +1,8 @@ +error: generic associated types in trait paths are currently not implemented + --> $DIR/trait-path-type-error-once-implemented.rs:8:30 + | +LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {} + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/generic-associated-types/parse/trait-path-types.rs b/src/test/ui/generic-associated-types/parse/trait-path-types.rs new file mode 100644 index 00000000000..6cdb501ec65 --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-types.rs @@ -0,0 +1,23 @@ +#![feature(generic_associated_types)] +//~^ WARNING: the feature `generic_associated_types` is incomplete + +trait X { + type Y<'a>; +} + +const _: () = { + fn f<'a>(arg : Box<dyn X< [u8; 1] = u32>>) {} + //~^ ERROR: only path types can be used in associated type constraints +}; + +const _: () = { + fn f1<'a>(arg : Box<dyn X<(Y<'a>) = &'a ()>>) {} + //~^ ERROR: only path types can be used in associated type constraints +}; + +const _: () = { + fn f1<'a>(arg : Box<dyn X< 'a = u32 >>) {} + //~^ ERROR: only types can be used in associated type constraints +}; + +fn main() {} diff --git a/src/test/ui/generic-associated-types/parse/trait-path-types.stderr b/src/test/ui/generic-associated-types/parse/trait-path-types.stderr new file mode 100644 index 00000000000..f5be084613b --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-types.stderr @@ -0,0 +1,29 @@ +error: only path types can be used in associated type constraints + --> $DIR/trait-path-types.rs:9:29 + | +LL | fn f<'a>(arg : Box<dyn X< [u8; 1] = u32>>) {} + | ^^^^^^^ + +error: only path types can be used in associated type constraints + --> $DIR/trait-path-types.rs:14:29 + | +LL | fn f1<'a>(arg : Box<dyn X<(Y<'a>) = &'a ()>>) {} + | ^^^^^^^ + +error: only types can be used in associated type constraints + --> $DIR/trait-path-types.rs:19:30 + | +LL | fn f1<'a>(arg : Box<dyn X< 'a = u32 >>) {} + | ^^ + +warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/trait-path-types.rs:1:12 + | +LL | #![feature(generic_associated_types)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information + +error: aborting due to 3 previous errors; 1 warning emitted + diff --git a/src/test/ui/generic-associated-types/parse/trait-path-unimplemented.rs b/src/test/ui/generic-associated-types/parse/trait-path-unimplemented.rs new file mode 100644 index 00000000000..02d53d5faee --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-unimplemented.rs @@ -0,0 +1,17 @@ +#![feature(generic_associated_types)] + +trait X { + type Y<'a>; +} + +const _: () = { + fn f1<'a>(arg : Box<dyn X<Y<'a> = &'a ()>>) {} + //~^ ERROR: generic associated types in trait paths are currently not implemented +}; + +const _: () = { + fn f1<'a>(arg : Box<dyn X<Y('a) = &'a ()>>) {} + //~^ ERROR: lifetime in trait object type must be followed by `+` +}; + +fn main() {} diff --git a/src/test/ui/generic-associated-types/parse/trait-path-unimplemented.stderr b/src/test/ui/generic-associated-types/parse/trait-path-unimplemented.stderr new file mode 100644 index 00000000000..1fba9cebd24 --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-unimplemented.stderr @@ -0,0 +1,14 @@ +error: lifetime in trait object type must be followed by `+` + --> $DIR/trait-path-unimplemented.rs:13:31 + | +LL | fn f1<'a>(arg : Box<dyn X<Y('a) = &'a ()>>) {} + | ^^ + +error: generic associated types in trait paths are currently not implemented + --> $DIR/trait-path-unimplemented.rs:8:30 + | +LL | fn f1<'a>(arg : Box<dyn X<Y<'a> = &'a ()>>) {} + | ^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/issues/issue-10767.rs b/src/test/ui/issues/issue-10767.rs index fa10f073b45..f40815fdbdb 100644 --- a/src/test/ui/issues/issue-10767.rs +++ b/src/test/ui/issues/issue-10767.rs @@ -5,6 +5,6 @@ pub fn main() { fn f() { - }; + } let _: Box<fn()> = box (f as fn()); } diff --git a/src/test/ui/issues/issue-20616-2.rs b/src/test/ui/issues/issue-20616-2.rs index 2f2c6903a9f..f108ae5de14 100644 --- a/src/test/ui/issues/issue-20616-2.rs +++ b/src/test/ui/issues/issue-20616-2.rs @@ -9,7 +9,7 @@ type Type_1_<'a, T> = &'a T; //type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` -type Type_2 = Type_1_<'static ()>; //~ error: expected one of `,` or `>`, found `(` +type Type_2 = Type_1_<'static ()>; //~ error: expected one of `,`, `:`, `=`, or `>`, found `(` //type Type_3<T> = Box<T,,>; // error: expected type, found `,` diff --git a/src/test/ui/issues/issue-20616-2.stderr b/src/test/ui/issues/issue-20616-2.stderr index 50ec7a304c5..01e3d3dd7cc 100644 --- a/src/test/ui/issues/issue-20616-2.stderr +++ b/src/test/ui/issues/issue-20616-2.stderr @@ -1,8 +1,8 @@ -error: expected one of `,` or `>`, found `(` +error: expected one of `,`, `:`, `=`, or `>`, found `(` --> $DIR/issue-20616-2.rs:12:31 | LL | type Type_2 = Type_1_<'static ()>; - | ^ expected one of `,` or `>` + | ^ expected one of `,`, `:`, `=`, or `>` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-3.rs b/src/test/ui/issues/issue-20616-3.rs index 9bfd5bf2313..780038c11b8 100644 --- a/src/test/ui/issues/issue-20616-3.rs +++ b/src/test/ui/issues/issue-20616-3.rs @@ -11,7 +11,7 @@ type Type_1_<'a, T> = &'a T; type Type_3<T> = Box<T,,>; -//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,` +//~^ error: expected one of `>`, const, lifetime, or type, found `,` //type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,` diff --git a/src/test/ui/issues/issue-20616-3.stderr b/src/test/ui/issues/issue-20616-3.stderr index cc4d79484e7..2f8cf8a79ed 100644 --- a/src/test/ui/issues/issue-20616-3.stderr +++ b/src/test/ui/issues/issue-20616-3.stderr @@ -1,8 +1,8 @@ -error: expected one of `>`, const, identifier, lifetime, or type, found `,` +error: expected one of `>`, const, lifetime, or type, found `,` --> $DIR/issue-20616-3.rs:13:24 | LL | type Type_3<T> = Box<T,,>; - | ^ expected one of `>`, const, identifier, lifetime, or type + | ^ expected one of `>`, const, lifetime, or type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-4.rs b/src/test/ui/issues/issue-20616-4.rs index e9a34a04667..85aa9c1146d 100644 --- a/src/test/ui/issues/issue-20616-4.rs +++ b/src/test/ui/issues/issue-20616-4.rs @@ -14,7 +14,7 @@ type Type_1_<'a, T> = &'a T; type Type_4<T> = Type_1_<'static,, T>; -//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,` +//~^ error: expected one of `>`, const, lifetime, or type, found `,` type Type_5_<'a> = Type_1_<'a, ()>; diff --git a/src/test/ui/issues/issue-20616-4.stderr b/src/test/ui/issues/issue-20616-4.stderr index 254e4d6a34d..3be6c2e78ce 100644 --- a/src/test/ui/issues/issue-20616-4.stderr +++ b/src/test/ui/issues/issue-20616-4.stderr @@ -1,8 +1,8 @@ -error: expected one of `>`, const, identifier, lifetime, or type, found `,` +error: expected one of `>`, const, lifetime, or type, found `,` --> $DIR/issue-20616-4.rs:16:34 | LL | type Type_4<T> = Type_1_<'static,, T>; - | ^ expected one of `>`, const, identifier, lifetime, or type + | ^ expected one of `>`, const, lifetime, or type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-5.rs b/src/test/ui/issues/issue-20616-5.rs index 23862516d2c..c0c6bc6dd97 100644 --- a/src/test/ui/issues/issue-20616-5.rs +++ b/src/test/ui/issues/issue-20616-5.rs @@ -20,7 +20,7 @@ type Type_5_<'a> = Type_1_<'a, ()>; type Type_5<'a> = Type_1_<'a, (),,>; -//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,` +//~^ error: expected one of `>`, const, lifetime, or type, found `,` //type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` diff --git a/src/test/ui/issues/issue-20616-5.stderr b/src/test/ui/issues/issue-20616-5.stderr index aee8bf01a43..b90fbf60051 100644 --- a/src/test/ui/issues/issue-20616-5.stderr +++ b/src/test/ui/issues/issue-20616-5.stderr @@ -1,8 +1,8 @@ -error: expected one of `>`, const, identifier, lifetime, or type, found `,` +error: expected one of `>`, const, lifetime, or type, found `,` --> $DIR/issue-20616-5.rs:22:34 | LL | type Type_5<'a> = Type_1_<'a, (),,>; - | ^ expected one of `>`, const, identifier, lifetime, or type + | ^ expected one of `>`, const, lifetime, or type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-6.rs b/src/test/ui/issues/issue-20616-6.rs index dc327f3f788..73c75bdc45f 100644 --- a/src/test/ui/issues/issue-20616-6.rs +++ b/src/test/ui/issues/issue-20616-6.rs @@ -23,7 +23,7 @@ type Type_5_<'a> = Type_1_<'a, ()>; type Type_6 = Type_5_<'a,,>; -//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,` +//~^ error: expected one of `>`, const, lifetime, or type, found `,` //type Type_7 = Box<(),,>; // error: expected type, found `,` diff --git a/src/test/ui/issues/issue-20616-6.stderr b/src/test/ui/issues/issue-20616-6.stderr index 7192a87bc18..ea1c15ba423 100644 --- a/src/test/ui/issues/issue-20616-6.stderr +++ b/src/test/ui/issues/issue-20616-6.stderr @@ -1,8 +1,8 @@ -error: expected one of `>`, const, identifier, lifetime, or type, found `,` +error: expected one of `>`, const, lifetime, or type, found `,` --> $DIR/issue-20616-6.rs:25:26 | LL | type Type_6 = Type_5_<'a,,>; - | ^ expected one of `>`, const, identifier, lifetime, or type + | ^ expected one of `>`, const, lifetime, or type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-7.rs b/src/test/ui/issues/issue-20616-7.rs index ffd1620c1d3..8beeebd7a95 100644 --- a/src/test/ui/issues/issue-20616-7.rs +++ b/src/test/ui/issues/issue-20616-7.rs @@ -26,7 +26,7 @@ type Type_5_<'a> = Type_1_<'a, ()>; type Type_7 = Box<(),,>; -//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,` +//~^ error: expected one of `>`, const, lifetime, or type, found `,` //type Type_8<'a,,> = &'a (); // error: expected ident, found `,` diff --git a/src/test/ui/issues/issue-20616-7.stderr b/src/test/ui/issues/issue-20616-7.stderr index 123dc1e2b7d..dcd199902fc 100644 --- a/src/test/ui/issues/issue-20616-7.stderr +++ b/src/test/ui/issues/issue-20616-7.stderr @@ -1,8 +1,8 @@ -error: expected one of `>`, const, identifier, lifetime, or type, found `,` +error: expected one of `>`, const, lifetime, or type, found `,` --> $DIR/issue-20616-7.rs:28:22 | LL | type Type_7 = Box<(),,>; - | ^ expected one of `>`, const, identifier, lifetime, or type + | ^ expected one of `>`, const, lifetime, or type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-2074.rs b/src/test/ui/issues/issue-2074.rs index bd5f015cca0..a6bea385804 100644 --- a/src/test/ui/issues/issue-2074.rs +++ b/src/test/ui/issues/issue-2074.rs @@ -5,11 +5,11 @@ pub fn main() { let one = || { - enum r { a }; + enum r { a } r::a as usize }; let two = || { - enum r { a }; + enum r { a } r::a as usize }; one(); two(); diff --git a/src/test/ui/issues/issue-34334.rs b/src/test/ui/issues/issue-34334.rs index bf2d091a01e..b45c00f6943 100644 --- a/src/test/ui/issues/issue-34334.rs +++ b/src/test/ui/issues/issue-34334.rs @@ -1,6 +1,6 @@ fn main () { let sr: Vec<(u32, _, _) = vec![]; - //~^ ERROR expected one of `,` or `>`, found `=` + //~^ ERROR only path types can be used in associated type constraints let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect(); //~^ ERROR a value of type `Vec<(u32, _, _)>` cannot be built } diff --git a/src/test/ui/issues/issue-34334.stderr b/src/test/ui/issues/issue-34334.stderr index c10a4144305..a9b9bf06d7f 100644 --- a/src/test/ui/issues/issue-34334.stderr +++ b/src/test/ui/issues/issue-34334.stderr @@ -1,8 +1,8 @@ -error: expected one of `,` or `>`, found `=` - --> $DIR/issue-34334.rs:2:29 +error: only path types can be used in associated type constraints + --> $DIR/issue-34334.rs:2:17 | LL | let sr: Vec<(u32, _, _) = vec![]; - | -- ^ expected one of `,` or `>` + | -- ^^^^^^^^^^^ | | | while parsing the type for `sr` diff --git a/src/test/ui/lint/inline-trait-and-foreign-items.stderr b/src/test/ui/lint/inline-trait-and-foreign-items.stderr index ae04612a4dd..6ac884c12ce 100644 --- a/src/test/ui/lint/inline-trait-and-foreign-items.stderr +++ b/src/test/ui/lint/inline-trait-and-foreign-items.stderr @@ -1,19 +1,3 @@ -error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:30:5 - | -LL | #[inline] - | ^^^^^^^^^ -LL | static X: u32; - | -------------- not a function or closure - -error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:33:5 - | -LL | #[inline] - | ^^^^^^^^^ -LL | type T; - | ------- not a function or closure - warning: `#[inline]` is ignored on constants --> $DIR/inline-trait-and-foreign-items.rs:7:5 | @@ -61,6 +45,22 @@ LL | #[inline] LL | type U = impl Trait; | -------------------- not a function or closure +error[E0518]: attribute should be applied to function or closure + --> $DIR/inline-trait-and-foreign-items.rs:30:5 + | +LL | #[inline] + | ^^^^^^^^^ +LL | static X: u32; + | -------------- not a function or closure + +error[E0518]: attribute should be applied to function or closure + --> $DIR/inline-trait-and-foreign-items.rs:33:5 + | +LL | #[inline] + | ^^^^^^^^^ +LL | type T; + | ------- not a function or closure + error: could not find defining uses --> $DIR/inline-trait-and-foreign-items.rs:26:14 | diff --git a/src/test/ui/lint/redundant-semicolon/item-stmt-semi.rs b/src/test/ui/lint/redundant-semicolon/item-stmt-semi.rs new file mode 100644 index 00000000000..4592bc31a39 --- /dev/null +++ b/src/test/ui/lint/redundant-semicolon/item-stmt-semi.rs @@ -0,0 +1,10 @@ +// check-pass +// This test should stop compiling +// we decide to enable this lint for item statements. + +#![deny(redundant_semicolons)] + +fn main() { + fn inner() {}; + struct Bar {}; +} diff --git a/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr b/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr index 843db8ce815..ab19d80e732 100644 --- a/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr +++ b/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr @@ -1,5 +1,5 @@ error: `#[inline]` is ignored on function prototypes - --> $DIR/warn-unused-inline-on-fn-prototypes.rs:9:5 + --> $DIR/warn-unused-inline-on-fn-prototypes.rs:4:5 | LL | #[inline] | ^^^^^^^^^ @@ -11,7 +11,7 @@ LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ error: `#[inline]` is ignored on function prototypes - --> $DIR/warn-unused-inline-on-fn-prototypes.rs:4:5 + --> $DIR/warn-unused-inline-on-fn-prototypes.rs:9:5 | LL | #[inline] | ^^^^^^^^^ diff --git a/src/test/ui/macros/macro-2.rs b/src/test/ui/macros/macro-2.rs index 4890c991dcd..a315981b6a6 100644 --- a/src/test/ui/macros/macro-2.rs +++ b/src/test/ui/macros/macro-2.rs @@ -3,7 +3,7 @@ pub fn main() { macro_rules! mylambda_tt { ($x:ident, $body:expr) => ({ - fn f($x: isize) -> isize { return $body; }; + fn f($x: isize) -> isize { return $body; } f }) } diff --git a/src/test/ui/macros/macro-path.rs b/src/test/ui/macros/macro-path.rs index be59d8d139b..6c011c897da 100644 --- a/src/test/ui/macros/macro-path.rs +++ b/src/test/ui/macros/macro-path.rs @@ -8,7 +8,7 @@ mod m { macro_rules! foo { ($p:path) => ({ - fn f() -> $p { 10 }; + fn f() -> $p { 10 } f() }) } diff --git a/src/test/ui/parser/issue-62660.rs b/src/test/ui/parser/issue-62660.rs index 33c8a9fa328..4f866b78976 100644 --- a/src/test/ui/parser/issue-62660.rs +++ b/src/test/ui/parser/issue-62660.rs @@ -5,7 +5,7 @@ struct Foo; impl Foo { pub fn foo(_: i32, self: Box<Self) {} - //~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)` + //~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, `=`, or `>`, found `)` } fn main() {} diff --git a/src/test/ui/parser/issue-62660.stderr b/src/test/ui/parser/issue-62660.stderr index 0844da1bd92..a50ada9056b 100644 --- a/src/test/ui/parser/issue-62660.stderr +++ b/src/test/ui/parser/issue-62660.stderr @@ -1,8 +1,8 @@ -error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)` +error: expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, `=`, or `>`, found `)` --> $DIR/issue-62660.rs:7:38 | LL | pub fn foo(_: i32, self: Box<Self) {} - | ^ expected one of 7 possible tokens + | ^ expected one of 9 possible tokens error: aborting due to previous error diff --git a/src/test/ui/parser/issue-63116.stderr b/src/test/ui/parser/issue-63116.stderr index 80a450dbd36..e249a93df92 100644 --- a/src/test/ui/parser/issue-63116.stderr +++ b/src/test/ui/parser/issue-63116.stderr @@ -12,7 +12,7 @@ error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `;` LL | impl W <s(f;Y(;] | ^ expected one of 7 possible tokens -error: expected one of `!`, `&&`, `&`, `(`, `)`, `*`, `+`, `,`, `->`, `...`, `::`, `<`, `>`, `?`, `[`, `_`, `async`, `const`, `dyn`, `extern`, `fn`, `for`, `impl`, `unsafe`, lifetime, or path, found `;` +error: expected one of `!`, `&&`, `&`, `(`, `)`, `*`, `+`, `,`, `->`, `...`, `::`, `:`, `<`, `=`, `>`, `?`, `[`, `_`, `async`, `const`, `dyn`, `extern`, `fn`, `for`, `impl`, `unsafe`, lifetime, or path, found `;` --> $DIR/issue-63116.rs:3:15 | LL | impl W <s(f;Y(;] diff --git a/src/test/ui/parser/lifetime-semicolon.rs b/src/test/ui/parser/lifetime-semicolon.rs index 1f147216ea6..7cc14971f63 100644 --- a/src/test/ui/parser/lifetime-semicolon.rs +++ b/src/test/ui/parser/lifetime-semicolon.rs @@ -3,6 +3,6 @@ struct Foo<'a, 'b> { } fn foo<'a, 'b>(x: &mut Foo<'a; 'b>) {} -//~^ ERROR expected one of `,` or `>`, found `;` +//~^ ERROR expected one of `,`, `:`, `=`, or `>`, found `;` fn main() {} diff --git a/src/test/ui/parser/lifetime-semicolon.stderr b/src/test/ui/parser/lifetime-semicolon.stderr index 4641c286cb8..3b67705aae9 100644 --- a/src/test/ui/parser/lifetime-semicolon.stderr +++ b/src/test/ui/parser/lifetime-semicolon.stderr @@ -1,8 +1,8 @@ -error: expected one of `,` or `>`, found `;` +error: expected one of `,`, `:`, `=`, or `>`, found `;` --> $DIR/lifetime-semicolon.rs:5:30 | LL | fn foo<'a, 'b>(x: &mut Foo<'a; 'b>) {} - | ^ expected one of `,` or `>` + | ^ expected one of `,`, `:`, `=`, or `>` error: aborting due to previous error diff --git a/src/test/ui/parser/removed-syntax-closure-lifetime.rs b/src/test/ui/parser/removed-syntax-closure-lifetime.rs index ceac9408006..e807a179473 100644 --- a/src/test/ui/parser/removed-syntax-closure-lifetime.rs +++ b/src/test/ui/parser/removed-syntax-closure-lifetime.rs @@ -1,2 +1,2 @@ type closure = Box<lt/fn()>; -//~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `/` +//~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, `=`, or `>`, found `/` diff --git a/src/test/ui/parser/removed-syntax-closure-lifetime.stderr b/src/test/ui/parser/removed-syntax-closure-lifetime.stderr index a100f689fb8..63b6e138ce5 100644 --- a/src/test/ui/parser/removed-syntax-closure-lifetime.stderr +++ b/src/test/ui/parser/removed-syntax-closure-lifetime.stderr @@ -1,8 +1,8 @@ -error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `/` +error: expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, `=`, or `>`, found `/` --> $DIR/removed-syntax-closure-lifetime.rs:1:22 | LL | type closure = Box<lt/fn()>; - | ^ expected one of 7 possible tokens + | ^ expected one of 9 possible tokens error: aborting due to previous error diff --git a/src/test/ui/proc-macro/allowed-attr-stmt-expr.rs b/src/test/ui/proc-macro/allowed-attr-stmt-expr.rs index 03c10a43248..25243aeef3b 100644 --- a/src/test/ui/proc-macro/allowed-attr-stmt-expr.rs +++ b/src/test/ui/proc-macro/allowed-attr-stmt-expr.rs @@ -13,19 +13,28 @@ extern crate std; extern crate attr_stmt_expr; extern crate test_macros; -use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr}; +use attr_stmt_expr::{expect_let, expect_my_macro_stmt, expect_expr, expect_my_macro_expr}; use test_macros::print_attr; -use std::println; + +// We don't use `std::println` so that we avoid loading hygiene +// information from libstd, which would affect the SyntaxContext ids +macro_rules! my_macro { + ($($tt:tt)*) => { () } +} + fn print_str(string: &'static str) { // macros are handled a bit differently - #[expect_print_expr] - println!("{}", string) + #[expect_my_macro_expr] + my_macro!("{}", string) } macro_rules! make_stmt { ($stmt:stmt) => { - $stmt + #[print_attr] + #[rustc_dummy] + $stmt; // This semicolon is *not* passed to the macro, + // since `$stmt` is already a statement. } } @@ -35,6 +44,10 @@ macro_rules! second_make_stmt { } } +// The macro will see a semicolon here +#[print_attr] +struct ItemWithSemi; + fn main() { make_stmt!(struct Foo {}); @@ -44,8 +57,8 @@ fn main() { let string = "Hello, world!"; #[print_attr] - #[expect_print_stmt] - println!("{}", string); + #[expect_my_macro_stmt] + my_macro!("{}", string); #[print_attr] second_make_stmt!(#[allow(dead_code)] struct Bar {}); @@ -54,6 +67,12 @@ fn main() { #[rustc_dummy] struct Other {}; + // The macro also sees a semicolon, + // for consistency with the `ItemWithSemi` case above. + #[print_attr] + #[rustc_dummy] + struct NonBracedStruct; + #[expect_expr] print_str("string") } diff --git a/src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout b/src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout index 0c7ac4fb682..6cf864f3590 100644 --- a/src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout +++ b/src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout @@ -1,70 +1,117 @@ +PRINT-ATTR INPUT (DISPLAY): struct ItemWithSemi ; +PRINT-ATTR INPUT (DEBUG): TokenStream [ + Ident { + ident: "struct", + span: $DIR/allowed-attr-stmt-expr.rs:49:1: 49:7 (#0), + }, + Ident { + ident: "ItemWithSemi", + span: $DIR/allowed-attr-stmt-expr.rs:49:8: 49:20 (#0), + }, + Punct { + ch: ';', + spacing: Alone, + span: $DIR/allowed-attr-stmt-expr.rs:49:20: 49:21 (#0), + }, +] +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Foo { } +PRINT-ATTR INPUT (DEBUG): TokenStream [ + Punct { + ch: '#', + spacing: Alone, + span: $DIR/allowed-attr-stmt-expr.rs:35:9: 35:10 (#11), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "rustc_dummy", + span: $DIR/allowed-attr-stmt-expr.rs:35:11: 35:22 (#11), + }, + ], + span: $DIR/allowed-attr-stmt-expr.rs:35:10: 35:23 (#11), + }, + Ident { + ident: "struct", + span: $DIR/allowed-attr-stmt-expr.rs:53:16: 53:22 (#0), + }, + Ident { + ident: "Foo", + span: $DIR/allowed-attr-stmt-expr.rs:53:23: 53:26 (#0), + }, + Group { + delimiter: Brace, + stream: TokenStream [], + span: $DIR/allowed-attr-stmt-expr.rs:53:27: 53:29 (#0), + }, +] PRINT-ATTR INPUT (DISPLAY): #[expect_let] let string = "Hello, world!" ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:56:5: 56:6 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "expect_let", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:56:7: 56:17 (#0), }, ], - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:56:6: 56:18 (#0), }, Ident { ident: "let", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:57:5: 57:8 (#0), }, Ident { ident: "string", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:57:9: 57:15 (#0), }, Punct { ch: '=', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:57:16: 57:17 (#0), }, Literal { kind: Str, symbol: "Hello, world!", suffix: None, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:57:18: 57:33 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:57:33: 57:34 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[expect_print_stmt] println ! ("{}", string) ; +PRINT-ATTR INPUT (DISPLAY): #[expect_my_macro_stmt] my_macro ! ("{}", string) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:60:5: 60:6 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { - ident: "expect_print_stmt", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + ident: "expect_my_macro_stmt", + span: $DIR/allowed-attr-stmt-expr.rs:60:7: 60:27 (#0), }, ], - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:60:6: 60:28 (#0), }, Ident { - ident: "println", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + ident: "my_macro", + span: $DIR/allowed-attr-stmt-expr.rs:61:5: 61:13 (#0), }, Punct { ch: '!', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:61:13: 61:14 (#0), }, Group { delimiter: Parenthesis, @@ -73,36 +120,36 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ kind: Str, symbol: "{}", suffix: None, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:61:15: 61:19 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:61:19: 61:20 (#0), }, Ident { ident: "string", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:61:21: 61:27 (#0), }, ], - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:61:14: 61:28 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:61:28: 61:29 (#0), }, ] PRINT-ATTR INPUT (DISPLAY): second_make_stmt ! (#[allow(dead_code)] struct Bar { }) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "second_make_stmt", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:64:5: 64:21 (#0), }, Punct { ch: '!', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:64:21: 64:22 (#0), }, Group { delimiter: Parenthesis, @@ -110,48 +157,104 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:64:23: 64:24 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "allow", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:64:25: 64:30 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "dead_code", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:64:31: 64:40 (#0), }, ], - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:64:30: 64:41 (#0), }, ], - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:64:24: 64:42 (#0), }, Ident { ident: "struct", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:64:43: 64:49 (#0), }, Ident { ident: "Bar", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:64:50: 64:53 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:64:54: 64:56 (#0), }, ], - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:64:22: 64:57 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:64:57: 64:58 (#0), + }, +] +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] #[allow(dead_code)] struct Bar { } +PRINT-ATTR INPUT (DEBUG): TokenStream [ + Punct { + ch: '#', + spacing: Alone, + span: $DIR/allowed-attr-stmt-expr.rs:35:9: 35:10 (#32), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "rustc_dummy", + span: $DIR/allowed-attr-stmt-expr.rs:35:11: 35:22 (#32), + }, + ], + span: $DIR/allowed-attr-stmt-expr.rs:35:10: 35:23 (#32), + }, + Punct { + ch: '#', + spacing: Alone, + span: $DIR/allowed-attr-stmt-expr.rs:64:23: 64:24 (#0), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "allow", + span: $DIR/allowed-attr-stmt-expr.rs:64:25: 64:30 (#0), + }, + Group { + delimiter: Parenthesis, + stream: TokenStream [ + Ident { + ident: "dead_code", + span: $DIR/allowed-attr-stmt-expr.rs:64:31: 64:40 (#0), + }, + ], + span: $DIR/allowed-attr-stmt-expr.rs:64:30: 64:41 (#0), + }, + ], + span: $DIR/allowed-attr-stmt-expr.rs:64:24: 64:42 (#0), + }, + Ident { + ident: "struct", + span: $DIR/allowed-attr-stmt-expr.rs:64:43: 64:49 (#0), + }, + Ident { + ident: "Bar", + span: $DIR/allowed-attr-stmt-expr.rs:64:50: 64:53 (#0), + }, + Group { + delimiter: Brace, + stream: TokenStream [], + span: $DIR/allowed-attr-stmt-expr.rs:64:54: 64:56 (#0), }, ] PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Other { } @@ -159,29 +262,60 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:67:5: 67:6 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "rustc_dummy", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:67:7: 67:18 (#0), }, ], - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:67:6: 67:19 (#0), }, Ident { ident: "struct", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:68:5: 68:11 (#0), }, Ident { ident: "Other", - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:68:12: 68:17 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/allowed-attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/allowed-attr-stmt-expr.rs:68:18: 68:20 (#0), + }, +] +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct NonBracedStruct ; +PRINT-ATTR INPUT (DEBUG): TokenStream [ + Punct { + ch: '#', + spacing: Alone, + span: $DIR/allowed-attr-stmt-expr.rs:73:5: 73:6 (#0), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "rustc_dummy", + span: $DIR/allowed-attr-stmt-expr.rs:73:7: 73:18 (#0), + }, + ], + span: $DIR/allowed-attr-stmt-expr.rs:73:6: 73:19 (#0), + }, + Ident { + ident: "struct", + span: $DIR/allowed-attr-stmt-expr.rs:74:5: 74:11 (#0), + }, + Ident { + ident: "NonBracedStruct", + span: $DIR/allowed-attr-stmt-expr.rs:74:12: 74:27 (#0), + }, + Punct { + ch: ';', + spacing: Alone, + span: $DIR/allowed-attr-stmt-expr.rs:74:27: 74:28 (#0), }, ] diff --git a/src/test/ui/proc-macro/attr-stmt-expr.rs b/src/test/ui/proc-macro/attr-stmt-expr.rs index ca1b163c986..0403684cda0 100644 --- a/src/test/ui/proc-macro/attr-stmt-expr.rs +++ b/src/test/ui/proc-macro/attr-stmt-expr.rs @@ -11,19 +11,26 @@ extern crate test_macros; extern crate attr_stmt_expr; use test_macros::print_attr; -use std::println; -use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr}; +use attr_stmt_expr::{expect_let, expect_my_macro_stmt, expect_expr, expect_my_macro_expr}; + +// We don't use `std::println` so that we avoid loading hygiene +// information from libstd, which would affect the SyntaxContext ids +macro_rules! my_macro { + ($($tt:tt)*) => { () } +} fn print_str(string: &'static str) { // macros are handled a bit differently - #[expect_print_expr] + #[expect_my_macro_expr] //~^ ERROR attributes on expressions are experimental //~| HELP add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable - println!("{}", string) + my_macro!("{}", string) } macro_rules! make_stmt { ($stmt:stmt) => { + #[print_attr] + #[rustc_dummy] $stmt } } @@ -42,8 +49,8 @@ fn main() { let string = "Hello, world!"; #[print_attr] - #[expect_print_stmt] - println!("{}", string); + #[expect_my_macro_stmt] + my_macro!("{}", string); #[print_attr] second_make_stmt!(#[allow(dead_code)] struct Bar {}); diff --git a/src/test/ui/proc-macro/attr-stmt-expr.stderr b/src/test/ui/proc-macro/attr-stmt-expr.stderr index 7bd60e8ee77..56178259d43 100644 --- a/src/test/ui/proc-macro/attr-stmt-expr.stderr +++ b/src/test/ui/proc-macro/attr-stmt-expr.stderr @@ -1,14 +1,14 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/attr-stmt-expr.rs:19:5 + --> $DIR/attr-stmt-expr.rs:24:5 | -LL | #[expect_print_expr] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #[expect_my_macro_expr] + | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable error[E0658]: attributes on expressions are experimental - --> $DIR/attr-stmt-expr.rs:55:5 + --> $DIR/attr-stmt-expr.rs:62:5 | LL | #[expect_expr] | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/proc-macro/attr-stmt-expr.stdout b/src/test/ui/proc-macro/attr-stmt-expr.stdout index 5c1b586725b..f75309e6872 100644 --- a/src/test/ui/proc-macro/attr-stmt-expr.stdout +++ b/src/test/ui/proc-macro/attr-stmt-expr.stdout @@ -1,70 +1,101 @@ +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Foo { } +PRINT-ATTR INPUT (DEBUG): TokenStream [ + Punct { + ch: '#', + spacing: Alone, + span: $DIR/attr-stmt-expr.rs:33:9: 33:10 (#8), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "rustc_dummy", + span: $DIR/attr-stmt-expr.rs:33:11: 33:22 (#8), + }, + ], + span: $DIR/attr-stmt-expr.rs:33:10: 33:23 (#8), + }, + Ident { + ident: "struct", + span: $DIR/attr-stmt-expr.rs:45:16: 45:22 (#0), + }, + Ident { + ident: "Foo", + span: $DIR/attr-stmt-expr.rs:45:23: 45:26 (#0), + }, + Group { + delimiter: Brace, + stream: TokenStream [], + span: $DIR/attr-stmt-expr.rs:45:27: 45:29 (#0), + }, +] PRINT-ATTR INPUT (DISPLAY): #[expect_let] let string = "Hello, world!" ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:48:5: 48:6 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "expect_let", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:48:7: 48:17 (#0), }, ], - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:48:6: 48:18 (#0), }, Ident { ident: "let", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:49:5: 49:8 (#0), }, Ident { ident: "string", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:49:9: 49:15 (#0), }, Punct { ch: '=', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:49:16: 49:17 (#0), }, Literal { kind: Str, symbol: "Hello, world!", suffix: None, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:49:18: 49:33 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:49:33: 49:34 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[expect_print_stmt] println ! ("{}", string) ; +PRINT-ATTR INPUT (DISPLAY): #[expect_my_macro_stmt] my_macro ! ("{}", string) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:52:5: 52:6 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { - ident: "expect_print_stmt", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + ident: "expect_my_macro_stmt", + span: $DIR/attr-stmt-expr.rs:52:7: 52:27 (#0), }, ], - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:52:6: 52:28 (#0), }, Ident { - ident: "println", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + ident: "my_macro", + span: $DIR/attr-stmt-expr.rs:53:5: 53:13 (#0), }, Punct { ch: '!', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:53:13: 53:14 (#0), }, Group { delimiter: Parenthesis, @@ -73,36 +104,36 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ kind: Str, symbol: "{}", suffix: None, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:53:15: 53:19 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:53:19: 53:20 (#0), }, Ident { ident: "string", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:53:21: 53:27 (#0), }, ], - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:53:14: 53:28 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:53:28: 53:29 (#0), }, ] PRINT-ATTR INPUT (DISPLAY): second_make_stmt ! (#[allow(dead_code)] struct Bar { }) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "second_make_stmt", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:56:5: 56:21 (#0), }, Punct { ch: '!', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:56:21: 56:22 (#0), }, Group { delimiter: Parenthesis, @@ -110,48 +141,104 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:56:23: 56:24 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "allow", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:56:25: 56:30 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "dead_code", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:56:31: 56:40 (#0), }, ], - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:56:30: 56:41 (#0), }, ], - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:56:24: 56:42 (#0), }, Ident { ident: "struct", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:56:43: 56:49 (#0), }, Ident { ident: "Bar", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:56:50: 56:53 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:56:54: 56:56 (#0), }, ], - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:56:22: 56:57 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:56:57: 56:58 (#0), + }, +] +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] #[allow(dead_code)] struct Bar { } +PRINT-ATTR INPUT (DEBUG): TokenStream [ + Punct { + ch: '#', + spacing: Alone, + span: $DIR/attr-stmt-expr.rs:33:9: 33:10 (#29), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "rustc_dummy", + span: $DIR/attr-stmt-expr.rs:33:11: 33:22 (#29), + }, + ], + span: $DIR/attr-stmt-expr.rs:33:10: 33:23 (#29), + }, + Punct { + ch: '#', + spacing: Alone, + span: $DIR/attr-stmt-expr.rs:56:23: 56:24 (#0), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "allow", + span: $DIR/attr-stmt-expr.rs:56:25: 56:30 (#0), + }, + Group { + delimiter: Parenthesis, + stream: TokenStream [ + Ident { + ident: "dead_code", + span: $DIR/attr-stmt-expr.rs:56:31: 56:40 (#0), + }, + ], + span: $DIR/attr-stmt-expr.rs:56:30: 56:41 (#0), + }, + ], + span: $DIR/attr-stmt-expr.rs:56:24: 56:42 (#0), + }, + Ident { + ident: "struct", + span: $DIR/attr-stmt-expr.rs:56:43: 56:49 (#0), + }, + Ident { + ident: "Bar", + span: $DIR/attr-stmt-expr.rs:56:50: 56:53 (#0), + }, + Group { + delimiter: Brace, + stream: TokenStream [], + span: $DIR/attr-stmt-expr.rs:56:54: 56:56 (#0), }, ] PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Other { } @@ -159,29 +246,29 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:59:5: 59:6 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "rustc_dummy", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:59:7: 59:18 (#0), }, ], - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:59:6: 59:19 (#0), }, Ident { ident: "struct", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:60:5: 60:11 (#0), }, Ident { ident: "Other", - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:60:12: 60:17 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/attr-stmt-expr.rs:1:1: 1:1 (#0), + span: $DIR/attr-stmt-expr.rs:60:18: 60:20 (#0), }, ] diff --git a/src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs b/src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs index 213f999e9d0..19183c61651 100644 --- a/src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs +++ b/src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs @@ -15,9 +15,9 @@ pub fn expect_let(attr: TokenStream, item: TokenStream) -> TokenStream { } #[proc_macro_attribute] -pub fn expect_print_stmt(attr: TokenStream, item: TokenStream) -> TokenStream { +pub fn expect_my_macro_stmt(attr: TokenStream, item: TokenStream) -> TokenStream { assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "println ! (\"{}\", string) ;"); + assert_eq!(item.to_string(), "my_macro ! (\"{}\", string) ;"); item } @@ -29,9 +29,9 @@ pub fn expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream { } #[proc_macro_attribute] -pub fn expect_print_expr(attr: TokenStream, item: TokenStream) -> TokenStream { +pub fn expect_my_macro_expr(attr: TokenStream, item: TokenStream) -> TokenStream { assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "println ! (\"{}\", string)"); + assert_eq!(item.to_string(), "my_macro ! (\"{}\", string)"); item } diff --git a/src/test/ui/proc-macro/auxiliary/issue-79242.rs b/src/test/ui/proc-macro/auxiliary/issue-79242.rs new file mode 100644 index 00000000000..e586980f0ad --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/issue-79242.rs @@ -0,0 +1,16 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro] +pub fn dummy(input: TokenStream) -> TokenStream { + // Iterate to force internal conversion of nonterminals + // to `proc_macro` structs + for _ in input {} + TokenStream::new() +} diff --git a/src/test/ui/proc-macro/issue-79242-slow-retokenize-check.rs b/src/test/ui/proc-macro/issue-79242-slow-retokenize-check.rs new file mode 100644 index 00000000000..b68f19c5dd2 --- /dev/null +++ b/src/test/ui/proc-macro/issue-79242-slow-retokenize-check.rs @@ -0,0 +1,34 @@ +// check-pass +// aux-build:issue-79242.rs + +// Regression test for issue #79242 +// Tests that compilation time doesn't blow up for a proc-macro +// invocation with deeply nested nonterminals + +#![allow(unused)] + +extern crate issue_79242; + +macro_rules! declare_nats { + ($prev:ty) => {}; + ($prev:ty, $n:literal$(, $tail:literal)*) => { + + issue_79242::dummy! { + $prev + } + + declare_nats!(Option<$prev>$(, $tail)*); + }; + (0, $($n:literal),+) => { + pub struct N0; + declare_nats!(N0, $($n),+); + }; +} + +declare_nats! { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 +} + + +fn main() {} diff --git a/src/test/ui/structs-enums/nested-enum-same-names.rs b/src/test/ui/structs-enums/nested-enum-same-names.rs index dece3dcd54b..111b9ba9477 100644 --- a/src/test/ui/structs-enums/nested-enum-same-names.rs +++ b/src/test/ui/structs-enums/nested-enum-same-names.rs @@ -17,10 +17,10 @@ as it does not include the method name in the symbol name. pub struct Foo; impl Foo { pub fn foo() { - enum Panic { Common }; + enum Panic { Common } } pub fn bar() { - enum Panic { Common }; + enum Panic { Common } } } diff --git a/src/test/ui/try-is-identifier-edition2015.rs b/src/test/ui/try-is-identifier-edition2015.rs index dfb05599be6..90f56d5fa71 100644 --- a/src/test/ui/try-is-identifier-edition2015.rs +++ b/src/test/ui/try-is-identifier-edition2015.rs @@ -5,7 +5,7 @@ fn main() { let try = 2; - struct try { try: u32 }; + struct try { try: u32 } let try: try = try { try }; assert_eq!(try.try, 2); } diff --git a/src/test/ui/zero-sized/zero-size-type-destructors.rs b/src/test/ui/zero-sized/zero-size-type-destructors.rs index 98b5a439c82..fb87d8ea0ba 100644 --- a/src/test/ui/zero-sized/zero-size-type-destructors.rs +++ b/src/test/ui/zero-sized/zero-size-type-destructors.rs @@ -10,7 +10,7 @@ pub fn foo() { fn drop(&mut self) { unsafe { destructions -= 1 }; } - }; + } let _x = [Foo, Foo, Foo]; } diff --git a/src/tools/clippy/clippy_lints/src/missing_doc.rs b/src/tools/clippy/clippy_lints/src/missing_doc.rs index 009e3d8937e..4678f6872f3 100644 --- a/src/tools/clippy/clippy_lints/src/missing_doc.rs +++ b/src/tools/clippy/clippy_lints/src/missing_doc.rs @@ -147,7 +147,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc { hir::ItemKind::Union(..) => "a union", hir::ItemKind::OpaqueTy(..) => "an existential type", hir::ItemKind::ExternCrate(..) - | hir::ItemKind::ForeignMod(..) + | hir::ItemKind::ForeignMod { .. } | hir::ItemKind::GlobalAsm(..) | hir::ItemKind::Impl { .. } | hir::ItemKind::Use(..) => return, diff --git a/src/tools/clippy/clippy_lints/src/missing_inline.rs b/src/tools/clippy/clippy_lints/src/missing_inline.rs index 53abe6086ea..913d9daff46 100644 --- a/src/tools/clippy/clippy_lints/src/missing_inline.rs +++ b/src/tools/clippy/clippy_lints/src/missing_inline.rs @@ -125,7 +125,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline { | hir::ItemKind::Union(..) | hir::ItemKind::OpaqueTy(..) | hir::ItemKind::ExternCrate(..) - | hir::ItemKind::ForeignMod(..) + | hir::ItemKind::ForeignMod { .. } | hir::ItemKind::Impl { .. } | hir::ItemKind::Use(..) => {}, }; diff --git a/src/tools/clippy/clippy_lints/src/utils/inspector.rs b/src/tools/clippy/clippy_lints/src/utils/inspector.rs index 4fbfb3be32c..8f0ef9150d4 100644 --- a/src/tools/clippy/clippy_lints/src/utils/inspector.rs +++ b/src/tools/clippy/clippy_lints/src/utils/inspector.rs @@ -395,7 +395,7 @@ fn print_item(cx: &LateContext<'_>, item: &hir::Item<'_>) { println!("function of type {:#?}", item_ty); }, hir::ItemKind::Mod(..) => println!("module"), - hir::ItemKind::ForeignMod(ref fm) => println!("foreign module with abi: {}", fm.abi), + hir::ItemKind::ForeignMod { abi, .. } => println!("foreign module with abi: {}", abi), hir::ItemKind::GlobalAsm(ref asm) => println!("global asm: {:?}", asm), hir::ItemKind::TyAlias(..) => { println!("type alias for {:?}", cx.tcx.type_of(did)); |
