diff --git a/Cargo.lock b/Cargo.lock index b1635cc468705..e446d7dafd888 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3336,6 +3336,7 @@ dependencies = [ "libc", "object 0.37.3", "regex", + "rustdoc-json-types", "serde_json", "similar", "wasmparser 0.236.1", diff --git a/bootstrap.example.toml b/bootstrap.example.toml index 08e96fda0714c..6a8da0305464a 100644 --- a/bootstrap.example.toml +++ b/bootstrap.example.toml @@ -708,6 +708,12 @@ # desired in distributions, for example. #rust.rpath = true +# Additional flags to pass to `rustc`. +# Takes precedence over bootstrap's own flags but not over per target rustflags nor env. vars. like RUSTFLAGS. +# Applies to all stages and targets. +# +#rust.rustflags = [] + # Indicates whether symbols should be stripped using `-Cstrip=symbols`. #rust.strip = false @@ -1013,6 +1019,12 @@ # and will override the same option under [rust] section. It only works on Unix platforms #rpath = rust.rpath (bool) +# Additional flags to pass to `rustc`. +# Takes precedence over bootstrap's own flags and `rust.rustflags` but not over env. vars. like RUSTFLAGS. +# Applies to all stages. +# +#rustflags = rust.rustflags + # Force static or dynamic linkage of the standard library for this target. If # this target is a host for rustc, this will also affect the linkage of the # compiler itself. This is useful for building rustc on targets that normally diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg.rs b/compiler/rustc_attr_parsing/src/attributes/cfg.rs index 53f8fd5af6b47..a8aa63bd05ee6 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg.rs @@ -82,7 +82,8 @@ pub fn parse_cfg_entry( } }, a @ (ArgParser::NoArgs | ArgParser::NameValue(_)) => { - let Some(name) = meta.path().word_sym() else { + let Some(name) = meta.path().word_sym().filter(|s| !s.is_path_segment_keyword()) + else { return Err(cx.expected_identifier(meta.path().span())); }; parse_name_value(name, meta.path().span(), a.name_value(), meta.span(), cx)? @@ -158,7 +159,7 @@ fn parse_cfg_entry_target( }; // Then, parse it as a name-value item - let Some(name) = sub_item.path().word_sym() else { + let Some(name) = sub_item.path().word_sym().filter(|s| !s.is_path_segment_keyword()) else { return Err(cx.expected_identifier(sub_item.path().span())); }; let name = Symbol::intern(&format!("target_{name}")); diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg_old.rs b/compiler/rustc_attr_parsing/src/attributes/cfg_old.rs index 3257d898eccbc..70228d1e15101 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg_old.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg_old.rs @@ -220,7 +220,10 @@ pub fn eval_condition( } } } - MetaItemKind::Word | MetaItemKind::NameValue(..) if cfg.path.segments.len() != 1 => { + MetaItemKind::Word | MetaItemKind::NameValue(..) + if cfg.path.segments.len() != 1 + || cfg.path.segments[0].ident.is_path_segment_keyword() => + { dcx.emit_err(session_diagnostics::CfgPredicateIdentifier { span: cfg.path.span }); true } diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 4cab7e407eec2..d9132ca123490 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -532,30 +532,24 @@ impl Emitter for HumanEmitter { } } -/// An emitter that does nothing when emitting a non-fatal diagnostic. -/// Fatal diagnostics are forwarded to `fatal_emitter` to avoid silent -/// failures of rustc, as witnessed e.g. in issue #89358. -pub struct FatalOnlyEmitter { - pub fatal_emitter: Box, - pub fatal_note: Option, +/// An emitter that adds a note to each diagnostic. +pub struct EmitterWithNote { + pub emitter: Box, + pub note: String, } -impl Emitter for FatalOnlyEmitter { +impl Emitter for EmitterWithNote { fn source_map(&self) -> Option<&SourceMap> { None } fn emit_diagnostic(&mut self, mut diag: DiagInner, registry: &Registry) { - if diag.level == Level::Fatal { - if let Some(fatal_note) = &self.fatal_note { - diag.sub(Level::Note, fatal_note.clone(), MultiSpan::new()); - } - self.fatal_emitter.emit_diagnostic(diag, registry); - } + diag.sub(Level::Note, self.note.clone(), MultiSpan::new()); + self.emitter.emit_diagnostic(diag, registry); } fn translator(&self) -> &Translator { - self.fatal_emitter.translator() + self.emitter.translator() } } diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index bc4e4127c8eda..af1c35774a67a 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -15,6 +15,7 @@ use rustc_middle::ty::CurrentGcx; use rustc_middle::util::Providers; use rustc_parse::lexer::StripTokens; use rustc_parse::new_parser_from_source_str; +use rustc_parse::parser::Recovery; use rustc_parse::parser::attr::AllowLeadingUnsafe; use rustc_query_impl::QueryCtxt; use rustc_query_system::query::print_query_stack; @@ -52,9 +53,9 @@ pub struct Compiler { pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec) -> Cfg { cfgs.into_iter() .map(|s| { - let psess = ParseSess::with_fatal_emitter( + let psess = ParseSess::emitter_with_note( vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE], - format!("this error occurred on the command line: `--cfg={s}`"), + format!("this occurred on the command line: `--cfg={s}`"), ); let filename = FileName::cfg_spec_source_code(&s); @@ -62,36 +63,46 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec) -> Cfg { ($reason: expr) => { #[allow(rustc::untranslatable_diagnostic)] #[allow(rustc::diagnostic_outside_of_impl)] - dcx.fatal(format!( - concat!("invalid `--cfg` argument: `{}` (", $reason, ")"), - s - )); + dcx.fatal(format!("invalid `--cfg` argument: `{s}` ({})", $reason)); }; } match new_parser_from_source_str(&psess, filename, s.to_string(), StripTokens::Nothing) { - Ok(mut parser) => match parser.parse_meta_item(AllowLeadingUnsafe::No) { - Ok(meta_item) if parser.token == token::Eof => { - if meta_item.path.segments.len() != 1 { - error!("argument key must be an identifier"); - } - match &meta_item.kind { - MetaItemKind::List(..) => {} - MetaItemKind::NameValue(lit) if !lit.kind.is_str() => { - error!("argument value must be a string"); + Ok(mut parser) => { + parser = parser.recovery(Recovery::Forbidden); + match parser.parse_meta_item(AllowLeadingUnsafe::No) { + Ok(meta_item) + if parser.token == token::Eof + && parser.dcx().has_errors().is_none() => + { + if meta_item.path.segments.len() != 1 { + error!("argument key must be an identifier"); } - MetaItemKind::NameValue(..) | MetaItemKind::Word => { - let ident = meta_item.ident().expect("multi-segment cfg key"); - return (ident.name, meta_item.value_str()); + match &meta_item.kind { + MetaItemKind::List(..) => {} + MetaItemKind::NameValue(lit) if !lit.kind.is_str() => { + error!("argument value must be a string"); + } + MetaItemKind::NameValue(..) | MetaItemKind::Word => { + let ident = meta_item.ident().expect("multi-segment cfg key"); + + if ident.is_path_segment_keyword() { + error!( + "malformed `cfg` input, expected a valid identifier" + ); + } + + return (ident.name, meta_item.value_str()); + } } } + Ok(..) => {} + Err(err) => err.cancel(), } - Ok(..) => {} - Err(err) => err.cancel(), - }, + } Err(errs) => errs.into_iter().for_each(|err| err.cancel()), - } + }; // If the user tried to use a key="value" flag, but is missing the quotes, provide // a hint about how to resolve this. @@ -116,9 +127,9 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec) -> Ch let mut check_cfg = CheckCfg { exhaustive_names, exhaustive_values, ..CheckCfg::default() }; for s in specs { - let psess = ParseSess::with_fatal_emitter( + let psess = ParseSess::emitter_with_note( vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE], - format!("this error occurred on the command line: `--check-cfg={s}`"), + format!("this occurred on the command line: `--check-cfg={s}`"), ); let filename = FileName::cfg_spec_source_code(&s); @@ -171,7 +182,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec) -> Ch let mut parser = match new_parser_from_source_str(&psess, filename, s.to_string(), StripTokens::Nothing) { - Ok(parser) => parser, + Ok(parser) => parser.recovery(Recovery::Forbidden), Err(errs) => { errs.into_iter().for_each(|err| err.cancel()); expected_error(); @@ -179,7 +190,9 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec) -> Ch }; let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::No) { - Ok(meta_item) if parser.token == token::Eof => meta_item, + Ok(meta_item) if parser.token == token::Eof && parser.dcx().has_errors().is_none() => { + meta_item + } Ok(..) => expected_error(), Err(err) => { err.cancel(); @@ -209,6 +222,11 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec) -> Ch if values_specified { error!("`cfg()` names cannot be after values"); } + + if ident.is_path_segment_keyword() { + error!("malformed `cfg` input, expected a valid identifier"); + } + names.push(ident); } else if let Some(boolean) = arg.boolean_literal() { if values_specified { diff --git a/compiler/rustc_mir_transform/src/elaborate_drop.rs b/compiler/rustc_mir_transform/src/elaborate_drop.rs index 4f3c53d761f10..8998be26412d5 100644 --- a/compiler/rustc_mir_transform/src/elaborate_drop.rs +++ b/compiler/rustc_mir_transform/src/elaborate_drop.rs @@ -511,19 +511,12 @@ where let tcx = self.tcx(); assert_eq!(self.elaborator.typing_env().typing_mode, ty::TypingMode::PostAnalysis); - let field_ty = match tcx.try_normalize_erasing_regions( - self.elaborator.typing_env(), - field.ty(tcx, args), - ) { - Ok(t) => t, - Err(_) => Ty::new_error( - self.tcx(), - self.tcx().dcx().span_delayed_bug( - self.elaborator.body().span, - "Error normalizing in drop elaboration.", - ), - ), - }; + let field_ty = field.ty(tcx, args); + // We silently leave an unnormalized type here to support polymorphic drop + // elaboration for users of rustc internal APIs + let field_ty = tcx + .try_normalize_erasing_regions(self.elaborator.typing_env(), field_ty) + .unwrap_or(field_ty); (tcx.mk_place_field(base_place, field_idx, field_ty), subpath) }) diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 203a93b52012b..14a738fb9d247 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -466,7 +466,7 @@ impl<'a> Parser<'a> { // Public for rustfmt usage. pub fn parse_ident(&mut self) -> PResult<'a, Ident> { - self.parse_ident_common(true) + self.parse_ident_common(self.may_recover()) } fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, Ident> { diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 0b4c52d68b6ff..da58c923695dd 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -823,8 +823,16 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { } if let Some(Res::Def(DefKind::Struct, def_id)) = res { - self.update_err_for_private_tuple_struct_fields(err, &source, def_id); - err.note("constructor is not visible here due to private fields"); + let private_fields = self.has_private_fields(def_id); + let adjust_error_message = + private_fields && self.is_struct_with_fn_ctor(def_id); + if adjust_error_message { + self.update_err_for_private_tuple_struct_fields(err, &source, def_id); + } + + if private_fields { + err.note("constructor is not visible here due to private fields"); + } } else { err.span_suggestion( call_span, @@ -1642,6 +1650,19 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { } } + fn is_struct_with_fn_ctor(&mut self, def_id: DefId) -> bool { + def_id + .as_local() + .and_then(|local_id| self.r.struct_constructors.get(&local_id)) + .map(|struct_ctor| { + matches!( + struct_ctor.0, + def::Res::Def(DefKind::Ctor(CtorOf::Struct, CtorKind::Fn), _) + ) + }) + .unwrap_or(false) + } + fn update_err_for_private_tuple_struct_fields( &mut self, err: &mut Diag<'_>, @@ -1674,7 +1695,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { *call_span, &args[..], ); - // Use spans of the tuple struct definition. + self.r .field_idents(def_id) .map(|fields| fields.iter().map(|f| f.span).collect::>()) diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 9048c51d5b42d..8c70e18fb66dd 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -8,7 +8,7 @@ use rustc_ast::attr::AttrIdGenerator; use rustc_ast::node_id::NodeId; use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; use rustc_data_structures::sync::{AppendOnlyVec, Lock}; -use rustc_errors::emitter::{FatalOnlyEmitter, HumanEmitter, stderr_destination}; +use rustc_errors::emitter::{EmitterWithNote, HumanEmitter, stderr_destination}; use rustc_errors::translation::Translator; use rustc_errors::{ BufferedEarlyLint, ColorConfig, DecorateDiagCompat, Diag, DiagCtxt, DiagCtxtHandle, @@ -315,16 +315,12 @@ impl ParseSess { } } - pub fn with_fatal_emitter(locale_resources: Vec<&'static str>, fatal_note: String) -> Self { + pub fn emitter_with_note(locale_resources: Vec<&'static str>, note: String) -> Self { let translator = Translator::with_fallback_bundle(locale_resources, false); let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); - let fatal_emitter = + let emitter = Box::new(HumanEmitter::new(stderr_destination(ColorConfig::Auto), translator)); - let dcx = DiagCtxt::new(Box::new(FatalOnlyEmitter { - fatal_emitter, - fatal_note: Some(fatal_note), - })) - .disable_warnings(); + let dcx = DiagCtxt::new(Box::new(EmitterWithNote { emitter, note })); ParseSess::with_dcx(dcx, sm) } diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index c38e140898543..a685a0f2d8224 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -105,6 +105,7 @@ pub struct Cargo { allow_features: String, release_build: bool, build_compiler_stage: u32, + extra_rustflags: Vec, } impl Cargo { @@ -403,6 +404,11 @@ impl From for BootstrapCommand { cargo.args.insert(0, "--release".into()); } + for arg in &cargo.extra_rustflags { + cargo.rustflags.arg(arg); + cargo.rustdocflags.arg(arg); + } + // Propagate the envs here at the very end to make sure they override any previously set flags. cargo.rustflags.propagate_rustflag_envs(cargo.build_compiler_stage); cargo.rustdocflags.propagate_rustflag_envs(cargo.build_compiler_stage); @@ -1379,6 +1385,15 @@ impl Builder<'_> { rustflags.arg("-Zmir_strip_debuginfo=locals-in-tiny-functions"); } + // take target-specific extra rustflags if any otherwise take `rust.rustflags` + let extra_rustflags = self + .config + .target_config + .get(&target) + .map(|t| &t.rustflags) + .unwrap_or(&self.config.rust_rustflags) + .clone(); + let release_build = self.config.rust_optimize.is_release() && // cargo bench/install do not accept `--release` and miri doesn't want it !matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest); @@ -1394,6 +1409,7 @@ impl Builder<'_> { allow_features, release_build, build_compiler_stage, + extra_rustflags, } } } diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 9ad22e9de565d..2f493658ec0ec 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -225,6 +225,7 @@ pub struct Config { pub rust_std_features: BTreeSet, pub rust_break_on_ice: bool, pub rust_parallel_frontend_threads: Option, + pub rust_rustflags: Vec, pub llvm_profile_use: Option, pub llvm_profile_generate: bool, @@ -575,6 +576,7 @@ impl Config { bootstrap_override_lld_legacy: rust_bootstrap_override_lld_legacy, std_features: rust_std_features, break_on_ice: rust_break_on_ice, + rustflags: rust_rustflags, } = toml.rust.unwrap_or_default(); let Llvm { @@ -864,6 +866,7 @@ impl Config { sanitizers: target_sanitizers, profiler: target_profiler, rpath: target_rpath, + rustflags: target_rustflags, crt_static: target_crt_static, musl_root: target_musl_root, musl_libdir: target_musl_libdir, @@ -947,6 +950,7 @@ impl Config { target.sanitizers = target_sanitizers; target.profiler = target_profiler; target.rpath = target_rpath; + target.rustflags = target_rustflags.unwrap_or_default(); target.optimized_compiler_builtins = target_optimized_compiler_builtins; target.jemalloc = target_jemalloc; if let Some(backends) = target_codegen_backends { @@ -1441,6 +1445,7 @@ impl Config { rust_randomize_layout: rust_randomize_layout.unwrap_or(false), rust_remap_debuginfo: rust_remap_debuginfo.unwrap_or(false), rust_rpath: rust_rpath.unwrap_or(true), + rust_rustflags: rust_rustflags.unwrap_or_default(), rust_stack_protector, rust_std_features: rust_std_features .unwrap_or(BTreeSet::from([String::from("panic-unwind")])), diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index a9089ba499a4f..48042ba56bb61 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -33,6 +33,7 @@ define_config! { channel: Option = "channel", musl_root: Option = "musl-root", rpath: Option = "rpath", + rustflags: Option> = "rustflags", strip: Option = "strip", frame_pointers: Option = "frame-pointers", stack_protector: Option = "stack-protector", @@ -375,6 +376,7 @@ pub fn check_incompatible_options_for_ci_rustc( parallel_frontend_threads: _, bootstrap_override_lld: _, bootstrap_override_lld_legacy: _, + rustflags: _, } = ci_rust_config; // There are two kinds of checks for CI rustc incompatible options: diff --git a/src/bootstrap/src/core/config/toml/target.rs b/src/bootstrap/src/core/config/toml/target.rs index 4c7afa50b9658..847b75e696b47 100644 --- a/src/bootstrap/src/core/config/toml/target.rs +++ b/src/bootstrap/src/core/config/toml/target.rs @@ -37,6 +37,7 @@ define_config! { sanitizers: Option = "sanitizers", profiler: Option = "profiler", rpath: Option = "rpath", + rustflags: Option> = "rustflags", crt_static: Option = "crt-static", musl_root: Option = "musl-root", musl_libdir: Option = "musl-libdir", @@ -70,6 +71,7 @@ pub struct Target { pub sanitizers: Option, pub profiler: Option, pub rpath: Option, + pub rustflags: Vec, pub crt_static: Option, pub musl_root: Option, pub musl_libdir: Option, diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index 5f66d8a7d4c6b..ed280addb3b84 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -596,4 +596,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Info, summary: "The `-Zannotate-moves` option is now always enabled when building rustc, sysroot and tools.", }, + ChangeInfo { + change_id: 148795, + severity: ChangeSeverity::Info, + summary: "New options `rust.rustflags` for all targets and `rustflags` par target that will pass specified flags to rustc for all stages. Target specific flags override global `rust.rustflags` ones.", + }, ]; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a4f754912aea6..38b12405ea821 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -249,7 +249,7 @@ pub(crate) fn clean_trait_ref_with_constraints<'tcx>( trait_ref: ty::PolyTraitRef<'tcx>, constraints: ThinVec, ) -> Path { - let kind = cx.tcx.def_kind(trait_ref.def_id()).into(); + let kind = ItemType::from_def_id(trait_ref.def_id(), cx.tcx); if !matches!(kind, ItemType::Trait | ItemType::TraitAlias) { span_bug!(cx.tcx.def_span(trait_ref.def_id()), "`TraitRef` had unexpected kind {kind:?}"); } diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 6e4c65dc91273..f1b0f4a68beaa 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1,3 +1,4 @@ +use std::fmt::Write; use std::hash::Hash; use std::path::PathBuf; use std::sync::{Arc, OnceLock as OnceCell}; @@ -522,8 +523,16 @@ impl Item { debug!(?id); if let Ok(HrefInfo { mut url, .. }) = href(*id, cx) { debug!(?url); - if let Some(ref fragment) = *fragment { - fragment.render(&mut url, cx.tcx()) + match fragment { + Some(UrlFragment::Item(def_id)) => { + write!(url, "{}", crate::html::format::fragment(*def_id, cx.tcx())) + .unwrap(); + } + Some(UrlFragment::UserWritten(raw)) => { + url.push('#'); + url.push_str(raw); + } + None => {} } Some(RenderedLink { original_text: s.clone(), diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 060abfd05e042..cb5cd6523afea 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -26,6 +26,7 @@ use crate::clean::{ }; use crate::core::DocContext; use crate::display::Joined as _; +use crate::formats::item_type::ItemType; #[cfg(test)] mod tests; @@ -496,7 +497,7 @@ pub(crate) fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId { let (kind, did) = match res { Res::Def( - kind @ (AssocTy + AssocTy | AssocFn | AssocConst | Variant @@ -511,9 +512,9 @@ pub(crate) fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId { | Const | Static { .. } | Macro(..) - | TraitAlias), + | TraitAlias, did, - ) => (kind.into(), did), + ) => (ItemType::from_def_id(did, cx.tcx), did), _ => panic!("register_res: unexpected {res:?}"), }; diff --git a/src/librustdoc/formats/item_type.rs b/src/librustdoc/formats/item_type.rs index ab40c01cb369d..d3923e3e31166 100644 --- a/src/librustdoc/formats/item_type.rs +++ b/src/librustdoc/formats/item_type.rs @@ -3,6 +3,8 @@ use std::fmt; use rustc_hir::def::{CtorOf, DefKind, MacroKinds}; +use rustc_hir::def_id::DefId; +use rustc_middle::ty::TyCtxt; use rustc_span::hygiene::MacroKind; use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; @@ -147,17 +149,10 @@ impl<'a> From<&'a clean::Item> for ItemType { } } -impl From for ItemType { - fn from(other: DefKind) -> Self { - Self::from_def_kind(other, None) - } -} - impl ItemType { - /// Depending on the parent kind, some variants have a different translation (like a `Method` - /// becoming a `TyMethod`). - pub(crate) fn from_def_kind(kind: DefKind, parent_kind: Option) -> Self { - match kind { + pub(crate) fn from_def_id(def_id: DefId, tcx: TyCtxt<'_>) -> Self { + let def_kind = tcx.def_kind(def_id); + match def_kind { DefKind::Enum => Self::Enum, DefKind::Fn => Self::Function, DefKind::Mod => Self::Module, @@ -176,8 +171,13 @@ impl ItemType { DefKind::Variant => Self::Variant, DefKind::Field => Self::StructField, DefKind::AssocTy => Self::AssocType, - DefKind::AssocFn if let Some(DefKind::Trait) = parent_kind => Self::TyMethod, - DefKind::AssocFn => Self::Method, + DefKind::AssocFn => { + if tcx.associated_item(def_id).defaultness(tcx).has_value() { + Self::Method + } else { + Self::TyMethod + } + } DefKind::Ctor(CtorOf::Struct, _) => Self::Struct, DefKind::Ctor(CtorOf::Variant, _) => Self::Variant, DefKind::AssocConst => Self::AssocConst, diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index b7f6d84ea36c2..dd91cec531f59 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -431,7 +431,6 @@ fn generate_item_def_id_path( original_def_id: DefId, cx: &Context<'_>, root_path: Option<&str>, - original_def_kind: DefKind, ) -> Result { use rustc_middle::traits::ObligationCause; use rustc_trait_selection::infer::TyCtxtInferExt; @@ -457,15 +456,14 @@ fn generate_item_def_id_path( let relative = clean::inline::item_relative_path(tcx, def_id); let fqp: Vec = once(crate_name).chain(relative).collect(); - let def_kind = tcx.def_kind(def_id); - let shortty = def_kind.into(); + let shortty = ItemType::from_def_id(def_id, tcx); let module_fqp = to_module_fqp(shortty, &fqp); let mut is_remote = false; let url_parts = url_parts(cx.cache(), def_id, module_fqp, &cx.current, &mut is_remote)?; let mut url_parts = make_href(root_path, shortty, url_parts, &fqp, is_remote); if def_id != original_def_id { - let kind = ItemType::from_def_kind(original_def_kind, Some(def_kind)); + let kind = ItemType::from_def_id(original_def_id, tcx); url_parts = format!("{url_parts}#{kind}.{}", tcx.item_name(original_def_id)) }; Ok(HrefInfo { url: url_parts, kind: shortty, rust_path: fqp }) @@ -605,7 +603,7 @@ pub(crate) fn href_with_root_path( } else if did.is_local() { return Err(HrefError::Private); } else { - return generate_item_def_id_path(did, original_did, cx, root_path, def_kind); + return generate_item_def_id_path(did, original_did, cx, root_path); } } }; @@ -835,26 +833,36 @@ fn print_higher_ranked_params_with_space( }) } -pub(crate) fn print_anchor(did: DefId, text: Symbol, cx: &Context<'_>) -> impl Display { +pub(crate) fn fragment(did: DefId, tcx: TyCtxt<'_>) -> impl Display { fmt::from_fn(move |f| { - if let Ok(HrefInfo { url, kind, rust_path }) = href(did, cx) { - let tcx = cx.tcx(); - let def_kind = tcx.def_kind(did); - let anchor = if matches!( - def_kind, - DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst | DefKind::Variant - ) { + let def_kind = tcx.def_kind(did); + match def_kind { + DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst | DefKind::Variant => { + let item_type = ItemType::from_def_id(did, tcx); + write!(f, "#{}.{}", item_type.as_str(), tcx.item_name(did)) + } + DefKind::Field => { let parent_def_id = tcx.parent(did); - let item_type = - ItemType::from_def_kind(def_kind, Some(tcx.def_kind(parent_def_id))); - format!("#{}.{}", item_type.as_str(), tcx.item_name(did)) - } else { - String::new() - }; + f.write_char('#')?; + if tcx.def_kind(parent_def_id) == DefKind::Variant { + write!(f, "variant.{}.field", tcx.item_name(parent_def_id).as_str())?; + } else { + f.write_str("structfield")?; + }; + write!(f, ".{}", tcx.item_name(did)) + } + _ => Ok(()), + } + }) +} +pub(crate) fn print_anchor(did: DefId, text: Symbol, cx: &Context<'_>) -> impl Display { + fmt::from_fn(move |f| { + if let Ok(HrefInfo { url, kind, rust_path }) = href(did, cx) { write!( f, r#"{text}"#, + anchor = fragment(did, cx.tcx()), path = join_path_syms(rust_path), text = EscapeBodyText(text.as_str()), ) diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index b020e3d924a46..37d456ae796bd 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -302,6 +302,13 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { ExternalLocation::Remote(s) => Some(s.clone()), _ => None, }, + path: self + .tcx + .used_crate_source(*crate_num) + .paths() + .next() + .expect("crate should have at least 1 path") + .clone(), }, ) }) @@ -339,15 +346,12 @@ mod size_asserts { // tidy-alphabetical-start static_assert_size!(AssocItemConstraint, 112); static_assert_size!(Crate, 184); - static_assert_size!(ExternalCrate, 48); static_assert_size!(FunctionPointer, 168); static_assert_size!(GenericArg, 80); static_assert_size!(GenericArgs, 104); static_assert_size!(GenericBound, 72); static_assert_size!(GenericParamDef, 136); static_assert_size!(Impl, 304); - // `Item` contains a `PathBuf`, which is different sizes on different OSes. - static_assert_size!(Item, 528 + size_of::()); static_assert_size!(ItemSummary, 32); static_assert_size!(PolyTrait, 64); static_assert_size!(PreciseCapturingArg, 32); @@ -355,4 +359,8 @@ mod size_asserts { static_assert_size!(Type, 80); static_assert_size!(WherePredicate, 160); // tidy-alphabetical-end + + // These contains a `PathBuf`, which is different sizes on different OSes. + static_assert_size!(Item, 528 + size_of::()); + static_assert_size!(ExternalCrate, 48 + size_of::()); } diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index e29256bb5d1a5..4e4f21bf926fe 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -203,43 +203,6 @@ pub(crate) enum UrlFragment { UserWritten(String), } -impl UrlFragment { - /// Render the fragment, including the leading `#`. - pub(crate) fn render(&self, s: &mut String, tcx: TyCtxt<'_>) { - s.push('#'); - match self { - &UrlFragment::Item(def_id) => { - let kind = match tcx.def_kind(def_id) { - DefKind::AssocFn => { - if tcx.associated_item(def_id).defaultness(tcx).has_value() { - "method." - } else { - "tymethod." - } - } - DefKind::AssocConst => "associatedconstant.", - DefKind::AssocTy => "associatedtype.", - DefKind::Variant => "variant.", - DefKind::Field => { - let parent_id = tcx.parent(def_id); - if tcx.def_kind(parent_id) == DefKind::Variant { - s.push_str("variant."); - s.push_str(tcx.item_name(parent_id).as_str()); - ".field." - } else { - "structfield." - } - } - kind => bug!("unexpected associated item kind: {kind:?}"), - }; - s.push_str(kind); - s.push_str(tcx.item_name(def_id).as_str()); - } - UrlFragment::UserWritten(raw) => s.push_str(raw), - } - } -} - #[derive(Clone, Debug, Hash, PartialEq, Eq)] pub(crate) struct ResolutionInfo { item_id: DefId, diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index 658d3791d2578..9a59de4f844ab 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -37,8 +37,8 @@ pub type FxHashMap = HashMap; // re-export for use in src/librustdoc // will instead cause conflicts. See #94591 for more. (This paragraph and the "Latest feature" line // are deliberately not in a doc comment, because they need not be in public docs.) // -// Latest feature: Add `ItemKind::Attribute`. -pub const FORMAT_VERSION: u32 = 56; +// Latest feature: Add `ExternCrate::path`. +pub const FORMAT_VERSION: u32 = 57; /// The root of the emitted JSON blob. /// @@ -135,6 +135,12 @@ pub struct ExternalCrate { pub name: String, /// The root URL at which the crate's documentation lives. pub html_root_url: Option, + + /// A path from where this crate was loaded. + /// + /// This will typically be a `.rlib` or `.rmeta`. It can be used to determine which crate + /// this was in terms of whatever build-system invoked rustc. + pub path: PathBuf, } /// Information about an external (not defined in the local crate) [`Item`]. diff --git a/src/tools/clippy/tests/ui/cast_size.32bit.stderr b/src/tools/clippy/tests/ui/cast_size.r32bit.stderr similarity index 100% rename from src/tools/clippy/tests/ui/cast_size.32bit.stderr rename to src/tools/clippy/tests/ui/cast_size.r32bit.stderr diff --git a/src/tools/clippy/tests/ui/cast_size.64bit.stderr b/src/tools/clippy/tests/ui/cast_size.r64bit.stderr similarity index 100% rename from src/tools/clippy/tests/ui/cast_size.64bit.stderr rename to src/tools/clippy/tests/ui/cast_size.r64bit.stderr diff --git a/src/tools/clippy/tests/ui/cast_size.rs b/src/tools/clippy/tests/ui/cast_size.rs index ecc5866941918..cefab253bbeed 100644 --- a/src/tools/clippy/tests/ui/cast_size.rs +++ b/src/tools/clippy/tests/ui/cast_size.rs @@ -1,6 +1,6 @@ -//@revisions: 32bit 64bit -//@[32bit]ignore-bitwidth: 64 -//@[64bit]ignore-bitwidth: 32 +//@revisions: r32bit r64bit +//@[r32bit]ignore-bitwidth: 64 +//@[r64bit]ignore-bitwidth: 32 //@no-rustfix: only some diagnostics have suggestions #![warn( @@ -62,7 +62,7 @@ fn main() { //~^ cast_precision_loss 9_999_999_999_999_999usize as f64; //~^ cast_precision_loss - //~[32bit]^^ ERROR: literal out of range for `usize` + //~[r32bit]^^ ERROR: literal out of range for `usize` // 999_999_999_999_999_999_999_999_999_999u128 as f128; } diff --git a/src/tools/clippy/tests/ui/fn_to_numeric_cast.32bit.stderr b/src/tools/clippy/tests/ui/fn_to_numeric_cast.r32bit.stderr similarity index 100% rename from src/tools/clippy/tests/ui/fn_to_numeric_cast.32bit.stderr rename to src/tools/clippy/tests/ui/fn_to_numeric_cast.r32bit.stderr diff --git a/src/tools/clippy/tests/ui/fn_to_numeric_cast.64bit.stderr b/src/tools/clippy/tests/ui/fn_to_numeric_cast.r64bit.stderr similarity index 100% rename from src/tools/clippy/tests/ui/fn_to_numeric_cast.64bit.stderr rename to src/tools/clippy/tests/ui/fn_to_numeric_cast.r64bit.stderr diff --git a/src/tools/clippy/tests/ui/fn_to_numeric_cast.rs b/src/tools/clippy/tests/ui/fn_to_numeric_cast.rs index 0a07aeff366eb..3659ca24278f6 100644 --- a/src/tools/clippy/tests/ui/fn_to_numeric_cast.rs +++ b/src/tools/clippy/tests/ui/fn_to_numeric_cast.rs @@ -1,6 +1,6 @@ -//@revisions: 32bit 64bit -//@[32bit]ignore-bitwidth: 64 -//@[64bit]ignore-bitwidth: 32 +//@revisions: r32bit r64bit +//@[r32bit]ignore-bitwidth: 64 +//@[r64bit]ignore-bitwidth: 32 //@no-rustfix #![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)] #![allow(function_casts_as_integer)] @@ -15,8 +15,8 @@ fn test_function_to_numeric_cast() { let _ = foo as i16; //~^ fn_to_numeric_cast_with_truncation let _ = foo as i32; - //~[64bit]^ fn_to_numeric_cast_with_truncation - //~[32bit]^^ fn_to_numeric_cast + //~[r64bit]^ fn_to_numeric_cast_with_truncation + //~[r32bit]^^ fn_to_numeric_cast let _ = foo as i64; //~^ fn_to_numeric_cast let _ = foo as i128; @@ -29,8 +29,8 @@ fn test_function_to_numeric_cast() { let _ = foo as u16; //~^ fn_to_numeric_cast_with_truncation let _ = foo as u32; - //~[64bit]^ fn_to_numeric_cast_with_truncation - //~[32bit]^^ fn_to_numeric_cast + //~[r64bit]^ fn_to_numeric_cast_with_truncation + //~[r32bit]^^ fn_to_numeric_cast let _ = foo as u64; //~^ fn_to_numeric_cast let _ = foo as u128; @@ -52,8 +52,8 @@ fn test_function_var_to_numeric_cast() { let _ = abc as i16; //~^ fn_to_numeric_cast_with_truncation let _ = abc as i32; - //~[64bit]^ fn_to_numeric_cast_with_truncation - //~[32bit]^^ fn_to_numeric_cast + //~[r64bit]^ fn_to_numeric_cast_with_truncation + //~[r32bit]^^ fn_to_numeric_cast let _ = abc as i64; //~^ fn_to_numeric_cast let _ = abc as i128; @@ -66,8 +66,8 @@ fn test_function_var_to_numeric_cast() { let _ = abc as u16; //~^ fn_to_numeric_cast_with_truncation let _ = abc as u32; - //~[64bit]^ fn_to_numeric_cast_with_truncation - //~[32bit]^^ fn_to_numeric_cast + //~[r64bit]^ fn_to_numeric_cast_with_truncation + //~[r32bit]^^ fn_to_numeric_cast let _ = abc as u64; //~^ fn_to_numeric_cast let _ = abc as u128; @@ -79,8 +79,8 @@ fn test_function_var_to_numeric_cast() { fn fn_with_fn_args(f: fn(i32) -> i32) -> i32 { f as i32 - //~[64bit]^ fn_to_numeric_cast_with_truncation - //~[32bit]^^ fn_to_numeric_cast + //~[r64bit]^ fn_to_numeric_cast_with_truncation + //~[r32bit]^^ fn_to_numeric_cast } fn main() {} diff --git a/src/tools/clippy/tests/ui/large_enum_variant.32bit.stderr b/src/tools/clippy/tests/ui/large_enum_variant.r32bit.stderr similarity index 100% rename from src/tools/clippy/tests/ui/large_enum_variant.32bit.stderr rename to src/tools/clippy/tests/ui/large_enum_variant.r32bit.stderr diff --git a/src/tools/clippy/tests/ui/large_enum_variant.64bit.stderr b/src/tools/clippy/tests/ui/large_enum_variant.r64bit.stderr similarity index 100% rename from src/tools/clippy/tests/ui/large_enum_variant.64bit.stderr rename to src/tools/clippy/tests/ui/large_enum_variant.r64bit.stderr diff --git a/src/tools/clippy/tests/ui/large_enum_variant.rs b/src/tools/clippy/tests/ui/large_enum_variant.rs index 9cf6318ca342b..43c19d6486269 100644 --- a/src/tools/clippy/tests/ui/large_enum_variant.rs +++ b/src/tools/clippy/tests/ui/large_enum_variant.rs @@ -1,8 +1,8 @@ -//@revisions: 32bit 64bit +//@revisions: r32bit r64bit //@aux-build:proc_macros.rs //@no-rustfix -//@[32bit]ignore-bitwidth: 64 -//@[64bit]ignore-bitwidth: 32 +//@[r32bit]ignore-bitwidth: 64 +//@[r64bit]ignore-bitwidth: 32 #![allow(dead_code)] #![allow(unused_variables)] #![warn(clippy::large_enum_variant)] @@ -221,13 +221,13 @@ mod issue11915 { } enum NoWarnings { - //~[64bit]^ large_enum_variant + //~[r64bit]^ large_enum_variant BigBoi(PublishWithBytes), _SmallBoi(u8), } enum MakesClippyAngry { - //~[64bit]^ large_enum_variant + //~[r64bit]^ large_enum_variant BigBoi(PublishWithVec), _SmallBoi(u8), } diff --git a/src/tools/run-make-support/Cargo.toml b/src/tools/run-make-support/Cargo.toml index 250e0f65a9f44..9d9cd656f5700 100644 --- a/src/tools/run-make-support/Cargo.toml +++ b/src/tools/run-make-support/Cargo.toml @@ -22,6 +22,8 @@ wasmparser = { version = "0.236", default-features = false, features = ["std", " # Shared with bootstrap and compiletest build_helper = { path = "../../build_helper" } +# Shared with rustdoc +rustdoc-json-types = { path = "../../rustdoc-json-types" } [lib] crate-type = ["lib", "dylib"] diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index fef75401d9456..5253dc04a93e2 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -34,7 +34,7 @@ pub mod rfs { } // Re-exports of third-party library crates. -pub use {bstr, gimli, libc, object, regex, serde_json, similar, wasmparser}; +pub use {bstr, gimli, libc, object, regex, rustdoc_json_types, serde_json, similar, wasmparser}; // Helpers for building names of output artifacts that are potentially target-specific. pub use crate::artifact_names::{ diff --git a/tests/codegen-llvm/cf-protection.rs b/tests/codegen-llvm/cf-protection.rs index c9e9d3433f1f7..a1c902755afbc 100644 --- a/tests/codegen-llvm/cf-protection.rs +++ b/tests/codegen-llvm/cf-protection.rs @@ -1,12 +1,12 @@ // Test that the correct module flags are emitted with different control-flow protection flags. //@ add-minicore -//@ revisions: undefined none branch return full +//@ revisions: undefined none branch return_ full //@ needs-llvm-components: x86 // [undefined] no extra compile-flags //@ [none] compile-flags: -Z cf-protection=none //@ [branch] compile-flags: -Z cf-protection=branch -//@ [return] compile-flags: -Z cf-protection=return +//@ [return_] compile-flags: -Z cf-protection=return //@ [full] compile-flags: -Z cf-protection=full //@ compile-flags: --target x86_64-unknown-linux-gnu @@ -30,9 +30,9 @@ pub fn test() {} // branch: !"cf-protection-branch", i32 1 // branch-NOT: !"cf-protection-return" -// return-NOT: !"cf-protection-branch" -// return: !"cf-protection-return", i32 1 -// return-NOT: !"cf-protection-branch" +// return_-NOT: !"cf-protection-branch" +// return_: !"cf-protection-return", i32 1 +// return_-NOT: !"cf-protection-branch" // full: !"cf-protection-branch", i32 1 // full: !"cf-protection-return", i32 1 diff --git a/tests/run-make/rustdoc-json-external-crate-path/dep.rs b/tests/run-make/rustdoc-json-external-crate-path/dep.rs new file mode 100644 index 0000000000000..25c5dcac9f755 --- /dev/null +++ b/tests/run-make/rustdoc-json-external-crate-path/dep.rs @@ -0,0 +1,5 @@ +#![no_std] + +pub struct S; + +pub use trans_dep::S as TransDep; diff --git a/tests/run-make/rustdoc-json-external-crate-path/entry.rs b/tests/run-make/rustdoc-json-external-crate-path/entry.rs new file mode 100644 index 0000000000000..5e0d8610e7ad6 --- /dev/null +++ b/tests/run-make/rustdoc-json-external-crate-path/entry.rs @@ -0,0 +1,4 @@ +#![no_std] + +pub type FromDep = dep::S; +pub type FromTransDep = dep::TransDep; diff --git a/tests/run-make/rustdoc-json-external-crate-path/rmake.rs b/tests/run-make/rustdoc-json-external-crate-path/rmake.rs new file mode 100644 index 0000000000000..40790e56cab51 --- /dev/null +++ b/tests/run-make/rustdoc-json-external-crate-path/rmake.rs @@ -0,0 +1,89 @@ +use std::path; + +use run_make_support::rustdoc_json_types::{Crate, ItemEnum, Path, Type, TypeAlias}; +use run_make_support::{cwd, rfs, rust_lib_name, rustc, rustdoc, serde_json}; + +#[track_caller] +fn canonicalize(p: &path::Path) -> path::PathBuf { + std::fs::canonicalize(p).expect("path should be canonicalizeable") +} + +fn main() { + rustc().input("trans_dep.rs").edition("2024").crate_type("lib").run(); + + rustc() + .input("dep.rs") + .edition("2024") + .crate_type("lib") + .extern_("trans_dep", rust_lib_name("trans_dep")) + .run(); + + rustdoc() + .input("entry.rs") + .edition("2024") + .output_format("json") + .library_search_path(cwd()) + .extern_("dep", rust_lib_name("dep")) + .arg("-Zunstable-options") + .run(); + + let bytes = rfs::read("doc/entry.json"); + + let krate: Crate = serde_json::from_slice(&bytes).expect("output should be valid json"); + + let root_item = &krate.index[&krate.root]; + let ItemEnum::Module(root_mod) = &root_item.inner else { panic!("expected ItemEnum::Module") }; + + assert_eq!(root_mod.items.len(), 2); + + let items = root_mod.items.iter().map(|id| &krate.index[id]).collect::>(); + + let from_dep = items + .iter() + .filter(|item| item.name.as_deref() == Some("FromDep")) + .next() + .expect("there should be en item called FromDep"); + + let from_trans_dep = items + .iter() + .filter(|item| item.name.as_deref() == Some("FromTransDep")) + .next() + .expect("there should be en item called FromDep"); + + let ItemEnum::TypeAlias(TypeAlias { + type_: Type::ResolvedPath(Path { id: from_dep_id, .. }), + .. + }) = &from_dep.inner + else { + panic!("Expected FromDep to be a TypeAlias"); + }; + + let ItemEnum::TypeAlias(TypeAlias { + type_: Type::ResolvedPath(Path { id: from_trans_dep_id, .. }), + .. + }) = &from_trans_dep.inner + else { + panic!("Expected FromDep to be a TypeAlias"); + }; + + assert_eq!(krate.index.get(from_dep_id), None); + assert_eq!(krate.index.get(from_trans_dep_id), None); + + let from_dep_externalinfo = &krate.paths[from_dep_id]; + let from_trans_dep_externalinfo = &krate.paths[from_trans_dep_id]; + + let dep_crate_id = from_dep_externalinfo.crate_id; + let trans_dep_crate_id = from_trans_dep_externalinfo.crate_id; + + let dep = &krate.external_crates[&dep_crate_id]; + let trans_dep = &krate.external_crates[&trans_dep_crate_id]; + + assert_eq!(dep.name, "dep"); + assert_eq!(trans_dep.name, "trans_dep"); + + assert_eq!(canonicalize(&dep.path), canonicalize(&cwd().join(rust_lib_name("dep")))); + assert_eq!( + canonicalize(&trans_dep.path), + canonicalize(&cwd().join(rust_lib_name("trans_dep"))) + ); +} diff --git a/tests/run-make/rustdoc-json-external-crate-path/trans_dep.rs b/tests/run-make/rustdoc-json-external-crate-path/trans_dep.rs new file mode 100644 index 0000000000000..8f185393a7c3a --- /dev/null +++ b/tests/run-make/rustdoc-json-external-crate-path/trans_dep.rs @@ -0,0 +1,3 @@ +#![no_std] + +pub struct S; diff --git a/tests/ui/cfg/cmdline-false.rs b/tests/ui/cfg/cmdline-false.rs index d4b7d3bbfdca2..917679e2e424b 100644 --- a/tests/ui/cfg/cmdline-false.rs +++ b/tests/ui/cfg/cmdline-false.rs @@ -1,5 +1,5 @@ /// Test that `--cfg false` doesn't cause `cfg(false)` to evaluate to `true` -//@ compile-flags: --cfg false +//@ compile-flags: --cfg r#false #[cfg(false)] fn foo() {} diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_crate.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_crate.stderr new file mode 100644 index 0000000000000..daaddd3074160 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_crate.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `crate` (malformed `cfg` input, expected a valid identifier) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_priv.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_priv.stderr new file mode 100644 index 0000000000000..5fd341485cd99 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_priv.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `priv` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_crate.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_crate.stderr new file mode 100644 index 0000000000000..a5f8b25fe4272 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_crate.stderr @@ -0,0 +1,6 @@ +error: `crate` cannot be a raw identifier + | + = note: this occurred on the command line: `--cfg=r#crate` + +error: invalid `--cfg` argument: `r#crate` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_lower.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_lower.stderr new file mode 100644 index 0000000000000..25dbaa36dbec0 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_lower.stderr @@ -0,0 +1,6 @@ +error: `self` cannot be a raw identifier + | + = note: this occurred on the command line: `--cfg=r#self` + +error: invalid `--cfg` argument: `r#self` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_upper.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_upper.stderr new file mode 100644 index 0000000000000..04341926143a5 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_upper.stderr @@ -0,0 +1,6 @@ +error: `Self` cannot be a raw identifier + | + = note: this occurred on the command line: `--cfg=r#Self` + +error: invalid `--cfg` argument: `r#Self` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_super.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_super.stderr new file mode 100644 index 0000000000000..9c70442394cac --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_super.stderr @@ -0,0 +1,6 @@ +error: `super` cannot be a raw identifier + | + = note: this occurred on the command line: `--cfg=r#super` + +error: invalid `--cfg` argument: `r#super` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_underscore.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_underscore.stderr new file mode 100644 index 0000000000000..144f6a1349896 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_underscore.stderr @@ -0,0 +1,6 @@ +error: `_` cannot be a raw identifier + | + = note: this occurred on the command line: `--cfg=r#_` + +error: invalid `--cfg` argument: `r#_` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_lower.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_lower.stderr new file mode 100644 index 0000000000000..9d7897c48ef46 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_lower.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `self` (malformed `cfg` input, expected a valid identifier) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_upper.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_upper.stderr new file mode 100644 index 0000000000000..16c91198eea79 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_upper.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `Self` (malformed `cfg` input, expected a valid identifier) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_struct.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_struct.stderr new file mode 100644 index 0000000000000..5ee3f35ae0cfe --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_struct.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `struct` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_super.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_super.stderr new file mode 100644 index 0000000000000..08513ac466cb7 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_super.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `super` (malformed `cfg` input, expected a valid identifier) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_underscore.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_underscore.stderr new file mode 100644 index 0000000000000..4dfb3f8276469 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_underscore.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `_` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.rs b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.rs new file mode 100644 index 0000000000000..b50b8216ca47b --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.rs @@ -0,0 +1,24 @@ +//@ edition: 2024 + +//@ revisions: cfg_crate cfg_super cfg_self_lower cfg_self_upper +//@ revisions: cfg_raw_crate cfg_raw_super cfg_raw_self_lower cfg_raw_self_upper +//@ revisions: cfg_struct cfg_priv cfg_underscore cfg_raw_underscore + +//@ [cfg_crate]compile-flags: --cfg crate +//@ [cfg_super]compile-flags: --cfg super +//@ [cfg_self_lower]compile-flags: --cfg self +//@ [cfg_self_upper]compile-flags: --cfg Self + +//@ [cfg_raw_crate]compile-flags: --cfg r#crate +//@ [cfg_raw_super]compile-flags: --cfg r#super +//@ [cfg_raw_self_lower]compile-flags: --cfg r#self +//@ [cfg_raw_self_upper]compile-flags: --cfg r#Self + +//@ [cfg_struct]compile-flags: --cfg struct +//@ [cfg_priv]compile-flags: --cfg priv +//@ [cfg_underscore]compile-flags: --cfg _ +//@ [cfg_raw_underscore]compile-flags: --cfg r#_ + +fn main() {} + +//~? ERROR invalid `--cfg` argument diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_crate.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_crate.stderr new file mode 100644 index 0000000000000..69f06cf5e216c --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_crate.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(crate)` + | + = note: malformed `cfg` input, expected a valid identifier + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_priv.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_priv.stderr new file mode 100644 index 0000000000000..2165d37500a91 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_priv.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(priv)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_crate.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_crate.stderr new file mode 100644 index 0000000000000..f440c07779da0 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_crate.stderr @@ -0,0 +1,9 @@ +error: `crate` cannot be a raw identifier + | + = note: this occurred on the command line: `--check-cfg=cfg(r#crate)` + +error: invalid `--check-cfg` argument: `cfg(r#crate)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_lower.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_lower.stderr new file mode 100644 index 0000000000000..bccc694084e3b --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_lower.stderr @@ -0,0 +1,9 @@ +error: `self` cannot be a raw identifier + | + = note: this occurred on the command line: `--check-cfg=cfg(r#self)` + +error: invalid `--check-cfg` argument: `cfg(r#self)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_upper.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_upper.stderr new file mode 100644 index 0000000000000..68c149a01fb50 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_upper.stderr @@ -0,0 +1,9 @@ +error: `Self` cannot be a raw identifier + | + = note: this occurred on the command line: `--check-cfg=cfg(r#Self)` + +error: invalid `--check-cfg` argument: `cfg(r#Self)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_super.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_super.stderr new file mode 100644 index 0000000000000..b3ef744226207 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_super.stderr @@ -0,0 +1,9 @@ +error: `super` cannot be a raw identifier + | + = note: this occurred on the command line: `--check-cfg=cfg(r#super)` + +error: invalid `--check-cfg` argument: `cfg(r#super)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_underscore.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_underscore.stderr new file mode 100644 index 0000000000000..c05536b4185e1 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_underscore.stderr @@ -0,0 +1,9 @@ +error: `_` cannot be a raw identifier + | + = note: this occurred on the command line: `--check-cfg=cfg(r#_)` + +error: invalid `--check-cfg` argument: `cfg(r#_)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_lower.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_lower.stderr new file mode 100644 index 0000000000000..b109650d116d4 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_lower.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(self)` + | + = note: malformed `cfg` input, expected a valid identifier + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_upper.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_upper.stderr new file mode 100644 index 0000000000000..649cde33e159a --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_upper.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(Self)` + | + = note: malformed `cfg` input, expected a valid identifier + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_struct.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_struct.stderr new file mode 100644 index 0000000000000..40942a955bf92 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_struct.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(struct)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_super.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_super.stderr new file mode 100644 index 0000000000000..488d2982e7b80 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_super.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(super)` + | + = note: malformed `cfg` input, expected a valid identifier + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_underscore.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_underscore.stderr new file mode 100644 index 0000000000000..98a645f039a51 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_underscore.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(_)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.rs b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.rs new file mode 100644 index 0000000000000..57ec3f3d54bd4 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.rs @@ -0,0 +1,25 @@ +//@ edition: 2021 + +//@ revisions: check_cfg_crate check_cfg_super check_cfg_self_lower check_cfg_self_upper +//@ revisions: check_cfg_raw_crate check_cfg_raw_super check_cfg_raw_self_lower +//@ revisions: check_cfg_raw_self_upper +//@ revisions: check_cfg_struct check_cfg_priv check_cfg_underscore check_cfg_raw_underscore + +//@ [check_cfg_crate]compile-flags: --check-cfg 'cfg(crate)' +//@ [check_cfg_super]compile-flags: --check-cfg 'cfg(super)' +//@ [check_cfg_self_lower]compile-flags: --check-cfg 'cfg(self)' +//@ [check_cfg_self_upper]compile-flags: --check-cfg 'cfg(Self)' + +//@ [check_cfg_raw_crate]compile-flags: --check-cfg 'cfg(r#crate)' +//@ [check_cfg_raw_super]compile-flags: --check-cfg 'cfg(r#super)' +//@ [check_cfg_raw_self_lower]compile-flags: --check-cfg 'cfg(r#self)' +//@ [check_cfg_raw_self_upper]compile-flags: --check-cfg 'cfg(r#Self)' + +//@ [check_cfg_struct]compile-flags: --check-cfg 'cfg(struct)' +//@ [check_cfg_priv]compile-flags: --check-cfg 'cfg(priv)' +//@ [check_cfg_underscore]compile-flags: --check-cfg 'cfg(_)' +//@ [check_cfg_raw_underscore]compile-flags: --check-cfg 'cfg(r#_)' + +fn main() {} + +//~? ERROR invalid `--check-cfg` argument diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-raw-allow.rs b/tests/ui/cfg/path-kw-as-cfg-pred-cli-raw-allow.rs new file mode 100644 index 0000000000000..2f603baf28bd3 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-raw-allow.rs @@ -0,0 +1,6 @@ +//@ edition: 2024 +//@ check-pass +//@ compile-flags: --cfg r#struct --cfg r#priv +//@ compile-flags: --check-cfg 'cfg(r#struct)' --check-cfg 'cfg(r#priv)' + +fn main() {} diff --git a/tests/ui/cfg/path-kw-as-cfg-pred.rs b/tests/ui/cfg/path-kw-as-cfg-pred.rs new file mode 100644 index 0000000000000..d3b419175163f --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred.rs @@ -0,0 +1,129 @@ +//@ edition: 2024 + +#![allow(unexpected_cfgs)] + +macro_rules! foo { + () => { + #[cfg($crate)] //~ ERROR malformed `cfg` attribute input + mod _cfg_dollar_crate {} + #[cfg_attr($crate, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input + mod _cfg_attr_dollar_crate {} + #[cfg_attr(true, cfg($crate))] //~ ERROR malformed `cfg` attribute input + mod _cfg_attr_true_cfg_crate {} + + cfg!($crate); //~ ERROR malformed `cfg` macro input + }; +} + +#[cfg(crate)] //~ ERROR malformed `cfg` attribute input +mod _cfg_crate {} +#[cfg(super)] //~ ERROR malformed `cfg` attribute input +mod _cfg_super {} +#[cfg(self)] //~ ERROR malformed `cfg` attribute input +mod _cfg_self_lower {} +#[cfg(Self)] //~ ERROR malformed `cfg` attribute input +mod _cfg_self_upper {} +#[cfg_attr(crate, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input +mod _cfg_attr_crate {} +#[cfg_attr(super, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input +mod _cfg_attr_super {} +#[cfg_attr(self, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input +mod _cfg_attr_self_lower {} +#[cfg_attr(Self, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input +mod _cfg_attr_self_upper {} +#[cfg_attr(true, cfg(crate))] //~ ERROR malformed `cfg` attribute input +mod _cfg_attr_true_cfg_crate {} +#[cfg_attr(true, cfg(super))] //~ ERROR malformed `cfg` attribute input +mod _cfg_attr_true_cfg_super {} +#[cfg_attr(true, cfg(self))] //~ ERROR malformed `cfg` attribute input +mod _cfg_attr_true_cfg_self_lower {} +#[cfg_attr(true, cfg(Self))] //~ ERROR malformed `cfg` attribute input +mod _cfg_attr_true_cfg_self_upper {} + +#[cfg(struct)] //~ ERROR expected identifier, found keyword +mod _cfg_struct {} +#[cfg(priv)] //~ ERROR expected identifier, found reserved keyword `priv` +mod _cfg_priv {} +#[cfg(_)] //~ ERROR expected identifier, found reserved identifier `_` +mod _cfg_underscore {} +#[cfg_attr(struct, path = "foo")] //~ ERROR expected identifier, found keyword +mod _cfg_attr_struct {} +#[cfg_attr(priv, path = "foo")] //~ ERROR expected identifier, found reserved keyword `priv` +mod _cfg_attr_priv {} +#[cfg_attr(_, path = "foo")] //~ ERROR expected identifier, found reserved identifier `_` +mod _cfg_attr_underscore {} +#[cfg_attr(true, cfg(struct))] //~ ERROR expected identifier, found keyword +mod _cfg_attr_true_cfg_struct {} +#[cfg_attr(true, cfg(priv))] //~ ERROR expected identifier, found reserved keyword `priv` +mod _cfg_attr_true_cfg_priv {} +#[cfg_attr(true, cfg(_))] //~ ERROR expected identifier, found reserved identifier `_` +mod _cfg_attr_true_cfg_underscore {} + +fn main() { + foo!(); + + cfg!(crate); //~ ERROR malformed `cfg` macro input + cfg!(super); //~ ERROR malformed `cfg` macro input + cfg!(self); //~ ERROR malformed `cfg` macro input + cfg!(Self); //~ ERROR malformed `cfg` macro input + + cfg!(r#crate); //~ ERROR `crate` cannot be a raw identifier + //~^ ERROR malformed `cfg` macro input + cfg!(r#super); //~ ERROR `super` cannot be a raw identifier + //~^ ERROR malformed `cfg` macro input + cfg!(r#self); //~ ERROR `self` cannot be a raw identifier + //~^ ERROR malformed `cfg` macro input + cfg!(r#Self); //~ ERROR `Self` cannot be a raw identifier + //~^ ERROR malformed `cfg` macro input + + cfg!(struct); //~ ERROR expected identifier, found keyword + cfg!(priv); //~ ERROR expected identifier, found reserved keyword `priv` + cfg!(_); //~ ERROR expected identifier, found reserved identifier `_` + + cfg!(r#struct); // Ok + cfg!(r#priv); // Ok + cfg!(r#_); //~ ERROR `_` cannot be a raw identifier +} + +#[cfg(r#crate)] //~ ERROR malformed `cfg` attribute input +//~^ ERROR `crate` cannot be a raw identifier +mod _cfg_r_crate {} +#[cfg(r#super)] //~ ERROR malformed `cfg` attribute input +//~^ ERROR `super` cannot be a raw identifier +mod _cfg_r_super {} +#[cfg(r#self)] //~ ERROR malformed `cfg` attribute input +//~^ ERROR `self` cannot be a raw identifier +mod _cfg_r_self_lower {} +#[cfg(r#Self)] //~ ERROR malformed `cfg` attribute input +//~^ ERROR `Self` cannot be a raw identifier +mod _cfg_r_self_upper {} +#[cfg_attr(r#crate, cfg(r#crate))] //~ ERROR malformed `cfg_attr` attribute input +//~^ ERROR `crate` cannot be a raw identifier +//~^^ ERROR `crate` cannot be a raw identifier +mod _cfg_attr_r_crate {} +#[cfg_attr(r#super, cfg(r#super))] //~ ERROR malformed `cfg_attr` attribute input +//~^ ERROR `super` cannot be a raw identifier +//~^^ ERROR `super` cannot be a raw identifier +mod _cfg_attr_r_super {} +#[cfg_attr(r#self, cfg(r#self))] //~ ERROR malformed `cfg_attr` attribute input +//~^ ERROR `self` cannot be a raw identifier +//~^^ ERROR `self` cannot be a raw identifier +mod _cfg_attr_r_self_lower {} +#[cfg_attr(r#Self, cfg(r#Self))] //~ ERROR malformed `cfg_attr` attribute input +//~^ ERROR `Self` cannot be a raw identifier +//~^^ ERROR `Self` cannot be a raw identifier +mod _cfg_attr_r_self_upper {} + +#[cfg(r#struct)] // Ok +mod _cfg_r_struct {} +#[cfg(r#priv)] // Ok +mod _cfg_r_priv {} +#[cfg(r#_)] //~ ERROR `_` cannot be a raw identifier +mod _cfg_r_underscore {} +#[cfg_attr(r#struct, cfg(r#struct))] // Ok +mod _cfg_attr_r_struct {} +#[cfg_attr(r#priv, cfg(r#priv))] // Ok +mod _cfg_attr_r_priv {} +#[cfg_attr(r#_, cfg(r#_))] //~ ERROR `_` cannot be a raw identifier +//~^ ERROR `_` cannot be a raw identifier +mod _cfg_attr_r_underscore {} diff --git a/tests/ui/cfg/path-kw-as-cfg-pred.stderr b/tests/ui/cfg/path-kw-as-cfg-pred.stderr new file mode 100644 index 0000000000000..f0bc0b67b9339 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred.stderr @@ -0,0 +1,573 @@ +error: `crate` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:70:10 + | +LL | cfg!(r#crate); + | ^^^^^^^ + +error: `super` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:72:10 + | +LL | cfg!(r#super); + | ^^^^^^^ + +error: `self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:74:10 + | +LL | cfg!(r#self); + | ^^^^^^ + +error: `Self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:76:10 + | +LL | cfg!(r#Self); + | ^^^^^^ + +error: `_` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:85:10 + | +LL | cfg!(r#_); + | ^^^ + +error: `crate` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:88:7 + | +LL | #[cfg(r#crate)] + | ^^^^^^^ + +error: `super` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:91:7 + | +LL | #[cfg(r#super)] + | ^^^^^^^ + +error: `self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:94:7 + | +LL | #[cfg(r#self)] + | ^^^^^^ + +error: `Self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:97:7 + | +LL | #[cfg(r#Self)] + | ^^^^^^ + +error: `crate` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:100:12 + | +LL | #[cfg_attr(r#crate, cfg(r#crate))] + | ^^^^^^^ + +error: `crate` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:100:25 + | +LL | #[cfg_attr(r#crate, cfg(r#crate))] + | ^^^^^^^ + +error: `super` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:104:12 + | +LL | #[cfg_attr(r#super, cfg(r#super))] + | ^^^^^^^ + +error: `super` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:104:25 + | +LL | #[cfg_attr(r#super, cfg(r#super))] + | ^^^^^^^ + +error: `self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:108:12 + | +LL | #[cfg_attr(r#self, cfg(r#self))] + | ^^^^^^ + +error: `self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:108:24 + | +LL | #[cfg_attr(r#self, cfg(r#self))] + | ^^^^^^ + +error: `Self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:112:12 + | +LL | #[cfg_attr(r#Self, cfg(r#Self))] + | ^^^^^^ + +error: `Self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:112:24 + | +LL | #[cfg_attr(r#Self, cfg(r#Self))] + | ^^^^^^ + +error: `_` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:121:7 + | +LL | #[cfg(r#_)] + | ^^^ + +error: `_` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:127:12 + | +LL | #[cfg_attr(r#_, cfg(r#_))] + | ^^^ + +error: `_` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:127:21 + | +LL | #[cfg_attr(r#_, cfg(r#_))] + | ^^^ + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:18:1 + | +LL | #[cfg(crate)] + | ^^^^^^-----^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:20:1 + | +LL | #[cfg(super)] + | ^^^^^^-----^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:22:1 + | +LL | #[cfg(self)] + | ^^^^^^----^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:24:1 + | +LL | #[cfg(Self)] + | ^^^^^^----^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:26:1 + | +LL | #[cfg_attr(crate, path = "foo")] + | ^^^^^^^^^^^-----^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:28:1 + | +LL | #[cfg_attr(super, path = "foo")] + | ^^^^^^^^^^^-----^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:30:1 + | +LL | #[cfg_attr(self, path = "foo")] + | ^^^^^^^^^^^----^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:32:1 + | +LL | #[cfg_attr(Self, path = "foo")] + | ^^^^^^^^^^^----^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:34:18 + | +LL | #[cfg_attr(true, cfg(crate))] + | ^^^^-----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:36:18 + | +LL | #[cfg_attr(true, cfg(super))] + | ^^^^-----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:38:18 + | +LL | #[cfg_attr(true, cfg(self))] + | ^^^^----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:40:18 + | +LL | #[cfg_attr(true, cfg(Self))] + | ^^^^----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg(predicate)` + | + = note: for more information, visit + +error: expected identifier, found keyword `struct` + --> $DIR/path-kw-as-cfg-pred.rs:43:7 + | +LL | #[cfg(struct)] + | ^^^^^^ expected identifier, found keyword + +error: expected identifier, found reserved keyword `priv` + --> $DIR/path-kw-as-cfg-pred.rs:45:7 + | +LL | #[cfg(priv)] + | ^^^^ expected identifier, found reserved keyword + +error: expected identifier, found reserved identifier `_` + --> $DIR/path-kw-as-cfg-pred.rs:47:7 + | +LL | #[cfg(_)] + | ^ expected identifier, found reserved identifier + +error: expected identifier, found keyword `struct` + --> $DIR/path-kw-as-cfg-pred.rs:49:12 + | +LL | #[cfg_attr(struct, path = "foo")] + | ^^^^^^ expected identifier, found keyword + | +help: escape `struct` to use it as an identifier + | +LL | #[cfg_attr(r#struct, path = "foo")] + | ++ + +error: expected identifier, found reserved keyword `priv` + --> $DIR/path-kw-as-cfg-pred.rs:51:12 + | +LL | #[cfg_attr(priv, path = "foo")] + | ^^^^ expected identifier, found reserved keyword + | +help: escape `priv` to use it as an identifier + | +LL | #[cfg_attr(r#priv, path = "foo")] + | ++ + +error: expected identifier, found reserved identifier `_` + --> $DIR/path-kw-as-cfg-pred.rs:53:12 + | +LL | #[cfg_attr(_, path = "foo")] + | ^ expected identifier, found reserved identifier + +error: expected identifier, found keyword `struct` + --> $DIR/path-kw-as-cfg-pred.rs:55:22 + | +LL | #[cfg_attr(true, cfg(struct))] + | ^^^^^^ expected identifier, found keyword + +error: expected identifier, found reserved keyword `priv` + --> $DIR/path-kw-as-cfg-pred.rs:57:22 + | +LL | #[cfg_attr(true, cfg(priv))] + | ^^^^ expected identifier, found reserved keyword + +error: expected identifier, found reserved identifier `_` + --> $DIR/path-kw-as-cfg-pred.rs:59:22 + | +LL | #[cfg_attr(true, cfg(_))] + | ^ expected identifier, found reserved identifier + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:88:1 + | +LL | #[cfg(r#crate)] + | ^^^^^^-------^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:91:1 + | +LL | #[cfg(r#super)] + | ^^^^^^-------^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:94:1 + | +LL | #[cfg(r#self)] + | ^^^^^^------^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:97:1 + | +LL | #[cfg(r#Self)] + | ^^^^^^------^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:100:1 + | +LL | #[cfg_attr(r#crate, cfg(r#crate))] + | ^^^^^^^^^^^-------^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:104:1 + | +LL | #[cfg_attr(r#super, cfg(r#super))] + | ^^^^^^^^^^^-------^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:108:1 + | +LL | #[cfg_attr(r#self, cfg(r#self))] + | ^^^^^^^^^^^------^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:112:1 + | +LL | #[cfg_attr(r#Self, cfg(r#Self))] + | ^^^^^^^^^^^------^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:7:9 + | +LL | #[cfg($crate)] + | ^^^^^^------^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` +... +LL | foo!(); + | ------ in this macro invocation + | + = note: for more information, visit + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:9:9 + | +LL | #[cfg_attr($crate, path = "foo")] + | ^^^^^^^^^^^------^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` +... +LL | foo!(); + | ------ in this macro invocation + | + = note: for more information, visit + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:11:26 + | +LL | #[cfg_attr(true, cfg($crate))] + | ^^^^------^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg(predicate)` +... +LL | foo!(); + | ------ in this macro invocation + | + = note: for more information, visit + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:14:9 + | +LL | cfg!($crate); + | ^^^^^------^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` +... +LL | foo!(); + | ------ in this macro invocation + | + = note: for more information, visit + = note: this error originates in the macro `cfg` which comes from the expansion of the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:65:5 + | +LL | cfg!(crate); + | ^^^^^-----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:66:5 + | +LL | cfg!(super); + | ^^^^^-----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:67:5 + | +LL | cfg!(self); + | ^^^^^----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:68:5 + | +LL | cfg!(Self); + | ^^^^^----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:70:5 + | +LL | cfg!(r#crate); + | ^^^^^-------^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:72:5 + | +LL | cfg!(r#super); + | ^^^^^-------^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:74:5 + | +LL | cfg!(r#self); + | ^^^^^------^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:76:5 + | +LL | cfg!(r#Self); + | ^^^^^------^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error: expected identifier, found keyword `struct` + --> $DIR/path-kw-as-cfg-pred.rs:79:10 + | +LL | cfg!(struct); + | ^^^^^^ expected identifier, found keyword + +error: expected identifier, found reserved keyword `priv` + --> $DIR/path-kw-as-cfg-pred.rs:80:10 + | +LL | cfg!(priv); + | ^^^^ expected identifier, found reserved keyword + +error: expected identifier, found reserved identifier `_` + --> $DIR/path-kw-as-cfg-pred.rs:81:10 + | +LL | cfg!(_); + | ^ expected identifier, found reserved identifier + +error: aborting due to 64 previous errors + +For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/cfg/raw-true-false.rs b/tests/ui/cfg/raw-true-false.rs index c92672fc144e3..9f4c6c1fcd42f 100644 --- a/tests/ui/cfg/raw-true-false.rs +++ b/tests/ui/cfg/raw-true-false.rs @@ -1,9 +1,5 @@ //@ check-pass -//@ revisions: r0x0 r0x1 r1x0 r1x1 -//@[r0x0] compile-flags: --cfg false --check-cfg=cfg(false) -//@[r0x1] compile-flags: --cfg false --check-cfg=cfg(r#false) -//@[r1x0] compile-flags: --cfg r#false --check-cfg=cfg(false) -//@[r1x1] compile-flags: --cfg r#false --check-cfg=cfg(r#false) +//@ compile-flags: --cfg r#false --check-cfg=cfg(r#false) #![deny(unexpected_cfgs)] fn main() { #[cfg(not(r#false))] diff --git a/tests/ui/check-cfg/raw-keywords.rs b/tests/ui/check-cfg/raw-keywords.rs index b82eb5a64e9a1..07daf564f6d8d 100644 --- a/tests/ui/check-cfg/raw-keywords.rs +++ b/tests/ui/check-cfg/raw-keywords.rs @@ -3,7 +3,7 @@ // //@ check-pass //@ no-auto-check-cfg -//@ compile-flags: --cfg=true --cfg=async --check-cfg=cfg(r#true,r#async,edition2015,edition2021) +//@ compile-flags: --cfg=r#true --cfg=r#async --check-cfg=cfg(r#true,r#async,edition2015,edition2021) // //@ revisions: edition2015 edition2021 //@ [edition2015] edition: 2015 diff --git a/tests/ui/conditional-compilation/cfg-arg-invalid-7.rs b/tests/ui/conditional-compilation/cfg-arg-invalid-7.rs index f05adc7bf7aad..d90075da3e63c 100644 --- a/tests/ui/conditional-compilation/cfg-arg-invalid-7.rs +++ b/tests/ui/conditional-compilation/cfg-arg-invalid-7.rs @@ -3,4 +3,4 @@ //@ compile-flags: --cfg a" //~? RAW unterminated double quote string -//~? RAW this error occurred on the command line +//~? RAW this occurred on the command line diff --git a/tests/ui/conditional-compilation/cfg-arg-invalid-7.stderr b/tests/ui/conditional-compilation/cfg-arg-invalid-7.stderr index 919709c847019..833d24a907dc2 100644 --- a/tests/ui/conditional-compilation/cfg-arg-invalid-7.stderr +++ b/tests/ui/conditional-compilation/cfg-arg-invalid-7.stderr @@ -1,4 +1,4 @@ error[E0765]: unterminated double quote string | - = note: this error occurred on the command line: `--cfg=a"` + = note: this occurred on the command line: `--cfg=a"` diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr similarity index 59% rename from tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr rename to tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr index 25e30397c8322..5102f278f0273 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr @@ -10,15 +10,15 @@ note: inside `rec_id` LL | inner(0, n) | ^^^^^^^^^^^ note: [... 125 additional calls inside `inner` ...] - --> $DIR/ctfe-id-unlimited.rs:17:42 + --> $DIR/ctfe-id-unlimited.rs:17:41 | -LL | #[cfg(r#return)] _ => return inner(acc + 1, n - 1), - | ^^^^^^^^^^^^^^^^^^^^^ +LL | #[cfg(return_)] _ => return inner(acc + 1, n - 1), + | ^^^^^^^^^^^^^^^^^^^^^ note: inside `inner` - --> $DIR/ctfe-id-unlimited.rs:17:42 + --> $DIR/ctfe-id-unlimited.rs:17:41 | -LL | #[cfg(r#return)] _ => return inner(acc + 1, n - 1), - | ^^^^^^^^^^^^^^^^^^^^^ the failure occurred here +LL | #[cfg(return_)] _ => return inner(acc + 1, n - 1), + | ^^^^^^^^^^^^^^^^^^^^^ the failure occurred here error: aborting due to 1 previous error diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs index 53cccb38e2b88..0efd8967f8bd9 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs @@ -1,5 +1,5 @@ -//@ revisions: become return -//@ [become] run-pass +//@ revisions: become_ return_ +//@ [become_] run-pass #![expect(incomplete_features)] #![feature(explicit_tail_calls)] @@ -13,8 +13,8 @@ const fn rec_id(n: u32) -> u32 { const fn inner(acc: u32, n: u32) -> u32 { match n { 0 => acc, - #[cfg(r#become)] _ => become inner(acc + 1, n - 1), - #[cfg(r#return)] _ => return inner(acc + 1, n - 1), + #[cfg(become_)] _ => become inner(acc + 1, n - 1), + #[cfg(return_)] _ => return inner(acc + 1, n - 1), } } @@ -25,7 +25,7 @@ const fn rec_id(n: u32) -> u32 { const ORIGINAL: u32 = 12345; // Original number, but with identity function applied // (this is the same, but requires execution of the recursion) -const ID_ED: u32 = rec_id(ORIGINAL); //[return]~ ERROR: reached the configured maximum number of stack frames +const ID_ED: u32 = rec_id(ORIGINAL); //[return_]~ ERROR: reached the configured maximum number of stack frames // Assert to make absolutely sure the computation actually happens const ASSERT: () = assert!(ORIGINAL == ID_ED); diff --git a/tests/ui/resolve/regression-struct-called-as-function-148919.rs b/tests/ui/resolve/regression-struct-called-as-function-148919.rs new file mode 100644 index 0000000000000..7358e1716c11a --- /dev/null +++ b/tests/ui/resolve/regression-struct-called-as-function-148919.rs @@ -0,0 +1,10 @@ +struct Bar {} + +impl Bar { + fn into_self(self) -> Bar { + Bar(self) + //~^ ERROR expected function, tuple struct or tuple variant, found struct `Bar` [E0423] + } +} + +fn main() {} diff --git a/tests/ui/resolve/regression-struct-called-as-function-148919.stderr b/tests/ui/resolve/regression-struct-called-as-function-148919.stderr new file mode 100644 index 0000000000000..d3e62b3a5a987 --- /dev/null +++ b/tests/ui/resolve/regression-struct-called-as-function-148919.stderr @@ -0,0 +1,9 @@ +error[E0423]: expected function, tuple struct or tuple variant, found struct `Bar` + --> $DIR/regression-struct-called-as-function-148919.rs:5:9 + | +LL | Bar(self) + | ^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0423`. diff --git a/tests/ui/use/use-path-segment-kw.rs b/tests/ui/use/use-path-segment-kw.rs new file mode 100644 index 0000000000000..137a9e18aef30 --- /dev/null +++ b/tests/ui/use/use-path-segment-kw.rs @@ -0,0 +1,250 @@ +//@ edition: 2021 + +macro_rules! macro_dollar_crate { + () => { + use $crate::*; + use $crate::{}; + + type A1 = $crate; //~ ERROR expected type, found module `$crate` + use $crate; //~ ERROR `$crate` may not be imported + pub use $crate as _dollar_crate; //~ ERROR `$crate` may not be imported + + type A2 = ::$crate; //~ ERROR failed to resolve: global paths cannot start with `$crate` + use ::$crate; //~ ERROR unresolved import `$crate` + use ::$crate as _dollar_crate2; //~ ERROR unresolved import `$crate` + use ::{$crate}; //~ ERROR unresolved import `$crate` + use ::{$crate as _nested_dollar_crate2}; //~ ERROR unresolved import `$crate` + + type A3 = foobar::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position + use foobar::$crate; //~ ERROR unresolved import `foobar::$crate` + use foobar::$crate as _dollar_crate3; //~ ERROR unresolved import `foobar::$crate` + use foobar::{$crate}; //~ ERROR unresolved import `foobar::$crate` + use foobar::{$crate as _nested_dollar_crate3}; //~ ERROR unresolved import `foobar::$crate` + + type A4 = crate::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position + use crate::$crate; //~ ERROR unresolved import `crate::$crate` + use crate::$crate as _dollar_crate4; //~ ERROR unresolved import `crate::$crate` + use crate::{$crate}; //~ ERROR unresolved import `crate::$crate` + use crate::{$crate as _nested_dollar_crate4}; //~ ERROR unresolved import `crate::$crate` + + type A5 = super::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position + use super::$crate; //~ ERROR unresolved import `super::$crate` + use super::$crate as _dollar_crate5; //~ ERROR unresolved import `super::$crate` + use super::{$crate}; //~ ERROR unresolved import `super::$crate` + use super::{$crate as _nested_dollar_crate5}; //~ ERROR unresolved import `super::$crate` + + type A6 = self::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position + use self::$crate; + use self::$crate as _dollar_crate6; + use self::{$crate}; + use self::{$crate as _nested_dollar_crate6}; + + type A7 = $crate::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position + use $crate::$crate; //~ ERROR unresolved import `$crate::$crate` + use $crate::$crate as _dollar_crate7; //~ ERROR unresolved import `$crate::$crate` + use $crate::{$crate}; //~ ERROR unresolved import `$crate::$crate` + use $crate::{$crate as _nested_dollar_crate7}; //~ ERROR unresolved import `$crate::$crate` + + type A8 = $crate::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position + use $crate::crate; //~ ERROR unresolved import `$crate::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use $crate::crate as _m_crate8; //~ ERROR unresolved import `$crate::crate` + use $crate::{crate}; //~ ERROR unresolved import `$crate::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use $crate::{crate as _m_nested_crate8}; //~ ERROR unresolved import `$crate::crate` + + type A9 = $crate::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position + use $crate::super; //~ ERROR unresolved import `$crate::super` + use $crate::super as _m_super8; //~ ERROR unresolved import `$crate::super` + use $crate::{super}; //~ ERROR unresolved import `$crate::super` + use $crate::{super as _m_nested_super8}; //~ ERROR unresolved import `$crate::super` + + type A10 = $crate::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position + use $crate::self; //~ ERROR `$crate` may not be imported + //~^ ERROR `self` imports are only allowed within a { } list + //~^^ ERROR the name `` is defined multiple times + pub use $crate::self as _m_self8; //~ ERROR `self` imports are only allowed within a { } list + //~^ ERROR `$crate` may not be imported + use $crate::{self}; + //~^ ERROR the name `$crate` is defined multiple times + pub use $crate::{self as _m_nested_self8}; // Good + } +} + +fn outer() {} + +mod foo { + pub mod bar { + pub mod foobar { + pub mod qux { + pub use super::inner; + } + + pub mod baz { + pub use super::inner; + } + + pub fn inner() {} + } + + // --- $crate --- + macro_dollar_crate!(); + + // --- crate --- + use crate::*; + use crate::{}; + + type B1 = crate; //~ ERROR expected type, found module `crate` + use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + pub use crate as _crate; // Good + + type B2 = ::crate; //~ ERROR failed to resolve: global paths cannot start with `crate` + use ::crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR unresolved import `crate` + use ::crate as _crate2; //~ ERROR unresolved import `crate` + use ::{crate}; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR unresolved import `crate` + use ::{crate as _nested_crate2}; //~ ERROR unresolved import `crate` + + type B3 = foobar::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position + use foobar::crate; //~ ERROR unresolved import `foobar::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use foobar::crate as _crate3; //~ ERROR unresolved import `foobar::crate` + use foobar::{crate}; //~ ERROR unresolved import `foobar::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use foobar::{crate as _nested_crate3}; //~ ERROR unresolved import `foobar::crate` + + type B4 = crate::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position + use crate::crate; //~ ERROR unresolved import `crate::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use crate::crate as _crate4; //~ ERROR unresolved import `crate::crate` + use crate::{crate}; //~ ERROR unresolved import `crate::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use crate::{crate as _nested_crate4}; //~ ERROR unresolved import `crate::crate` + + type B5 = super::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position + use super::crate; //~ ERROR unresolved import `super::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use super::crate as _crate5; //~ ERROR unresolved import `super::crate` + use super::{crate}; //~ ERROR unresolved import `super::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use super::{crate as _nested_crate5}; //~ ERROR unresolved import `super::crate` + + type B6 = self::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position + use self::crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR the name `crate` is defined multiple times + use self::crate as _crate6; + use self::{crate}; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR the name `crate` is defined multiple times + use self::{crate as _nested_crate6}; + + // --- super --- + use super::*; + use super::{}; //~ ERROR unresolved import `super` + + type C1 = super; //~ ERROR expected type, found module `super` + use super; //~ ERROR unresolved import `super` + pub use super as _super; //~ ERROR unresolved import `super` + + type C2 = ::super; //~ ERROR failed to resolve: global paths cannot start with `super` + use ::super; //~ ERROR unresolved import `super` + use ::super as _super2; //~ ERROR unresolved import `super` + use ::{super}; //~ ERROR unresolved import `super` + use ::{super as _nested_super2}; //~ ERROR unresolved import `super` + + type C3 = foobar::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position + use foobar::super; //~ ERROR unresolved import `foobar::super` + use foobar::super as _super3; //~ ERROR unresolved import `foobar::super` + use foobar::{super}; //~ ERROR unresolved import `foobar::super` + use foobar::{super as _nested_super3}; //~ ERROR unresolved import `foobar::super` + + type C4 = crate::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position + use crate::super; //~ ERROR unresolved import `crate::super` + use crate::super as _super4; //~ ERROR unresolved import `crate::super` + use crate::{super}; //~ ERROR unresolved import `crate::super` + use crate::{super as _nested_super4}; //~ ERROR unresolved import `crate::super` + + type C5 = super::super; //~ ERROR expected type, found module `super::super` + use super::super; //~ ERROR unresolved import `super::super` + pub use super::super as _super5; //~ ERROR unresolved import `super::super` + use super::{super}; //~ ERROR unresolved import `super::super` + pub use super::{super as _nested_super5}; //~ ERROR unresolved import `super::super` + + type C6 = self::super; //~ ERROR expected type, found module `self::super` + use self::super; + use self::super as _super6; + use self::{super}; + use self::{super as _nested_super6}; + + // --- self --- + // use self::*; // Suppress other errors + use self::{}; //~ ERROR unresolved import `self` + + type D1 = self; //~ ERROR expected type, found module `self` + use self; //~ ERROR `self` imports are only allowed within a { } list + pub use self as _self; //~ ERROR `self` imports are only allowed within a { } list + + type D2 = ::self; //~ ERROR failed to resolve: global paths cannot start with `self` + use ::self; //~ ERROR `self` imports are only allowed within a { } list + //~^ ERROR unresolved import `{{root}}` + use ::self as _self2; //~ ERROR `self` imports are only allowed within a { } list + //~^ ERROR unresolved import `{{root}}` + use ::{self}; //~ ERROR `self` import can only appear in an import list with a non-empty prefix + use ::{self as _nested_self2}; //~ ERROR `self` import can only appear in an import list with a non-empty prefix + + type D3 = foobar::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position + pub use foobar::qux::self; //~ ERROR `self` imports are only allowed within a { } list + pub use foobar::self as _self3; //~ ERROR `self` imports are only allowed within a { } list + pub use foobar::baz::{self}; // Good + pub use foobar::{self as _nested_self3}; // Good + + type D4 = crate::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position + use crate::self; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR `self` imports are only allowed within a { } list + //~^^ ERROR the name `crate` is defined multiple times + pub use crate::self as _self4; //~ ERROR `self` imports are only allowed within a { } list + use crate::{self}; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR the name `crate` is defined multiple times + pub use crate::{self as _nested_self4}; // Good + + type D5 = super::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position + use super::self; //~ ERROR unresolved import `super` + //~^ ERROR `self` imports are only allowed within a { } list + pub use super::self as _self5; //~ ERROR `self` imports are only allowed within a { } list + //~^ ERROR unresolved import `super` + use super::{self}; //~ ERROR unresolved import `super` + pub use super::{self as _nested_self5}; //~ ERROR unresolved import `super` + + type D6 = self::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position + use self::self; //~ ERROR `self` imports are only allowed within a { } list + pub use self::self as _self6; //~ ERROR `self` imports are only allowed within a { } list + use self::{self}; //~ ERROR unresolved import `self` + pub use self::{self as _nested_self6}; //~ ERROR unresolved import `self` + } +} + +fn main() { + foo::bar::_dollar_crate::outer(); + foo::bar::_m_self8::outer(); + foo::bar::_dollar_crate::foo::bar::foobar::inner(); + foo::bar::_m_self8::foo::bar::foobar::inner(); + + foo::bar::_crate::outer(); + foo::bar::_crate::foo::bar::foobar::inner(); + + foo::bar::_super::bar::foobar::inner(); + foo::bar::_super5::outer(); + foo::bar::_nested_super5::outer(); + + foo::bar::_self::foobar::inner(); + foo::bar::qux::inner(); // Works after recovery + foo::bar::baz::inner(); + foo::bar::_self3::inner(); // Works after recovery + foo::bar::_nested_self3::inner(); + foo::bar::_self4::outer(); // Works after recovery + foo::bar::_nested_self4::outer(); + foo::bar::_self5::bar::foobar::inner(); // Works after recovery + foo::bar::_nested_self5::bar::foobar::inner(); + foo::bar::_self6::foobar::inner(); // Works after recovery + foo::bar::_nested_self6::foobar::inner(); +} diff --git a/tests/ui/use/use-path-segment-kw.stderr b/tests/ui/use/use-path-segment-kw.stderr new file mode 100644 index 0000000000000..407e99059b2a3 --- /dev/null +++ b/tests/ui/use/use-path-segment-kw.stderr @@ -0,0 +1,1245 @@ +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:98:13 + | +LL | use crate; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:102:15 + | +LL | use ::crate; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:105:16 + | +LL | use ::{crate}; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:110:21 + | +LL | use foobar::crate; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:113:22 + | +LL | use foobar::{crate}; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:118:20 + | +LL | use crate::crate; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:121:21 + | +LL | use crate::{crate}; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:126:20 + | +LL | use super::crate; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:129:21 + | +LL | use super::{crate}; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:134:19 + | +LL | use self::crate; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:137:20 + | +LL | use self::{crate}; + | ^^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:184:13 + | +LL | use self; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:185:17 + | +LL | pub use self as _self; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:188:13 + | +LL | use ::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use ::self; +LL + use ; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use ::{self}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:190:13 + | +LL | use ::self as _self2; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use ::self as _self2; +LL + use as _self2; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use ::{self as _self2}; + | + + + +error[E0431]: `self` import can only appear in an import list with a non-empty prefix + --> $DIR/use-path-segment-kw.rs:192:16 + | +LL | use ::{self}; + | ^^^^ can only appear in an import list with a non-empty prefix + +error[E0431]: `self` import can only appear in an import list with a non-empty prefix + --> $DIR/use-path-segment-kw.rs:193:16 + | +LL | use ::{self as _nested_self2}; + | ^^^^^^^^^^^^^^^^^^^^^ can only appear in an import list with a non-empty prefix + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:196:28 + | +LL | pub use foobar::qux::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use foobar::qux::self; +LL + pub use foobar::qux; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use foobar::qux::{self}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:197:23 + | +LL | pub use foobar::self as _self3; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use foobar::self as _self3; +LL + pub use foobar as _self3; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use foobar::{self as _self3}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:202:18 + | +LL | use crate::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use crate::self; +LL + use crate; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use crate::{self}; + | + + + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:202:13 + | +LL | use crate::self; + | ^^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:205:22 + | +LL | pub use crate::self as _self4; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use crate::self as _self4; +LL + pub use crate as _self4; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use crate::{self as _self4}; + | + + + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:206:21 + | +LL | use crate::{self}; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:211:18 + | +LL | use super::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use super::self; +LL + use super; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use super::{self}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:213:22 + | +LL | pub use super::self as _self5; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use super::self as _self5; +LL + pub use super as _self5; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use super::{self as _self5}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:219:17 + | +LL | use self::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use self::self; +LL + use self; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use self::{self}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:220:21 + | +LL | pub use self::self as _self6; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use self::self as _self6; +LL + pub use self as _self6; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use self::{self as _self6}; + | + + + +error[E0252]: the name `crate` is defined multiple times + --> $DIR/use-path-segment-kw.rs:134:13 + | +LL | use crate; + | ----- previous import of the module `crate` here +... +LL | use self::crate; + | ^^^^^^^^^^^ `crate` reimported here + | + = note: `crate` must be defined only once in the type namespace of this module + +error[E0252]: the name `crate` is defined multiple times + --> $DIR/use-path-segment-kw.rs:137:20 + | +LL | use crate; + | ----- previous import of the module `crate` here +... +LL | use self::{crate}; + | -----------^^^^^-- + | | | + | | `crate` reimported here + | help: remove unnecessary import + | + = note: `crate` must be defined only once in the type namespace of this module + +error[E0252]: the name `crate` is defined multiple times + --> $DIR/use-path-segment-kw.rs:202:13 + | +LL | use crate; + | ----- previous import of the module `crate` here +... +LL | use crate::self; + | ^^^^^^^^^^^ `crate` reimported here + | + = note: `crate` must be defined only once in the type namespace of this module + +error[E0252]: the name `crate` is defined multiple times + --> $DIR/use-path-segment-kw.rs:206:21 + | +LL | use crate; + | ----- previous import of the module `crate` here +... +LL | use crate::{self}; + | ------------^^^^-- + | | | + | | `crate` reimported here + | help: remove unnecessary import + | + = note: `crate` must be defined only once in the type namespace of this module + +error: `$crate` may not be imported + --> $DIR/use-path-segment-kw.rs:9:9 + | +LL | use $crate; + | ^^^^^^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` may not be imported + --> $DIR/use-path-segment-kw.rs:10:9 + | +LL | pub use $crate as _dollar_crate; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:49:21 + | +LL | use $crate::crate; + | ^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:52:22 + | +LL | use $crate::{crate}; + | ^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:63:19 + | +LL | use $crate::self; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider importing the module directly + | +LL - use $crate::self; +LL + use $crate; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use $crate::{self}; + | + + + +error: `$crate` may not be imported + --> $DIR/use-path-segment-kw.rs:63:9 + | +LL | use $crate::self; + | ^^^^^^^^^^^^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:66:23 + | +LL | pub use $crate::self as _m_self8; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider importing the module directly + | +LL - pub use $crate::self as _m_self8; +LL + pub use $crate as _m_self8; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use $crate::{self as _m_self8}; + | + + + +error: `$crate` may not be imported + --> $DIR/use-path-segment-kw.rs:66:9 + | +LL | pub use $crate::self as _m_self8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0252]: the name `` is defined multiple times + --> $DIR/use-path-segment-kw.rs:63:13 + | +LL | use $crate; + | ------ previous import of the module `` here +... +LL | use $crate::self; + | ^^^^^^^^^^^^ `` reimported here +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: `` must be defined only once in the type namespace of this module + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0252]: the name `$crate` is defined multiple times + --> $DIR/use-path-segment-kw.rs:68:22 + | +LL | use self::$crate; + | ------------ previous import of the module `$crate` here +... +LL | use $crate::{self}; + | -------------^^^^-- + | | | + | | `$crate` reimported here + | help: remove unnecessary import +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: `$crate` must be defined only once in the type namespace of this module + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `crate` + --> $DIR/use-path-segment-kw.rs:102:13 + | +LL | use ::crate; + | ^^^^^^^ no `crate` in the root + +error[E0432]: unresolved import `crate` + --> $DIR/use-path-segment-kw.rs:104:13 + | +LL | use ::crate as _crate2; + | ^^^^^^^^^^^^^^^^^^ no `crate` in the root + +error[E0432]: unresolved import `crate` + --> $DIR/use-path-segment-kw.rs:105:16 + | +LL | use ::{crate}; + | ^^^^^ no `crate` in the root + +error[E0432]: unresolved import `crate` + --> $DIR/use-path-segment-kw.rs:107:16 + | +LL | use ::{crate as _nested_crate2}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root + +error[E0432]: unresolved import `foobar::crate` + --> $DIR/use-path-segment-kw.rs:110:13 + | +LL | use foobar::crate; + | ^^^^^^^^^^^^^ no `crate` in `foo::bar::foobar` + +error[E0432]: unresolved import `foobar::crate` + --> $DIR/use-path-segment-kw.rs:112:13 + | +LL | use foobar::crate as _crate3; + | ^^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo::bar::foobar` + +error[E0432]: unresolved import `foobar::crate` + --> $DIR/use-path-segment-kw.rs:113:22 + | +LL | use foobar::{crate}; + | ^^^^^ no `crate` in `foo::bar::foobar` + +error[E0432]: unresolved import `foobar::crate` + --> $DIR/use-path-segment-kw.rs:115:22 + | +LL | use foobar::{crate as _nested_crate3}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo::bar::foobar` + +error[E0432]: unresolved import `crate::crate` + --> $DIR/use-path-segment-kw.rs:118:13 + | +LL | use crate::crate; + | ^^^^^^^^^^^^ no `crate` in the root + +error[E0432]: unresolved import `crate::crate` + --> $DIR/use-path-segment-kw.rs:120:13 + | +LL | use crate::crate as _crate4; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root + +error[E0432]: unresolved import `crate::crate` + --> $DIR/use-path-segment-kw.rs:121:21 + | +LL | use crate::{crate}; + | ^^^^^ no `crate` in the root + +error[E0432]: unresolved import `crate::crate` + --> $DIR/use-path-segment-kw.rs:123:21 + | +LL | use crate::{crate as _nested_crate4}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root + +error[E0432]: unresolved import `super::crate` + --> $DIR/use-path-segment-kw.rs:126:13 + | +LL | use super::crate; + | ^^^^^^^^^^^^ no `crate` in `foo` + +error[E0432]: unresolved import `super::crate` + --> $DIR/use-path-segment-kw.rs:128:13 + | +LL | use super::crate as _crate5; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo` + +error[E0432]: unresolved import `super::crate` + --> $DIR/use-path-segment-kw.rs:129:21 + | +LL | use super::{crate}; + | ^^^^^ no `crate` in `foo` + +error[E0432]: unresolved import `super::crate` + --> $DIR/use-path-segment-kw.rs:131:21 + | +LL | use super::{crate as _nested_crate5}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo` + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:143:13 + | +LL | use super::{}; + | ^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:146:13 + | +LL | use super; + | ^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:147:17 + | +LL | pub use super as _super; + | ^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:150:13 + | +LL | use ::super; + | ^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:151:13 + | +LL | use ::super as _super2; + | ^^^^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:152:16 + | +LL | use ::{super}; + | ^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:153:16 + | +LL | use ::{super as _nested_super2}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `foobar::super` + --> $DIR/use-path-segment-kw.rs:156:13 + | +LL | use foobar::super; + | ^^^^^^^^^^^^^ no `super` in `foo::bar::foobar` + +error[E0432]: unresolved import `foobar::super` + --> $DIR/use-path-segment-kw.rs:157:13 + | +LL | use foobar::super as _super3; + | ^^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo::bar::foobar` + +error[E0432]: unresolved import `foobar::super` + --> $DIR/use-path-segment-kw.rs:158:22 + | +LL | use foobar::{super}; + | ^^^^^ no `super` in `foo::bar::foobar` + +error[E0432]: unresolved import `foobar::super` + --> $DIR/use-path-segment-kw.rs:159:22 + | +LL | use foobar::{super as _nested_super3}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo::bar::foobar` + +error[E0432]: unresolved import `crate::super` + --> $DIR/use-path-segment-kw.rs:162:13 + | +LL | use crate::super; + | ^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `crate::super` + --> $DIR/use-path-segment-kw.rs:163:13 + | +LL | use crate::super as _super4; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `crate::super` + --> $DIR/use-path-segment-kw.rs:164:21 + | +LL | use crate::{super}; + | ^^^^^ no `super` in the root + +error[E0432]: unresolved import `crate::super` + --> $DIR/use-path-segment-kw.rs:165:21 + | +LL | use crate::{super as _nested_super4}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super::super` + --> $DIR/use-path-segment-kw.rs:168:13 + | +LL | use super::super; + | ^^^^^^^^^^^^ no `super` in `foo` + +error[E0432]: unresolved import `super::super` + --> $DIR/use-path-segment-kw.rs:169:17 + | +LL | pub use super::super as _super5; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo` + +error[E0432]: unresolved import `super::super` + --> $DIR/use-path-segment-kw.rs:170:21 + | +LL | use super::{super}; + | ^^^^^ no `super` in `foo` + +error[E0432]: unresolved import `super::super` + --> $DIR/use-path-segment-kw.rs:171:25 + | +LL | pub use super::{super as _nested_super5}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo` + +error[E0432]: unresolved import `self` + --> $DIR/use-path-segment-kw.rs:181:13 + | +LL | use self::{}; + | ^^^^^^^^ no `self` in the root + +error[E0432]: unresolved import `{{root}}` + --> $DIR/use-path-segment-kw.rs:188:13 + | +LL | use ::self; + | ^^^^^^ no `{{root}}` in the root + +error[E0432]: unresolved import `{{root}}` + --> $DIR/use-path-segment-kw.rs:190:13 + | +LL | use ::self as _self2; + | ^^^^^^^^^^^^^^^^ no `{{root}}` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:211:13 + | +LL | use super::self; + | ^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:213:17 + | +LL | pub use super::self as _self5; + | ^^^^^^^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:215:21 + | +LL | use super::{self}; + | ^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:216:25 + | +LL | pub use super::{self as _nested_self5}; + | ^^^^^^^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `self` + --> $DIR/use-path-segment-kw.rs:221:20 + | +LL | use self::{self}; + | ^^^^ no `self` in the root + +error[E0432]: unresolved import `self` + --> $DIR/use-path-segment-kw.rs:222:24 + | +LL | pub use self::{self as _nested_self6}; + | ^^^^^^^^^^^^^^^^^^^^^ no `self` in the root + +error[E0432]: unresolved import `$crate` + --> $DIR/use-path-segment-kw.rs:13:13 + | +LL | use ::$crate; + | ^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate` + --> $DIR/use-path-segment-kw.rs:14:13 + | +LL | use ::$crate as _dollar_crate2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate` + --> $DIR/use-path-segment-kw.rs:15:16 + | +LL | use ::{$crate}; + | ^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate` + --> $DIR/use-path-segment-kw.rs:16:16 + | +LL | use ::{$crate as _nested_dollar_crate2}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `foobar::$crate` + --> $DIR/use-path-segment-kw.rs:19:13 + | +LL | use foobar::$crate; + | ^^^^^^^^^^^^^^ no `$crate` in `foo::bar::foobar` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `foobar::$crate` + --> $DIR/use-path-segment-kw.rs:20:13 + | +LL | use foobar::$crate as _dollar_crate3; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo::bar::foobar` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `foobar::$crate` + --> $DIR/use-path-segment-kw.rs:21:22 + | +LL | use foobar::{$crate}; + | ^^^^^^ no `$crate` in `foo::bar::foobar` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `foobar::$crate` + --> $DIR/use-path-segment-kw.rs:22:22 + | +LL | use foobar::{$crate as _nested_dollar_crate3}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo::bar::foobar` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `crate::$crate` + --> $DIR/use-path-segment-kw.rs:25:13 + | +LL | use crate::$crate; + | ^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `crate::$crate` + --> $DIR/use-path-segment-kw.rs:26:13 + | +LL | use crate::$crate as _dollar_crate4; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `crate::$crate` + --> $DIR/use-path-segment-kw.rs:27:21 + | +LL | use crate::{$crate}; + | ^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `crate::$crate` + --> $DIR/use-path-segment-kw.rs:28:21 + | +LL | use crate::{$crate as _nested_dollar_crate4}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `super::$crate` + --> $DIR/use-path-segment-kw.rs:31:13 + | +LL | use super::$crate; + | ^^^^^^^^^^^^^ no `$crate` in `foo` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `super::$crate` + --> $DIR/use-path-segment-kw.rs:32:13 + | +LL | use super::$crate as _dollar_crate5; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `super::$crate` + --> $DIR/use-path-segment-kw.rs:33:21 + | +LL | use super::{$crate}; + | ^^^^^^ no `$crate` in `foo` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `super::$crate` + --> $DIR/use-path-segment-kw.rs:34:21 + | +LL | use super::{$crate as _nested_dollar_crate5}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::$crate` + --> $DIR/use-path-segment-kw.rs:43:13 + | +LL | use $crate::$crate; + | ^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::$crate` + --> $DIR/use-path-segment-kw.rs:44:13 + | +LL | use $crate::$crate as _dollar_crate7; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::$crate` + --> $DIR/use-path-segment-kw.rs:45:22 + | +LL | use $crate::{$crate}; + | ^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::$crate` + --> $DIR/use-path-segment-kw.rs:46:22 + | +LL | use $crate::{$crate as _nested_dollar_crate7}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::crate` + --> $DIR/use-path-segment-kw.rs:49:13 + | +LL | use $crate::crate; + | ^^^^^^^^^^^^^ no `crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::crate` + --> $DIR/use-path-segment-kw.rs:51:13 + | +LL | use $crate::crate as _m_crate8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::crate` + --> $DIR/use-path-segment-kw.rs:52:22 + | +LL | use $crate::{crate}; + | ^^^^^ no `crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::crate` + --> $DIR/use-path-segment-kw.rs:54:22 + | +LL | use $crate::{crate as _m_nested_crate8}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::super` + --> $DIR/use-path-segment-kw.rs:57:13 + | +LL | use $crate::super; + | ^^^^^^^^^^^^^ no `super` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::super` + --> $DIR/use-path-segment-kw.rs:58:13 + | +LL | use $crate::super as _m_super8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::super` + --> $DIR/use-path-segment-kw.rs:59:22 + | +LL | use $crate::{super}; + | ^^^^^ no `super` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::super` + --> $DIR/use-path-segment-kw.rs:60:22 + | +LL | use $crate::{super as _m_nested_super8}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0573]: expected type, found module `$crate` + --> $DIR/use-path-segment-kw.rs:8:19 + | +LL | type A1 = $crate; + | ^^^^^^ not a type +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0573]: expected type, found module `crate` + --> $DIR/use-path-segment-kw.rs:97:19 + | +LL | type B1 = crate; + | ^^^^^ not a type + +error[E0573]: expected type, found module `super` + --> $DIR/use-path-segment-kw.rs:145:19 + | +LL | type C1 = super; + | ^^^^^ not a type + +error[E0573]: expected type, found module `super::super` + --> $DIR/use-path-segment-kw.rs:167:19 + | +LL | type C5 = super::super; + | ^^^^^^^^^^^^ not a type + +error[E0573]: expected type, found module `self::super` + --> $DIR/use-path-segment-kw.rs:173:19 + | +LL | type C6 = self::super; + | ^^^^^^^^^^^ not a type + +error[E0573]: expected type, found module `self` + --> $DIR/use-path-segment-kw.rs:183:19 + | +LL | type D1 = self; + | ^^^^ not a type + +error[E0433]: failed to resolve: global paths cannot start with `$crate` + --> $DIR/use-path-segment-kw.rs:12:21 + | +LL | type A2 = ::$crate; + | ^^^^^^ global paths cannot start with `$crate` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:18:27 + | +LL | type A3 = foobar::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:24:26 + | +LL | type A4 = crate::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:30:26 + | +LL | type A5 = super::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:36:25 + | +LL | type A6 = self::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:42:27 + | +LL | type A7 = $crate::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:48:27 + | +LL | type A8 = $crate::crate; + | ^^^^^ `crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `super` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:56:27 + | +LL | type A9 = $crate::super; + | ^^^^^ `super` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:62:28 + | +LL | type A10 = $crate::self; + | ^^^^ `self` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: global paths cannot start with `crate` + --> $DIR/use-path-segment-kw.rs:101:21 + | +LL | type B2 = ::crate; + | ^^^^^ global paths cannot start with `crate` + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:109:27 + | +LL | type B3 = foobar::crate; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:117:26 + | +LL | type B4 = crate::crate; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:125:26 + | +LL | type B5 = super::crate; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:133:25 + | +LL | type B6 = self::crate; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: global paths cannot start with `super` + --> $DIR/use-path-segment-kw.rs:149:21 + | +LL | type C2 = ::super; + | ^^^^^ global paths cannot start with `super` + +error[E0433]: failed to resolve: `super` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:155:27 + | +LL | type C3 = foobar::super; + | ^^^^^ `super` in paths can only be used in start position + +error[E0433]: failed to resolve: `super` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:161:26 + | +LL | type C4 = crate::super; + | ^^^^^ `super` in paths can only be used in start position + +error[E0433]: failed to resolve: global paths cannot start with `self` + --> $DIR/use-path-segment-kw.rs:187:21 + | +LL | type D2 = ::self; + | ^^^^ global paths cannot start with `self` + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:195:27 + | +LL | type D3 = foobar::self; + | ^^^^ `self` in paths can only be used in start position + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:201:26 + | +LL | type D4 = crate::self; + | ^^^^ `self` in paths can only be used in start position + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:210:26 + | +LL | type D5 = super::self; + | ^^^^ `self` in paths can only be used in start position + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:218:25 + | +LL | type D6 = self::self; + | ^^^^ `self` in paths can only be used in start position + +error: aborting due to 141 previous errors + +Some errors have detailed explanations: E0252, E0429, E0431, E0432, E0433, E0573. +For more information about an error, try `rustc --explain E0252`.