authorbors <bors@rust-lang.org> 2025-11-21 20:45:11 UTC
committerbors <bors@rust-lang.org> 2025-11-21 20:45:11 UTC
log27b076af7e3e7a363975443d81dfa9ecee5a74ec
tree9513bd135f4878f1008605519298035a2d48d4dd
parente22dab387f6b4f6a87dfc54ac2f6013dddb41e68
parent228b49e7916b18937b8e9dade04f0d52b53de834

Auto merge of #149196 - GuillaumeGomez:rollup-pn0aoy3, r=GuillaumeGomez

Rollup of 7 pull requests Successful merges: - rust-lang/rust#146978 (Emit error when using path-segment keyword as cfg pred) - rust-lang/rust#148719 (Allow unnormalized types in drop elaboration) - rust-lang/rust#148795 (add `rust.rustflags` and per target `rustflags` options to `bootstrap.toml`) - rust-lang/rust#149028 ([rustdoc] Remove `UrlFragment::render` method to unify `clean::types::links` and `anchor`) - rust-lang/rust#149043 ( rustdoc-json: add rlib path to ExternalCrate to enable robust crate resolution) - rust-lang/rust#149098 (Fix error message for calling a non-tuple struct) - rust-lang/rust#149151 (Add test for importing path-segment keyword) r? `@ghost` `@rustbot` modify labels: rollup

86 files changed, 4177 insertions(+), 1619 deletions(-)

Cargo.lock+1
......@@ -3336,6 +3336,7 @@ dependencies = [
33363336 "libc",
33373337 "object 0.37.3",
33383338 "regex",
3339 "rustdoc-json-types",
33393340 "serde_json",
33403341 "similar",
33413342 "wasmparser 0.236.1",
bootstrap.example.toml+12
......@@ -708,6 +708,12 @@
708708# desired in distributions, for example.
709709#rust.rpath = true
710710
711# Additional flags to pass to `rustc`.
712# Takes precedence over bootstrap's own flags but not over per target rustflags nor env. vars. like RUSTFLAGS.
713# Applies to all stages and targets.
714#
715#rust.rustflags = []
716
711717# Indicates whether symbols should be stripped using `-Cstrip=symbols`.
712718#rust.strip = false
713719
......@@ -1013,6 +1019,12 @@
10131019# and will override the same option under [rust] section. It only works on Unix platforms
10141020#rpath = rust.rpath (bool)
10151021
1022# Additional flags to pass to `rustc`.
1023# Takes precedence over bootstrap's own flags and `rust.rustflags` but not over env. vars. like RUSTFLAGS.
1024# Applies to all stages.
1025#
1026#rustflags = rust.rustflags
1027
10161028# Force static or dynamic linkage of the standard library for this target. If
10171029# this target is a host for rustc, this will also affect the linkage of the
10181030# compiler itself. This is useful for building rustc on targets that normally
compiler/rustc_attr_parsing/src/attributes/cfg.rs+3-2
......@@ -82,7 +82,8 @@ pub fn parse_cfg_entry<S: Stage>(
8282 }
8383 },
8484 a @ (ArgParser::NoArgs | ArgParser::NameValue(_)) => {
85 let Some(name) = meta.path().word_sym() else {
85 let Some(name) = meta.path().word_sym().filter(|s| !s.is_path_segment_keyword())
86 else {
8687 return Err(cx.expected_identifier(meta.path().span()));
8788 };
8889 parse_name_value(name, meta.path().span(), a.name_value(), meta.span(), cx)?
......@@ -158,7 +159,7 @@ fn parse_cfg_entry_target<S: Stage>(
158159 };
159160
160161 // Then, parse it as a name-value item
161 let Some(name) = sub_item.path().word_sym() else {
162 let Some(name) = sub_item.path().word_sym().filter(|s| !s.is_path_segment_keyword()) else {
162163 return Err(cx.expected_identifier(sub_item.path().span()));
163164 };
164165 let name = Symbol::intern(&format!("target_{name}"));
compiler/rustc_attr_parsing/src/attributes/cfg_old.rs+4-1
......@@ -220,7 +220,10 @@ pub fn eval_condition(
220220 }
221221 }
222222 }
223 MetaItemKind::Word | MetaItemKind::NameValue(..) if cfg.path.segments.len() != 1 => {
223 MetaItemKind::Word | MetaItemKind::NameValue(..)
224 if cfg.path.segments.len() != 1
225 || cfg.path.segments[0].ident.is_path_segment_keyword() =>
226 {
224227 dcx.emit_err(session_diagnostics::CfgPredicateIdentifier { span: cfg.path.span });
225228 true
226229 }
compiler/rustc_errors/src/emitter.rs+8-14
......@@ -532,30 +532,24 @@ impl Emitter for HumanEmitter {
532532 }
533533}
534534
535/// An emitter that does nothing when emitting a non-fatal diagnostic.
536/// Fatal diagnostics are forwarded to `fatal_emitter` to avoid silent
537/// failures of rustc, as witnessed e.g. in issue #89358.
538pub struct FatalOnlyEmitter {
539 pub fatal_emitter: Box<dyn Emitter + DynSend>,
540 pub fatal_note: Option<String>,
535/// An emitter that adds a note to each diagnostic.
536pub struct EmitterWithNote {
537 pub emitter: Box<dyn Emitter + DynSend>,
538 pub note: String,
541539}
542540
543impl Emitter for FatalOnlyEmitter {
541impl Emitter for EmitterWithNote {
544542 fn source_map(&self) -> Option<&SourceMap> {
545543 None
546544 }
547545
548546 fn emit_diagnostic(&mut self, mut diag: DiagInner, registry: &Registry) {
549 if diag.level == Level::Fatal {
550 if let Some(fatal_note) = &self.fatal_note {
551 diag.sub(Level::Note, fatal_note.clone(), MultiSpan::new());
552 }
553 self.fatal_emitter.emit_diagnostic(diag, registry);
554 }
547 diag.sub(Level::Note, self.note.clone(), MultiSpan::new());
548 self.emitter.emit_diagnostic(diag, registry);
555549 }
556550
557551 fn translator(&self) -> &Translator {
558 self.fatal_emitter.translator()
552 self.emitter.translator()
559553 }
560554}
561555
compiler/rustc_interface/src/interface.rs+44-26
......@@ -15,6 +15,7 @@ use rustc_middle::ty::CurrentGcx;
1515use rustc_middle::util::Providers;
1616use rustc_parse::lexer::StripTokens;
1717use rustc_parse::new_parser_from_source_str;
18use rustc_parse::parser::Recovery;
1819use rustc_parse::parser::attr::AllowLeadingUnsafe;
1920use rustc_query_impl::QueryCtxt;
2021use rustc_query_system::query::print_query_stack;
......@@ -52,9 +53,9 @@ pub struct Compiler {
5253pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec<String>) -> Cfg {
5354 cfgs.into_iter()
5455 .map(|s| {
55 let psess = ParseSess::with_fatal_emitter(
56 let psess = ParseSess::emitter_with_note(
5657 vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
57 format!("this error occurred on the command line: `--cfg={s}`"),
58 format!("this occurred on the command line: `--cfg={s}`"),
5859 );
5960 let filename = FileName::cfg_spec_source_code(&s);
6061
......@@ -62,36 +63,46 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec<String>) -> Cfg {
6263 ($reason: expr) => {
6364 #[allow(rustc::untranslatable_diagnostic)]
6465 #[allow(rustc::diagnostic_outside_of_impl)]
65 dcx.fatal(format!(
66 concat!("invalid `--cfg` argument: `{}` (", $reason, ")"),
67 s
68 ));
66 dcx.fatal(format!("invalid `--cfg` argument: `{s}` ({})", $reason));
6967 };
7068 }
7169
7270 match new_parser_from_source_str(&psess, filename, s.to_string(), StripTokens::Nothing)
7371 {
74 Ok(mut parser) => match parser.parse_meta_item(AllowLeadingUnsafe::No) {
75 Ok(meta_item) if parser.token == token::Eof => {
76 if meta_item.path.segments.len() != 1 {
77 error!("argument key must be an identifier");
78 }
79 match &meta_item.kind {
80 MetaItemKind::List(..) => {}
81 MetaItemKind::NameValue(lit) if !lit.kind.is_str() => {
82 error!("argument value must be a string");
72 Ok(mut parser) => {
73 parser = parser.recovery(Recovery::Forbidden);
74 match parser.parse_meta_item(AllowLeadingUnsafe::No) {
75 Ok(meta_item)
76 if parser.token == token::Eof
77 && parser.dcx().has_errors().is_none() =>
78 {
79 if meta_item.path.segments.len() != 1 {
80 error!("argument key must be an identifier");
8381 }
84 MetaItemKind::NameValue(..) | MetaItemKind::Word => {
85 let ident = meta_item.ident().expect("multi-segment cfg key");
86 return (ident.name, meta_item.value_str());
82 match &meta_item.kind {
83 MetaItemKind::List(..) => {}
84 MetaItemKind::NameValue(lit) if !lit.kind.is_str() => {
85 error!("argument value must be a string");
86 }
87 MetaItemKind::NameValue(..) | MetaItemKind::Word => {
88 let ident = meta_item.ident().expect("multi-segment cfg key");
89
90 if ident.is_path_segment_keyword() {
91 error!(
92 "malformed `cfg` input, expected a valid identifier"
93 );
94 }
95
96 return (ident.name, meta_item.value_str());
97 }
8798 }
8899 }
100 Ok(..) => {}
101 Err(err) => err.cancel(),
89102 }
90 Ok(..) => {}
91 Err(err) => err.cancel(),
92 },
103 }
93104 Err(errs) => errs.into_iter().for_each(|err| err.cancel()),
94 }
105 };
95106
96107 // If the user tried to use a key="value" flag, but is missing the quotes, provide
97108 // a hint about how to resolve this.
......@@ -116,9 +127,9 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
116127 let mut check_cfg = CheckCfg { exhaustive_names, exhaustive_values, ..CheckCfg::default() };
117128
118129 for s in specs {
119 let psess = ParseSess::with_fatal_emitter(
130 let psess = ParseSess::emitter_with_note(
120131 vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
121 format!("this error occurred on the command line: `--check-cfg={s}`"),
132 format!("this occurred on the command line: `--check-cfg={s}`"),
122133 );
123134 let filename = FileName::cfg_spec_source_code(&s);
124135
......@@ -171,7 +182,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
171182 let mut parser =
172183 match new_parser_from_source_str(&psess, filename, s.to_string(), StripTokens::Nothing)
173184 {
174 Ok(parser) => parser,
185 Ok(parser) => parser.recovery(Recovery::Forbidden),
175186 Err(errs) => {
176187 errs.into_iter().for_each(|err| err.cancel());
177188 expected_error();
......@@ -179,7 +190,9 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
179190 };
180191
181192 let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::No) {
182 Ok(meta_item) if parser.token == token::Eof => meta_item,
193 Ok(meta_item) if parser.token == token::Eof && parser.dcx().has_errors().is_none() => {
194 meta_item
195 }
183196 Ok(..) => expected_error(),
184197 Err(err) => {
185198 err.cancel();
......@@ -209,6 +222,11 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
209222 if values_specified {
210223 error!("`cfg()` names cannot be after values");
211224 }
225
226 if ident.is_path_segment_keyword() {
227 error!("malformed `cfg` input, expected a valid identifier");
228 }
229
212230 names.push(ident);
213231 } else if let Some(boolean) = arg.boolean_literal() {
214232 if values_specified {
compiler/rustc_mir_transform/src/elaborate_drop.rs+6-13
......@@ -511,19 +511,12 @@ where
511511 let tcx = self.tcx();
512512
513513 assert_eq!(self.elaborator.typing_env().typing_mode, ty::TypingMode::PostAnalysis);
514 let field_ty = match tcx.try_normalize_erasing_regions(
515 self.elaborator.typing_env(),
516 field.ty(tcx, args),
517 ) {
518 Ok(t) => t,
519 Err(_) => Ty::new_error(
520 self.tcx(),
521 self.tcx().dcx().span_delayed_bug(
522 self.elaborator.body().span,
523 "Error normalizing in drop elaboration.",
524 ),
525 ),
526 };
514 let field_ty = field.ty(tcx, args);
515 // We silently leave an unnormalized type here to support polymorphic drop
516 // elaboration for users of rustc internal APIs
517 let field_ty = tcx
518 .try_normalize_erasing_regions(self.elaborator.typing_env(), field_ty)
519 .unwrap_or(field_ty);
527520
528521 (tcx.mk_place_field(base_place, field_idx, field_ty), subpath)
529522 })
compiler/rustc_parse/src/parser/mod.rs+1-1
......@@ -466,7 +466,7 @@ impl<'a> Parser<'a> {
466466
467467 // Public for rustfmt usage.
468468 pub fn parse_ident(&mut self) -> PResult<'a, Ident> {
469 self.parse_ident_common(true)
469 self.parse_ident_common(self.may_recover())
470470 }
471471
472472 fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, Ident> {
compiler/rustc_resolve/src/late/diagnostics.rs+24-3
......@@ -823,8 +823,16 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
823823 }
824824
825825 if let Some(Res::Def(DefKind::Struct, def_id)) = res {
826 self.update_err_for_private_tuple_struct_fields(err, &source, def_id);
827 err.note("constructor is not visible here due to private fields");
826 let private_fields = self.has_private_fields(def_id);
827 let adjust_error_message =
828 private_fields && self.is_struct_with_fn_ctor(def_id);
829 if adjust_error_message {
830 self.update_err_for_private_tuple_struct_fields(err, &source, def_id);
831 }
832
833 if private_fields {
834 err.note("constructor is not visible here due to private fields");
835 }
828836 } else {
829837 err.span_suggestion(
830838 call_span,
......@@ -1642,6 +1650,19 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
16421650 }
16431651 }
16441652
1653 fn is_struct_with_fn_ctor(&mut self, def_id: DefId) -> bool {
1654 def_id
1655 .as_local()
1656 .and_then(|local_id| self.r.struct_constructors.get(&local_id))
1657 .map(|struct_ctor| {
1658 matches!(
1659 struct_ctor.0,
1660 def::Res::Def(DefKind::Ctor(CtorOf::Struct, CtorKind::Fn), _)
1661 )
1662 })
1663 .unwrap_or(false)
1664 }
1665
16451666 fn update_err_for_private_tuple_struct_fields(
16461667 &mut self,
16471668 err: &mut Diag<'_>,
......@@ -1674,7 +1695,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
16741695 *call_span,
16751696 &args[..],
16761697 );
1677 // Use spans of the tuple struct definition.
1698
16781699 self.r
16791700 .field_idents(def_id)
16801701 .map(|fields| fields.iter().map(|f| f.span).collect::<Vec<_>>())
compiler/rustc_session/src/parse.rs+4-8
......@@ -8,7 +8,7 @@ use rustc_ast::attr::AttrIdGenerator;
88use rustc_ast::node_id::NodeId;
99use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
1010use rustc_data_structures::sync::{AppendOnlyVec, Lock};
11use rustc_errors::emitter::{FatalOnlyEmitter, HumanEmitter, stderr_destination};
11use rustc_errors::emitter::{EmitterWithNote, HumanEmitter, stderr_destination};
1212use rustc_errors::translation::Translator;
1313use rustc_errors::{
1414 BufferedEarlyLint, ColorConfig, DecorateDiagCompat, Diag, DiagCtxt, DiagCtxtHandle,
......@@ -315,16 +315,12 @@ impl ParseSess {
315315 }
316316 }
317317
318 pub fn with_fatal_emitter(locale_resources: Vec<&'static str>, fatal_note: String) -> Self {
318 pub fn emitter_with_note(locale_resources: Vec<&'static str>, note: String) -> Self {
319319 let translator = Translator::with_fallback_bundle(locale_resources, false);
320320 let sm = Arc::new(SourceMap::new(FilePathMapping::empty()));
321 let fatal_emitter =
321 let emitter =
322322 Box::new(HumanEmitter::new(stderr_destination(ColorConfig::Auto), translator));
323 let dcx = DiagCtxt::new(Box::new(FatalOnlyEmitter {
324 fatal_emitter,
325 fatal_note: Some(fatal_note),
326 }))
327 .disable_warnings();
323 let dcx = DiagCtxt::new(Box::new(EmitterWithNote { emitter, note }));
328324 ParseSess::with_dcx(dcx, sm)
329325 }
330326
src/bootstrap/src/core/builder/cargo.rs+16
......@@ -105,6 +105,7 @@ pub struct Cargo {
105105 allow_features: String,
106106 release_build: bool,
107107 build_compiler_stage: u32,
108 extra_rustflags: Vec<String>,
108109}
109110
110111impl Cargo {
......@@ -403,6 +404,11 @@ impl From<Cargo> for BootstrapCommand {
403404 cargo.args.insert(0, "--release".into());
404405 }
405406
407 for arg in &cargo.extra_rustflags {
408 cargo.rustflags.arg(arg);
409 cargo.rustdocflags.arg(arg);
410 }
411
406412 // Propagate the envs here at the very end to make sure they override any previously set flags.
407413 cargo.rustflags.propagate_rustflag_envs(cargo.build_compiler_stage);
408414 cargo.rustdocflags.propagate_rustflag_envs(cargo.build_compiler_stage);
......@@ -1379,6 +1385,15 @@ impl Builder<'_> {
13791385 rustflags.arg("-Zmir_strip_debuginfo=locals-in-tiny-functions");
13801386 }
13811387
1388 // take target-specific extra rustflags if any otherwise take `rust.rustflags`
1389 let extra_rustflags = self
1390 .config
1391 .target_config
1392 .get(&target)
1393 .map(|t| &t.rustflags)
1394 .unwrap_or(&self.config.rust_rustflags)
1395 .clone();
1396
13821397 let release_build = self.config.rust_optimize.is_release() &&
13831398 // cargo bench/install do not accept `--release` and miri doesn't want it
13841399 !matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest);
......@@ -1394,6 +1409,7 @@ impl Builder<'_> {
13941409 allow_features,
13951410 release_build,
13961411 build_compiler_stage,
1412 extra_rustflags,
13971413 }
13981414 }
13991415}
src/bootstrap/src/core/config/config.rs+5
......@@ -225,6 +225,7 @@ pub struct Config {
225225 pub rust_std_features: BTreeSet<String>,
226226 pub rust_break_on_ice: bool,
227227 pub rust_parallel_frontend_threads: Option<u32>,
228 pub rust_rustflags: Vec<String>,
228229
229230 pub llvm_profile_use: Option<String>,
230231 pub llvm_profile_generate: bool,
......@@ -575,6 +576,7 @@ impl Config {
575576 bootstrap_override_lld_legacy: rust_bootstrap_override_lld_legacy,
576577 std_features: rust_std_features,
577578 break_on_ice: rust_break_on_ice,
579 rustflags: rust_rustflags,
578580 } = toml.rust.unwrap_or_default();
579581
580582 let Llvm {
......@@ -864,6 +866,7 @@ impl Config {
864866 sanitizers: target_sanitizers,
865867 profiler: target_profiler,
866868 rpath: target_rpath,
869 rustflags: target_rustflags,
867870 crt_static: target_crt_static,
868871 musl_root: target_musl_root,
869872 musl_libdir: target_musl_libdir,
......@@ -947,6 +950,7 @@ impl Config {
947950 target.sanitizers = target_sanitizers;
948951 target.profiler = target_profiler;
949952 target.rpath = target_rpath;
953 target.rustflags = target_rustflags.unwrap_or_default();
950954 target.optimized_compiler_builtins = target_optimized_compiler_builtins;
951955 target.jemalloc = target_jemalloc;
952956 if let Some(backends) = target_codegen_backends {
......@@ -1441,6 +1445,7 @@ impl Config {
14411445 rust_randomize_layout: rust_randomize_layout.unwrap_or(false),
14421446 rust_remap_debuginfo: rust_remap_debuginfo.unwrap_or(false),
14431447 rust_rpath: rust_rpath.unwrap_or(true),
1448 rust_rustflags: rust_rustflags.unwrap_or_default(),
14441449 rust_stack_protector,
14451450 rust_std_features: rust_std_features
14461451 .unwrap_or(BTreeSet::from([String::from("panic-unwind")])),
src/bootstrap/src/core/config/toml/rust.rs+2
......@@ -33,6 +33,7 @@ define_config! {
3333 channel: Option<String> = "channel",
3434 musl_root: Option<String> = "musl-root",
3535 rpath: Option<bool> = "rpath",
36 rustflags: Option<Vec<String>> = "rustflags",
3637 strip: Option<bool> = "strip",
3738 frame_pointers: Option<bool> = "frame-pointers",
3839 stack_protector: Option<String> = "stack-protector",
......@@ -375,6 +376,7 @@ pub fn check_incompatible_options_for_ci_rustc(
375376 parallel_frontend_threads: _,
376377 bootstrap_override_lld: _,
377378 bootstrap_override_lld_legacy: _,
379 rustflags: _,
378380 } = ci_rust_config;
379381
380382 // There are two kinds of checks for CI rustc incompatible options:
src/bootstrap/src/core/config/toml/target.rs+2
......@@ -37,6 +37,7 @@ define_config! {
3737 sanitizers: Option<bool> = "sanitizers",
3838 profiler: Option<StringOrBool> = "profiler",
3939 rpath: Option<bool> = "rpath",
40 rustflags: Option<Vec<String>> = "rustflags",
4041 crt_static: Option<bool> = "crt-static",
4142 musl_root: Option<String> = "musl-root",
4243 musl_libdir: Option<String> = "musl-libdir",
......@@ -70,6 +71,7 @@ pub struct Target {
7071 pub sanitizers: Option<bool>,
7172 pub profiler: Option<StringOrBool>,
7273 pub rpath: Option<bool>,
74 pub rustflags: Vec<String>,
7375 pub crt_static: Option<bool>,
7476 pub musl_root: Option<PathBuf>,
7577 pub musl_libdir: Option<PathBuf>,
src/bootstrap/src/utils/change_tracker.rs+5
......@@ -596,4 +596,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
596596 severity: ChangeSeverity::Info,
597597 summary: "The `-Zannotate-moves` option is now always enabled when building rustc, sysroot and tools.",
598598 },
599 ChangeInfo {
600 change_id: 148795,
601 severity: ChangeSeverity::Info,
602 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.",
603 },
599604];
src/librustdoc/clean/mod.rs+1-1
......@@ -249,7 +249,7 @@ pub(crate) fn clean_trait_ref_with_constraints<'tcx>(
249249 trait_ref: ty::PolyTraitRef<'tcx>,
250250 constraints: ThinVec<AssocItemConstraint>,
251251) -> Path {
252 let kind = cx.tcx.def_kind(trait_ref.def_id()).into();
252 let kind = ItemType::from_def_id(trait_ref.def_id(), cx.tcx);
253253 if !matches!(kind, ItemType::Trait | ItemType::TraitAlias) {
254254 span_bug!(cx.tcx.def_span(trait_ref.def_id()), "`TraitRef` had unexpected kind {kind:?}");
255255 }
src/librustdoc/clean/types.rs+11-2
......@@ -1,3 +1,4 @@
1use std::fmt::Write;
12use std::hash::Hash;
23use std::path::PathBuf;
34use std::sync::{Arc, OnceLock as OnceCell};
......@@ -522,8 +523,16 @@ impl Item {
522523 debug!(?id);
523524 if let Ok(HrefInfo { mut url, .. }) = href(*id, cx) {
524525 debug!(?url);
525 if let Some(ref fragment) = *fragment {
526 fragment.render(&mut url, cx.tcx())
526 match fragment {
527 Some(UrlFragment::Item(def_id)) => {
528 write!(url, "{}", crate::html::format::fragment(*def_id, cx.tcx()))
529 .unwrap();
530 }
531 Some(UrlFragment::UserWritten(raw)) => {
532 url.push('#');
533 url.push_str(raw);
534 }
535 None => {}
527536 }
528537 Some(RenderedLink {
529538 original_text: s.clone(),
src/librustdoc/clean/utils.rs+4-3
......@@ -26,6 +26,7 @@ use crate::clean::{
2626};
2727use crate::core::DocContext;
2828use crate::display::Joined as _;
29use crate::formats::item_type::ItemType;
2930
3031#[cfg(test)]
3132mod tests;
......@@ -496,7 +497,7 @@ pub(crate) fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
496497
497498 let (kind, did) = match res {
498499 Res::Def(
499 kind @ (AssocTy
500 AssocTy
500501 | AssocFn
501502 | AssocConst
502503 | Variant
......@@ -511,9 +512,9 @@ pub(crate) fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
511512 | Const
512513 | Static { .. }
513514 | Macro(..)
514 | TraitAlias),
515 | TraitAlias,
515516 did,
516 ) => (kind.into(), did),
517 ) => (ItemType::from_def_id(did, cx.tcx), did),
517518
518519 _ => panic!("register_res: unexpected {res:?}"),
519520 };
src/librustdoc/formats/item_type.rs+12-12
......@@ -3,6 +3,8 @@
33use std::fmt;
44
55use rustc_hir::def::{CtorOf, DefKind, MacroKinds};
6use rustc_hir::def_id::DefId;
7use rustc_middle::ty::TyCtxt;
68use rustc_span::hygiene::MacroKind;
79use serde::{Deserialize, Deserializer, Serialize, Serializer, de};
810
......@@ -147,17 +149,10 @@ impl<'a> From<&'a clean::Item> for ItemType {
147149 }
148150}
149151
150impl From<DefKind> for ItemType {
151 fn from(other: DefKind) -> Self {
152 Self::from_def_kind(other, None)
153 }
154}
155
156152impl ItemType {
157 /// Depending on the parent kind, some variants have a different translation (like a `Method`
158 /// becoming a `TyMethod`).
159 pub(crate) fn from_def_kind(kind: DefKind, parent_kind: Option<DefKind>) -> Self {
160 match kind {
153 pub(crate) fn from_def_id(def_id: DefId, tcx: TyCtxt<'_>) -> Self {
154 let def_kind = tcx.def_kind(def_id);
155 match def_kind {
161156 DefKind::Enum => Self::Enum,
162157 DefKind::Fn => Self::Function,
163158 DefKind::Mod => Self::Module,
......@@ -176,8 +171,13 @@ impl ItemType {
176171 DefKind::Variant => Self::Variant,
177172 DefKind::Field => Self::StructField,
178173 DefKind::AssocTy => Self::AssocType,
179 DefKind::AssocFn if let Some(DefKind::Trait) = parent_kind => Self::TyMethod,
180 DefKind::AssocFn => Self::Method,
174 DefKind::AssocFn => {
175 if tcx.associated_item(def_id).defaultness(tcx).has_value() {
176 Self::Method
177 } else {
178 Self::TyMethod
179 }
180 }
181181 DefKind::Ctor(CtorOf::Struct, _) => Self::Struct,
182182 DefKind::Ctor(CtorOf::Variant, _) => Self::Variant,
183183 DefKind::AssocConst => Self::AssocConst,
src/librustdoc/html/format.rs+27-19
......@@ -431,7 +431,6 @@ fn generate_item_def_id_path(
431431 original_def_id: DefId,
432432 cx: &Context<'_>,
433433 root_path: Option<&str>,
434 original_def_kind: DefKind,
435434) -> Result<HrefInfo, HrefError> {
436435 use rustc_middle::traits::ObligationCause;
437436 use rustc_trait_selection::infer::TyCtxtInferExt;
......@@ -457,15 +456,14 @@ fn generate_item_def_id_path(
457456 let relative = clean::inline::item_relative_path(tcx, def_id);
458457 let fqp: Vec<Symbol> = once(crate_name).chain(relative).collect();
459458
460 let def_kind = tcx.def_kind(def_id);
461 let shortty = def_kind.into();
459 let shortty = ItemType::from_def_id(def_id, tcx);
462460 let module_fqp = to_module_fqp(shortty, &fqp);
463461 let mut is_remote = false;
464462
465463 let url_parts = url_parts(cx.cache(), def_id, module_fqp, &cx.current, &mut is_remote)?;
466464 let mut url_parts = make_href(root_path, shortty, url_parts, &fqp, is_remote);
467465 if def_id != original_def_id {
468 let kind = ItemType::from_def_kind(original_def_kind, Some(def_kind));
466 let kind = ItemType::from_def_id(original_def_id, tcx);
469467 url_parts = format!("{url_parts}#{kind}.{}", tcx.item_name(original_def_id))
470468 };
471469 Ok(HrefInfo { url: url_parts, kind: shortty, rust_path: fqp })
......@@ -605,7 +603,7 @@ pub(crate) fn href_with_root_path(
605603 } else if did.is_local() {
606604 return Err(HrefError::Private);
607605 } else {
608 return generate_item_def_id_path(did, original_did, cx, root_path, def_kind);
606 return generate_item_def_id_path(did, original_did, cx, root_path);
609607 }
610608 }
611609 };
......@@ -835,26 +833,36 @@ fn print_higher_ranked_params_with_space(
835833 })
836834}
837835
838pub(crate) fn print_anchor(did: DefId, text: Symbol, cx: &Context<'_>) -> impl Display {
836pub(crate) fn fragment(did: DefId, tcx: TyCtxt<'_>) -> impl Display {
839837 fmt::from_fn(move |f| {
840 if let Ok(HrefInfo { url, kind, rust_path }) = href(did, cx) {
841 let tcx = cx.tcx();
842 let def_kind = tcx.def_kind(did);
843 let anchor = if matches!(
844 def_kind,
845 DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst | DefKind::Variant
846 ) {
838 let def_kind = tcx.def_kind(did);
839 match def_kind {
840 DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst | DefKind::Variant => {
841 let item_type = ItemType::from_def_id(did, tcx);
842 write!(f, "#{}.{}", item_type.as_str(), tcx.item_name(did))
843 }
844 DefKind::Field => {
847845 let parent_def_id = tcx.parent(did);
848 let item_type =
849 ItemType::from_def_kind(def_kind, Some(tcx.def_kind(parent_def_id)));
850 format!("#{}.{}", item_type.as_str(), tcx.item_name(did))
851 } else {
852 String::new()
853 };
846 f.write_char('#')?;
847 if tcx.def_kind(parent_def_id) == DefKind::Variant {
848 write!(f, "variant.{}.field", tcx.item_name(parent_def_id).as_str())?;
849 } else {
850 f.write_str("structfield")?;
851 };
852 write!(f, ".{}", tcx.item_name(did))
853 }
854 _ => Ok(()),
855 }
856 })
857}
854858
859pub(crate) fn print_anchor(did: DefId, text: Symbol, cx: &Context<'_>) -> impl Display {
860 fmt::from_fn(move |f| {
861 if let Ok(HrefInfo { url, kind, rust_path }) = href(did, cx) {
855862 write!(
856863 f,
857864 r#"<a class="{kind}" href="{url}{anchor}" title="{kind} {path}">{text}</a>"#,
865 anchor = fragment(did, cx.tcx()),
858866 path = join_path_syms(rust_path),
859867 text = EscapeBodyText(text.as_str()),
860868 )
src/librustdoc/json/mod.rs+11-3
......@@ -302,6 +302,13 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
302302 ExternalLocation::Remote(s) => Some(s.clone()),
303303 _ => None,
304304 },
305 path: self
306 .tcx
307 .used_crate_source(*crate_num)
308 .paths()
309 .next()
310 .expect("crate should have at least 1 path")
311 .clone(),
305312 },
306313 )
307314 })
......@@ -339,15 +346,12 @@ mod size_asserts {
339346 // tidy-alphabetical-start
340347 static_assert_size!(AssocItemConstraint, 112);
341348 static_assert_size!(Crate, 184);
342 static_assert_size!(ExternalCrate, 48);
343349 static_assert_size!(FunctionPointer, 168);
344350 static_assert_size!(GenericArg, 80);
345351 static_assert_size!(GenericArgs, 104);
346352 static_assert_size!(GenericBound, 72);
347353 static_assert_size!(GenericParamDef, 136);
348354 static_assert_size!(Impl, 304);
349 // `Item` contains a `PathBuf`, which is different sizes on different OSes.
350 static_assert_size!(Item, 528 + size_of::<std::path::PathBuf>());
351355 static_assert_size!(ItemSummary, 32);
352356 static_assert_size!(PolyTrait, 64);
353357 static_assert_size!(PreciseCapturingArg, 32);
......@@ -355,4 +359,8 @@ mod size_asserts {
355359 static_assert_size!(Type, 80);
356360 static_assert_size!(WherePredicate, 160);
357361 // tidy-alphabetical-end
362
363 // These contains a `PathBuf`, which is different sizes on different OSes.
364 static_assert_size!(Item, 528 + size_of::<std::path::PathBuf>());
365 static_assert_size!(ExternalCrate, 48 + size_of::<std::path::PathBuf>());
358366}
src/librustdoc/passes/collect_intra_doc_links.rs-37
......@@ -203,43 +203,6 @@ pub(crate) enum UrlFragment {
203203 UserWritten(String),
204204}
205205
206impl UrlFragment {
207 /// Render the fragment, including the leading `#`.
208 pub(crate) fn render(&self, s: &mut String, tcx: TyCtxt<'_>) {
209 s.push('#');
210 match self {
211 &UrlFragment::Item(def_id) => {
212 let kind = match tcx.def_kind(def_id) {
213 DefKind::AssocFn => {
214 if tcx.associated_item(def_id).defaultness(tcx).has_value() {
215 "method."
216 } else {
217 "tymethod."
218 }
219 }
220 DefKind::AssocConst => "associatedconstant.",
221 DefKind::AssocTy => "associatedtype.",
222 DefKind::Variant => "variant.",
223 DefKind::Field => {
224 let parent_id = tcx.parent(def_id);
225 if tcx.def_kind(parent_id) == DefKind::Variant {
226 s.push_str("variant.");
227 s.push_str(tcx.item_name(parent_id).as_str());
228 ".field."
229 } else {
230 "structfield."
231 }
232 }
233 kind => bug!("unexpected associated item kind: {kind:?}"),
234 };
235 s.push_str(kind);
236 s.push_str(tcx.item_name(def_id).as_str());
237 }
238 UrlFragment::UserWritten(raw) => s.push_str(raw),
239 }
240 }
241}
242
243206#[derive(Clone, Debug, Hash, PartialEq, Eq)]
244207pub(crate) struct ResolutionInfo {
245208 item_id: DefId,
src/rustdoc-json-types/lib.rs+8-2
......@@ -37,8 +37,8 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc
3737// will instead cause conflicts. See #94591 for more. (This paragraph and the "Latest feature" line
3838// are deliberately not in a doc comment, because they need not be in public docs.)
3939//
40// Latest feature: Add `ItemKind::Attribute`.
41pub const FORMAT_VERSION: u32 = 56;
40// Latest feature: Add `ExternCrate::path`.
41pub const FORMAT_VERSION: u32 = 57;
4242
4343/// The root of the emitted JSON blob.
4444///
......@@ -135,6 +135,12 @@ pub struct ExternalCrate {
135135 pub name: String,
136136 /// The root URL at which the crate's documentation lives.
137137 pub html_root_url: Option<String>,
138
139 /// A path from where this crate was loaded.
140 ///
141 /// This will typically be a `.rlib` or `.rmeta`. It can be used to determine which crate
142 /// this was in terms of whatever build-system invoked rustc.
143 pub path: PathBuf,
138144}
139145
140146/// Information about an external (not defined in the local crate) [`Item`].
src/tools/clippy/tests/ui/cast_size.32bit.stderr deleted-198
......@@ -1,198 +0,0 @@
1error: casting `isize` to `i8` may truncate the value
2 --> tests/ui/cast_size.rs:17:5
3 |
4LL | 1isize as i8;
5 | ^^^^^^^^^^^^
6 |
7 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
8 = note: `-D clippy::cast-possible-truncation` implied by `-D warnings`
9 = help: to override `-D warnings` add `#[allow(clippy::cast_possible_truncation)]`
10help: ... or use `try_from` and handle the error accordingly
11 |
12LL - 1isize as i8;
13LL + i8::try_from(1isize);
14 |
15
16error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
17 --> tests/ui/cast_size.rs:24:5
18 |
19LL | x0 as f32;
20 | ^^^^^^^^^
21 |
22 = note: `-D clippy::cast-precision-loss` implied by `-D warnings`
23 = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]`
24
25error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
26 --> tests/ui/cast_size.rs:26:5
27 |
28LL | x1 as f32;
29 | ^^^^^^^^^
30
31error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
32 --> tests/ui/cast_size.rs:28:5
33 |
34LL | x0 as f64;
35 | ^^^^^^^^^
36
37error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
38 --> tests/ui/cast_size.rs:30:5
39 |
40LL | x1 as f64;
41 | ^^^^^^^^^
42
43error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers
44 --> tests/ui/cast_size.rs:35:5
45 |
46LL | 1isize as i32;
47 | ^^^^^^^^^^^^^
48 |
49 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
50help: ... or use `try_from` and handle the error accordingly
51 |
52LL - 1isize as i32;
53LL + i32::try_from(1isize);
54 |
55
56error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers
57 --> tests/ui/cast_size.rs:37:5
58 |
59LL | 1isize as u32;
60 | ^^^^^^^^^^^^^
61 |
62 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
63help: ... or use `try_from` and handle the error accordingly
64 |
65LL - 1isize as u32;
66LL + u32::try_from(1isize);
67 |
68
69error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers
70 --> tests/ui/cast_size.rs:39:5
71 |
72LL | 1usize as u32;
73 | ^^^^^^^^^^^^^
74 |
75 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
76help: ... or use `try_from` and handle the error accordingly
77 |
78LL - 1usize as u32;
79LL + u32::try_from(1usize);
80 |
81
82error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers
83 --> tests/ui/cast_size.rs:41:5
84 |
85LL | 1usize as i32;
86 | ^^^^^^^^^^^^^
87 |
88 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
89help: ... or use `try_from` and handle the error accordingly
90 |
91LL - 1usize as i32;
92LL + i32::try_from(1usize);
93 |
94
95error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers
96 --> tests/ui/cast_size.rs:41:5
97 |
98LL | 1usize as i32;
99 | ^^^^^^^^^^^^^
100 |
101 = note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
102 = help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]`
103
104error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers
105 --> tests/ui/cast_size.rs:44:5
106 |
107LL | 1i64 as isize;
108 | ^^^^^^^^^^^^^
109 |
110 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
111help: ... or use `try_from` and handle the error accordingly
112 |
113LL - 1i64 as isize;
114LL + isize::try_from(1i64);
115 |
116
117error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers
118 --> tests/ui/cast_size.rs:46:5
119 |
120LL | 1i64 as usize;
121 | ^^^^^^^^^^^^^
122 |
123 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
124help: ... or use `try_from` and handle the error accordingly
125 |
126LL - 1i64 as usize;
127LL + usize::try_from(1i64);
128 |
129
130error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers
131 --> tests/ui/cast_size.rs:48:5
132 |
133LL | 1u64 as isize;
134 | ^^^^^^^^^^^^^
135 |
136 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
137help: ... or use `try_from` and handle the error accordingly
138 |
139LL - 1u64 as isize;
140LL + isize::try_from(1u64);
141 |
142
143error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers
144 --> tests/ui/cast_size.rs:48:5
145 |
146LL | 1u64 as isize;
147 | ^^^^^^^^^^^^^
148
149error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
150 --> tests/ui/cast_size.rs:51:5
151 |
152LL | 1u64 as usize;
153 | ^^^^^^^^^^^^^
154 |
155 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
156help: ... or use `try_from` and handle the error accordingly
157 |
158LL - 1u64 as usize;
159LL + usize::try_from(1u64);
160 |
161
162error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers
163 --> tests/ui/cast_size.rs:53:5
164 |
165LL | 1u32 as isize;
166 | ^^^^^^^^^^^^^
167
168error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
169 --> tests/ui/cast_size.rs:61:5
170 |
171LL | 999_999_999 as f32;
172 | ^^^^^^^^^^^^^^^^^^
173
174error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
175 --> tests/ui/cast_size.rs:63:5
176 |
177LL | 9_999_999_999_999_999usize as f64;
178 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
179
180error: casting `usize` to `u16` may truncate the value
181 --> tests/ui/cast_size.rs:71:20
182 |
183LL | const N: u16 = M as u16;
184 | ^^^^^^^^
185 |
186 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
187
188error: literal out of range for `usize`
189 --> tests/ui/cast_size.rs:63:5
190 |
191LL | 9_999_999_999_999_999usize as f64;
192 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
193 |
194 = note: the literal `9_999_999_999_999_999usize` does not fit into the type `usize` whose range is `0..=4294967295`
195 = note: `#[deny(overflowing_literals)]` on by default
196
197error: aborting due to 20 previous errors
198
src/tools/clippy/tests/ui/cast_size.64bit.stderr deleted-189
......@@ -1,189 +0,0 @@
1error: casting `isize` to `i8` may truncate the value
2 --> tests/ui/cast_size.rs:17:5
3 |
4LL | 1isize as i8;
5 | ^^^^^^^^^^^^
6 |
7 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
8 = note: `-D clippy::cast-possible-truncation` implied by `-D warnings`
9 = help: to override `-D warnings` add `#[allow(clippy::cast_possible_truncation)]`
10help: ... or use `try_from` and handle the error accordingly
11 |
12LL - 1isize as i8;
13LL + i8::try_from(1isize);
14 |
15
16error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
17 --> tests/ui/cast_size.rs:24:5
18 |
19LL | x0 as f32;
20 | ^^^^^^^^^
21 |
22 = note: `-D clippy::cast-precision-loss` implied by `-D warnings`
23 = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]`
24
25error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
26 --> tests/ui/cast_size.rs:26:5
27 |
28LL | x1 as f32;
29 | ^^^^^^^^^
30
31error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
32 --> tests/ui/cast_size.rs:28:5
33 |
34LL | x0 as f64;
35 | ^^^^^^^^^
36
37error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
38 --> tests/ui/cast_size.rs:30:5
39 |
40LL | x1 as f64;
41 | ^^^^^^^^^
42
43error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers
44 --> tests/ui/cast_size.rs:35:5
45 |
46LL | 1isize as i32;
47 | ^^^^^^^^^^^^^
48 |
49 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
50help: ... or use `try_from` and handle the error accordingly
51 |
52LL - 1isize as i32;
53LL + i32::try_from(1isize);
54 |
55
56error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers
57 --> tests/ui/cast_size.rs:37:5
58 |
59LL | 1isize as u32;
60 | ^^^^^^^^^^^^^
61 |
62 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
63help: ... or use `try_from` and handle the error accordingly
64 |
65LL - 1isize as u32;
66LL + u32::try_from(1isize);
67 |
68
69error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers
70 --> tests/ui/cast_size.rs:39:5
71 |
72LL | 1usize as u32;
73 | ^^^^^^^^^^^^^
74 |
75 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
76help: ... or use `try_from` and handle the error accordingly
77 |
78LL - 1usize as u32;
79LL + u32::try_from(1usize);
80 |
81
82error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers
83 --> tests/ui/cast_size.rs:41:5
84 |
85LL | 1usize as i32;
86 | ^^^^^^^^^^^^^
87 |
88 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
89help: ... or use `try_from` and handle the error accordingly
90 |
91LL - 1usize as i32;
92LL + i32::try_from(1usize);
93 |
94
95error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers
96 --> tests/ui/cast_size.rs:41:5
97 |
98LL | 1usize as i32;
99 | ^^^^^^^^^^^^^
100 |
101 = note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
102 = help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]`
103
104error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers
105 --> tests/ui/cast_size.rs:44:5
106 |
107LL | 1i64 as isize;
108 | ^^^^^^^^^^^^^
109 |
110 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
111help: ... or use `try_from` and handle the error accordingly
112 |
113LL - 1i64 as isize;
114LL + isize::try_from(1i64);
115 |
116
117error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers
118 --> tests/ui/cast_size.rs:46:5
119 |
120LL | 1i64 as usize;
121 | ^^^^^^^^^^^^^
122 |
123 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
124help: ... or use `try_from` and handle the error accordingly
125 |
126LL - 1i64 as usize;
127LL + usize::try_from(1i64);
128 |
129
130error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers
131 --> tests/ui/cast_size.rs:48:5
132 |
133LL | 1u64 as isize;
134 | ^^^^^^^^^^^^^
135 |
136 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
137help: ... or use `try_from` and handle the error accordingly
138 |
139LL - 1u64 as isize;
140LL + isize::try_from(1u64);
141 |
142
143error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers
144 --> tests/ui/cast_size.rs:48:5
145 |
146LL | 1u64 as isize;
147 | ^^^^^^^^^^^^^
148
149error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
150 --> tests/ui/cast_size.rs:51:5
151 |
152LL | 1u64 as usize;
153 | ^^^^^^^^^^^^^
154 |
155 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
156help: ... or use `try_from` and handle the error accordingly
157 |
158LL - 1u64 as usize;
159LL + usize::try_from(1u64);
160 |
161
162error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers
163 --> tests/ui/cast_size.rs:53:5
164 |
165LL | 1u32 as isize;
166 | ^^^^^^^^^^^^^
167
168error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
169 --> tests/ui/cast_size.rs:61:5
170 |
171LL | 999_999_999 as f32;
172 | ^^^^^^^^^^^^^^^^^^
173
174error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
175 --> tests/ui/cast_size.rs:63:5
176 |
177LL | 9_999_999_999_999_999usize as f64;
178 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
179
180error: casting `usize` to `u16` may truncate the value
181 --> tests/ui/cast_size.rs:71:20
182 |
183LL | const N: u16 = M as u16;
184 | ^^^^^^^^
185 |
186 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
187
188error: aborting due to 19 previous errors
189
src/tools/clippy/tests/ui/cast_size.r32bit.stderr created+198
......@@ -0,0 +1,198 @@
1error: casting `isize` to `i8` may truncate the value
2 --> tests/ui/cast_size.rs:17:5
3 |
4LL | 1isize as i8;
5 | ^^^^^^^^^^^^
6 |
7 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
8 = note: `-D clippy::cast-possible-truncation` implied by `-D warnings`
9 = help: to override `-D warnings` add `#[allow(clippy::cast_possible_truncation)]`
10help: ... or use `try_from` and handle the error accordingly
11 |
12LL - 1isize as i8;
13LL + i8::try_from(1isize);
14 |
15
16error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
17 --> tests/ui/cast_size.rs:24:5
18 |
19LL | x0 as f32;
20 | ^^^^^^^^^
21 |
22 = note: `-D clippy::cast-precision-loss` implied by `-D warnings`
23 = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]`
24
25error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
26 --> tests/ui/cast_size.rs:26:5
27 |
28LL | x1 as f32;
29 | ^^^^^^^^^
30
31error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
32 --> tests/ui/cast_size.rs:28:5
33 |
34LL | x0 as f64;
35 | ^^^^^^^^^
36
37error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
38 --> tests/ui/cast_size.rs:30:5
39 |
40LL | x1 as f64;
41 | ^^^^^^^^^
42
43error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers
44 --> tests/ui/cast_size.rs:35:5
45 |
46LL | 1isize as i32;
47 | ^^^^^^^^^^^^^
48 |
49 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
50help: ... or use `try_from` and handle the error accordingly
51 |
52LL - 1isize as i32;
53LL + i32::try_from(1isize);
54 |
55
56error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers
57 --> tests/ui/cast_size.rs:37:5
58 |
59LL | 1isize as u32;
60 | ^^^^^^^^^^^^^
61 |
62 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
63help: ... or use `try_from` and handle the error accordingly
64 |
65LL - 1isize as u32;
66LL + u32::try_from(1isize);
67 |
68
69error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers
70 --> tests/ui/cast_size.rs:39:5
71 |
72LL | 1usize as u32;
73 | ^^^^^^^^^^^^^
74 |
75 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
76help: ... or use `try_from` and handle the error accordingly
77 |
78LL - 1usize as u32;
79LL + u32::try_from(1usize);
80 |
81
82error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers
83 --> tests/ui/cast_size.rs:41:5
84 |
85LL | 1usize as i32;
86 | ^^^^^^^^^^^^^
87 |
88 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
89help: ... or use `try_from` and handle the error accordingly
90 |
91LL - 1usize as i32;
92LL + i32::try_from(1usize);
93 |
94
95error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers
96 --> tests/ui/cast_size.rs:41:5
97 |
98LL | 1usize as i32;
99 | ^^^^^^^^^^^^^
100 |
101 = note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
102 = help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]`
103
104error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers
105 --> tests/ui/cast_size.rs:44:5
106 |
107LL | 1i64 as isize;
108 | ^^^^^^^^^^^^^
109 |
110 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
111help: ... or use `try_from` and handle the error accordingly
112 |
113LL - 1i64 as isize;
114LL + isize::try_from(1i64);
115 |
116
117error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers
118 --> tests/ui/cast_size.rs:46:5
119 |
120LL | 1i64 as usize;
121 | ^^^^^^^^^^^^^
122 |
123 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
124help: ... or use `try_from` and handle the error accordingly
125 |
126LL - 1i64 as usize;
127LL + usize::try_from(1i64);
128 |
129
130error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers
131 --> tests/ui/cast_size.rs:48:5
132 |
133LL | 1u64 as isize;
134 | ^^^^^^^^^^^^^
135 |
136 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
137help: ... or use `try_from` and handle the error accordingly
138 |
139LL - 1u64 as isize;
140LL + isize::try_from(1u64);
141 |
142
143error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers
144 --> tests/ui/cast_size.rs:48:5
145 |
146LL | 1u64 as isize;
147 | ^^^^^^^^^^^^^
148
149error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
150 --> tests/ui/cast_size.rs:51:5
151 |
152LL | 1u64 as usize;
153 | ^^^^^^^^^^^^^
154 |
155 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
156help: ... or use `try_from` and handle the error accordingly
157 |
158LL - 1u64 as usize;
159LL + usize::try_from(1u64);
160 |
161
162error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers
163 --> tests/ui/cast_size.rs:53:5
164 |
165LL | 1u32 as isize;
166 | ^^^^^^^^^^^^^
167
168error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
169 --> tests/ui/cast_size.rs:61:5
170 |
171LL | 999_999_999 as f32;
172 | ^^^^^^^^^^^^^^^^^^
173
174error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
175 --> tests/ui/cast_size.rs:63:5
176 |
177LL | 9_999_999_999_999_999usize as f64;
178 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
179
180error: casting `usize` to `u16` may truncate the value
181 --> tests/ui/cast_size.rs:71:20
182 |
183LL | const N: u16 = M as u16;
184 | ^^^^^^^^
185 |
186 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
187
188error: literal out of range for `usize`
189 --> tests/ui/cast_size.rs:63:5
190 |
191LL | 9_999_999_999_999_999usize as f64;
192 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
193 |
194 = note: the literal `9_999_999_999_999_999usize` does not fit into the type `usize` whose range is `0..=4294967295`
195 = note: `#[deny(overflowing_literals)]` on by default
196
197error: aborting due to 20 previous errors
198
src/tools/clippy/tests/ui/cast_size.r64bit.stderr created+189
......@@ -0,0 +1,189 @@
1error: casting `isize` to `i8` may truncate the value
2 --> tests/ui/cast_size.rs:17:5
3 |
4LL | 1isize as i8;
5 | ^^^^^^^^^^^^
6 |
7 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
8 = note: `-D clippy::cast-possible-truncation` implied by `-D warnings`
9 = help: to override `-D warnings` add `#[allow(clippy::cast_possible_truncation)]`
10help: ... or use `try_from` and handle the error accordingly
11 |
12LL - 1isize as i8;
13LL + i8::try_from(1isize);
14 |
15
16error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
17 --> tests/ui/cast_size.rs:24:5
18 |
19LL | x0 as f32;
20 | ^^^^^^^^^
21 |
22 = note: `-D clippy::cast-precision-loss` implied by `-D warnings`
23 = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]`
24
25error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
26 --> tests/ui/cast_size.rs:26:5
27 |
28LL | x1 as f32;
29 | ^^^^^^^^^
30
31error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
32 --> tests/ui/cast_size.rs:28:5
33 |
34LL | x0 as f64;
35 | ^^^^^^^^^
36
37error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
38 --> tests/ui/cast_size.rs:30:5
39 |
40LL | x1 as f64;
41 | ^^^^^^^^^
42
43error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers
44 --> tests/ui/cast_size.rs:35:5
45 |
46LL | 1isize as i32;
47 | ^^^^^^^^^^^^^
48 |
49 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
50help: ... or use `try_from` and handle the error accordingly
51 |
52LL - 1isize as i32;
53LL + i32::try_from(1isize);
54 |
55
56error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers
57 --> tests/ui/cast_size.rs:37:5
58 |
59LL | 1isize as u32;
60 | ^^^^^^^^^^^^^
61 |
62 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
63help: ... or use `try_from` and handle the error accordingly
64 |
65LL - 1isize as u32;
66LL + u32::try_from(1isize);
67 |
68
69error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers
70 --> tests/ui/cast_size.rs:39:5
71 |
72LL | 1usize as u32;
73 | ^^^^^^^^^^^^^
74 |
75 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
76help: ... or use `try_from` and handle the error accordingly
77 |
78LL - 1usize as u32;
79LL + u32::try_from(1usize);
80 |
81
82error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers
83 --> tests/ui/cast_size.rs:41:5
84 |
85LL | 1usize as i32;
86 | ^^^^^^^^^^^^^
87 |
88 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
89help: ... or use `try_from` and handle the error accordingly
90 |
91LL - 1usize as i32;
92LL + i32::try_from(1usize);
93 |
94
95error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers
96 --> tests/ui/cast_size.rs:41:5
97 |
98LL | 1usize as i32;
99 | ^^^^^^^^^^^^^
100 |
101 = note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
102 = help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]`
103
104error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers
105 --> tests/ui/cast_size.rs:44:5
106 |
107LL | 1i64 as isize;
108 | ^^^^^^^^^^^^^
109 |
110 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
111help: ... or use `try_from` and handle the error accordingly
112 |
113LL - 1i64 as isize;
114LL + isize::try_from(1i64);
115 |
116
117error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers
118 --> tests/ui/cast_size.rs:46:5
119 |
120LL | 1i64 as usize;
121 | ^^^^^^^^^^^^^
122 |
123 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
124help: ... or use `try_from` and handle the error accordingly
125 |
126LL - 1i64 as usize;
127LL + usize::try_from(1i64);
128 |
129
130error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers
131 --> tests/ui/cast_size.rs:48:5
132 |
133LL | 1u64 as isize;
134 | ^^^^^^^^^^^^^
135 |
136 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
137help: ... or use `try_from` and handle the error accordingly
138 |
139LL - 1u64 as isize;
140LL + isize::try_from(1u64);
141 |
142
143error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers
144 --> tests/ui/cast_size.rs:48:5
145 |
146LL | 1u64 as isize;
147 | ^^^^^^^^^^^^^
148
149error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
150 --> tests/ui/cast_size.rs:51:5
151 |
152LL | 1u64 as usize;
153 | ^^^^^^^^^^^^^
154 |
155 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
156help: ... or use `try_from` and handle the error accordingly
157 |
158LL - 1u64 as usize;
159LL + usize::try_from(1u64);
160 |
161
162error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers
163 --> tests/ui/cast_size.rs:53:5
164 |
165LL | 1u32 as isize;
166 | ^^^^^^^^^^^^^
167
168error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
169 --> tests/ui/cast_size.rs:61:5
170 |
171LL | 999_999_999 as f32;
172 | ^^^^^^^^^^^^^^^^^^
173
174error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
175 --> tests/ui/cast_size.rs:63:5
176 |
177LL | 9_999_999_999_999_999usize as f64;
178 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
179
180error: casting `usize` to `u16` may truncate the value
181 --> tests/ui/cast_size.rs:71:20
182 |
183LL | const N: u16 = M as u16;
184 | ^^^^^^^^
185 |
186 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
187
188error: aborting due to 19 previous errors
189
src/tools/clippy/tests/ui/cast_size.rs+4-4
......@@ -1,6 +1,6 @@
1//@revisions: 32bit 64bit
2//@[32bit]ignore-bitwidth: 64
3//@[64bit]ignore-bitwidth: 32
1//@revisions: r32bit r64bit
2//@[r32bit]ignore-bitwidth: 64
3//@[r64bit]ignore-bitwidth: 32
44//@no-rustfix: only some diagnostics have suggestions
55
66#![warn(
......@@ -62,7 +62,7 @@ fn main() {
6262 //~^ cast_precision_loss
6363 9_999_999_999_999_999usize as f64;
6464 //~^ cast_precision_loss
65 //~[32bit]^^ ERROR: literal out of range for `usize`
65 //~[r32bit]^^ ERROR: literal out of range for `usize`
6666 // 999_999_999_999_999_999_999_999_999_999u128 as f128;
6767}
6868
src/tools/clippy/tests/ui/fn_to_numeric_cast.32bit.stderr deleted-146
......@@ -1,146 +0,0 @@
1error: casting function pointer `foo` to `i8`, which truncates the value
2 --> tests/ui/fn_to_numeric_cast.rs:13:13
3 |
4LL | let _ = foo as i8;
5 | ^^^^^^^^^ help: try: `foo as usize`
6 |
7 = note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings`
8 = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_with_truncation)]`
9
10error: casting function pointer `foo` to `i16`, which truncates the value
11 --> tests/ui/fn_to_numeric_cast.rs:15:13
12 |
13LL | let _ = foo as i16;
14 | ^^^^^^^^^^ help: try: `foo as usize`
15
16error: casting function pointer `foo` to `i32`
17 --> tests/ui/fn_to_numeric_cast.rs:17:13
18 |
19LL | let _ = foo as i32;
20 | ^^^^^^^^^^ help: try: `foo as usize`
21 |
22 = note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings`
23 = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast)]`
24
25error: casting function pointer `foo` to `i64`
26 --> tests/ui/fn_to_numeric_cast.rs:20:13
27 |
28LL | let _ = foo as i64;
29 | ^^^^^^^^^^ help: try: `foo as usize`
30
31error: casting function pointer `foo` to `i128`
32 --> tests/ui/fn_to_numeric_cast.rs:22:13
33 |
34LL | let _ = foo as i128;
35 | ^^^^^^^^^^^ help: try: `foo as usize`
36
37error: casting function pointer `foo` to `isize`
38 --> tests/ui/fn_to_numeric_cast.rs:24:13
39 |
40LL | let _ = foo as isize;
41 | ^^^^^^^^^^^^ help: try: `foo as usize`
42
43error: casting function pointer `foo` to `u8`, which truncates the value
44 --> tests/ui/fn_to_numeric_cast.rs:27:13
45 |
46LL | let _ = foo as u8;
47 | ^^^^^^^^^ help: try: `foo as usize`
48
49error: casting function pointer `foo` to `u16`, which truncates the value
50 --> tests/ui/fn_to_numeric_cast.rs:29:13
51 |
52LL | let _ = foo as u16;
53 | ^^^^^^^^^^ help: try: `foo as usize`
54
55error: casting function pointer `foo` to `u32`
56 --> tests/ui/fn_to_numeric_cast.rs:31:13
57 |
58LL | let _ = foo as u32;
59 | ^^^^^^^^^^ help: try: `foo as usize`
60
61error: casting function pointer `foo` to `u64`
62 --> tests/ui/fn_to_numeric_cast.rs:34:13
63 |
64LL | let _ = foo as u64;
65 | ^^^^^^^^^^ help: try: `foo as usize`
66
67error: casting function pointer `foo` to `u128`
68 --> tests/ui/fn_to_numeric_cast.rs:36:13
69 |
70LL | let _ = foo as u128;
71 | ^^^^^^^^^^^ help: try: `foo as usize`
72
73error: casting function pointer `abc` to `i8`, which truncates the value
74 --> tests/ui/fn_to_numeric_cast.rs:50:13
75 |
76LL | let _ = abc as i8;
77 | ^^^^^^^^^ help: try: `abc as usize`
78
79error: casting function pointer `abc` to `i16`, which truncates the value
80 --> tests/ui/fn_to_numeric_cast.rs:52:13
81 |
82LL | let _ = abc as i16;
83 | ^^^^^^^^^^ help: try: `abc as usize`
84
85error: casting function pointer `abc` to `i32`
86 --> tests/ui/fn_to_numeric_cast.rs:54:13
87 |
88LL | let _ = abc as i32;
89 | ^^^^^^^^^^ help: try: `abc as usize`
90
91error: casting function pointer `abc` to `i64`
92 --> tests/ui/fn_to_numeric_cast.rs:57:13
93 |
94LL | let _ = abc as i64;
95 | ^^^^^^^^^^ help: try: `abc as usize`
96
97error: casting function pointer `abc` to `i128`
98 --> tests/ui/fn_to_numeric_cast.rs:59:13
99 |
100LL | let _ = abc as i128;
101 | ^^^^^^^^^^^ help: try: `abc as usize`
102
103error: casting function pointer `abc` to `isize`
104 --> tests/ui/fn_to_numeric_cast.rs:61:13
105 |
106LL | let _ = abc as isize;
107 | ^^^^^^^^^^^^ help: try: `abc as usize`
108
109error: casting function pointer `abc` to `u8`, which truncates the value
110 --> tests/ui/fn_to_numeric_cast.rs:64:13
111 |
112LL | let _ = abc as u8;
113 | ^^^^^^^^^ help: try: `abc as usize`
114
115error: casting function pointer `abc` to `u16`, which truncates the value
116 --> tests/ui/fn_to_numeric_cast.rs:66:13
117 |
118LL | let _ = abc as u16;
119 | ^^^^^^^^^^ help: try: `abc as usize`
120
121error: casting function pointer `abc` to `u32`
122 --> tests/ui/fn_to_numeric_cast.rs:68:13
123 |
124LL | let _ = abc as u32;
125 | ^^^^^^^^^^ help: try: `abc as usize`
126
127error: casting function pointer `abc` to `u64`
128 --> tests/ui/fn_to_numeric_cast.rs:71:13
129 |
130LL | let _ = abc as u64;
131 | ^^^^^^^^^^ help: try: `abc as usize`
132
133error: casting function pointer `abc` to `u128`
134 --> tests/ui/fn_to_numeric_cast.rs:73:13
135 |
136LL | let _ = abc as u128;
137 | ^^^^^^^^^^^ help: try: `abc as usize`
138
139error: casting function pointer `f` to `i32`
140 --> tests/ui/fn_to_numeric_cast.rs:81:5
141 |
142LL | f as i32
143 | ^^^^^^^^ help: try: `f as usize`
144
145error: aborting due to 23 previous errors
146
src/tools/clippy/tests/ui/fn_to_numeric_cast.64bit.stderr deleted-146
......@@ -1,146 +0,0 @@
1error: casting function pointer `foo` to `i8`, which truncates the value
2 --> tests/ui/fn_to_numeric_cast.rs:13:13
3 |
4LL | let _ = foo as i8;
5 | ^^^^^^^^^ help: try: `foo as usize`
6 |
7 = note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings`
8 = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_with_truncation)]`
9
10error: casting function pointer `foo` to `i16`, which truncates the value
11 --> tests/ui/fn_to_numeric_cast.rs:15:13
12 |
13LL | let _ = foo as i16;
14 | ^^^^^^^^^^ help: try: `foo as usize`
15
16error: casting function pointer `foo` to `i32`, which truncates the value
17 --> tests/ui/fn_to_numeric_cast.rs:17:13
18 |
19LL | let _ = foo as i32;
20 | ^^^^^^^^^^ help: try: `foo as usize`
21
22error: casting function pointer `foo` to `i64`
23 --> tests/ui/fn_to_numeric_cast.rs:20:13
24 |
25LL | let _ = foo as i64;
26 | ^^^^^^^^^^ help: try: `foo as usize`
27 |
28 = note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings`
29 = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast)]`
30
31error: casting function pointer `foo` to `i128`
32 --> tests/ui/fn_to_numeric_cast.rs:22:13
33 |
34LL | let _ = foo as i128;
35 | ^^^^^^^^^^^ help: try: `foo as usize`
36
37error: casting function pointer `foo` to `isize`
38 --> tests/ui/fn_to_numeric_cast.rs:24:13
39 |
40LL | let _ = foo as isize;
41 | ^^^^^^^^^^^^ help: try: `foo as usize`
42
43error: casting function pointer `foo` to `u8`, which truncates the value
44 --> tests/ui/fn_to_numeric_cast.rs:27:13
45 |
46LL | let _ = foo as u8;
47 | ^^^^^^^^^ help: try: `foo as usize`
48
49error: casting function pointer `foo` to `u16`, which truncates the value
50 --> tests/ui/fn_to_numeric_cast.rs:29:13
51 |
52LL | let _ = foo as u16;
53 | ^^^^^^^^^^ help: try: `foo as usize`
54
55error: casting function pointer `foo` to `u32`, which truncates the value
56 --> tests/ui/fn_to_numeric_cast.rs:31:13
57 |
58LL | let _ = foo as u32;
59 | ^^^^^^^^^^ help: try: `foo as usize`
60
61error: casting function pointer `foo` to `u64`
62 --> tests/ui/fn_to_numeric_cast.rs:34:13
63 |
64LL | let _ = foo as u64;
65 | ^^^^^^^^^^ help: try: `foo as usize`
66
67error: casting function pointer `foo` to `u128`
68 --> tests/ui/fn_to_numeric_cast.rs:36:13
69 |
70LL | let _ = foo as u128;
71 | ^^^^^^^^^^^ help: try: `foo as usize`
72
73error: casting function pointer `abc` to `i8`, which truncates the value
74 --> tests/ui/fn_to_numeric_cast.rs:50:13
75 |
76LL | let _ = abc as i8;
77 | ^^^^^^^^^ help: try: `abc as usize`
78
79error: casting function pointer `abc` to `i16`, which truncates the value
80 --> tests/ui/fn_to_numeric_cast.rs:52:13
81 |
82LL | let _ = abc as i16;
83 | ^^^^^^^^^^ help: try: `abc as usize`
84
85error: casting function pointer `abc` to `i32`, which truncates the value
86 --> tests/ui/fn_to_numeric_cast.rs:54:13
87 |
88LL | let _ = abc as i32;
89 | ^^^^^^^^^^ help: try: `abc as usize`
90
91error: casting function pointer `abc` to `i64`
92 --> tests/ui/fn_to_numeric_cast.rs:57:13
93 |
94LL | let _ = abc as i64;
95 | ^^^^^^^^^^ help: try: `abc as usize`
96
97error: casting function pointer `abc` to `i128`
98 --> tests/ui/fn_to_numeric_cast.rs:59:13
99 |
100LL | let _ = abc as i128;
101 | ^^^^^^^^^^^ help: try: `abc as usize`
102
103error: casting function pointer `abc` to `isize`
104 --> tests/ui/fn_to_numeric_cast.rs:61:13
105 |
106LL | let _ = abc as isize;
107 | ^^^^^^^^^^^^ help: try: `abc as usize`
108
109error: casting function pointer `abc` to `u8`, which truncates the value
110 --> tests/ui/fn_to_numeric_cast.rs:64:13
111 |
112LL | let _ = abc as u8;
113 | ^^^^^^^^^ help: try: `abc as usize`
114
115error: casting function pointer `abc` to `u16`, which truncates the value
116 --> tests/ui/fn_to_numeric_cast.rs:66:13
117 |
118LL | let _ = abc as u16;
119 | ^^^^^^^^^^ help: try: `abc as usize`
120
121error: casting function pointer `abc` to `u32`, which truncates the value
122 --> tests/ui/fn_to_numeric_cast.rs:68:13
123 |
124LL | let _ = abc as u32;
125 | ^^^^^^^^^^ help: try: `abc as usize`
126
127error: casting function pointer `abc` to `u64`
128 --> tests/ui/fn_to_numeric_cast.rs:71:13
129 |
130LL | let _ = abc as u64;
131 | ^^^^^^^^^^ help: try: `abc as usize`
132
133error: casting function pointer `abc` to `u128`
134 --> tests/ui/fn_to_numeric_cast.rs:73:13
135 |
136LL | let _ = abc as u128;
137 | ^^^^^^^^^^^ help: try: `abc as usize`
138
139error: casting function pointer `f` to `i32`, which truncates the value
140 --> tests/ui/fn_to_numeric_cast.rs:81:5
141 |
142LL | f as i32
143 | ^^^^^^^^ help: try: `f as usize`
144
145error: aborting due to 23 previous errors
146
src/tools/clippy/tests/ui/fn_to_numeric_cast.r32bit.stderr created+146
......@@ -0,0 +1,146 @@
1error: casting function pointer `foo` to `i8`, which truncates the value
2 --> tests/ui/fn_to_numeric_cast.rs:13:13
3 |
4LL | let _ = foo as i8;
5 | ^^^^^^^^^ help: try: `foo as usize`
6 |
7 = note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings`
8 = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_with_truncation)]`
9
10error: casting function pointer `foo` to `i16`, which truncates the value
11 --> tests/ui/fn_to_numeric_cast.rs:15:13
12 |
13LL | let _ = foo as i16;
14 | ^^^^^^^^^^ help: try: `foo as usize`
15
16error: casting function pointer `foo` to `i32`
17 --> tests/ui/fn_to_numeric_cast.rs:17:13
18 |
19LL | let _ = foo as i32;
20 | ^^^^^^^^^^ help: try: `foo as usize`
21 |
22 = note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings`
23 = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast)]`
24
25error: casting function pointer `foo` to `i64`
26 --> tests/ui/fn_to_numeric_cast.rs:20:13
27 |
28LL | let _ = foo as i64;
29 | ^^^^^^^^^^ help: try: `foo as usize`
30
31error: casting function pointer `foo` to `i128`
32 --> tests/ui/fn_to_numeric_cast.rs:22:13
33 |
34LL | let _ = foo as i128;
35 | ^^^^^^^^^^^ help: try: `foo as usize`
36
37error: casting function pointer `foo` to `isize`
38 --> tests/ui/fn_to_numeric_cast.rs:24:13
39 |
40LL | let _ = foo as isize;
41 | ^^^^^^^^^^^^ help: try: `foo as usize`
42
43error: casting function pointer `foo` to `u8`, which truncates the value
44 --> tests/ui/fn_to_numeric_cast.rs:27:13
45 |
46LL | let _ = foo as u8;
47 | ^^^^^^^^^ help: try: `foo as usize`
48
49error: casting function pointer `foo` to `u16`, which truncates the value
50 --> tests/ui/fn_to_numeric_cast.rs:29:13
51 |
52LL | let _ = foo as u16;
53 | ^^^^^^^^^^ help: try: `foo as usize`
54
55error: casting function pointer `foo` to `u32`
56 --> tests/ui/fn_to_numeric_cast.rs:31:13
57 |
58LL | let _ = foo as u32;
59 | ^^^^^^^^^^ help: try: `foo as usize`
60
61error: casting function pointer `foo` to `u64`
62 --> tests/ui/fn_to_numeric_cast.rs:34:13
63 |
64LL | let _ = foo as u64;
65 | ^^^^^^^^^^ help: try: `foo as usize`
66
67error: casting function pointer `foo` to `u128`
68 --> tests/ui/fn_to_numeric_cast.rs:36:13
69 |
70LL | let _ = foo as u128;
71 | ^^^^^^^^^^^ help: try: `foo as usize`
72
73error: casting function pointer `abc` to `i8`, which truncates the value
74 --> tests/ui/fn_to_numeric_cast.rs:50:13
75 |
76LL | let _ = abc as i8;
77 | ^^^^^^^^^ help: try: `abc as usize`
78
79error: casting function pointer `abc` to `i16`, which truncates the value
80 --> tests/ui/fn_to_numeric_cast.rs:52:13
81 |
82LL | let _ = abc as i16;
83 | ^^^^^^^^^^ help: try: `abc as usize`
84
85error: casting function pointer `abc` to `i32`
86 --> tests/ui/fn_to_numeric_cast.rs:54:13
87 |
88LL | let _ = abc as i32;
89 | ^^^^^^^^^^ help: try: `abc as usize`
90
91error: casting function pointer `abc` to `i64`
92 --> tests/ui/fn_to_numeric_cast.rs:57:13
93 |
94LL | let _ = abc as i64;
95 | ^^^^^^^^^^ help: try: `abc as usize`
96
97error: casting function pointer `abc` to `i128`
98 --> tests/ui/fn_to_numeric_cast.rs:59:13
99 |
100LL | let _ = abc as i128;
101 | ^^^^^^^^^^^ help: try: `abc as usize`
102
103error: casting function pointer `abc` to `isize`
104 --> tests/ui/fn_to_numeric_cast.rs:61:13
105 |
106LL | let _ = abc as isize;
107 | ^^^^^^^^^^^^ help: try: `abc as usize`
108
109error: casting function pointer `abc` to `u8`, which truncates the value
110 --> tests/ui/fn_to_numeric_cast.rs:64:13
111 |
112LL | let _ = abc as u8;
113 | ^^^^^^^^^ help: try: `abc as usize`
114
115error: casting function pointer `abc` to `u16`, which truncates the value
116 --> tests/ui/fn_to_numeric_cast.rs:66:13
117 |
118LL | let _ = abc as u16;
119 | ^^^^^^^^^^ help: try: `abc as usize`
120
121error: casting function pointer `abc` to `u32`
122 --> tests/ui/fn_to_numeric_cast.rs:68:13
123 |
124LL | let _ = abc as u32;
125 | ^^^^^^^^^^ help: try: `abc as usize`
126
127error: casting function pointer `abc` to `u64`
128 --> tests/ui/fn_to_numeric_cast.rs:71:13
129 |
130LL | let _ = abc as u64;
131 | ^^^^^^^^^^ help: try: `abc as usize`
132
133error: casting function pointer `abc` to `u128`
134 --> tests/ui/fn_to_numeric_cast.rs:73:13
135 |
136LL | let _ = abc as u128;
137 | ^^^^^^^^^^^ help: try: `abc as usize`
138
139error: casting function pointer `f` to `i32`
140 --> tests/ui/fn_to_numeric_cast.rs:81:5
141 |
142LL | f as i32
143 | ^^^^^^^^ help: try: `f as usize`
144
145error: aborting due to 23 previous errors
146
src/tools/clippy/tests/ui/fn_to_numeric_cast.r64bit.stderr created+146
......@@ -0,0 +1,146 @@
1error: casting function pointer `foo` to `i8`, which truncates the value
2 --> tests/ui/fn_to_numeric_cast.rs:13:13
3 |
4LL | let _ = foo as i8;
5 | ^^^^^^^^^ help: try: `foo as usize`
6 |
7 = note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings`
8 = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_with_truncation)]`
9
10error: casting function pointer `foo` to `i16`, which truncates the value
11 --> tests/ui/fn_to_numeric_cast.rs:15:13
12 |
13LL | let _ = foo as i16;
14 | ^^^^^^^^^^ help: try: `foo as usize`
15
16error: casting function pointer `foo` to `i32`, which truncates the value
17 --> tests/ui/fn_to_numeric_cast.rs:17:13
18 |
19LL | let _ = foo as i32;
20 | ^^^^^^^^^^ help: try: `foo as usize`
21
22error: casting function pointer `foo` to `i64`
23 --> tests/ui/fn_to_numeric_cast.rs:20:13
24 |
25LL | let _ = foo as i64;
26 | ^^^^^^^^^^ help: try: `foo as usize`
27 |
28 = note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings`
29 = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast)]`
30
31error: casting function pointer `foo` to `i128`
32 --> tests/ui/fn_to_numeric_cast.rs:22:13
33 |
34LL | let _ = foo as i128;
35 | ^^^^^^^^^^^ help: try: `foo as usize`
36
37error: casting function pointer `foo` to `isize`
38 --> tests/ui/fn_to_numeric_cast.rs:24:13
39 |
40LL | let _ = foo as isize;
41 | ^^^^^^^^^^^^ help: try: `foo as usize`
42
43error: casting function pointer `foo` to `u8`, which truncates the value
44 --> tests/ui/fn_to_numeric_cast.rs:27:13
45 |
46LL | let _ = foo as u8;
47 | ^^^^^^^^^ help: try: `foo as usize`
48
49error: casting function pointer `foo` to `u16`, which truncates the value
50 --> tests/ui/fn_to_numeric_cast.rs:29:13
51 |
52LL | let _ = foo as u16;
53 | ^^^^^^^^^^ help: try: `foo as usize`
54
55error: casting function pointer `foo` to `u32`, which truncates the value
56 --> tests/ui/fn_to_numeric_cast.rs:31:13
57 |
58LL | let _ = foo as u32;
59 | ^^^^^^^^^^ help: try: `foo as usize`
60
61error: casting function pointer `foo` to `u64`
62 --> tests/ui/fn_to_numeric_cast.rs:34:13
63 |
64LL | let _ = foo as u64;
65 | ^^^^^^^^^^ help: try: `foo as usize`
66
67error: casting function pointer `foo` to `u128`
68 --> tests/ui/fn_to_numeric_cast.rs:36:13
69 |
70LL | let _ = foo as u128;
71 | ^^^^^^^^^^^ help: try: `foo as usize`
72
73error: casting function pointer `abc` to `i8`, which truncates the value
74 --> tests/ui/fn_to_numeric_cast.rs:50:13
75 |
76LL | let _ = abc as i8;
77 | ^^^^^^^^^ help: try: `abc as usize`
78
79error: casting function pointer `abc` to `i16`, which truncates the value
80 --> tests/ui/fn_to_numeric_cast.rs:52:13
81 |
82LL | let _ = abc as i16;
83 | ^^^^^^^^^^ help: try: `abc as usize`
84
85error: casting function pointer `abc` to `i32`, which truncates the value
86 --> tests/ui/fn_to_numeric_cast.rs:54:13
87 |
88LL | let _ = abc as i32;
89 | ^^^^^^^^^^ help: try: `abc as usize`
90
91error: casting function pointer `abc` to `i64`
92 --> tests/ui/fn_to_numeric_cast.rs:57:13
93 |
94LL | let _ = abc as i64;
95 | ^^^^^^^^^^ help: try: `abc as usize`
96
97error: casting function pointer `abc` to `i128`
98 --> tests/ui/fn_to_numeric_cast.rs:59:13
99 |
100LL | let _ = abc as i128;
101 | ^^^^^^^^^^^ help: try: `abc as usize`
102
103error: casting function pointer `abc` to `isize`
104 --> tests/ui/fn_to_numeric_cast.rs:61:13
105 |
106LL | let _ = abc as isize;
107 | ^^^^^^^^^^^^ help: try: `abc as usize`
108
109error: casting function pointer `abc` to `u8`, which truncates the value
110 --> tests/ui/fn_to_numeric_cast.rs:64:13
111 |
112LL | let _ = abc as u8;
113 | ^^^^^^^^^ help: try: `abc as usize`
114
115error: casting function pointer `abc` to `u16`, which truncates the value
116 --> tests/ui/fn_to_numeric_cast.rs:66:13
117 |
118LL | let _ = abc as u16;
119 | ^^^^^^^^^^ help: try: `abc as usize`
120
121error: casting function pointer `abc` to `u32`, which truncates the value
122 --> tests/ui/fn_to_numeric_cast.rs:68:13
123 |
124LL | let _ = abc as u32;
125 | ^^^^^^^^^^ help: try: `abc as usize`
126
127error: casting function pointer `abc` to `u64`
128 --> tests/ui/fn_to_numeric_cast.rs:71:13
129 |
130LL | let _ = abc as u64;
131 | ^^^^^^^^^^ help: try: `abc as usize`
132
133error: casting function pointer `abc` to `u128`
134 --> tests/ui/fn_to_numeric_cast.rs:73:13
135 |
136LL | let _ = abc as u128;
137 | ^^^^^^^^^^^ help: try: `abc as usize`
138
139error: casting function pointer `f` to `i32`, which truncates the value
140 --> tests/ui/fn_to_numeric_cast.rs:81:5
141 |
142LL | f as i32
143 | ^^^^^^^^ help: try: `f as usize`
144
145error: aborting due to 23 previous errors
146
src/tools/clippy/tests/ui/fn_to_numeric_cast.rs+13-13
......@@ -1,6 +1,6 @@
1//@revisions: 32bit 64bit
2//@[32bit]ignore-bitwidth: 64
3//@[64bit]ignore-bitwidth: 32
1//@revisions: r32bit r64bit
2//@[r32bit]ignore-bitwidth: 64
3//@[r64bit]ignore-bitwidth: 32
44//@no-rustfix
55#![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)]
66#![allow(function_casts_as_integer)]
......@@ -15,8 +15,8 @@ fn test_function_to_numeric_cast() {
1515 let _ = foo as i16;
1616 //~^ fn_to_numeric_cast_with_truncation
1717 let _ = foo as i32;
18 //~[64bit]^ fn_to_numeric_cast_with_truncation
19 //~[32bit]^^ fn_to_numeric_cast
18 //~[r64bit]^ fn_to_numeric_cast_with_truncation
19 //~[r32bit]^^ fn_to_numeric_cast
2020 let _ = foo as i64;
2121 //~^ fn_to_numeric_cast
2222 let _ = foo as i128;
......@@ -29,8 +29,8 @@ fn test_function_to_numeric_cast() {
2929 let _ = foo as u16;
3030 //~^ fn_to_numeric_cast_with_truncation
3131 let _ = foo as u32;
32 //~[64bit]^ fn_to_numeric_cast_with_truncation
33 //~[32bit]^^ fn_to_numeric_cast
32 //~[r64bit]^ fn_to_numeric_cast_with_truncation
33 //~[r32bit]^^ fn_to_numeric_cast
3434 let _ = foo as u64;
3535 //~^ fn_to_numeric_cast
3636 let _ = foo as u128;
......@@ -52,8 +52,8 @@ fn test_function_var_to_numeric_cast() {
5252 let _ = abc as i16;
5353 //~^ fn_to_numeric_cast_with_truncation
5454 let _ = abc as i32;
55 //~[64bit]^ fn_to_numeric_cast_with_truncation
56 //~[32bit]^^ fn_to_numeric_cast
55 //~[r64bit]^ fn_to_numeric_cast_with_truncation
56 //~[r32bit]^^ fn_to_numeric_cast
5757 let _ = abc as i64;
5858 //~^ fn_to_numeric_cast
5959 let _ = abc as i128;
......@@ -66,8 +66,8 @@ fn test_function_var_to_numeric_cast() {
6666 let _ = abc as u16;
6767 //~^ fn_to_numeric_cast_with_truncation
6868 let _ = abc as u32;
69 //~[64bit]^ fn_to_numeric_cast_with_truncation
70 //~[32bit]^^ fn_to_numeric_cast
69 //~[r64bit]^ fn_to_numeric_cast_with_truncation
70 //~[r32bit]^^ fn_to_numeric_cast
7171 let _ = abc as u64;
7272 //~^ fn_to_numeric_cast
7373 let _ = abc as u128;
......@@ -79,8 +79,8 @@ fn test_function_var_to_numeric_cast() {
7979
8080fn fn_with_fn_args(f: fn(i32) -> i32) -> i32 {
8181 f as i32
82 //~[64bit]^ fn_to_numeric_cast_with_truncation
83 //~[32bit]^^ fn_to_numeric_cast
82 //~[r64bit]^ fn_to_numeric_cast_with_truncation
83 //~[r32bit]^^ fn_to_numeric_cast
8484}
8585
8686fn main() {}
src/tools/clippy/tests/ui/large_enum_variant.32bit.stderr deleted-345
......@@ -1,345 +0,0 @@
1error: large size difference between variants
2 --> tests/ui/large_enum_variant.rs:13:1
3 |
4LL | / enum LargeEnum {
5LL | |
6LL | | A(i32),
7 | | ------ the second-largest variant contains at least 4 bytes
8LL | | B([i32; 8000]),
9 | | -------------- the largest variant contains at least 32000 bytes
10LL | | }
11 | |_^ the entire enum is at least 32004 bytes
12 |
13 = note: `-D clippy::large-enum-variant` implied by `-D warnings`
14 = help: to override `-D warnings` add `#[allow(clippy::large_enum_variant)]`
15help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
16 |
17LL - B([i32; 8000]),
18LL + B(Box<[i32; 8000]>),
19 |
20
21error: large size difference between variants
22 --> tests/ui/large_enum_variant.rs:38:1
23 |
24LL | / enum LargeEnum2 {
25LL | |
26LL | | VariantOk(i32, u32),
27 | | ------------------- the second-largest variant contains at least 8 bytes
28LL | | ContainingLargeEnum(LargeEnum),
29 | | ------------------------------ the largest variant contains at least 32004 bytes
30LL | | }
31 | |_^ the entire enum is at least 32004 bytes
32 |
33help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
34 |
35LL - ContainingLargeEnum(LargeEnum),
36LL + ContainingLargeEnum(Box<LargeEnum>),
37 |
38
39error: large size difference between variants
40 --> tests/ui/large_enum_variant.rs:44:1
41 |
42LL | / enum LargeEnum3 {
43LL | |
44LL | | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]),
45 | | --------------------------------------------------------- the largest variant contains at least 70004 bytes
46LL | | VoidVariant,
47LL | | StructLikeLittle { x: i32, y: i32 },
48 | | ----------------------------------- the second-largest variant contains at least 8 bytes
49LL | | }
50 | |_^ the entire enum is at least 70008 bytes
51 |
52help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
53 |
54LL - ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]),
55LL + ContainingMoreThanOneField(i32, Box<[i32; 8000]>, Box<[i32; 9500]>),
56 |
57
58error: large size difference between variants
59 --> tests/ui/large_enum_variant.rs:51:1
60 |
61LL | / enum LargeEnum4 {
62LL | |
63LL | | VariantOk(i32, u32),
64 | | ------------------- the second-largest variant contains at least 8 bytes
65LL | | StructLikeLarge { x: [i32; 8000], y: i32 },
66 | | ------------------------------------------ the largest variant contains at least 32004 bytes
67LL | | }
68 | |_^ the entire enum is at least 32008 bytes
69 |
70help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
71 |
72LL - StructLikeLarge { x: [i32; 8000], y: i32 },
73LL + StructLikeLarge { x: Box<[i32; 8000]>, y: i32 },
74 |
75
76error: large size difference between variants
77 --> tests/ui/large_enum_variant.rs:57:1
78 |
79LL | / enum LargeEnum5 {
80LL | |
81LL | | VariantOk(i32, u32),
82 | | ------------------- the second-largest variant contains at least 8 bytes
83LL | | StructLikeLarge2 { x: [i32; 8000] },
84 | | ----------------------------------- the largest variant contains at least 32000 bytes
85LL | | }
86 | |_^ the entire enum is at least 32004 bytes
87 |
88help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
89 |
90LL - StructLikeLarge2 { x: [i32; 8000] },
91LL + StructLikeLarge2 { x: Box<[i32; 8000]> },
92 |
93
94error: large size difference between variants
95 --> tests/ui/large_enum_variant.rs:74:1
96 |
97LL | / enum LargeEnum7 {
98LL | |
99LL | | A,
100LL | | B([u8; 1255]),
101 | | ------------- the largest variant contains at least 1255 bytes
102LL | | C([u8; 200]),
103 | | ------------ the second-largest variant contains at least 200 bytes
104LL | | }
105 | |_^ the entire enum is at least 1256 bytes
106 |
107help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
108 |
109LL - B([u8; 1255]),
110LL + B(Box<[u8; 1255]>),
111 |
112
113error: large size difference between variants
114 --> tests/ui/large_enum_variant.rs:81:1
115 |
116LL | / enum LargeEnum8 {
117LL | |
118LL | | VariantOk(i32, u32),
119 | | ------------------- the second-largest variant contains at least 8 bytes
120LL | | ContainingMoreThanOneField([i32; 8000], [i32; 2], [i32; 9500], [i32; 30]),
121 | | ------------------------------------------------------------------------- the largest variant contains at least 70128 bytes
122LL | | }
123 | |_^ the entire enum is at least 70132 bytes
124 |
125help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
126 |
127LL - ContainingMoreThanOneField([i32; 8000], [i32; 2], [i32; 9500], [i32; 30]),
128LL + ContainingMoreThanOneField(Box<[i32; 8000]>, [i32; 2], Box<[i32; 9500]>, [i32; 30]),
129 |
130
131error: large size difference between variants
132 --> tests/ui/large_enum_variant.rs:87:1
133 |
134LL | / enum LargeEnum9 {
135LL | |
136LL | | A(Struct<()>),
137 | | ------------- the second-largest variant contains at least 4 bytes
138LL | | B(Struct2),
139 | | ---------- the largest variant contains at least 32000 bytes
140LL | | }
141 | |_^ the entire enum is at least 32004 bytes
142 |
143help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
144 |
145LL - B(Struct2),
146LL + B(Box<Struct2>),
147 |
148
149error: large size difference between variants
150 --> tests/ui/large_enum_variant.rs:93:1
151 |
152LL | / enum LargeEnumOk2<T> {
153LL | |
154LL | | A(T),
155 | | ---- the second-largest variant contains at least 0 bytes
156LL | | B(Struct2),
157 | | ---------- the largest variant contains at least 32000 bytes
158LL | | }
159 | |_^ the entire enum is at least 32000 bytes
160 |
161help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
162 |
163LL - B(Struct2),
164LL + B(Box<Struct2>),
165 |
166
167error: large size difference between variants
168 --> tests/ui/large_enum_variant.rs:99:1
169 |
170LL | / enum LargeEnumOk3<T> {
171LL | |
172LL | | A(Struct<T>),
173 | | ------------ the second-largest variant contains at least 4 bytes
174LL | | B(Struct2),
175 | | ---------- the largest variant contains at least 32000 bytes
176LL | | }
177 | |_^ the entire enum is at least 32000 bytes
178 |
179help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
180 |
181LL - B(Struct2),
182LL + B(Box<Struct2>),
183 |
184
185error: large size difference between variants
186 --> tests/ui/large_enum_variant.rs:115:1
187 |
188LL | / enum CopyableLargeEnum {
189LL | |
190LL | | A(bool),
191 | | ------- the second-largest variant contains at least 1 bytes
192LL | | B([u64; 8000]),
193 | | -------------- the largest variant contains at least 64000 bytes
194LL | | }
195 | |_^ the entire enum is at least 64004 bytes
196 |
197note: boxing a variant would require the type no longer be `Copy`
198 --> tests/ui/large_enum_variant.rs:115:6
199 |
200LL | enum CopyableLargeEnum {
201 | ^^^^^^^^^^^^^^^^^
202help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
203 --> tests/ui/large_enum_variant.rs:118:5
204 |
205LL | B([u64; 8000]),
206 | ^^^^^^^^^^^^^^
207
208error: large size difference between variants
209 --> tests/ui/large_enum_variant.rs:121:1
210 |
211LL | / enum ManuallyCopyLargeEnum {
212LL | |
213LL | | A(bool),
214 | | ------- the second-largest variant contains at least 1 bytes
215LL | | B([u64; 8000]),
216 | | -------------- the largest variant contains at least 64000 bytes
217LL | | }
218 | |_^ the entire enum is at least 64004 bytes
219 |
220note: boxing a variant would require the type no longer be `Copy`
221 --> tests/ui/large_enum_variant.rs:121:6
222 |
223LL | enum ManuallyCopyLargeEnum {
224 | ^^^^^^^^^^^^^^^^^^^^^
225help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
226 --> tests/ui/large_enum_variant.rs:124:5
227 |
228LL | B([u64; 8000]),
229 | ^^^^^^^^^^^^^^
230
231error: large size difference between variants
232 --> tests/ui/large_enum_variant.rs:135:1
233 |
234LL | / enum SomeGenericPossiblyCopyEnum<T> {
235LL | |
236LL | | A(bool, std::marker::PhantomData<T>),
237 | | ------------------------------------ the second-largest variant contains at least 1 bytes
238LL | | B([u64; 4000]),
239 | | -------------- the largest variant contains at least 32000 bytes
240LL | | }
241 | |_^ the entire enum is at least 32004 bytes
242 |
243note: boxing a variant would require the type no longer be `Copy`
244 --> tests/ui/large_enum_variant.rs:135:6
245 |
246LL | enum SomeGenericPossiblyCopyEnum<T> {
247 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
248help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
249 --> tests/ui/large_enum_variant.rs:138:5
250 |
251LL | B([u64; 4000]),
252 | ^^^^^^^^^^^^^^
253
254error: large size difference between variants
255 --> tests/ui/large_enum_variant.rs:149:1
256 |
257LL | / enum LargeEnumWithGenerics<T> {
258LL | |
259LL | | Small,
260 | | ----- the second-largest variant carries no data at all
261LL | | Large((T, [u8; 512])),
262 | | --------------------- the largest variant contains at least 512 bytes
263LL | | }
264 | |_^ the entire enum is at least 512 bytes
265 |
266help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
267 |
268LL - Large((T, [u8; 512])),
269LL + Large(Box<(T, [u8; 512])>),
270 |
271
272error: large size difference between variants
273 --> tests/ui/large_enum_variant.rs:159:1
274 |
275LL | / enum WithGenerics {
276LL | |
277LL | | Large([Foo<u64>; 64]),
278 | | --------------------- the largest variant contains at least 512 bytes
279LL | | Small(u8),
280 | | --------- the second-largest variant contains at least 1 bytes
281LL | | }
282 | |_^ the entire enum is at least 516 bytes
283 |
284help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
285 |
286LL - Large([Foo<u64>; 64]),
287LL + Large(Box<[Foo<u64>; 64]>),
288 |
289
290error: large size difference between variants
291 --> tests/ui/large_enum_variant.rs:170:1
292 |
293LL | / enum LargeEnumOfConst {
294LL | |
295LL | | Ok,
296 | | -- the second-largest variant carries no data at all
297LL | | Error(PossiblyLargeEnumWithConst<256>),
298 | | -------------------------------------- the largest variant contains at least 514 bytes
299LL | | }
300 | |_^ the entire enum is at least 514 bytes
301 |
302help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
303 |
304LL - Error(PossiblyLargeEnumWithConst<256>),
305LL + Error(Box<PossiblyLargeEnumWithConst<256>>),
306 |
307
308error: large size difference between variants
309 --> tests/ui/large_enum_variant.rs:176:1
310 |
311LL | / enum WithRecursion {
312LL | |
313LL | | Large([u64; 64]),
314 | | ---------------- the largest variant contains at least 512 bytes
315LL | | Recursive(Box<WithRecursion>),
316 | | ----------------------------- the second-largest variant contains at least 4 bytes
317LL | | }
318 | |_^ the entire enum is at least 516 bytes
319 |
320help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
321 |
322LL - Large([u64; 64]),
323LL + Large(Box<[u64; 64]>),
324 |
325
326error: large size difference between variants
327 --> tests/ui/large_enum_variant.rs:187:1
328 |
329LL | / enum LargeEnumWithGenericsAndRecursive {
330LL | |
331LL | | Ok(),
332 | | ---- the second-largest variant carries no data at all
333LL | | Error(WithRecursionAndGenerics<u64>),
334 | | ------------------------------------ the largest variant contains at least 516 bytes
335LL | | }
336 | |_^ the entire enum is at least 516 bytes
337 |
338help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
339 |
340LL - Error(WithRecursionAndGenerics<u64>),
341LL + Error(Box<WithRecursionAndGenerics<u64>>),
342 |
343
344error: aborting due to 18 previous errors
345
src/tools/clippy/tests/ui/large_enum_variant.64bit.stderr deleted-381
......@@ -1,381 +0,0 @@
1error: large size difference between variants
2 --> tests/ui/large_enum_variant.rs:13:1
3 |
4LL | / enum LargeEnum {
5LL | |
6LL | | A(i32),
7 | | ------ the second-largest variant contains at least 4 bytes
8LL | | B([i32; 8000]),
9 | | -------------- the largest variant contains at least 32000 bytes
10LL | | }
11 | |_^ the entire enum is at least 32004 bytes
12 |
13 = note: `-D clippy::large-enum-variant` implied by `-D warnings`
14 = help: to override `-D warnings` add `#[allow(clippy::large_enum_variant)]`
15help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
16 |
17LL - B([i32; 8000]),
18LL + B(Box<[i32; 8000]>),
19 |
20
21error: large size difference between variants
22 --> tests/ui/large_enum_variant.rs:38:1
23 |
24LL | / enum LargeEnum2 {
25LL | |
26LL | | VariantOk(i32, u32),
27 | | ------------------- the second-largest variant contains at least 8 bytes
28LL | | ContainingLargeEnum(LargeEnum),
29 | | ------------------------------ the largest variant contains at least 32004 bytes
30LL | | }
31 | |_^ the entire enum is at least 32004 bytes
32 |
33help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
34 |
35LL - ContainingLargeEnum(LargeEnum),
36LL + ContainingLargeEnum(Box<LargeEnum>),
37 |
38
39error: large size difference between variants
40 --> tests/ui/large_enum_variant.rs:44:1
41 |
42LL | / enum LargeEnum3 {
43LL | |
44LL | | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]),
45 | | --------------------------------------------------------- the largest variant contains at least 70004 bytes
46LL | | VoidVariant,
47LL | | StructLikeLittle { x: i32, y: i32 },
48 | | ----------------------------------- the second-largest variant contains at least 8 bytes
49LL | | }
50 | |_^ the entire enum is at least 70008 bytes
51 |
52help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
53 |
54LL - ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]),
55LL + ContainingMoreThanOneField(i32, Box<[i32; 8000]>, Box<[i32; 9500]>),
56 |
57
58error: large size difference between variants
59 --> tests/ui/large_enum_variant.rs:51:1
60 |
61LL | / enum LargeEnum4 {
62LL | |
63LL | | VariantOk(i32, u32),
64 | | ------------------- the second-largest variant contains at least 8 bytes
65LL | | StructLikeLarge { x: [i32; 8000], y: i32 },
66 | | ------------------------------------------ the largest variant contains at least 32004 bytes
67LL | | }
68 | |_^ the entire enum is at least 32008 bytes
69 |
70help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
71 |
72LL - StructLikeLarge { x: [i32; 8000], y: i32 },
73LL + StructLikeLarge { x: Box<[i32; 8000]>, y: i32 },
74 |
75
76error: large size difference between variants
77 --> tests/ui/large_enum_variant.rs:57:1
78 |
79LL | / enum LargeEnum5 {
80LL | |
81LL | | VariantOk(i32, u32),
82 | | ------------------- the second-largest variant contains at least 8 bytes
83LL | | StructLikeLarge2 { x: [i32; 8000] },
84 | | ----------------------------------- the largest variant contains at least 32000 bytes
85LL | | }
86 | |_^ the entire enum is at least 32004 bytes
87 |
88help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
89 |
90LL - StructLikeLarge2 { x: [i32; 8000] },
91LL + StructLikeLarge2 { x: Box<[i32; 8000]> },
92 |
93
94error: large size difference between variants
95 --> tests/ui/large_enum_variant.rs:74:1
96 |
97LL | / enum LargeEnum7 {
98LL | |
99LL | | A,
100LL | | B([u8; 1255]),
101 | | ------------- the largest variant contains at least 1255 bytes
102LL | | C([u8; 200]),
103 | | ------------ the second-largest variant contains at least 200 bytes
104LL | | }
105 | |_^ the entire enum is at least 1256 bytes
106 |
107help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
108 |
109LL - B([u8; 1255]),
110LL + B(Box<[u8; 1255]>),
111 |
112
113error: large size difference between variants
114 --> tests/ui/large_enum_variant.rs:81:1
115 |
116LL | / enum LargeEnum8 {
117LL | |
118LL | | VariantOk(i32, u32),
119 | | ------------------- the second-largest variant contains at least 8 bytes
120LL | | ContainingMoreThanOneField([i32; 8000], [i32; 2], [i32; 9500], [i32; 30]),
121 | | ------------------------------------------------------------------------- the largest variant contains at least 70128 bytes
122LL | | }
123 | |_^ the entire enum is at least 70132 bytes
124 |
125help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
126 |
127LL - ContainingMoreThanOneField([i32; 8000], [i32; 2], [i32; 9500], [i32; 30]),
128LL + ContainingMoreThanOneField(Box<[i32; 8000]>, [i32; 2], Box<[i32; 9500]>, [i32; 30]),
129 |
130
131error: large size difference between variants
132 --> tests/ui/large_enum_variant.rs:87:1
133 |
134LL | / enum LargeEnum9 {
135LL | |
136LL | | A(Struct<()>),
137 | | ------------- the second-largest variant contains at least 4 bytes
138LL | | B(Struct2),
139 | | ---------- the largest variant contains at least 32000 bytes
140LL | | }
141 | |_^ the entire enum is at least 32004 bytes
142 |
143help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
144 |
145LL - B(Struct2),
146LL + B(Box<Struct2>),
147 |
148
149error: large size difference between variants
150 --> tests/ui/large_enum_variant.rs:93:1
151 |
152LL | / enum LargeEnumOk2<T> {
153LL | |
154LL | | A(T),
155 | | ---- the second-largest variant contains at least 0 bytes
156LL | | B(Struct2),
157 | | ---------- the largest variant contains at least 32000 bytes
158LL | | }
159 | |_^ the entire enum is at least 32000 bytes
160 |
161help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
162 |
163LL - B(Struct2),
164LL + B(Box<Struct2>),
165 |
166
167error: large size difference between variants
168 --> tests/ui/large_enum_variant.rs:99:1
169 |
170LL | / enum LargeEnumOk3<T> {
171LL | |
172LL | | A(Struct<T>),
173 | | ------------ the second-largest variant contains at least 4 bytes
174LL | | B(Struct2),
175 | | ---------- the largest variant contains at least 32000 bytes
176LL | | }
177 | |_^ the entire enum is at least 32000 bytes
178 |
179help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
180 |
181LL - B(Struct2),
182LL + B(Box<Struct2>),
183 |
184
185error: large size difference between variants
186 --> tests/ui/large_enum_variant.rs:115:1
187 |
188LL | / enum CopyableLargeEnum {
189LL | |
190LL | | A(bool),
191 | | ------- the second-largest variant contains at least 1 bytes
192LL | | B([u64; 8000]),
193 | | -------------- the largest variant contains at least 64000 bytes
194LL | | }
195 | |_^ the entire enum is at least 64008 bytes
196 |
197note: boxing a variant would require the type no longer be `Copy`
198 --> tests/ui/large_enum_variant.rs:115:6
199 |
200LL | enum CopyableLargeEnum {
201 | ^^^^^^^^^^^^^^^^^
202help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
203 --> tests/ui/large_enum_variant.rs:118:5
204 |
205LL | B([u64; 8000]),
206 | ^^^^^^^^^^^^^^
207
208error: large size difference between variants
209 --> tests/ui/large_enum_variant.rs:121:1
210 |
211LL | / enum ManuallyCopyLargeEnum {
212LL | |
213LL | | A(bool),
214 | | ------- the second-largest variant contains at least 1 bytes
215LL | | B([u64; 8000]),
216 | | -------------- the largest variant contains at least 64000 bytes
217LL | | }
218 | |_^ the entire enum is at least 64008 bytes
219 |
220note: boxing a variant would require the type no longer be `Copy`
221 --> tests/ui/large_enum_variant.rs:121:6
222 |
223LL | enum ManuallyCopyLargeEnum {
224 | ^^^^^^^^^^^^^^^^^^^^^
225help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
226 --> tests/ui/large_enum_variant.rs:124:5
227 |
228LL | B([u64; 8000]),
229 | ^^^^^^^^^^^^^^
230
231error: large size difference between variants
232 --> tests/ui/large_enum_variant.rs:135:1
233 |
234LL | / enum SomeGenericPossiblyCopyEnum<T> {
235LL | |
236LL | | A(bool, std::marker::PhantomData<T>),
237 | | ------------------------------------ the second-largest variant contains at least 1 bytes
238LL | | B([u64; 4000]),
239 | | -------------- the largest variant contains at least 32000 bytes
240LL | | }
241 | |_^ the entire enum is at least 32008 bytes
242 |
243note: boxing a variant would require the type no longer be `Copy`
244 --> tests/ui/large_enum_variant.rs:135:6
245 |
246LL | enum SomeGenericPossiblyCopyEnum<T> {
247 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
248help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
249 --> tests/ui/large_enum_variant.rs:138:5
250 |
251LL | B([u64; 4000]),
252 | ^^^^^^^^^^^^^^
253
254error: large size difference between variants
255 --> tests/ui/large_enum_variant.rs:149:1
256 |
257LL | / enum LargeEnumWithGenerics<T> {
258LL | |
259LL | | Small,
260 | | ----- the second-largest variant carries no data at all
261LL | | Large((T, [u8; 512])),
262 | | --------------------- the largest variant contains at least 512 bytes
263LL | | }
264 | |_^ the entire enum is at least 512 bytes
265 |
266help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
267 |
268LL - Large((T, [u8; 512])),
269LL + Large(Box<(T, [u8; 512])>),
270 |
271
272error: large size difference between variants
273 --> tests/ui/large_enum_variant.rs:159:1
274 |
275LL | / enum WithGenerics {
276LL | |
277LL | | Large([Foo<u64>; 64]),
278 | | --------------------- the largest variant contains at least 512 bytes
279LL | | Small(u8),
280 | | --------- the second-largest variant contains at least 1 bytes
281LL | | }
282 | |_^ the entire enum is at least 520 bytes
283 |
284help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
285 |
286LL - Large([Foo<u64>; 64]),
287LL + Large(Box<[Foo<u64>; 64]>),
288 |
289
290error: large size difference between variants
291 --> tests/ui/large_enum_variant.rs:170:1
292 |
293LL | / enum LargeEnumOfConst {
294LL | |
295LL | | Ok,
296 | | -- the second-largest variant carries no data at all
297LL | | Error(PossiblyLargeEnumWithConst<256>),
298 | | -------------------------------------- the largest variant contains at least 514 bytes
299LL | | }
300 | |_^ the entire enum is at least 514 bytes
301 |
302help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
303 |
304LL - Error(PossiblyLargeEnumWithConst<256>),
305LL + Error(Box<PossiblyLargeEnumWithConst<256>>),
306 |
307
308error: large size difference between variants
309 --> tests/ui/large_enum_variant.rs:176:1
310 |
311LL | / enum WithRecursion {
312LL | |
313LL | | Large([u64; 64]),
314 | | ---------------- the largest variant contains at least 512 bytes
315LL | | Recursive(Box<WithRecursion>),
316 | | ----------------------------- the second-largest variant contains at least 8 bytes
317LL | | }
318 | |_^ the entire enum is at least 520 bytes
319 |
320help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
321 |
322LL - Large([u64; 64]),
323LL + Large(Box<[u64; 64]>),
324 |
325
326error: large size difference between variants
327 --> tests/ui/large_enum_variant.rs:187:1
328 |
329LL | / enum LargeEnumWithGenericsAndRecursive {
330LL | |
331LL | | Ok(),
332 | | ---- the second-largest variant carries no data at all
333LL | | Error(WithRecursionAndGenerics<u64>),
334 | | ------------------------------------ the largest variant contains at least 520 bytes
335LL | | }
336 | |_^ the entire enum is at least 520 bytes
337 |
338help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
339 |
340LL - Error(WithRecursionAndGenerics<u64>),
341LL + Error(Box<WithRecursionAndGenerics<u64>>),
342 |
343
344error: large size difference between variants
345 --> tests/ui/large_enum_variant.rs:223:5
346 |
347LL | / enum NoWarnings {
348LL | |
349LL | | BigBoi(PublishWithBytes),
350 | | ------------------------ the largest variant contains at least 296 bytes
351LL | | _SmallBoi(u8),
352 | | ------------- the second-largest variant contains at least 1 bytes
353LL | | }
354 | |_____^ the entire enum is at least 296 bytes
355 |
356help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
357 |
358LL - BigBoi(PublishWithBytes),
359LL + BigBoi(Box<PublishWithBytes>),
360 |
361
362error: large size difference between variants
363 --> tests/ui/large_enum_variant.rs:229:5
364 |
365LL | / enum MakesClippyAngry {
366LL | |
367LL | | BigBoi(PublishWithVec),
368 | | ---------------------- the largest variant contains at least 224 bytes
369LL | | _SmallBoi(u8),
370 | | ------------- the second-largest variant contains at least 1 bytes
371LL | | }
372 | |_____^ the entire enum is at least 224 bytes
373 |
374help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
375 |
376LL - BigBoi(PublishWithVec),
377LL + BigBoi(Box<PublishWithVec>),
378 |
379
380error: aborting due to 20 previous errors
381
src/tools/clippy/tests/ui/large_enum_variant.r32bit.stderr created+345
......@@ -0,0 +1,345 @@
1error: large size difference between variants
2 --> tests/ui/large_enum_variant.rs:13:1
3 |
4LL | / enum LargeEnum {
5LL | |
6LL | | A(i32),
7 | | ------ the second-largest variant contains at least 4 bytes
8LL | | B([i32; 8000]),
9 | | -------------- the largest variant contains at least 32000 bytes
10LL | | }
11 | |_^ the entire enum is at least 32004 bytes
12 |
13 = note: `-D clippy::large-enum-variant` implied by `-D warnings`
14 = help: to override `-D warnings` add `#[allow(clippy::large_enum_variant)]`
15help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
16 |
17LL - B([i32; 8000]),
18LL + B(Box<[i32; 8000]>),
19 |
20
21error: large size difference between variants
22 --> tests/ui/large_enum_variant.rs:38:1
23 |
24LL | / enum LargeEnum2 {
25LL | |
26LL | | VariantOk(i32, u32),
27 | | ------------------- the second-largest variant contains at least 8 bytes
28LL | | ContainingLargeEnum(LargeEnum),
29 | | ------------------------------ the largest variant contains at least 32004 bytes
30LL | | }
31 | |_^ the entire enum is at least 32004 bytes
32 |
33help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
34 |
35LL - ContainingLargeEnum(LargeEnum),
36LL + ContainingLargeEnum(Box<LargeEnum>),
37 |
38
39error: large size difference between variants
40 --> tests/ui/large_enum_variant.rs:44:1
41 |
42LL | / enum LargeEnum3 {
43LL | |
44LL | | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]),
45 | | --------------------------------------------------------- the largest variant contains at least 70004 bytes
46LL | | VoidVariant,
47LL | | StructLikeLittle { x: i32, y: i32 },
48 | | ----------------------------------- the second-largest variant contains at least 8 bytes
49LL | | }
50 | |_^ the entire enum is at least 70008 bytes
51 |
52help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
53 |
54LL - ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]),
55LL + ContainingMoreThanOneField(i32, Box<[i32; 8000]>, Box<[i32; 9500]>),
56 |
57
58error: large size difference between variants
59 --> tests/ui/large_enum_variant.rs:51:1
60 |
61LL | / enum LargeEnum4 {
62LL | |
63LL | | VariantOk(i32, u32),
64 | | ------------------- the second-largest variant contains at least 8 bytes
65LL | | StructLikeLarge { x: [i32; 8000], y: i32 },
66 | | ------------------------------------------ the largest variant contains at least 32004 bytes
67LL | | }
68 | |_^ the entire enum is at least 32008 bytes
69 |
70help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
71 |
72LL - StructLikeLarge { x: [i32; 8000], y: i32 },
73LL + StructLikeLarge { x: Box<[i32; 8000]>, y: i32 },
74 |
75
76error: large size difference between variants
77 --> tests/ui/large_enum_variant.rs:57:1
78 |
79LL | / enum LargeEnum5 {
80LL | |
81LL | | VariantOk(i32, u32),
82 | | ------------------- the second-largest variant contains at least 8 bytes
83LL | | StructLikeLarge2 { x: [i32; 8000] },
84 | | ----------------------------------- the largest variant contains at least 32000 bytes
85LL | | }
86 | |_^ the entire enum is at least 32004 bytes
87 |
88help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
89 |
90LL - StructLikeLarge2 { x: [i32; 8000] },
91LL + StructLikeLarge2 { x: Box<[i32; 8000]> },
92 |
93
94error: large size difference between variants
95 --> tests/ui/large_enum_variant.rs:74:1
96 |
97LL | / enum LargeEnum7 {
98LL | |
99LL | | A,
100LL | | B([u8; 1255]),
101 | | ------------- the largest variant contains at least 1255 bytes
102LL | | C([u8; 200]),
103 | | ------------ the second-largest variant contains at least 200 bytes
104LL | | }
105 | |_^ the entire enum is at least 1256 bytes
106 |
107help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
108 |
109LL - B([u8; 1255]),
110LL + B(Box<[u8; 1255]>),
111 |
112
113error: large size difference between variants
114 --> tests/ui/large_enum_variant.rs:81:1
115 |
116LL | / enum LargeEnum8 {
117LL | |
118LL | | VariantOk(i32, u32),
119 | | ------------------- the second-largest variant contains at least 8 bytes
120LL | | ContainingMoreThanOneField([i32; 8000], [i32; 2], [i32; 9500], [i32; 30]),
121 | | ------------------------------------------------------------------------- the largest variant contains at least 70128 bytes
122LL | | }
123 | |_^ the entire enum is at least 70132 bytes
124 |
125help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
126 |
127LL - ContainingMoreThanOneField([i32; 8000], [i32; 2], [i32; 9500], [i32; 30]),
128LL + ContainingMoreThanOneField(Box<[i32; 8000]>, [i32; 2], Box<[i32; 9500]>, [i32; 30]),
129 |
130
131error: large size difference between variants
132 --> tests/ui/large_enum_variant.rs:87:1
133 |
134LL | / enum LargeEnum9 {
135LL | |
136LL | | A(Struct<()>),
137 | | ------------- the second-largest variant contains at least 4 bytes
138LL | | B(Struct2),
139 | | ---------- the largest variant contains at least 32000 bytes
140LL | | }
141 | |_^ the entire enum is at least 32004 bytes
142 |
143help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
144 |
145LL - B(Struct2),
146LL + B(Box<Struct2>),
147 |
148
149error: large size difference between variants
150 --> tests/ui/large_enum_variant.rs:93:1
151 |
152LL | / enum LargeEnumOk2<T> {
153LL | |
154LL | | A(T),
155 | | ---- the second-largest variant contains at least 0 bytes
156LL | | B(Struct2),
157 | | ---------- the largest variant contains at least 32000 bytes
158LL | | }
159 | |_^ the entire enum is at least 32000 bytes
160 |
161help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
162 |
163LL - B(Struct2),
164LL + B(Box<Struct2>),
165 |
166
167error: large size difference between variants
168 --> tests/ui/large_enum_variant.rs:99:1
169 |
170LL | / enum LargeEnumOk3<T> {
171LL | |
172LL | | A(Struct<T>),
173 | | ------------ the second-largest variant contains at least 4 bytes
174LL | | B(Struct2),
175 | | ---------- the largest variant contains at least 32000 bytes
176LL | | }
177 | |_^ the entire enum is at least 32000 bytes
178 |
179help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
180 |
181LL - B(Struct2),
182LL + B(Box<Struct2>),
183 |
184
185error: large size difference between variants
186 --> tests/ui/large_enum_variant.rs:115:1
187 |
188LL | / enum CopyableLargeEnum {
189LL | |
190LL | | A(bool),
191 | | ------- the second-largest variant contains at least 1 bytes
192LL | | B([u64; 8000]),
193 | | -------------- the largest variant contains at least 64000 bytes
194LL | | }
195 | |_^ the entire enum is at least 64004 bytes
196 |
197note: boxing a variant would require the type no longer be `Copy`
198 --> tests/ui/large_enum_variant.rs:115:6
199 |
200LL | enum CopyableLargeEnum {
201 | ^^^^^^^^^^^^^^^^^
202help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
203 --> tests/ui/large_enum_variant.rs:118:5
204 |
205LL | B([u64; 8000]),
206 | ^^^^^^^^^^^^^^
207
208error: large size difference between variants
209 --> tests/ui/large_enum_variant.rs:121:1
210 |
211LL | / enum ManuallyCopyLargeEnum {
212LL | |
213LL | | A(bool),
214 | | ------- the second-largest variant contains at least 1 bytes
215LL | | B([u64; 8000]),
216 | | -------------- the largest variant contains at least 64000 bytes
217LL | | }
218 | |_^ the entire enum is at least 64004 bytes
219 |
220note: boxing a variant would require the type no longer be `Copy`
221 --> tests/ui/large_enum_variant.rs:121:6
222 |
223LL | enum ManuallyCopyLargeEnum {
224 | ^^^^^^^^^^^^^^^^^^^^^
225help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
226 --> tests/ui/large_enum_variant.rs:124:5
227 |
228LL | B([u64; 8000]),
229 | ^^^^^^^^^^^^^^
230
231error: large size difference between variants
232 --> tests/ui/large_enum_variant.rs:135:1
233 |
234LL | / enum SomeGenericPossiblyCopyEnum<T> {
235LL | |
236LL | | A(bool, std::marker::PhantomData<T>),
237 | | ------------------------------------ the second-largest variant contains at least 1 bytes
238LL | | B([u64; 4000]),
239 | | -------------- the largest variant contains at least 32000 bytes
240LL | | }
241 | |_^ the entire enum is at least 32004 bytes
242 |
243note: boxing a variant would require the type no longer be `Copy`
244 --> tests/ui/large_enum_variant.rs:135:6
245 |
246LL | enum SomeGenericPossiblyCopyEnum<T> {
247 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
248help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
249 --> tests/ui/large_enum_variant.rs:138:5
250 |
251LL | B([u64; 4000]),
252 | ^^^^^^^^^^^^^^
253
254error: large size difference between variants
255 --> tests/ui/large_enum_variant.rs:149:1
256 |
257LL | / enum LargeEnumWithGenerics<T> {
258LL | |
259LL | | Small,
260 | | ----- the second-largest variant carries no data at all
261LL | | Large((T, [u8; 512])),
262 | | --------------------- the largest variant contains at least 512 bytes
263LL | | }
264 | |_^ the entire enum is at least 512 bytes
265 |
266help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
267 |
268LL - Large((T, [u8; 512])),
269LL + Large(Box<(T, [u8; 512])>),
270 |
271
272error: large size difference between variants
273 --> tests/ui/large_enum_variant.rs:159:1
274 |
275LL | / enum WithGenerics {
276LL | |
277LL | | Large([Foo<u64>; 64]),
278 | | --------------------- the largest variant contains at least 512 bytes
279LL | | Small(u8),
280 | | --------- the second-largest variant contains at least 1 bytes
281LL | | }
282 | |_^ the entire enum is at least 516 bytes
283 |
284help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
285 |
286LL - Large([Foo<u64>; 64]),
287LL + Large(Box<[Foo<u64>; 64]>),
288 |
289
290error: large size difference between variants
291 --> tests/ui/large_enum_variant.rs:170:1
292 |
293LL | / enum LargeEnumOfConst {
294LL | |
295LL | | Ok,
296 | | -- the second-largest variant carries no data at all
297LL | | Error(PossiblyLargeEnumWithConst<256>),
298 | | -------------------------------------- the largest variant contains at least 514 bytes
299LL | | }
300 | |_^ the entire enum is at least 514 bytes
301 |
302help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
303 |
304LL - Error(PossiblyLargeEnumWithConst<256>),
305LL + Error(Box<PossiblyLargeEnumWithConst<256>>),
306 |
307
308error: large size difference between variants
309 --> tests/ui/large_enum_variant.rs:176:1
310 |
311LL | / enum WithRecursion {
312LL | |
313LL | | Large([u64; 64]),
314 | | ---------------- the largest variant contains at least 512 bytes
315LL | | Recursive(Box<WithRecursion>),
316 | | ----------------------------- the second-largest variant contains at least 4 bytes
317LL | | }
318 | |_^ the entire enum is at least 516 bytes
319 |
320help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
321 |
322LL - Large([u64; 64]),
323LL + Large(Box<[u64; 64]>),
324 |
325
326error: large size difference between variants
327 --> tests/ui/large_enum_variant.rs:187:1
328 |
329LL | / enum LargeEnumWithGenericsAndRecursive {
330LL | |
331LL | | Ok(),
332 | | ---- the second-largest variant carries no data at all
333LL | | Error(WithRecursionAndGenerics<u64>),
334 | | ------------------------------------ the largest variant contains at least 516 bytes
335LL | | }
336 | |_^ the entire enum is at least 516 bytes
337 |
338help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
339 |
340LL - Error(WithRecursionAndGenerics<u64>),
341LL + Error(Box<WithRecursionAndGenerics<u64>>),
342 |
343
344error: aborting due to 18 previous errors
345
src/tools/clippy/tests/ui/large_enum_variant.r64bit.stderr created+381
......@@ -0,0 +1,381 @@
1error: large size difference between variants
2 --> tests/ui/large_enum_variant.rs:13:1
3 |
4LL | / enum LargeEnum {
5LL | |
6LL | | A(i32),
7 | | ------ the second-largest variant contains at least 4 bytes
8LL | | B([i32; 8000]),
9 | | -------------- the largest variant contains at least 32000 bytes
10LL | | }
11 | |_^ the entire enum is at least 32004 bytes
12 |
13 = note: `-D clippy::large-enum-variant` implied by `-D warnings`
14 = help: to override `-D warnings` add `#[allow(clippy::large_enum_variant)]`
15help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
16 |
17LL - B([i32; 8000]),
18LL + B(Box<[i32; 8000]>),
19 |
20
21error: large size difference between variants
22 --> tests/ui/large_enum_variant.rs:38:1
23 |
24LL | / enum LargeEnum2 {
25LL | |
26LL | | VariantOk(i32, u32),
27 | | ------------------- the second-largest variant contains at least 8 bytes
28LL | | ContainingLargeEnum(LargeEnum),
29 | | ------------------------------ the largest variant contains at least 32004 bytes
30LL | | }
31 | |_^ the entire enum is at least 32004 bytes
32 |
33help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
34 |
35LL - ContainingLargeEnum(LargeEnum),
36LL + ContainingLargeEnum(Box<LargeEnum>),
37 |
38
39error: large size difference between variants
40 --> tests/ui/large_enum_variant.rs:44:1
41 |
42LL | / enum LargeEnum3 {
43LL | |
44LL | | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]),
45 | | --------------------------------------------------------- the largest variant contains at least 70004 bytes
46LL | | VoidVariant,
47LL | | StructLikeLittle { x: i32, y: i32 },
48 | | ----------------------------------- the second-largest variant contains at least 8 bytes
49LL | | }
50 | |_^ the entire enum is at least 70008 bytes
51 |
52help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
53 |
54LL - ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]),
55LL + ContainingMoreThanOneField(i32, Box<[i32; 8000]>, Box<[i32; 9500]>),
56 |
57
58error: large size difference between variants
59 --> tests/ui/large_enum_variant.rs:51:1
60 |
61LL | / enum LargeEnum4 {
62LL | |
63LL | | VariantOk(i32, u32),
64 | | ------------------- the second-largest variant contains at least 8 bytes
65LL | | StructLikeLarge { x: [i32; 8000], y: i32 },
66 | | ------------------------------------------ the largest variant contains at least 32004 bytes
67LL | | }
68 | |_^ the entire enum is at least 32008 bytes
69 |
70help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
71 |
72LL - StructLikeLarge { x: [i32; 8000], y: i32 },
73LL + StructLikeLarge { x: Box<[i32; 8000]>, y: i32 },
74 |
75
76error: large size difference between variants
77 --> tests/ui/large_enum_variant.rs:57:1
78 |
79LL | / enum LargeEnum5 {
80LL | |
81LL | | VariantOk(i32, u32),
82 | | ------------------- the second-largest variant contains at least 8 bytes
83LL | | StructLikeLarge2 { x: [i32; 8000] },
84 | | ----------------------------------- the largest variant contains at least 32000 bytes
85LL | | }
86 | |_^ the entire enum is at least 32004 bytes
87 |
88help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
89 |
90LL - StructLikeLarge2 { x: [i32; 8000] },
91LL + StructLikeLarge2 { x: Box<[i32; 8000]> },
92 |
93
94error: large size difference between variants
95 --> tests/ui/large_enum_variant.rs:74:1
96 |
97LL | / enum LargeEnum7 {
98LL | |
99LL | | A,
100LL | | B([u8; 1255]),
101 | | ------------- the largest variant contains at least 1255 bytes
102LL | | C([u8; 200]),
103 | | ------------ the second-largest variant contains at least 200 bytes
104LL | | }
105 | |_^ the entire enum is at least 1256 bytes
106 |
107help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
108 |
109LL - B([u8; 1255]),
110LL + B(Box<[u8; 1255]>),
111 |
112
113error: large size difference between variants
114 --> tests/ui/large_enum_variant.rs:81:1
115 |
116LL | / enum LargeEnum8 {
117LL | |
118LL | | VariantOk(i32, u32),
119 | | ------------------- the second-largest variant contains at least 8 bytes
120LL | | ContainingMoreThanOneField([i32; 8000], [i32; 2], [i32; 9500], [i32; 30]),
121 | | ------------------------------------------------------------------------- the largest variant contains at least 70128 bytes
122LL | | }
123 | |_^ the entire enum is at least 70132 bytes
124 |
125help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
126 |
127LL - ContainingMoreThanOneField([i32; 8000], [i32; 2], [i32; 9500], [i32; 30]),
128LL + ContainingMoreThanOneField(Box<[i32; 8000]>, [i32; 2], Box<[i32; 9500]>, [i32; 30]),
129 |
130
131error: large size difference between variants
132 --> tests/ui/large_enum_variant.rs:87:1
133 |
134LL | / enum LargeEnum9 {
135LL | |
136LL | | A(Struct<()>),
137 | | ------------- the second-largest variant contains at least 4 bytes
138LL | | B(Struct2),
139 | | ---------- the largest variant contains at least 32000 bytes
140LL | | }
141 | |_^ the entire enum is at least 32004 bytes
142 |
143help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
144 |
145LL - B(Struct2),
146LL + B(Box<Struct2>),
147 |
148
149error: large size difference between variants
150 --> tests/ui/large_enum_variant.rs:93:1
151 |
152LL | / enum LargeEnumOk2<T> {
153LL | |
154LL | | A(T),
155 | | ---- the second-largest variant contains at least 0 bytes
156LL | | B(Struct2),
157 | | ---------- the largest variant contains at least 32000 bytes
158LL | | }
159 | |_^ the entire enum is at least 32000 bytes
160 |
161help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
162 |
163LL - B(Struct2),
164LL + B(Box<Struct2>),
165 |
166
167error: large size difference between variants
168 --> tests/ui/large_enum_variant.rs:99:1
169 |
170LL | / enum LargeEnumOk3<T> {
171LL | |
172LL | | A(Struct<T>),
173 | | ------------ the second-largest variant contains at least 4 bytes
174LL | | B(Struct2),
175 | | ---------- the largest variant contains at least 32000 bytes
176LL | | }
177 | |_^ the entire enum is at least 32000 bytes
178 |
179help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
180 |
181LL - B(Struct2),
182LL + B(Box<Struct2>),
183 |
184
185error: large size difference between variants
186 --> tests/ui/large_enum_variant.rs:115:1
187 |
188LL | / enum CopyableLargeEnum {
189LL | |
190LL | | A(bool),
191 | | ------- the second-largest variant contains at least 1 bytes
192LL | | B([u64; 8000]),
193 | | -------------- the largest variant contains at least 64000 bytes
194LL | | }
195 | |_^ the entire enum is at least 64008 bytes
196 |
197note: boxing a variant would require the type no longer be `Copy`
198 --> tests/ui/large_enum_variant.rs:115:6
199 |
200LL | enum CopyableLargeEnum {
201 | ^^^^^^^^^^^^^^^^^
202help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
203 --> tests/ui/large_enum_variant.rs:118:5
204 |
205LL | B([u64; 8000]),
206 | ^^^^^^^^^^^^^^
207
208error: large size difference between variants
209 --> tests/ui/large_enum_variant.rs:121:1
210 |
211LL | / enum ManuallyCopyLargeEnum {
212LL | |
213LL | | A(bool),
214 | | ------- the second-largest variant contains at least 1 bytes
215LL | | B([u64; 8000]),
216 | | -------------- the largest variant contains at least 64000 bytes
217LL | | }
218 | |_^ the entire enum is at least 64008 bytes
219 |
220note: boxing a variant would require the type no longer be `Copy`
221 --> tests/ui/large_enum_variant.rs:121:6
222 |
223LL | enum ManuallyCopyLargeEnum {
224 | ^^^^^^^^^^^^^^^^^^^^^
225help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
226 --> tests/ui/large_enum_variant.rs:124:5
227 |
228LL | B([u64; 8000]),
229 | ^^^^^^^^^^^^^^
230
231error: large size difference between variants
232 --> tests/ui/large_enum_variant.rs:135:1
233 |
234LL | / enum SomeGenericPossiblyCopyEnum<T> {
235LL | |
236LL | | A(bool, std::marker::PhantomData<T>),
237 | | ------------------------------------ the second-largest variant contains at least 1 bytes
238LL | | B([u64; 4000]),
239 | | -------------- the largest variant contains at least 32000 bytes
240LL | | }
241 | |_^ the entire enum is at least 32008 bytes
242 |
243note: boxing a variant would require the type no longer be `Copy`
244 --> tests/ui/large_enum_variant.rs:135:6
245 |
246LL | enum SomeGenericPossiblyCopyEnum<T> {
247 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
248help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
249 --> tests/ui/large_enum_variant.rs:138:5
250 |
251LL | B([u64; 4000]),
252 | ^^^^^^^^^^^^^^
253
254error: large size difference between variants
255 --> tests/ui/large_enum_variant.rs:149:1
256 |
257LL | / enum LargeEnumWithGenerics<T> {
258LL | |
259LL | | Small,
260 | | ----- the second-largest variant carries no data at all
261LL | | Large((T, [u8; 512])),
262 | | --------------------- the largest variant contains at least 512 bytes
263LL | | }
264 | |_^ the entire enum is at least 512 bytes
265 |
266help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
267 |
268LL - Large((T, [u8; 512])),
269LL + Large(Box<(T, [u8; 512])>),
270 |
271
272error: large size difference between variants
273 --> tests/ui/large_enum_variant.rs:159:1
274 |
275LL | / enum WithGenerics {
276LL | |
277LL | | Large([Foo<u64>; 64]),
278 | | --------------------- the largest variant contains at least 512 bytes
279LL | | Small(u8),
280 | | --------- the second-largest variant contains at least 1 bytes
281LL | | }
282 | |_^ the entire enum is at least 520 bytes
283 |
284help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
285 |
286LL - Large([Foo<u64>; 64]),
287LL + Large(Box<[Foo<u64>; 64]>),
288 |
289
290error: large size difference between variants
291 --> tests/ui/large_enum_variant.rs:170:1
292 |
293LL | / enum LargeEnumOfConst {
294LL | |
295LL | | Ok,
296 | | -- the second-largest variant carries no data at all
297LL | | Error(PossiblyLargeEnumWithConst<256>),
298 | | -------------------------------------- the largest variant contains at least 514 bytes
299LL | | }
300 | |_^ the entire enum is at least 514 bytes
301 |
302help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
303 |
304LL - Error(PossiblyLargeEnumWithConst<256>),
305LL + Error(Box<PossiblyLargeEnumWithConst<256>>),
306 |
307
308error: large size difference between variants
309 --> tests/ui/large_enum_variant.rs:176:1
310 |
311LL | / enum WithRecursion {
312LL | |
313LL | | Large([u64; 64]),
314 | | ---------------- the largest variant contains at least 512 bytes
315LL | | Recursive(Box<WithRecursion>),
316 | | ----------------------------- the second-largest variant contains at least 8 bytes
317LL | | }
318 | |_^ the entire enum is at least 520 bytes
319 |
320help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
321 |
322LL - Large([u64; 64]),
323LL + Large(Box<[u64; 64]>),
324 |
325
326error: large size difference between variants
327 --> tests/ui/large_enum_variant.rs:187:1
328 |
329LL | / enum LargeEnumWithGenericsAndRecursive {
330LL | |
331LL | | Ok(),
332 | | ---- the second-largest variant carries no data at all
333LL | | Error(WithRecursionAndGenerics<u64>),
334 | | ------------------------------------ the largest variant contains at least 520 bytes
335LL | | }
336 | |_^ the entire enum is at least 520 bytes
337 |
338help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
339 |
340LL - Error(WithRecursionAndGenerics<u64>),
341LL + Error(Box<WithRecursionAndGenerics<u64>>),
342 |
343
344error: large size difference between variants
345 --> tests/ui/large_enum_variant.rs:223:5
346 |
347LL | / enum NoWarnings {
348LL | |
349LL | | BigBoi(PublishWithBytes),
350 | | ------------------------ the largest variant contains at least 296 bytes
351LL | | _SmallBoi(u8),
352 | | ------------- the second-largest variant contains at least 1 bytes
353LL | | }
354 | |_____^ the entire enum is at least 296 bytes
355 |
356help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
357 |
358LL - BigBoi(PublishWithBytes),
359LL + BigBoi(Box<PublishWithBytes>),
360 |
361
362error: large size difference between variants
363 --> tests/ui/large_enum_variant.rs:229:5
364 |
365LL | / enum MakesClippyAngry {
366LL | |
367LL | | BigBoi(PublishWithVec),
368 | | ---------------------- the largest variant contains at least 224 bytes
369LL | | _SmallBoi(u8),
370 | | ------------- the second-largest variant contains at least 1 bytes
371LL | | }
372 | |_____^ the entire enum is at least 224 bytes
373 |
374help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
375 |
376LL - BigBoi(PublishWithVec),
377LL + BigBoi(Box<PublishWithVec>),
378 |
379
380error: aborting due to 20 previous errors
381
src/tools/clippy/tests/ui/large_enum_variant.rs+5-5
......@@ -1,8 +1,8 @@
1//@revisions: 32bit 64bit
1//@revisions: r32bit r64bit
22//@aux-build:proc_macros.rs
33//@no-rustfix
4//@[32bit]ignore-bitwidth: 64
5//@[64bit]ignore-bitwidth: 32
4//@[r32bit]ignore-bitwidth: 64
5//@[r64bit]ignore-bitwidth: 32
66#![allow(dead_code)]
77#![allow(unused_variables)]
88#![warn(clippy::large_enum_variant)]
......@@ -221,13 +221,13 @@ mod issue11915 {
221221 }
222222
223223 enum NoWarnings {
224 //~[64bit]^ large_enum_variant
224 //~[r64bit]^ large_enum_variant
225225 BigBoi(PublishWithBytes),
226226 _SmallBoi(u8),
227227 }
228228
229229 enum MakesClippyAngry {
230 //~[64bit]^ large_enum_variant
230 //~[r64bit]^ large_enum_variant
231231 BigBoi(PublishWithVec),
232232 _SmallBoi(u8),
233233 }
src/tools/run-make-support/Cargo.toml+2
......@@ -22,6 +22,8 @@ wasmparser = { version = "0.236", default-features = false, features = ["std", "
2222
2323# Shared with bootstrap and compiletest
2424build_helper = { path = "../../build_helper" }
25# Shared with rustdoc
26rustdoc-json-types = { path = "../../rustdoc-json-types" }
2527
2628[lib]
2729crate-type = ["lib", "dylib"]
src/tools/run-make-support/src/lib.rs+1-1
......@@ -34,7 +34,7 @@ pub mod rfs {
3434}
3535
3636// Re-exports of third-party library crates.
37pub use {bstr, gimli, libc, object, regex, serde_json, similar, wasmparser};
37pub use {bstr, gimli, libc, object, regex, rustdoc_json_types, serde_json, similar, wasmparser};
3838
3939// Helpers for building names of output artifacts that are potentially target-specific.
4040pub use crate::artifact_names::{
tests/codegen-llvm/cf-protection.rs+5-5
......@@ -1,12 +1,12 @@
11// Test that the correct module flags are emitted with different control-flow protection flags.
22
33//@ add-minicore
4//@ revisions: undefined none branch return full
4//@ revisions: undefined none branch return_ full
55//@ needs-llvm-components: x86
66// [undefined] no extra compile-flags
77//@ [none] compile-flags: -Z cf-protection=none
88//@ [branch] compile-flags: -Z cf-protection=branch
9//@ [return] compile-flags: -Z cf-protection=return
9//@ [return_] compile-flags: -Z cf-protection=return
1010//@ [full] compile-flags: -Z cf-protection=full
1111//@ compile-flags: --target x86_64-unknown-linux-gnu
1212
......@@ -30,9 +30,9 @@ pub fn test() {}
3030// branch: !"cf-protection-branch", i32 1
3131// branch-NOT: !"cf-protection-return"
3232
33// return-NOT: !"cf-protection-branch"
34// return: !"cf-protection-return", i32 1
35// return-NOT: !"cf-protection-branch"
33// return_-NOT: !"cf-protection-branch"
34// return_: !"cf-protection-return", i32 1
35// return_-NOT: !"cf-protection-branch"
3636
3737// full: !"cf-protection-branch", i32 1
3838// full: !"cf-protection-return", i32 1
tests/run-make/rustdoc-json-external-crate-path/dep.rs created+5
......@@ -0,0 +1,5 @@
1#![no_std]
2
3pub struct S;
4
5pub use trans_dep::S as TransDep;
tests/run-make/rustdoc-json-external-crate-path/entry.rs created+4
......@@ -0,0 +1,4 @@
1#![no_std]
2
3pub type FromDep = dep::S;
4pub type FromTransDep = dep::TransDep;
tests/run-make/rustdoc-json-external-crate-path/rmake.rs created+89
......@@ -0,0 +1,89 @@
1use std::path;
2
3use run_make_support::rustdoc_json_types::{Crate, ItemEnum, Path, Type, TypeAlias};
4use run_make_support::{cwd, rfs, rust_lib_name, rustc, rustdoc, serde_json};
5
6#[track_caller]
7fn canonicalize(p: &path::Path) -> path::PathBuf {
8 std::fs::canonicalize(p).expect("path should be canonicalizeable")
9}
10
11fn main() {
12 rustc().input("trans_dep.rs").edition("2024").crate_type("lib").run();
13
14 rustc()
15 .input("dep.rs")
16 .edition("2024")
17 .crate_type("lib")
18 .extern_("trans_dep", rust_lib_name("trans_dep"))
19 .run();
20
21 rustdoc()
22 .input("entry.rs")
23 .edition("2024")
24 .output_format("json")
25 .library_search_path(cwd())
26 .extern_("dep", rust_lib_name("dep"))
27 .arg("-Zunstable-options")
28 .run();
29
30 let bytes = rfs::read("doc/entry.json");
31
32 let krate: Crate = serde_json::from_slice(&bytes).expect("output should be valid json");
33
34 let root_item = &krate.index[&krate.root];
35 let ItemEnum::Module(root_mod) = &root_item.inner else { panic!("expected ItemEnum::Module") };
36
37 assert_eq!(root_mod.items.len(), 2);
38
39 let items = root_mod.items.iter().map(|id| &krate.index[id]).collect::<Vec<_>>();
40
41 let from_dep = items
42 .iter()
43 .filter(|item| item.name.as_deref() == Some("FromDep"))
44 .next()
45 .expect("there should be en item called FromDep");
46
47 let from_trans_dep = items
48 .iter()
49 .filter(|item| item.name.as_deref() == Some("FromTransDep"))
50 .next()
51 .expect("there should be en item called FromDep");
52
53 let ItemEnum::TypeAlias(TypeAlias {
54 type_: Type::ResolvedPath(Path { id: from_dep_id, .. }),
55 ..
56 }) = &from_dep.inner
57 else {
58 panic!("Expected FromDep to be a TypeAlias");
59 };
60
61 let ItemEnum::TypeAlias(TypeAlias {
62 type_: Type::ResolvedPath(Path { id: from_trans_dep_id, .. }),
63 ..
64 }) = &from_trans_dep.inner
65 else {
66 panic!("Expected FromDep to be a TypeAlias");
67 };
68
69 assert_eq!(krate.index.get(from_dep_id), None);
70 assert_eq!(krate.index.get(from_trans_dep_id), None);
71
72 let from_dep_externalinfo = &krate.paths[from_dep_id];
73 let from_trans_dep_externalinfo = &krate.paths[from_trans_dep_id];
74
75 let dep_crate_id = from_dep_externalinfo.crate_id;
76 let trans_dep_crate_id = from_trans_dep_externalinfo.crate_id;
77
78 let dep = &krate.external_crates[&dep_crate_id];
79 let trans_dep = &krate.external_crates[&trans_dep_crate_id];
80
81 assert_eq!(dep.name, "dep");
82 assert_eq!(trans_dep.name, "trans_dep");
83
84 assert_eq!(canonicalize(&dep.path), canonicalize(&cwd().join(rust_lib_name("dep"))));
85 assert_eq!(
86 canonicalize(&trans_dep.path),
87 canonicalize(&cwd().join(rust_lib_name("trans_dep")))
88 );
89}
tests/run-make/rustdoc-json-external-crate-path/trans_dep.rs created+3
......@@ -0,0 +1,3 @@
1#![no_std]
2
3pub struct S;
tests/ui/cfg/cmdline-false.rs+1-1
......@@ -1,5 +1,5 @@
11/// Test that `--cfg false` doesn't cause `cfg(false)` to evaluate to `true`
2//@ compile-flags: --cfg false
2//@ compile-flags: --cfg r#false
33
44#[cfg(false)]
55fn foo() {}
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_crate.stderr created+2
......@@ -0,0 +1,2 @@
1error: invalid `--cfg` argument: `crate` (malformed `cfg` input, expected a valid identifier)
2
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_priv.stderr created+2
......@@ -0,0 +1,2 @@
1error: invalid `--cfg` argument: `priv` (expected `key` or `key="value"`)
2
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_crate.stderr created+6
......@@ -0,0 +1,6 @@
1error: `crate` cannot be a raw identifier
2 |
3 = note: this occurred on the command line: `--cfg=r#crate`
4
5error: invalid `--cfg` argument: `r#crate` (expected `key` or `key="value"`)
6
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_lower.stderr created+6
......@@ -0,0 +1,6 @@
1error: `self` cannot be a raw identifier
2 |
3 = note: this occurred on the command line: `--cfg=r#self`
4
5error: invalid `--cfg` argument: `r#self` (expected `key` or `key="value"`)
6
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_upper.stderr created+6
......@@ -0,0 +1,6 @@
1error: `Self` cannot be a raw identifier
2 |
3 = note: this occurred on the command line: `--cfg=r#Self`
4
5error: invalid `--cfg` argument: `r#Self` (expected `key` or `key="value"`)
6
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_super.stderr created+6
......@@ -0,0 +1,6 @@
1error: `super` cannot be a raw identifier
2 |
3 = note: this occurred on the command line: `--cfg=r#super`
4
5error: invalid `--cfg` argument: `r#super` (expected `key` or `key="value"`)
6
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_underscore.stderr created+6
......@@ -0,0 +1,6 @@
1error: `_` cannot be a raw identifier
2 |
3 = note: this occurred on the command line: `--cfg=r#_`
4
5error: invalid `--cfg` argument: `r#_` (expected `key` or `key="value"`)
6
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_lower.stderr created+2
......@@ -0,0 +1,2 @@
1error: invalid `--cfg` argument: `self` (malformed `cfg` input, expected a valid identifier)
2
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_upper.stderr created+2
......@@ -0,0 +1,2 @@
1error: invalid `--cfg` argument: `Self` (malformed `cfg` input, expected a valid identifier)
2
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_struct.stderr created+2
......@@ -0,0 +1,2 @@
1error: invalid `--cfg` argument: `struct` (expected `key` or `key="value"`)
2
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_super.stderr created+2
......@@ -0,0 +1,2 @@
1error: invalid `--cfg` argument: `super` (malformed `cfg` input, expected a valid identifier)
2
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_underscore.stderr created+2
......@@ -0,0 +1,2 @@
1error: invalid `--cfg` argument: `_` (expected `key` or `key="value"`)
2
tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.rs created+24
......@@ -0,0 +1,24 @@
1//@ edition: 2024
2
3//@ revisions: cfg_crate cfg_super cfg_self_lower cfg_self_upper
4//@ revisions: cfg_raw_crate cfg_raw_super cfg_raw_self_lower cfg_raw_self_upper
5//@ revisions: cfg_struct cfg_priv cfg_underscore cfg_raw_underscore
6
7//@ [cfg_crate]compile-flags: --cfg crate
8//@ [cfg_super]compile-flags: --cfg super
9//@ [cfg_self_lower]compile-flags: --cfg self
10//@ [cfg_self_upper]compile-flags: --cfg Self
11
12//@ [cfg_raw_crate]compile-flags: --cfg r#crate
13//@ [cfg_raw_super]compile-flags: --cfg r#super
14//@ [cfg_raw_self_lower]compile-flags: --cfg r#self
15//@ [cfg_raw_self_upper]compile-flags: --cfg r#Self
16
17//@ [cfg_struct]compile-flags: --cfg struct
18//@ [cfg_priv]compile-flags: --cfg priv
19//@ [cfg_underscore]compile-flags: --cfg _
20//@ [cfg_raw_underscore]compile-flags: --cfg r#_
21
22fn main() {}
23
24//~? ERROR invalid `--cfg` argument
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_crate.stderr created+5
......@@ -0,0 +1,5 @@
1error: invalid `--check-cfg` argument: `cfg(crate)`
2 |
3 = note: malformed `cfg` input, expected a valid identifier
4 = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
5
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_priv.stderr created+5
......@@ -0,0 +1,5 @@
1error: invalid `--check-cfg` argument: `cfg(priv)`
2 |
3 = note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
4 = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
5
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_crate.stderr created+9
......@@ -0,0 +1,9 @@
1error: `crate` cannot be a raw identifier
2 |
3 = note: this occurred on the command line: `--check-cfg=cfg(r#crate)`
4
5error: invalid `--check-cfg` argument: `cfg(r#crate)`
6 |
7 = note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
8 = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
9
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_lower.stderr created+9
......@@ -0,0 +1,9 @@
1error: `self` cannot be a raw identifier
2 |
3 = note: this occurred on the command line: `--check-cfg=cfg(r#self)`
4
5error: invalid `--check-cfg` argument: `cfg(r#self)`
6 |
7 = note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
8 = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
9
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_upper.stderr created+9
......@@ -0,0 +1,9 @@
1error: `Self` cannot be a raw identifier
2 |
3 = note: this occurred on the command line: `--check-cfg=cfg(r#Self)`
4
5error: invalid `--check-cfg` argument: `cfg(r#Self)`
6 |
7 = note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
8 = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
9
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_super.stderr created+9
......@@ -0,0 +1,9 @@
1error: `super` cannot be a raw identifier
2 |
3 = note: this occurred on the command line: `--check-cfg=cfg(r#super)`
4
5error: invalid `--check-cfg` argument: `cfg(r#super)`
6 |
7 = note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
8 = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
9
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_underscore.stderr created+9
......@@ -0,0 +1,9 @@
1error: `_` cannot be a raw identifier
2 |
3 = note: this occurred on the command line: `--check-cfg=cfg(r#_)`
4
5error: invalid `--check-cfg` argument: `cfg(r#_)`
6 |
7 = note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
8 = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
9
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_lower.stderr created+5
......@@ -0,0 +1,5 @@
1error: invalid `--check-cfg` argument: `cfg(self)`
2 |
3 = note: malformed `cfg` input, expected a valid identifier
4 = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
5
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_upper.stderr created+5
......@@ -0,0 +1,5 @@
1error: invalid `--check-cfg` argument: `cfg(Self)`
2 |
3 = note: malformed `cfg` input, expected a valid identifier
4 = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
5
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_struct.stderr created+5
......@@ -0,0 +1,5 @@
1error: invalid `--check-cfg` argument: `cfg(struct)`
2 |
3 = note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
4 = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
5
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_super.stderr created+5
......@@ -0,0 +1,5 @@
1error: invalid `--check-cfg` argument: `cfg(super)`
2 |
3 = note: malformed `cfg` input, expected a valid identifier
4 = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
5
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_underscore.stderr created+5
......@@ -0,0 +1,5 @@
1error: invalid `--check-cfg` argument: `cfg(_)`
2 |
3 = note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
4 = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
5
tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.rs created+25
......@@ -0,0 +1,25 @@
1//@ edition: 2021
2
3//@ revisions: check_cfg_crate check_cfg_super check_cfg_self_lower check_cfg_self_upper
4//@ revisions: check_cfg_raw_crate check_cfg_raw_super check_cfg_raw_self_lower
5//@ revisions: check_cfg_raw_self_upper
6//@ revisions: check_cfg_struct check_cfg_priv check_cfg_underscore check_cfg_raw_underscore
7
8//@ [check_cfg_crate]compile-flags: --check-cfg 'cfg(crate)'
9//@ [check_cfg_super]compile-flags: --check-cfg 'cfg(super)'
10//@ [check_cfg_self_lower]compile-flags: --check-cfg 'cfg(self)'
11//@ [check_cfg_self_upper]compile-flags: --check-cfg 'cfg(Self)'
12
13//@ [check_cfg_raw_crate]compile-flags: --check-cfg 'cfg(r#crate)'
14//@ [check_cfg_raw_super]compile-flags: --check-cfg 'cfg(r#super)'
15//@ [check_cfg_raw_self_lower]compile-flags: --check-cfg 'cfg(r#self)'
16//@ [check_cfg_raw_self_upper]compile-flags: --check-cfg 'cfg(r#Self)'
17
18//@ [check_cfg_struct]compile-flags: --check-cfg 'cfg(struct)'
19//@ [check_cfg_priv]compile-flags: --check-cfg 'cfg(priv)'
20//@ [check_cfg_underscore]compile-flags: --check-cfg 'cfg(_)'
21//@ [check_cfg_raw_underscore]compile-flags: --check-cfg 'cfg(r#_)'
22
23fn main() {}
24
25//~? ERROR invalid `--check-cfg` argument
tests/ui/cfg/path-kw-as-cfg-pred-cli-raw-allow.rs created+6
......@@ -0,0 +1,6 @@
1//@ edition: 2024
2//@ check-pass
3//@ compile-flags: --cfg r#struct --cfg r#priv
4//@ compile-flags: --check-cfg 'cfg(r#struct)' --check-cfg 'cfg(r#priv)'
5
6fn main() {}
tests/ui/cfg/path-kw-as-cfg-pred.rs created+129
......@@ -0,0 +1,129 @@
1//@ edition: 2024
2
3#![allow(unexpected_cfgs)]
4
5macro_rules! foo {
6 () => {
7 #[cfg($crate)] //~ ERROR malformed `cfg` attribute input
8 mod _cfg_dollar_crate {}
9 #[cfg_attr($crate, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input
10 mod _cfg_attr_dollar_crate {}
11 #[cfg_attr(true, cfg($crate))] //~ ERROR malformed `cfg` attribute input
12 mod _cfg_attr_true_cfg_crate {}
13
14 cfg!($crate); //~ ERROR malformed `cfg` macro input
15 };
16}
17
18#[cfg(crate)] //~ ERROR malformed `cfg` attribute input
19mod _cfg_crate {}
20#[cfg(super)] //~ ERROR malformed `cfg` attribute input
21mod _cfg_super {}
22#[cfg(self)] //~ ERROR malformed `cfg` attribute input
23mod _cfg_self_lower {}
24#[cfg(Self)] //~ ERROR malformed `cfg` attribute input
25mod _cfg_self_upper {}
26#[cfg_attr(crate, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input
27mod _cfg_attr_crate {}
28#[cfg_attr(super, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input
29mod _cfg_attr_super {}
30#[cfg_attr(self, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input
31mod _cfg_attr_self_lower {}
32#[cfg_attr(Self, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input
33mod _cfg_attr_self_upper {}
34#[cfg_attr(true, cfg(crate))] //~ ERROR malformed `cfg` attribute input
35mod _cfg_attr_true_cfg_crate {}
36#[cfg_attr(true, cfg(super))] //~ ERROR malformed `cfg` attribute input
37mod _cfg_attr_true_cfg_super {}
38#[cfg_attr(true, cfg(self))] //~ ERROR malformed `cfg` attribute input
39mod _cfg_attr_true_cfg_self_lower {}
40#[cfg_attr(true, cfg(Self))] //~ ERROR malformed `cfg` attribute input
41mod _cfg_attr_true_cfg_self_upper {}
42
43#[cfg(struct)] //~ ERROR expected identifier, found keyword
44mod _cfg_struct {}
45#[cfg(priv)] //~ ERROR expected identifier, found reserved keyword `priv`
46mod _cfg_priv {}
47#[cfg(_)] //~ ERROR expected identifier, found reserved identifier `_`
48mod _cfg_underscore {}
49#[cfg_attr(struct, path = "foo")] //~ ERROR expected identifier, found keyword
50mod _cfg_attr_struct {}
51#[cfg_attr(priv, path = "foo")] //~ ERROR expected identifier, found reserved keyword `priv`
52mod _cfg_attr_priv {}
53#[cfg_attr(_, path = "foo")] //~ ERROR expected identifier, found reserved identifier `_`
54mod _cfg_attr_underscore {}
55#[cfg_attr(true, cfg(struct))] //~ ERROR expected identifier, found keyword
56mod _cfg_attr_true_cfg_struct {}
57#[cfg_attr(true, cfg(priv))] //~ ERROR expected identifier, found reserved keyword `priv`
58mod _cfg_attr_true_cfg_priv {}
59#[cfg_attr(true, cfg(_))] //~ ERROR expected identifier, found reserved identifier `_`
60mod _cfg_attr_true_cfg_underscore {}
61
62fn main() {
63 foo!();
64
65 cfg!(crate); //~ ERROR malformed `cfg` macro input
66 cfg!(super); //~ ERROR malformed `cfg` macro input
67 cfg!(self); //~ ERROR malformed `cfg` macro input
68 cfg!(Self); //~ ERROR malformed `cfg` macro input
69
70 cfg!(r#crate); //~ ERROR `crate` cannot be a raw identifier
71 //~^ ERROR malformed `cfg` macro input
72 cfg!(r#super); //~ ERROR `super` cannot be a raw identifier
73 //~^ ERROR malformed `cfg` macro input
74 cfg!(r#self); //~ ERROR `self` cannot be a raw identifier
75 //~^ ERROR malformed `cfg` macro input
76 cfg!(r#Self); //~ ERROR `Self` cannot be a raw identifier
77 //~^ ERROR malformed `cfg` macro input
78
79 cfg!(struct); //~ ERROR expected identifier, found keyword
80 cfg!(priv); //~ ERROR expected identifier, found reserved keyword `priv`
81 cfg!(_); //~ ERROR expected identifier, found reserved identifier `_`
82
83 cfg!(r#struct); // Ok
84 cfg!(r#priv); // Ok
85 cfg!(r#_); //~ ERROR `_` cannot be a raw identifier
86}
87
88#[cfg(r#crate)] //~ ERROR malformed `cfg` attribute input
89//~^ ERROR `crate` cannot be a raw identifier
90mod _cfg_r_crate {}
91#[cfg(r#super)] //~ ERROR malformed `cfg` attribute input
92//~^ ERROR `super` cannot be a raw identifier
93mod _cfg_r_super {}
94#[cfg(r#self)] //~ ERROR malformed `cfg` attribute input
95//~^ ERROR `self` cannot be a raw identifier
96mod _cfg_r_self_lower {}
97#[cfg(r#Self)] //~ ERROR malformed `cfg` attribute input
98//~^ ERROR `Self` cannot be a raw identifier
99mod _cfg_r_self_upper {}
100#[cfg_attr(r#crate, cfg(r#crate))] //~ ERROR malformed `cfg_attr` attribute input
101//~^ ERROR `crate` cannot be a raw identifier
102//~^^ ERROR `crate` cannot be a raw identifier
103mod _cfg_attr_r_crate {}
104#[cfg_attr(r#super, cfg(r#super))] //~ ERROR malformed `cfg_attr` attribute input
105//~^ ERROR `super` cannot be a raw identifier
106//~^^ ERROR `super` cannot be a raw identifier
107mod _cfg_attr_r_super {}
108#[cfg_attr(r#self, cfg(r#self))] //~ ERROR malformed `cfg_attr` attribute input
109//~^ ERROR `self` cannot be a raw identifier
110//~^^ ERROR `self` cannot be a raw identifier
111mod _cfg_attr_r_self_lower {}
112#[cfg_attr(r#Self, cfg(r#Self))] //~ ERROR malformed `cfg_attr` attribute input
113//~^ ERROR `Self` cannot be a raw identifier
114//~^^ ERROR `Self` cannot be a raw identifier
115mod _cfg_attr_r_self_upper {}
116
117#[cfg(r#struct)] // Ok
118mod _cfg_r_struct {}
119#[cfg(r#priv)] // Ok
120mod _cfg_r_priv {}
121#[cfg(r#_)] //~ ERROR `_` cannot be a raw identifier
122mod _cfg_r_underscore {}
123#[cfg_attr(r#struct, cfg(r#struct))] // Ok
124mod _cfg_attr_r_struct {}
125#[cfg_attr(r#priv, cfg(r#priv))] // Ok
126mod _cfg_attr_r_priv {}
127#[cfg_attr(r#_, cfg(r#_))] //~ ERROR `_` cannot be a raw identifier
128//~^ ERROR `_` cannot be a raw identifier
129mod _cfg_attr_r_underscore {}
tests/ui/cfg/path-kw-as-cfg-pred.stderr created+573
......@@ -0,0 +1,573 @@
1error: `crate` cannot be a raw identifier
2 --> $DIR/path-kw-as-cfg-pred.rs:70:10
3 |
4LL | cfg!(r#crate);
5 | ^^^^^^^
6
7error: `super` cannot be a raw identifier
8 --> $DIR/path-kw-as-cfg-pred.rs:72:10
9 |
10LL | cfg!(r#super);
11 | ^^^^^^^
12
13error: `self` cannot be a raw identifier
14 --> $DIR/path-kw-as-cfg-pred.rs:74:10
15 |
16LL | cfg!(r#self);
17 | ^^^^^^
18
19error: `Self` cannot be a raw identifier
20 --> $DIR/path-kw-as-cfg-pred.rs:76:10
21 |
22LL | cfg!(r#Self);
23 | ^^^^^^
24
25error: `_` cannot be a raw identifier
26 --> $DIR/path-kw-as-cfg-pred.rs:85:10
27 |
28LL | cfg!(r#_);
29 | ^^^
30
31error: `crate` cannot be a raw identifier
32 --> $DIR/path-kw-as-cfg-pred.rs:88:7
33 |
34LL | #[cfg(r#crate)]
35 | ^^^^^^^
36
37error: `super` cannot be a raw identifier
38 --> $DIR/path-kw-as-cfg-pred.rs:91:7
39 |
40LL | #[cfg(r#super)]
41 | ^^^^^^^
42
43error: `self` cannot be a raw identifier
44 --> $DIR/path-kw-as-cfg-pred.rs:94:7
45 |
46LL | #[cfg(r#self)]
47 | ^^^^^^
48
49error: `Self` cannot be a raw identifier
50 --> $DIR/path-kw-as-cfg-pred.rs:97:7
51 |
52LL | #[cfg(r#Self)]
53 | ^^^^^^
54
55error: `crate` cannot be a raw identifier
56 --> $DIR/path-kw-as-cfg-pred.rs:100:12
57 |
58LL | #[cfg_attr(r#crate, cfg(r#crate))]
59 | ^^^^^^^
60
61error: `crate` cannot be a raw identifier
62 --> $DIR/path-kw-as-cfg-pred.rs:100:25
63 |
64LL | #[cfg_attr(r#crate, cfg(r#crate))]
65 | ^^^^^^^
66
67error: `super` cannot be a raw identifier
68 --> $DIR/path-kw-as-cfg-pred.rs:104:12
69 |
70LL | #[cfg_attr(r#super, cfg(r#super))]
71 | ^^^^^^^
72
73error: `super` cannot be a raw identifier
74 --> $DIR/path-kw-as-cfg-pred.rs:104:25
75 |
76LL | #[cfg_attr(r#super, cfg(r#super))]
77 | ^^^^^^^
78
79error: `self` cannot be a raw identifier
80 --> $DIR/path-kw-as-cfg-pred.rs:108:12
81 |
82LL | #[cfg_attr(r#self, cfg(r#self))]
83 | ^^^^^^
84
85error: `self` cannot be a raw identifier
86 --> $DIR/path-kw-as-cfg-pred.rs:108:24
87 |
88LL | #[cfg_attr(r#self, cfg(r#self))]
89 | ^^^^^^
90
91error: `Self` cannot be a raw identifier
92 --> $DIR/path-kw-as-cfg-pred.rs:112:12
93 |
94LL | #[cfg_attr(r#Self, cfg(r#Self))]
95 | ^^^^^^
96
97error: `Self` cannot be a raw identifier
98 --> $DIR/path-kw-as-cfg-pred.rs:112:24
99 |
100LL | #[cfg_attr(r#Self, cfg(r#Self))]
101 | ^^^^^^
102
103error: `_` cannot be a raw identifier
104 --> $DIR/path-kw-as-cfg-pred.rs:121:7
105 |
106LL | #[cfg(r#_)]
107 | ^^^
108
109error: `_` cannot be a raw identifier
110 --> $DIR/path-kw-as-cfg-pred.rs:127:12
111 |
112LL | #[cfg_attr(r#_, cfg(r#_))]
113 | ^^^
114
115error: `_` cannot be a raw identifier
116 --> $DIR/path-kw-as-cfg-pred.rs:127:21
117 |
118LL | #[cfg_attr(r#_, cfg(r#_))]
119 | ^^^
120
121error[E0539]: malformed `cfg` attribute input
122 --> $DIR/path-kw-as-cfg-pred.rs:18:1
123 |
124LL | #[cfg(crate)]
125 | ^^^^^^-----^^
126 | | |
127 | | expected a valid identifier here
128 | help: must be of the form: `#[cfg(predicate)]`
129 |
130 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
131
132error[E0539]: malformed `cfg` attribute input
133 --> $DIR/path-kw-as-cfg-pred.rs:20:1
134 |
135LL | #[cfg(super)]
136 | ^^^^^^-----^^
137 | | |
138 | | expected a valid identifier here
139 | help: must be of the form: `#[cfg(predicate)]`
140 |
141 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
142
143error[E0539]: malformed `cfg` attribute input
144 --> $DIR/path-kw-as-cfg-pred.rs:22:1
145 |
146LL | #[cfg(self)]
147 | ^^^^^^----^^
148 | | |
149 | | expected a valid identifier here
150 | help: must be of the form: `#[cfg(predicate)]`
151 |
152 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
153
154error[E0539]: malformed `cfg` attribute input
155 --> $DIR/path-kw-as-cfg-pred.rs:24:1
156 |
157LL | #[cfg(Self)]
158 | ^^^^^^----^^
159 | | |
160 | | expected a valid identifier here
161 | help: must be of the form: `#[cfg(predicate)]`
162 |
163 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
164
165error[E0539]: malformed `cfg_attr` attribute input
166 --> $DIR/path-kw-as-cfg-pred.rs:26:1
167 |
168LL | #[cfg_attr(crate, path = "foo")]
169 | ^^^^^^^^^^^-----^^^^^^^^^^^^^^^^
170 | | |
171 | | expected a valid identifier here
172 | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
173 |
174 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
175
176error[E0539]: malformed `cfg_attr` attribute input
177 --> $DIR/path-kw-as-cfg-pred.rs:28:1
178 |
179LL | #[cfg_attr(super, path = "foo")]
180 | ^^^^^^^^^^^-----^^^^^^^^^^^^^^^^
181 | | |
182 | | expected a valid identifier here
183 | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
184 |
185 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
186
187error[E0539]: malformed `cfg_attr` attribute input
188 --> $DIR/path-kw-as-cfg-pred.rs:30:1
189 |
190LL | #[cfg_attr(self, path = "foo")]
191 | ^^^^^^^^^^^----^^^^^^^^^^^^^^^^
192 | | |
193 | | expected a valid identifier here
194 | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
195 |
196 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
197
198error[E0539]: malformed `cfg_attr` attribute input
199 --> $DIR/path-kw-as-cfg-pred.rs:32:1
200 |
201LL | #[cfg_attr(Self, path = "foo")]
202 | ^^^^^^^^^^^----^^^^^^^^^^^^^^^^
203 | | |
204 | | expected a valid identifier here
205 | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
206 |
207 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
208
209error[E0539]: malformed `cfg` attribute input
210 --> $DIR/path-kw-as-cfg-pred.rs:34:18
211 |
212LL | #[cfg_attr(true, cfg(crate))]
213 | ^^^^-----^
214 | | |
215 | | expected a valid identifier here
216 | help: must be of the form: `cfg(predicate)`
217 |
218 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
219
220error[E0539]: malformed `cfg` attribute input
221 --> $DIR/path-kw-as-cfg-pred.rs:36:18
222 |
223LL | #[cfg_attr(true, cfg(super))]
224 | ^^^^-----^
225 | | |
226 | | expected a valid identifier here
227 | help: must be of the form: `cfg(predicate)`
228 |
229 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
230
231error[E0539]: malformed `cfg` attribute input
232 --> $DIR/path-kw-as-cfg-pred.rs:38:18
233 |
234LL | #[cfg_attr(true, cfg(self))]
235 | ^^^^----^
236 | | |
237 | | expected a valid identifier here
238 | help: must be of the form: `cfg(predicate)`
239 |
240 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
241
242error[E0539]: malformed `cfg` attribute input
243 --> $DIR/path-kw-as-cfg-pred.rs:40:18
244 |
245LL | #[cfg_attr(true, cfg(Self))]
246 | ^^^^----^
247 | | |
248 | | expected a valid identifier here
249 | help: must be of the form: `cfg(predicate)`
250 |
251 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
252
253error: expected identifier, found keyword `struct`
254 --> $DIR/path-kw-as-cfg-pred.rs:43:7
255 |
256LL | #[cfg(struct)]
257 | ^^^^^^ expected identifier, found keyword
258
259error: expected identifier, found reserved keyword `priv`
260 --> $DIR/path-kw-as-cfg-pred.rs:45:7
261 |
262LL | #[cfg(priv)]
263 | ^^^^ expected identifier, found reserved keyword
264
265error: expected identifier, found reserved identifier `_`
266 --> $DIR/path-kw-as-cfg-pred.rs:47:7
267 |
268LL | #[cfg(_)]
269 | ^ expected identifier, found reserved identifier
270
271error: expected identifier, found keyword `struct`
272 --> $DIR/path-kw-as-cfg-pred.rs:49:12
273 |
274LL | #[cfg_attr(struct, path = "foo")]
275 | ^^^^^^ expected identifier, found keyword
276 |
277help: escape `struct` to use it as an identifier
278 |
279LL | #[cfg_attr(r#struct, path = "foo")]
280 | ++
281
282error: expected identifier, found reserved keyword `priv`
283 --> $DIR/path-kw-as-cfg-pred.rs:51:12
284 |
285LL | #[cfg_attr(priv, path = "foo")]
286 | ^^^^ expected identifier, found reserved keyword
287 |
288help: escape `priv` to use it as an identifier
289 |
290LL | #[cfg_attr(r#priv, path = "foo")]
291 | ++
292
293error: expected identifier, found reserved identifier `_`
294 --> $DIR/path-kw-as-cfg-pred.rs:53:12
295 |
296LL | #[cfg_attr(_, path = "foo")]
297 | ^ expected identifier, found reserved identifier
298
299error: expected identifier, found keyword `struct`
300 --> $DIR/path-kw-as-cfg-pred.rs:55:22
301 |
302LL | #[cfg_attr(true, cfg(struct))]
303 | ^^^^^^ expected identifier, found keyword
304
305error: expected identifier, found reserved keyword `priv`
306 --> $DIR/path-kw-as-cfg-pred.rs:57:22
307 |
308LL | #[cfg_attr(true, cfg(priv))]
309 | ^^^^ expected identifier, found reserved keyword
310
311error: expected identifier, found reserved identifier `_`
312 --> $DIR/path-kw-as-cfg-pred.rs:59:22
313 |
314LL | #[cfg_attr(true, cfg(_))]
315 | ^ expected identifier, found reserved identifier
316
317error[E0539]: malformed `cfg` attribute input
318 --> $DIR/path-kw-as-cfg-pred.rs:88:1
319 |
320LL | #[cfg(r#crate)]
321 | ^^^^^^-------^^
322 | | |
323 | | expected a valid identifier here
324 | help: must be of the form: `#[cfg(predicate)]`
325 |
326 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
327
328error[E0539]: malformed `cfg` attribute input
329 --> $DIR/path-kw-as-cfg-pred.rs:91:1
330 |
331LL | #[cfg(r#super)]
332 | ^^^^^^-------^^
333 | | |
334 | | expected a valid identifier here
335 | help: must be of the form: `#[cfg(predicate)]`
336 |
337 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
338
339error[E0539]: malformed `cfg` attribute input
340 --> $DIR/path-kw-as-cfg-pred.rs:94:1
341 |
342LL | #[cfg(r#self)]
343 | ^^^^^^------^^
344 | | |
345 | | expected a valid identifier here
346 | help: must be of the form: `#[cfg(predicate)]`
347 |
348 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
349
350error[E0539]: malformed `cfg` attribute input
351 --> $DIR/path-kw-as-cfg-pred.rs:97:1
352 |
353LL | #[cfg(r#Self)]
354 | ^^^^^^------^^
355 | | |
356 | | expected a valid identifier here
357 | help: must be of the form: `#[cfg(predicate)]`
358 |
359 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
360
361error[E0539]: malformed `cfg_attr` attribute input
362 --> $DIR/path-kw-as-cfg-pred.rs:100:1
363 |
364LL | #[cfg_attr(r#crate, cfg(r#crate))]
365 | ^^^^^^^^^^^-------^^^^^^^^^^^^^^^^
366 | | |
367 | | expected a valid identifier here
368 | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
369 |
370 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
371
372error[E0539]: malformed `cfg_attr` attribute input
373 --> $DIR/path-kw-as-cfg-pred.rs:104:1
374 |
375LL | #[cfg_attr(r#super, cfg(r#super))]
376 | ^^^^^^^^^^^-------^^^^^^^^^^^^^^^^
377 | | |
378 | | expected a valid identifier here
379 | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
380 |
381 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
382
383error[E0539]: malformed `cfg_attr` attribute input
384 --> $DIR/path-kw-as-cfg-pred.rs:108:1
385 |
386LL | #[cfg_attr(r#self, cfg(r#self))]
387 | ^^^^^^^^^^^------^^^^^^^^^^^^^^^
388 | | |
389 | | expected a valid identifier here
390 | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
391 |
392 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
393
394error[E0539]: malformed `cfg_attr` attribute input
395 --> $DIR/path-kw-as-cfg-pred.rs:112:1
396 |
397LL | #[cfg_attr(r#Self, cfg(r#Self))]
398 | ^^^^^^^^^^^------^^^^^^^^^^^^^^^
399 | | |
400 | | expected a valid identifier here
401 | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
402 |
403 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
404
405error[E0539]: malformed `cfg` attribute input
406 --> $DIR/path-kw-as-cfg-pred.rs:7:9
407 |
408LL | #[cfg($crate)]
409 | ^^^^^^------^^
410 | | |
411 | | expected a valid identifier here
412 | help: must be of the form: `#[cfg(predicate)]`
413...
414LL | foo!();
415 | ------ in this macro invocation
416 |
417 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
418 = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
419
420error[E0539]: malformed `cfg_attr` attribute input
421 --> $DIR/path-kw-as-cfg-pred.rs:9:9
422 |
423LL | #[cfg_attr($crate, path = "foo")]
424 | ^^^^^^^^^^^------^^^^^^^^^^^^^^^^
425 | | |
426 | | expected a valid identifier here
427 | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
428...
429LL | foo!();
430 | ------ in this macro invocation
431 |
432 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
433 = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
434
435error[E0539]: malformed `cfg` attribute input
436 --> $DIR/path-kw-as-cfg-pred.rs:11:26
437 |
438LL | #[cfg_attr(true, cfg($crate))]
439 | ^^^^------^
440 | | |
441 | | expected a valid identifier here
442 | help: must be of the form: `cfg(predicate)`
443...
444LL | foo!();
445 | ------ in this macro invocation
446 |
447 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
448 = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
449
450error[E0539]: malformed `cfg` macro input
451 --> $DIR/path-kw-as-cfg-pred.rs:14:9
452 |
453LL | cfg!($crate);
454 | ^^^^^------^
455 | | |
456 | | expected a valid identifier here
457 | help: must be of the form: `cfg!(predicate)`
458...
459LL | foo!();
460 | ------ in this macro invocation
461 |
462 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
463 = 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)
464
465error[E0539]: malformed `cfg` macro input
466 --> $DIR/path-kw-as-cfg-pred.rs:65:5
467 |
468LL | cfg!(crate);
469 | ^^^^^-----^
470 | | |
471 | | expected a valid identifier here
472 | help: must be of the form: `cfg!(predicate)`
473 |
474 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
475
476error[E0539]: malformed `cfg` macro input
477 --> $DIR/path-kw-as-cfg-pred.rs:66:5
478 |
479LL | cfg!(super);
480 | ^^^^^-----^
481 | | |
482 | | expected a valid identifier here
483 | help: must be of the form: `cfg!(predicate)`
484 |
485 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
486
487error[E0539]: malformed `cfg` macro input
488 --> $DIR/path-kw-as-cfg-pred.rs:67:5
489 |
490LL | cfg!(self);
491 | ^^^^^----^
492 | | |
493 | | expected a valid identifier here
494 | help: must be of the form: `cfg!(predicate)`
495 |
496 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
497
498error[E0539]: malformed `cfg` macro input
499 --> $DIR/path-kw-as-cfg-pred.rs:68:5
500 |
501LL | cfg!(Self);
502 | ^^^^^----^
503 | | |
504 | | expected a valid identifier here
505 | help: must be of the form: `cfg!(predicate)`
506 |
507 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
508
509error[E0539]: malformed `cfg` macro input
510 --> $DIR/path-kw-as-cfg-pred.rs:70:5
511 |
512LL | cfg!(r#crate);
513 | ^^^^^-------^
514 | | |
515 | | expected a valid identifier here
516 | help: must be of the form: `cfg!(predicate)`
517 |
518 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
519
520error[E0539]: malformed `cfg` macro input
521 --> $DIR/path-kw-as-cfg-pred.rs:72:5
522 |
523LL | cfg!(r#super);
524 | ^^^^^-------^
525 | | |
526 | | expected a valid identifier here
527 | help: must be of the form: `cfg!(predicate)`
528 |
529 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
530
531error[E0539]: malformed `cfg` macro input
532 --> $DIR/path-kw-as-cfg-pred.rs:74:5
533 |
534LL | cfg!(r#self);
535 | ^^^^^------^
536 | | |
537 | | expected a valid identifier here
538 | help: must be of the form: `cfg!(predicate)`
539 |
540 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
541
542error[E0539]: malformed `cfg` macro input
543 --> $DIR/path-kw-as-cfg-pred.rs:76:5
544 |
545LL | cfg!(r#Self);
546 | ^^^^^------^
547 | | |
548 | | expected a valid identifier here
549 | help: must be of the form: `cfg!(predicate)`
550 |
551 = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
552
553error: expected identifier, found keyword `struct`
554 --> $DIR/path-kw-as-cfg-pred.rs:79:10
555 |
556LL | cfg!(struct);
557 | ^^^^^^ expected identifier, found keyword
558
559error: expected identifier, found reserved keyword `priv`
560 --> $DIR/path-kw-as-cfg-pred.rs:80:10
561 |
562LL | cfg!(priv);
563 | ^^^^ expected identifier, found reserved keyword
564
565error: expected identifier, found reserved identifier `_`
566 --> $DIR/path-kw-as-cfg-pred.rs:81:10
567 |
568LL | cfg!(_);
569 | ^ expected identifier, found reserved identifier
570
571error: aborting due to 64 previous errors
572
573For more information about this error, try `rustc --explain E0539`.
tests/ui/cfg/raw-true-false.rs+1-5
......@@ -1,9 +1,5 @@
11//@ check-pass
2//@ revisions: r0x0 r0x1 r1x0 r1x1
3//@[r0x0] compile-flags: --cfg false --check-cfg=cfg(false)
4//@[r0x1] compile-flags: --cfg false --check-cfg=cfg(r#false)
5//@[r1x0] compile-flags: --cfg r#false --check-cfg=cfg(false)
6//@[r1x1] compile-flags: --cfg r#false --check-cfg=cfg(r#false)
2//@ compile-flags: --cfg r#false --check-cfg=cfg(r#false)
73#![deny(unexpected_cfgs)]
84fn main() {
95 #[cfg(not(r#false))]
tests/ui/check-cfg/raw-keywords.rs+1-1
......@@ -3,7 +3,7 @@
33//
44//@ check-pass
55//@ no-auto-check-cfg
6//@ compile-flags: --cfg=true --cfg=async --check-cfg=cfg(r#true,r#async,edition2015,edition2021)
6//@ compile-flags: --cfg=r#true --cfg=r#async --check-cfg=cfg(r#true,r#async,edition2015,edition2021)
77//
88//@ revisions: edition2015 edition2021
99//@ [edition2015] edition: 2015
tests/ui/conditional-compilation/cfg-arg-invalid-7.rs+1-1
......@@ -3,4 +3,4 @@
33//@ compile-flags: --cfg a"
44
55//~? RAW unterminated double quote string
6//~? RAW this error occurred on the command line
6//~? RAW this occurred on the command line
tests/ui/conditional-compilation/cfg-arg-invalid-7.stderr+1-1
......@@ -1,4 +1,4 @@
11error[E0765]: unterminated double quote string
22 |
3 = note: this error occurred on the command line: `--cfg=a"`
3 = note: this occurred on the command line: `--cfg=a"`
44
tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr deleted-25
......@@ -1,25 +0,0 @@
1error[E0080]: reached the configured maximum number of stack frames
2 --> $DIR/ctfe-id-unlimited.rs:28:20
3 |
4LL | const ID_ED: u32 = rec_id(ORIGINAL);
5 | ^^^^^^^^^^^^^^^^ evaluation of `ID_ED` failed inside this call
6 |
7note: inside `rec_id`
8 --> $DIR/ctfe-id-unlimited.rs:21:5
9 |
10LL | inner(0, n)
11 | ^^^^^^^^^^^
12note: [... 125 additional calls inside `inner` ...]
13 --> $DIR/ctfe-id-unlimited.rs:17:42
14 |
15LL | #[cfg(r#return)] _ => return inner(acc + 1, n - 1),
16 | ^^^^^^^^^^^^^^^^^^^^^
17note: inside `inner`
18 --> $DIR/ctfe-id-unlimited.rs:17:42
19 |
20LL | #[cfg(r#return)] _ => return inner(acc + 1, n - 1),
21 | ^^^^^^^^^^^^^^^^^^^^^ the failure occurred here
22
23error: aborting due to 1 previous error
24
25For more information about this error, try `rustc --explain E0080`.
tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr created+25
......@@ -0,0 +1,25 @@
1error[E0080]: reached the configured maximum number of stack frames
2 --> $DIR/ctfe-id-unlimited.rs:28:20
3 |
4LL | const ID_ED: u32 = rec_id(ORIGINAL);
5 | ^^^^^^^^^^^^^^^^ evaluation of `ID_ED` failed inside this call
6 |
7note: inside `rec_id`
8 --> $DIR/ctfe-id-unlimited.rs:21:5
9 |
10LL | inner(0, n)
11 | ^^^^^^^^^^^
12note: [... 125 additional calls inside `inner` ...]
13 --> $DIR/ctfe-id-unlimited.rs:17:41
14 |
15LL | #[cfg(return_)] _ => return inner(acc + 1, n - 1),
16 | ^^^^^^^^^^^^^^^^^^^^^
17note: inside `inner`
18 --> $DIR/ctfe-id-unlimited.rs:17:41
19 |
20LL | #[cfg(return_)] _ => return inner(acc + 1, n - 1),
21 | ^^^^^^^^^^^^^^^^^^^^^ the failure occurred here
22
23error: aborting due to 1 previous error
24
25For more information about this error, try `rustc --explain E0080`.
tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs+5-5
......@@ -1,5 +1,5 @@
1//@ revisions: become return
2//@ [become] run-pass
1//@ revisions: become_ return_
2//@ [become_] run-pass
33#![expect(incomplete_features)]
44#![feature(explicit_tail_calls)]
55
......@@ -13,8 +13,8 @@ const fn rec_id(n: u32) -> u32 {
1313 const fn inner(acc: u32, n: u32) -> u32 {
1414 match n {
1515 0 => acc,
16 #[cfg(r#become)] _ => become inner(acc + 1, n - 1),
17 #[cfg(r#return)] _ => return inner(acc + 1, n - 1),
16 #[cfg(become_)] _ => become inner(acc + 1, n - 1),
17 #[cfg(return_)] _ => return inner(acc + 1, n - 1),
1818 }
1919 }
2020
......@@ -25,7 +25,7 @@ const fn rec_id(n: u32) -> u32 {
2525const ORIGINAL: u32 = 12345;
2626// Original number, but with identity function applied
2727// (this is the same, but requires execution of the recursion)
28const ID_ED: u32 = rec_id(ORIGINAL); //[return]~ ERROR: reached the configured maximum number of stack frames
28const ID_ED: u32 = rec_id(ORIGINAL); //[return_]~ ERROR: reached the configured maximum number of stack frames
2929// Assert to make absolutely sure the computation actually happens
3030const ASSERT: () = assert!(ORIGINAL == ID_ED);
3131
tests/ui/resolve/regression-struct-called-as-function-148919.rs created+10
......@@ -0,0 +1,10 @@
1struct Bar {}
2
3impl Bar {
4 fn into_self(self) -> Bar {
5 Bar(self)
6 //~^ ERROR expected function, tuple struct or tuple variant, found struct `Bar` [E0423]
7 }
8}
9
10fn main() {}
tests/ui/resolve/regression-struct-called-as-function-148919.stderr created+9
......@@ -0,0 +1,9 @@
1error[E0423]: expected function, tuple struct or tuple variant, found struct `Bar`
2 --> $DIR/regression-struct-called-as-function-148919.rs:5:9
3 |
4LL | Bar(self)
5 | ^^^
6
7error: aborting due to 1 previous error
8
9For more information about this error, try `rustc --explain E0423`.
tests/ui/use/use-path-segment-kw.rs created+250
......@@ -0,0 +1,250 @@
1//@ edition: 2021
2
3macro_rules! macro_dollar_crate {
4 () => {
5 use $crate::*;
6 use $crate::{};
7
8 type A1 = $crate; //~ ERROR expected type, found module `$crate`
9 use $crate; //~ ERROR `$crate` may not be imported
10 pub use $crate as _dollar_crate; //~ ERROR `$crate` may not be imported
11
12 type A2 = ::$crate; //~ ERROR failed to resolve: global paths cannot start with `$crate`
13 use ::$crate; //~ ERROR unresolved import `$crate`
14 use ::$crate as _dollar_crate2; //~ ERROR unresolved import `$crate`
15 use ::{$crate}; //~ ERROR unresolved import `$crate`
16 use ::{$crate as _nested_dollar_crate2}; //~ ERROR unresolved import `$crate`
17
18 type A3 = foobar::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position
19 use foobar::$crate; //~ ERROR unresolved import `foobar::$crate`
20 use foobar::$crate as _dollar_crate3; //~ ERROR unresolved import `foobar::$crate`
21 use foobar::{$crate}; //~ ERROR unresolved import `foobar::$crate`
22 use foobar::{$crate as _nested_dollar_crate3}; //~ ERROR unresolved import `foobar::$crate`
23
24 type A4 = crate::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position
25 use crate::$crate; //~ ERROR unresolved import `crate::$crate`
26 use crate::$crate as _dollar_crate4; //~ ERROR unresolved import `crate::$crate`
27 use crate::{$crate}; //~ ERROR unresolved import `crate::$crate`
28 use crate::{$crate as _nested_dollar_crate4}; //~ ERROR unresolved import `crate::$crate`
29
30 type A5 = super::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position
31 use super::$crate; //~ ERROR unresolved import `super::$crate`
32 use super::$crate as _dollar_crate5; //~ ERROR unresolved import `super::$crate`
33 use super::{$crate}; //~ ERROR unresolved import `super::$crate`
34 use super::{$crate as _nested_dollar_crate5}; //~ ERROR unresolved import `super::$crate`
35
36 type A6 = self::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position
37 use self::$crate;
38 use self::$crate as _dollar_crate6;
39 use self::{$crate};
40 use self::{$crate as _nested_dollar_crate6};
41
42 type A7 = $crate::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position
43 use $crate::$crate; //~ ERROR unresolved import `$crate::$crate`
44 use $crate::$crate as _dollar_crate7; //~ ERROR unresolved import `$crate::$crate`
45 use $crate::{$crate}; //~ ERROR unresolved import `$crate::$crate`
46 use $crate::{$crate as _nested_dollar_crate7}; //~ ERROR unresolved import `$crate::$crate`
47
48 type A8 = $crate::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position
49 use $crate::crate; //~ ERROR unresolved import `$crate::crate`
50 //~^ ERROR crate root imports need to be explicitly named: `use crate as name;`
51 use $crate::crate as _m_crate8; //~ ERROR unresolved import `$crate::crate`
52 use $crate::{crate}; //~ ERROR unresolved import `$crate::crate`
53 //~^ ERROR crate root imports need to be explicitly named: `use crate as name;`
54 use $crate::{crate as _m_nested_crate8}; //~ ERROR unresolved import `$crate::crate`
55
56 type A9 = $crate::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position
57 use $crate::super; //~ ERROR unresolved import `$crate::super`
58 use $crate::super as _m_super8; //~ ERROR unresolved import `$crate::super`
59 use $crate::{super}; //~ ERROR unresolved import `$crate::super`
60 use $crate::{super as _m_nested_super8}; //~ ERROR unresolved import `$crate::super`
61
62 type A10 = $crate::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position
63 use $crate::self; //~ ERROR `$crate` may not be imported
64 //~^ ERROR `self` imports are only allowed within a { } list
65 //~^^ ERROR the name `<!dummy!>` is defined multiple times
66 pub use $crate::self as _m_self8; //~ ERROR `self` imports are only allowed within a { } list
67 //~^ ERROR `$crate` may not be imported
68 use $crate::{self};
69 //~^ ERROR the name `$crate` is defined multiple times
70 pub use $crate::{self as _m_nested_self8}; // Good
71 }
72}
73
74fn outer() {}
75
76mod foo {
77 pub mod bar {
78 pub mod foobar {
79 pub mod qux {
80 pub use super::inner;
81 }
82
83 pub mod baz {
84 pub use super::inner;
85 }
86
87 pub fn inner() {}
88 }
89
90 // --- $crate ---
91 macro_dollar_crate!();
92
93 // --- crate ---
94 use crate::*;
95 use crate::{};
96
97 type B1 = crate; //~ ERROR expected type, found module `crate`
98 use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;`
99 pub use crate as _crate; // Good
100
101 type B2 = ::crate; //~ ERROR failed to resolve: global paths cannot start with `crate`
102 use ::crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;`
103 //~^ ERROR unresolved import `crate`
104 use ::crate as _crate2; //~ ERROR unresolved import `crate`
105 use ::{crate}; //~ ERROR crate root imports need to be explicitly named: `use crate as name;`
106 //~^ ERROR unresolved import `crate`
107 use ::{crate as _nested_crate2}; //~ ERROR unresolved import `crate`
108
109 type B3 = foobar::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position
110 use foobar::crate; //~ ERROR unresolved import `foobar::crate`
111 //~^ ERROR crate root imports need to be explicitly named: `use crate as name;`
112 use foobar::crate as _crate3; //~ ERROR unresolved import `foobar::crate`
113 use foobar::{crate}; //~ ERROR unresolved import `foobar::crate`
114 //~^ ERROR crate root imports need to be explicitly named: `use crate as name;`
115 use foobar::{crate as _nested_crate3}; //~ ERROR unresolved import `foobar::crate`
116
117 type B4 = crate::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position
118 use crate::crate; //~ ERROR unresolved import `crate::crate`
119 //~^ ERROR crate root imports need to be explicitly named: `use crate as name;`
120 use crate::crate as _crate4; //~ ERROR unresolved import `crate::crate`
121 use crate::{crate}; //~ ERROR unresolved import `crate::crate`
122 //~^ ERROR crate root imports need to be explicitly named: `use crate as name;`
123 use crate::{crate as _nested_crate4}; //~ ERROR unresolved import `crate::crate`
124
125 type B5 = super::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position
126 use super::crate; //~ ERROR unresolved import `super::crate`
127 //~^ ERROR crate root imports need to be explicitly named: `use crate as name;`
128 use super::crate as _crate5; //~ ERROR unresolved import `super::crate`
129 use super::{crate}; //~ ERROR unresolved import `super::crate`
130 //~^ ERROR crate root imports need to be explicitly named: `use crate as name;`
131 use super::{crate as _nested_crate5}; //~ ERROR unresolved import `super::crate`
132
133 type B6 = self::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position
134 use self::crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;`
135 //~^ ERROR the name `crate` is defined multiple times
136 use self::crate as _crate6;
137 use self::{crate}; //~ ERROR crate root imports need to be explicitly named: `use crate as name;`
138 //~^ ERROR the name `crate` is defined multiple times
139 use self::{crate as _nested_crate6};
140
141 // --- super ---
142 use super::*;
143 use super::{}; //~ ERROR unresolved import `super`
144
145 type C1 = super; //~ ERROR expected type, found module `super`
146 use super; //~ ERROR unresolved import `super`
147 pub use super as _super; //~ ERROR unresolved import `super`
148
149 type C2 = ::super; //~ ERROR failed to resolve: global paths cannot start with `super`
150 use ::super; //~ ERROR unresolved import `super`
151 use ::super as _super2; //~ ERROR unresolved import `super`
152 use ::{super}; //~ ERROR unresolved import `super`
153 use ::{super as _nested_super2}; //~ ERROR unresolved import `super`
154
155 type C3 = foobar::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position
156 use foobar::super; //~ ERROR unresolved import `foobar::super`
157 use foobar::super as _super3; //~ ERROR unresolved import `foobar::super`
158 use foobar::{super}; //~ ERROR unresolved import `foobar::super`
159 use foobar::{super as _nested_super3}; //~ ERROR unresolved import `foobar::super`
160
161 type C4 = crate::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position
162 use crate::super; //~ ERROR unresolved import `crate::super`
163 use crate::super as _super4; //~ ERROR unresolved import `crate::super`
164 use crate::{super}; //~ ERROR unresolved import `crate::super`
165 use crate::{super as _nested_super4}; //~ ERROR unresolved import `crate::super`
166
167 type C5 = super::super; //~ ERROR expected type, found module `super::super`
168 use super::super; //~ ERROR unresolved import `super::super`
169 pub use super::super as _super5; //~ ERROR unresolved import `super::super`
170 use super::{super}; //~ ERROR unresolved import `super::super`
171 pub use super::{super as _nested_super5}; //~ ERROR unresolved import `super::super`
172
173 type C6 = self::super; //~ ERROR expected type, found module `self::super`
174 use self::super;
175 use self::super as _super6;
176 use self::{super};
177 use self::{super as _nested_super6};
178
179 // --- self ---
180 // use self::*; // Suppress other errors
181 use self::{}; //~ ERROR unresolved import `self`
182
183 type D1 = self; //~ ERROR expected type, found module `self`
184 use self; //~ ERROR `self` imports are only allowed within a { } list
185 pub use self as _self; //~ ERROR `self` imports are only allowed within a { } list
186
187 type D2 = ::self; //~ ERROR failed to resolve: global paths cannot start with `self`
188 use ::self; //~ ERROR `self` imports are only allowed within a { } list
189 //~^ ERROR unresolved import `{{root}}`
190 use ::self as _self2; //~ ERROR `self` imports are only allowed within a { } list
191 //~^ ERROR unresolved import `{{root}}`
192 use ::{self}; //~ ERROR `self` import can only appear in an import list with a non-empty prefix
193 use ::{self as _nested_self2}; //~ ERROR `self` import can only appear in an import list with a non-empty prefix
194
195 type D3 = foobar::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position
196 pub use foobar::qux::self; //~ ERROR `self` imports are only allowed within a { } list
197 pub use foobar::self as _self3; //~ ERROR `self` imports are only allowed within a { } list
198 pub use foobar::baz::{self}; // Good
199 pub use foobar::{self as _nested_self3}; // Good
200
201 type D4 = crate::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position
202 use crate::self; //~ ERROR crate root imports need to be explicitly named: `use crate as name;`
203 //~^ ERROR `self` imports are only allowed within a { } list
204 //~^^ ERROR the name `crate` is defined multiple times
205 pub use crate::self as _self4; //~ ERROR `self` imports are only allowed within a { } list
206 use crate::{self}; //~ ERROR crate root imports need to be explicitly named: `use crate as name;`
207 //~^ ERROR the name `crate` is defined multiple times
208 pub use crate::{self as _nested_self4}; // Good
209
210 type D5 = super::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position
211 use super::self; //~ ERROR unresolved import `super`
212 //~^ ERROR `self` imports are only allowed within a { } list
213 pub use super::self as _self5; //~ ERROR `self` imports are only allowed within a { } list
214 //~^ ERROR unresolved import `super`
215 use super::{self}; //~ ERROR unresolved import `super`
216 pub use super::{self as _nested_self5}; //~ ERROR unresolved import `super`
217
218 type D6 = self::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position
219 use self::self; //~ ERROR `self` imports are only allowed within a { } list
220 pub use self::self as _self6; //~ ERROR `self` imports are only allowed within a { } list
221 use self::{self}; //~ ERROR unresolved import `self`
222 pub use self::{self as _nested_self6}; //~ ERROR unresolved import `self`
223 }
224}
225
226fn main() {
227 foo::bar::_dollar_crate::outer();
228 foo::bar::_m_self8::outer();
229 foo::bar::_dollar_crate::foo::bar::foobar::inner();
230 foo::bar::_m_self8::foo::bar::foobar::inner();
231
232 foo::bar::_crate::outer();
233 foo::bar::_crate::foo::bar::foobar::inner();
234
235 foo::bar::_super::bar::foobar::inner();
236 foo::bar::_super5::outer();
237 foo::bar::_nested_super5::outer();
238
239 foo::bar::_self::foobar::inner();
240 foo::bar::qux::inner(); // Works after recovery
241 foo::bar::baz::inner();
242 foo::bar::_self3::inner(); // Works after recovery
243 foo::bar::_nested_self3::inner();
244 foo::bar::_self4::outer(); // Works after recovery
245 foo::bar::_nested_self4::outer();
246 foo::bar::_self5::bar::foobar::inner(); // Works after recovery
247 foo::bar::_nested_self5::bar::foobar::inner();
248 foo::bar::_self6::foobar::inner(); // Works after recovery
249 foo::bar::_nested_self6::foobar::inner();
250}
tests/ui/use/use-path-segment-kw.stderr created+1245
......@@ -0,0 +1,1245 @@
1error: crate root imports need to be explicitly named: `use crate as name;`
2 --> $DIR/use-path-segment-kw.rs:98:13
3 |
4LL | use crate;
5 | ^^^^^
6
7error: crate root imports need to be explicitly named: `use crate as name;`
8 --> $DIR/use-path-segment-kw.rs:102:15
9 |
10LL | use ::crate;
11 | ^^^^^
12
13error: crate root imports need to be explicitly named: `use crate as name;`
14 --> $DIR/use-path-segment-kw.rs:105:16
15 |
16LL | use ::{crate};
17 | ^^^^^
18
19error: crate root imports need to be explicitly named: `use crate as name;`
20 --> $DIR/use-path-segment-kw.rs:110:21
21 |
22LL | use foobar::crate;
23 | ^^^^^
24
25error: crate root imports need to be explicitly named: `use crate as name;`
26 --> $DIR/use-path-segment-kw.rs:113:22
27 |
28LL | use foobar::{crate};
29 | ^^^^^
30
31error: crate root imports need to be explicitly named: `use crate as name;`
32 --> $DIR/use-path-segment-kw.rs:118:20
33 |
34LL | use crate::crate;
35 | ^^^^^
36
37error: crate root imports need to be explicitly named: `use crate as name;`
38 --> $DIR/use-path-segment-kw.rs:121:21
39 |
40LL | use crate::{crate};
41 | ^^^^^
42
43error: crate root imports need to be explicitly named: `use crate as name;`
44 --> $DIR/use-path-segment-kw.rs:126:20
45 |
46LL | use super::crate;
47 | ^^^^^
48
49error: crate root imports need to be explicitly named: `use crate as name;`
50 --> $DIR/use-path-segment-kw.rs:129:21
51 |
52LL | use super::{crate};
53 | ^^^^^
54
55error: crate root imports need to be explicitly named: `use crate as name;`
56 --> $DIR/use-path-segment-kw.rs:134:19
57 |
58LL | use self::crate;
59 | ^^^^^
60
61error: crate root imports need to be explicitly named: `use crate as name;`
62 --> $DIR/use-path-segment-kw.rs:137:20
63 |
64LL | use self::{crate};
65 | ^^^^^
66
67error[E0429]: `self` imports are only allowed within a { } list
68 --> $DIR/use-path-segment-kw.rs:184:13
69 |
70LL | use self;
71 | ^^^^
72
73error[E0429]: `self` imports are only allowed within a { } list
74 --> $DIR/use-path-segment-kw.rs:185:17
75 |
76LL | pub use self as _self;
77 | ^^^^
78
79error[E0429]: `self` imports are only allowed within a { } list
80 --> $DIR/use-path-segment-kw.rs:188:13
81 |
82LL | use ::self;
83 | ^^^^^^
84 |
85help: consider importing the module directly
86 |
87LL - use ::self;
88LL + use ;
89 |
90help: alternatively, use the multi-path `use` syntax to import `self`
91 |
92LL | use ::{self};
93 | + +
94
95error[E0429]: `self` imports are only allowed within a { } list
96 --> $DIR/use-path-segment-kw.rs:190:13
97 |
98LL | use ::self as _self2;
99 | ^^^^^^
100 |
101help: consider importing the module directly
102 |
103LL - use ::self as _self2;
104LL + use as _self2;
105 |
106help: alternatively, use the multi-path `use` syntax to import `self`
107 |
108LL | use ::{self as _self2};
109 | + +
110
111error[E0431]: `self` import can only appear in an import list with a non-empty prefix
112 --> $DIR/use-path-segment-kw.rs:192:16
113 |
114LL | use ::{self};
115 | ^^^^ can only appear in an import list with a non-empty prefix
116
117error[E0431]: `self` import can only appear in an import list with a non-empty prefix
118 --> $DIR/use-path-segment-kw.rs:193:16
119 |
120LL | use ::{self as _nested_self2};
121 | ^^^^^^^^^^^^^^^^^^^^^ can only appear in an import list with a non-empty prefix
122
123error[E0429]: `self` imports are only allowed within a { } list
124 --> $DIR/use-path-segment-kw.rs:196:28
125 |
126LL | pub use foobar::qux::self;
127 | ^^^^^^
128 |
129help: consider importing the module directly
130 |
131LL - pub use foobar::qux::self;
132LL + pub use foobar::qux;
133 |
134help: alternatively, use the multi-path `use` syntax to import `self`
135 |
136LL | pub use foobar::qux::{self};
137 | + +
138
139error[E0429]: `self` imports are only allowed within a { } list
140 --> $DIR/use-path-segment-kw.rs:197:23
141 |
142LL | pub use foobar::self as _self3;
143 | ^^^^^^
144 |
145help: consider importing the module directly
146 |
147LL - pub use foobar::self as _self3;
148LL + pub use foobar as _self3;
149 |
150help: alternatively, use the multi-path `use` syntax to import `self`
151 |
152LL | pub use foobar::{self as _self3};
153 | + +
154
155error[E0429]: `self` imports are only allowed within a { } list
156 --> $DIR/use-path-segment-kw.rs:202:18
157 |
158LL | use crate::self;
159 | ^^^^^^
160 |
161help: consider importing the module directly
162 |
163LL - use crate::self;
164LL + use crate;
165 |
166help: alternatively, use the multi-path `use` syntax to import `self`
167 |
168LL | use crate::{self};
169 | + +
170
171error: crate root imports need to be explicitly named: `use crate as name;`
172 --> $DIR/use-path-segment-kw.rs:202:13
173 |
174LL | use crate::self;
175 | ^^^^^
176
177error[E0429]: `self` imports are only allowed within a { } list
178 --> $DIR/use-path-segment-kw.rs:205:22
179 |
180LL | pub use crate::self as _self4;
181 | ^^^^^^
182 |
183help: consider importing the module directly
184 |
185LL - pub use crate::self as _self4;
186LL + pub use crate as _self4;
187 |
188help: alternatively, use the multi-path `use` syntax to import `self`
189 |
190LL | pub use crate::{self as _self4};
191 | + +
192
193error: crate root imports need to be explicitly named: `use crate as name;`
194 --> $DIR/use-path-segment-kw.rs:206:21
195 |
196LL | use crate::{self};
197 | ^^^^
198
199error[E0429]: `self` imports are only allowed within a { } list
200 --> $DIR/use-path-segment-kw.rs:211:18
201 |
202LL | use super::self;
203 | ^^^^^^
204 |
205help: consider importing the module directly
206 |
207LL - use super::self;
208LL + use super;
209 |
210help: alternatively, use the multi-path `use` syntax to import `self`
211 |
212LL | use super::{self};
213 | + +
214
215error[E0429]: `self` imports are only allowed within a { } list
216 --> $DIR/use-path-segment-kw.rs:213:22
217 |
218LL | pub use super::self as _self5;
219 | ^^^^^^
220 |
221help: consider importing the module directly
222 |
223LL - pub use super::self as _self5;
224LL + pub use super as _self5;
225 |
226help: alternatively, use the multi-path `use` syntax to import `self`
227 |
228LL | pub use super::{self as _self5};
229 | + +
230
231error[E0429]: `self` imports are only allowed within a { } list
232 --> $DIR/use-path-segment-kw.rs:219:17
233 |
234LL | use self::self;
235 | ^^^^^^
236 |
237help: consider importing the module directly
238 |
239LL - use self::self;
240LL + use self;
241 |
242help: alternatively, use the multi-path `use` syntax to import `self`
243 |
244LL | use self::{self};
245 | + +
246
247error[E0429]: `self` imports are only allowed within a { } list
248 --> $DIR/use-path-segment-kw.rs:220:21
249 |
250LL | pub use self::self as _self6;
251 | ^^^^^^
252 |
253help: consider importing the module directly
254 |
255LL - pub use self::self as _self6;
256LL + pub use self as _self6;
257 |
258help: alternatively, use the multi-path `use` syntax to import `self`
259 |
260LL | pub use self::{self as _self6};
261 | + +
262
263error[E0252]: the name `crate` is defined multiple times
264 --> $DIR/use-path-segment-kw.rs:134:13
265 |
266LL | use crate;
267 | ----- previous import of the module `crate` here
268...
269LL | use self::crate;
270 | ^^^^^^^^^^^ `crate` reimported here
271 |
272 = note: `crate` must be defined only once in the type namespace of this module
273
274error[E0252]: the name `crate` is defined multiple times
275 --> $DIR/use-path-segment-kw.rs:137:20
276 |
277LL | use crate;
278 | ----- previous import of the module `crate` here
279...
280LL | use self::{crate};
281 | -----------^^^^^--
282 | | |
283 | | `crate` reimported here
284 | help: remove unnecessary import
285 |
286 = note: `crate` must be defined only once in the type namespace of this module
287
288error[E0252]: the name `crate` is defined multiple times
289 --> $DIR/use-path-segment-kw.rs:202:13
290 |
291LL | use crate;
292 | ----- previous import of the module `crate` here
293...
294LL | use crate::self;
295 | ^^^^^^^^^^^ `crate` reimported here
296 |
297 = note: `crate` must be defined only once in the type namespace of this module
298
299error[E0252]: the name `crate` is defined multiple times
300 --> $DIR/use-path-segment-kw.rs:206:21
301 |
302LL | use crate;
303 | ----- previous import of the module `crate` here
304...
305LL | use crate::{self};
306 | ------------^^^^--
307 | | |
308 | | `crate` reimported here
309 | help: remove unnecessary import
310 |
311 = note: `crate` must be defined only once in the type namespace of this module
312
313error: `$crate` may not be imported
314 --> $DIR/use-path-segment-kw.rs:9:9
315 |
316LL | use $crate;
317 | ^^^^^^^^^^^
318...
319LL | macro_dollar_crate!();
320 | --------------------- in this macro invocation
321 |
322 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
323
324error: `$crate` may not be imported
325 --> $DIR/use-path-segment-kw.rs:10:9
326 |
327LL | pub use $crate as _dollar_crate;
328 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
329...
330LL | macro_dollar_crate!();
331 | --------------------- in this macro invocation
332 |
333 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
334
335error: crate root imports need to be explicitly named: `use crate as name;`
336 --> $DIR/use-path-segment-kw.rs:49:21
337 |
338LL | use $crate::crate;
339 | ^^^^^
340...
341LL | macro_dollar_crate!();
342 | --------------------- in this macro invocation
343 |
344 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
345
346error: crate root imports need to be explicitly named: `use crate as name;`
347 --> $DIR/use-path-segment-kw.rs:52:22
348 |
349LL | use $crate::{crate};
350 | ^^^^^
351...
352LL | macro_dollar_crate!();
353 | --------------------- in this macro invocation
354 |
355 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
356
357error[E0429]: `self` imports are only allowed within a { } list
358 --> $DIR/use-path-segment-kw.rs:63:19
359 |
360LL | use $crate::self;
361 | ^^^^^^
362...
363LL | macro_dollar_crate!();
364 | --------------------- in this macro invocation
365 |
366 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
367help: consider importing the module directly
368 |
369LL - use $crate::self;
370LL + use $crate;
371 |
372help: alternatively, use the multi-path `use` syntax to import `self`
373 |
374LL | use $crate::{self};
375 | + +
376
377error: `$crate` may not be imported
378 --> $DIR/use-path-segment-kw.rs:63:9
379 |
380LL | use $crate::self;
381 | ^^^^^^^^^^^^^^^^^
382...
383LL | macro_dollar_crate!();
384 | --------------------- in this macro invocation
385 |
386 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
387
388error[E0429]: `self` imports are only allowed within a { } list
389 --> $DIR/use-path-segment-kw.rs:66:23
390 |
391LL | pub use $crate::self as _m_self8;
392 | ^^^^^^
393...
394LL | macro_dollar_crate!();
395 | --------------------- in this macro invocation
396 |
397 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
398help: consider importing the module directly
399 |
400LL - pub use $crate::self as _m_self8;
401LL + pub use $crate as _m_self8;
402 |
403help: alternatively, use the multi-path `use` syntax to import `self`
404 |
405LL | pub use $crate::{self as _m_self8};
406 | + +
407
408error: `$crate` may not be imported
409 --> $DIR/use-path-segment-kw.rs:66:9
410 |
411LL | pub use $crate::self as _m_self8;
412 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
413...
414LL | macro_dollar_crate!();
415 | --------------------- in this macro invocation
416 |
417 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
418
419error[E0252]: the name `<!dummy!>` is defined multiple times
420 --> $DIR/use-path-segment-kw.rs:63:13
421 |
422LL | use $crate;
423 | ------ previous import of the module `<!dummy!>` here
424...
425LL | use $crate::self;
426 | ^^^^^^^^^^^^ `<!dummy!>` reimported here
427...
428LL | macro_dollar_crate!();
429 | --------------------- in this macro invocation
430 |
431 = note: `<!dummy!>` must be defined only once in the type namespace of this module
432 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
433
434error[E0252]: the name `$crate` is defined multiple times
435 --> $DIR/use-path-segment-kw.rs:68:22
436 |
437LL | use self::$crate;
438 | ------------ previous import of the module `$crate` here
439...
440LL | use $crate::{self};
441 | -------------^^^^--
442 | | |
443 | | `$crate` reimported here
444 | help: remove unnecessary import
445...
446LL | macro_dollar_crate!();
447 | --------------------- in this macro invocation
448 |
449 = note: `$crate` must be defined only once in the type namespace of this module
450 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
451
452error[E0432]: unresolved import `crate`
453 --> $DIR/use-path-segment-kw.rs:102:13
454 |
455LL | use ::crate;
456 | ^^^^^^^ no `crate` in the root
457
458error[E0432]: unresolved import `crate`
459 --> $DIR/use-path-segment-kw.rs:104:13
460 |
461LL | use ::crate as _crate2;
462 | ^^^^^^^^^^^^^^^^^^ no `crate` in the root
463
464error[E0432]: unresolved import `crate`
465 --> $DIR/use-path-segment-kw.rs:105:16
466 |
467LL | use ::{crate};
468 | ^^^^^ no `crate` in the root
469
470error[E0432]: unresolved import `crate`
471 --> $DIR/use-path-segment-kw.rs:107:16
472 |
473LL | use ::{crate as _nested_crate2};
474 | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root
475
476error[E0432]: unresolved import `foobar::crate`
477 --> $DIR/use-path-segment-kw.rs:110:13
478 |
479LL | use foobar::crate;
480 | ^^^^^^^^^^^^^ no `crate` in `foo::bar::foobar`
481
482error[E0432]: unresolved import `foobar::crate`
483 --> $DIR/use-path-segment-kw.rs:112:13
484 |
485LL | use foobar::crate as _crate3;
486 | ^^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo::bar::foobar`
487
488error[E0432]: unresolved import `foobar::crate`
489 --> $DIR/use-path-segment-kw.rs:113:22
490 |
491LL | use foobar::{crate};
492 | ^^^^^ no `crate` in `foo::bar::foobar`
493
494error[E0432]: unresolved import `foobar::crate`
495 --> $DIR/use-path-segment-kw.rs:115:22
496 |
497LL | use foobar::{crate as _nested_crate3};
498 | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo::bar::foobar`
499
500error[E0432]: unresolved import `crate::crate`
501 --> $DIR/use-path-segment-kw.rs:118:13
502 |
503LL | use crate::crate;
504 | ^^^^^^^^^^^^ no `crate` in the root
505
506error[E0432]: unresolved import `crate::crate`
507 --> $DIR/use-path-segment-kw.rs:120:13
508 |
509LL | use crate::crate as _crate4;
510 | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root
511
512error[E0432]: unresolved import `crate::crate`
513 --> $DIR/use-path-segment-kw.rs:121:21
514 |
515LL | use crate::{crate};
516 | ^^^^^ no `crate` in the root
517
518error[E0432]: unresolved import `crate::crate`
519 --> $DIR/use-path-segment-kw.rs:123:21
520 |
521LL | use crate::{crate as _nested_crate4};
522 | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root
523
524error[E0432]: unresolved import `super::crate`
525 --> $DIR/use-path-segment-kw.rs:126:13
526 |
527LL | use super::crate;
528 | ^^^^^^^^^^^^ no `crate` in `foo`
529
530error[E0432]: unresolved import `super::crate`
531 --> $DIR/use-path-segment-kw.rs:128:13
532 |
533LL | use super::crate as _crate5;
534 | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo`
535
536error[E0432]: unresolved import `super::crate`
537 --> $DIR/use-path-segment-kw.rs:129:21
538 |
539LL | use super::{crate};
540 | ^^^^^ no `crate` in `foo`
541
542error[E0432]: unresolved import `super::crate`
543 --> $DIR/use-path-segment-kw.rs:131:21
544 |
545LL | use super::{crate as _nested_crate5};
546 | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo`
547
548error[E0432]: unresolved import `super`
549 --> $DIR/use-path-segment-kw.rs:143:13
550 |
551LL | use super::{};
552 | ^^^^^^^^^ no `super` in the root
553
554error[E0432]: unresolved import `super`
555 --> $DIR/use-path-segment-kw.rs:146:13
556 |
557LL | use super;
558 | ^^^^^ no `super` in the root
559
560error[E0432]: unresolved import `super`
561 --> $DIR/use-path-segment-kw.rs:147:17
562 |
563LL | pub use super as _super;
564 | ^^^^^^^^^^^^^^^ no `super` in the root
565
566error[E0432]: unresolved import `super`
567 --> $DIR/use-path-segment-kw.rs:150:13
568 |
569LL | use ::super;
570 | ^^^^^^^ no `super` in the root
571
572error[E0432]: unresolved import `super`
573 --> $DIR/use-path-segment-kw.rs:151:13
574 |
575LL | use ::super as _super2;
576 | ^^^^^^^^^^^^^^^^^^ no `super` in the root
577
578error[E0432]: unresolved import `super`
579 --> $DIR/use-path-segment-kw.rs:152:16
580 |
581LL | use ::{super};
582 | ^^^^^ no `super` in the root
583
584error[E0432]: unresolved import `super`
585 --> $DIR/use-path-segment-kw.rs:153:16
586 |
587LL | use ::{super as _nested_super2};
588 | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root
589
590error[E0432]: unresolved import `foobar::super`
591 --> $DIR/use-path-segment-kw.rs:156:13
592 |
593LL | use foobar::super;
594 | ^^^^^^^^^^^^^ no `super` in `foo::bar::foobar`
595
596error[E0432]: unresolved import `foobar::super`
597 --> $DIR/use-path-segment-kw.rs:157:13
598 |
599LL | use foobar::super as _super3;
600 | ^^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo::bar::foobar`
601
602error[E0432]: unresolved import `foobar::super`
603 --> $DIR/use-path-segment-kw.rs:158:22
604 |
605LL | use foobar::{super};
606 | ^^^^^ no `super` in `foo::bar::foobar`
607
608error[E0432]: unresolved import `foobar::super`
609 --> $DIR/use-path-segment-kw.rs:159:22
610 |
611LL | use foobar::{super as _nested_super3};
612 | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo::bar::foobar`
613
614error[E0432]: unresolved import `crate::super`
615 --> $DIR/use-path-segment-kw.rs:162:13
616 |
617LL | use crate::super;
618 | ^^^^^^^^^^^^ no `super` in the root
619
620error[E0432]: unresolved import `crate::super`
621 --> $DIR/use-path-segment-kw.rs:163:13
622 |
623LL | use crate::super as _super4;
624 | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root
625
626error[E0432]: unresolved import `crate::super`
627 --> $DIR/use-path-segment-kw.rs:164:21
628 |
629LL | use crate::{super};
630 | ^^^^^ no `super` in the root
631
632error[E0432]: unresolved import `crate::super`
633 --> $DIR/use-path-segment-kw.rs:165:21
634 |
635LL | use crate::{super as _nested_super4};
636 | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root
637
638error[E0432]: unresolved import `super::super`
639 --> $DIR/use-path-segment-kw.rs:168:13
640 |
641LL | use super::super;
642 | ^^^^^^^^^^^^ no `super` in `foo`
643
644error[E0432]: unresolved import `super::super`
645 --> $DIR/use-path-segment-kw.rs:169:17
646 |
647LL | pub use super::super as _super5;
648 | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo`
649
650error[E0432]: unresolved import `super::super`
651 --> $DIR/use-path-segment-kw.rs:170:21
652 |
653LL | use super::{super};
654 | ^^^^^ no `super` in `foo`
655
656error[E0432]: unresolved import `super::super`
657 --> $DIR/use-path-segment-kw.rs:171:25
658 |
659LL | pub use super::{super as _nested_super5};
660 | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo`
661
662error[E0432]: unresolved import `self`
663 --> $DIR/use-path-segment-kw.rs:181:13
664 |
665LL | use self::{};
666 | ^^^^^^^^ no `self` in the root
667
668error[E0432]: unresolved import `{{root}}`
669 --> $DIR/use-path-segment-kw.rs:188:13
670 |
671LL | use ::self;
672 | ^^^^^^ no `{{root}}` in the root
673
674error[E0432]: unresolved import `{{root}}`
675 --> $DIR/use-path-segment-kw.rs:190:13
676 |
677LL | use ::self as _self2;
678 | ^^^^^^^^^^^^^^^^ no `{{root}}` in the root
679
680error[E0432]: unresolved import `super`
681 --> $DIR/use-path-segment-kw.rs:211:13
682 |
683LL | use super::self;
684 | ^^^^^^^^^^^ no `super` in the root
685
686error[E0432]: unresolved import `super`
687 --> $DIR/use-path-segment-kw.rs:213:17
688 |
689LL | pub use super::self as _self5;
690 | ^^^^^^^^^^^^^^^^^^^^^ no `super` in the root
691
692error[E0432]: unresolved import `super`
693 --> $DIR/use-path-segment-kw.rs:215:21
694 |
695LL | use super::{self};
696 | ^^^^ no `super` in the root
697
698error[E0432]: unresolved import `super`
699 --> $DIR/use-path-segment-kw.rs:216:25
700 |
701LL | pub use super::{self as _nested_self5};
702 | ^^^^^^^^^^^^^^^^^^^^^ no `super` in the root
703
704error[E0432]: unresolved import `self`
705 --> $DIR/use-path-segment-kw.rs:221:20
706 |
707LL | use self::{self};
708 | ^^^^ no `self` in the root
709
710error[E0432]: unresolved import `self`
711 --> $DIR/use-path-segment-kw.rs:222:24
712 |
713LL | pub use self::{self as _nested_self6};
714 | ^^^^^^^^^^^^^^^^^^^^^ no `self` in the root
715
716error[E0432]: unresolved import `$crate`
717 --> $DIR/use-path-segment-kw.rs:13:13
718 |
719LL | use ::$crate;
720 | ^^^^^^^^ no `$crate` in the root
721...
722LL | macro_dollar_crate!();
723 | --------------------- in this macro invocation
724 |
725 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
726
727error[E0432]: unresolved import `$crate`
728 --> $DIR/use-path-segment-kw.rs:14:13
729 |
730LL | use ::$crate as _dollar_crate2;
731 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root
732...
733LL | macro_dollar_crate!();
734 | --------------------- in this macro invocation
735 |
736 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
737
738error[E0432]: unresolved import `$crate`
739 --> $DIR/use-path-segment-kw.rs:15:16
740 |
741LL | use ::{$crate};
742 | ^^^^^^ no `$crate` in the root
743...
744LL | macro_dollar_crate!();
745 | --------------------- in this macro invocation
746 |
747 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
748
749error[E0432]: unresolved import `$crate`
750 --> $DIR/use-path-segment-kw.rs:16:16
751 |
752LL | use ::{$crate as _nested_dollar_crate2};
753 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root
754...
755LL | macro_dollar_crate!();
756 | --------------------- in this macro invocation
757 |
758 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
759
760error[E0432]: unresolved import `foobar::$crate`
761 --> $DIR/use-path-segment-kw.rs:19:13
762 |
763LL | use foobar::$crate;
764 | ^^^^^^^^^^^^^^ no `$crate` in `foo::bar::foobar`
765...
766LL | macro_dollar_crate!();
767 | --------------------- in this macro invocation
768 |
769 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
770
771error[E0432]: unresolved import `foobar::$crate`
772 --> $DIR/use-path-segment-kw.rs:20:13
773 |
774LL | use foobar::$crate as _dollar_crate3;
775 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo::bar::foobar`
776...
777LL | macro_dollar_crate!();
778 | --------------------- in this macro invocation
779 |
780 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
781
782error[E0432]: unresolved import `foobar::$crate`
783 --> $DIR/use-path-segment-kw.rs:21:22
784 |
785LL | use foobar::{$crate};
786 | ^^^^^^ no `$crate` in `foo::bar::foobar`
787...
788LL | macro_dollar_crate!();
789 | --------------------- in this macro invocation
790 |
791 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
792
793error[E0432]: unresolved import `foobar::$crate`
794 --> $DIR/use-path-segment-kw.rs:22:22
795 |
796LL | use foobar::{$crate as _nested_dollar_crate3};
797 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo::bar::foobar`
798...
799LL | macro_dollar_crate!();
800 | --------------------- in this macro invocation
801 |
802 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
803
804error[E0432]: unresolved import `crate::$crate`
805 --> $DIR/use-path-segment-kw.rs:25:13
806 |
807LL | use crate::$crate;
808 | ^^^^^^^^^^^^^ no `$crate` in the root
809...
810LL | macro_dollar_crate!();
811 | --------------------- in this macro invocation
812 |
813 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
814
815error[E0432]: unresolved import `crate::$crate`
816 --> $DIR/use-path-segment-kw.rs:26:13
817 |
818LL | use crate::$crate as _dollar_crate4;
819 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root
820...
821LL | macro_dollar_crate!();
822 | --------------------- in this macro invocation
823 |
824 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
825
826error[E0432]: unresolved import `crate::$crate`
827 --> $DIR/use-path-segment-kw.rs:27:21
828 |
829LL | use crate::{$crate};
830 | ^^^^^^ no `$crate` in the root
831...
832LL | macro_dollar_crate!();
833 | --------------------- in this macro invocation
834 |
835 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
836
837error[E0432]: unresolved import `crate::$crate`
838 --> $DIR/use-path-segment-kw.rs:28:21
839 |
840LL | use crate::{$crate as _nested_dollar_crate4};
841 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root
842...
843LL | macro_dollar_crate!();
844 | --------------------- in this macro invocation
845 |
846 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
847
848error[E0432]: unresolved import `super::$crate`
849 --> $DIR/use-path-segment-kw.rs:31:13
850 |
851LL | use super::$crate;
852 | ^^^^^^^^^^^^^ no `$crate` in `foo`
853...
854LL | macro_dollar_crate!();
855 | --------------------- in this macro invocation
856 |
857 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
858
859error[E0432]: unresolved import `super::$crate`
860 --> $DIR/use-path-segment-kw.rs:32:13
861 |
862LL | use super::$crate as _dollar_crate5;
863 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo`
864...
865LL | macro_dollar_crate!();
866 | --------------------- in this macro invocation
867 |
868 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
869
870error[E0432]: unresolved import `super::$crate`
871 --> $DIR/use-path-segment-kw.rs:33:21
872 |
873LL | use super::{$crate};
874 | ^^^^^^ no `$crate` in `foo`
875...
876LL | macro_dollar_crate!();
877 | --------------------- in this macro invocation
878 |
879 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
880
881error[E0432]: unresolved import `super::$crate`
882 --> $DIR/use-path-segment-kw.rs:34:21
883 |
884LL | use super::{$crate as _nested_dollar_crate5};
885 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo`
886...
887LL | macro_dollar_crate!();
888 | --------------------- in this macro invocation
889 |
890 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
891
892error[E0432]: unresolved import `$crate::$crate`
893 --> $DIR/use-path-segment-kw.rs:43:13
894 |
895LL | use $crate::$crate;
896 | ^^^^^^^^^^^^^^ no `$crate` in the root
897...
898LL | macro_dollar_crate!();
899 | --------------------- in this macro invocation
900 |
901 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
902
903error[E0432]: unresolved import `$crate::$crate`
904 --> $DIR/use-path-segment-kw.rs:44:13
905 |
906LL | use $crate::$crate as _dollar_crate7;
907 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root
908...
909LL | macro_dollar_crate!();
910 | --------------------- in this macro invocation
911 |
912 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
913
914error[E0432]: unresolved import `$crate::$crate`
915 --> $DIR/use-path-segment-kw.rs:45:22
916 |
917LL | use $crate::{$crate};
918 | ^^^^^^ no `$crate` in the root
919...
920LL | macro_dollar_crate!();
921 | --------------------- in this macro invocation
922 |
923 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
924
925error[E0432]: unresolved import `$crate::$crate`
926 --> $DIR/use-path-segment-kw.rs:46:22
927 |
928LL | use $crate::{$crate as _nested_dollar_crate7};
929 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root
930...
931LL | macro_dollar_crate!();
932 | --------------------- in this macro invocation
933 |
934 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
935
936error[E0432]: unresolved import `$crate::crate`
937 --> $DIR/use-path-segment-kw.rs:49:13
938 |
939LL | use $crate::crate;
940 | ^^^^^^^^^^^^^ no `crate` in the root
941...
942LL | macro_dollar_crate!();
943 | --------------------- in this macro invocation
944 |
945 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
946
947error[E0432]: unresolved import `$crate::crate`
948 --> $DIR/use-path-segment-kw.rs:51:13
949 |
950LL | use $crate::crate as _m_crate8;
951 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root
952...
953LL | macro_dollar_crate!();
954 | --------------------- in this macro invocation
955 |
956 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
957
958error[E0432]: unresolved import `$crate::crate`
959 --> $DIR/use-path-segment-kw.rs:52:22
960 |
961LL | use $crate::{crate};
962 | ^^^^^ no `crate` in the root
963...
964LL | macro_dollar_crate!();
965 | --------------------- in this macro invocation
966 |
967 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
968
969error[E0432]: unresolved import `$crate::crate`
970 --> $DIR/use-path-segment-kw.rs:54:22
971 |
972LL | use $crate::{crate as _m_nested_crate8};
973 | ^^^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root
974...
975LL | macro_dollar_crate!();
976 | --------------------- in this macro invocation
977 |
978 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
979
980error[E0432]: unresolved import `$crate::super`
981 --> $DIR/use-path-segment-kw.rs:57:13
982 |
983LL | use $crate::super;
984 | ^^^^^^^^^^^^^ no `super` in the root
985...
986LL | macro_dollar_crate!();
987 | --------------------- in this macro invocation
988 |
989 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
990
991error[E0432]: unresolved import `$crate::super`
992 --> $DIR/use-path-segment-kw.rs:58:13
993 |
994LL | use $crate::super as _m_super8;
995 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root
996...
997LL | macro_dollar_crate!();
998 | --------------------- in this macro invocation
999 |
1000 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1001
1002error[E0432]: unresolved import `$crate::super`
1003 --> $DIR/use-path-segment-kw.rs:59:22
1004 |
1005LL | use $crate::{super};
1006 | ^^^^^ no `super` in the root
1007...
1008LL | macro_dollar_crate!();
1009 | --------------------- in this macro invocation
1010 |
1011 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1012
1013error[E0432]: unresolved import `$crate::super`
1014 --> $DIR/use-path-segment-kw.rs:60:22
1015 |
1016LL | use $crate::{super as _m_nested_super8};
1017 | ^^^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root
1018...
1019LL | macro_dollar_crate!();
1020 | --------------------- in this macro invocation
1021 |
1022 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1023
1024error[E0573]: expected type, found module `$crate`
1025 --> $DIR/use-path-segment-kw.rs:8:19
1026 |
1027LL | type A1 = $crate;
1028 | ^^^^^^ not a type
1029...
1030LL | macro_dollar_crate!();
1031 | --------------------- in this macro invocation
1032 |
1033 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1034
1035error[E0573]: expected type, found module `crate`
1036 --> $DIR/use-path-segment-kw.rs:97:19
1037 |
1038LL | type B1 = crate;
1039 | ^^^^^ not a type
1040
1041error[E0573]: expected type, found module `super`
1042 --> $DIR/use-path-segment-kw.rs:145:19
1043 |
1044LL | type C1 = super;
1045 | ^^^^^ not a type
1046
1047error[E0573]: expected type, found module `super::super`
1048 --> $DIR/use-path-segment-kw.rs:167:19
1049 |
1050LL | type C5 = super::super;
1051 | ^^^^^^^^^^^^ not a type
1052
1053error[E0573]: expected type, found module `self::super`
1054 --> $DIR/use-path-segment-kw.rs:173:19
1055 |
1056LL | type C6 = self::super;
1057 | ^^^^^^^^^^^ not a type
1058
1059error[E0573]: expected type, found module `self`
1060 --> $DIR/use-path-segment-kw.rs:183:19
1061 |
1062LL | type D1 = self;
1063 | ^^^^ not a type
1064
1065error[E0433]: failed to resolve: global paths cannot start with `$crate`
1066 --> $DIR/use-path-segment-kw.rs:12:21
1067 |
1068LL | type A2 = ::$crate;
1069 | ^^^^^^ global paths cannot start with `$crate`
1070...
1071LL | macro_dollar_crate!();
1072 | --------------------- in this macro invocation
1073 |
1074 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1075
1076error[E0433]: failed to resolve: `$crate` in paths can only be used in start position
1077 --> $DIR/use-path-segment-kw.rs:18:27
1078 |
1079LL | type A3 = foobar::$crate;
1080 | ^^^^^^ `$crate` in paths can only be used in start position
1081...
1082LL | macro_dollar_crate!();
1083 | --------------------- in this macro invocation
1084 |
1085 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1086
1087error[E0433]: failed to resolve: `$crate` in paths can only be used in start position
1088 --> $DIR/use-path-segment-kw.rs:24:26
1089 |
1090LL | type A4 = crate::$crate;
1091 | ^^^^^^ `$crate` in paths can only be used in start position
1092...
1093LL | macro_dollar_crate!();
1094 | --------------------- in this macro invocation
1095 |
1096 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1097
1098error[E0433]: failed to resolve: `$crate` in paths can only be used in start position
1099 --> $DIR/use-path-segment-kw.rs:30:26
1100 |
1101LL | type A5 = super::$crate;
1102 | ^^^^^^ `$crate` in paths can only be used in start position
1103...
1104LL | macro_dollar_crate!();
1105 | --------------------- in this macro invocation
1106 |
1107 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1108
1109error[E0433]: failed to resolve: `$crate` in paths can only be used in start position
1110 --> $DIR/use-path-segment-kw.rs:36:25
1111 |
1112LL | type A6 = self::$crate;
1113 | ^^^^^^ `$crate` in paths can only be used in start position
1114...
1115LL | macro_dollar_crate!();
1116 | --------------------- in this macro invocation
1117 |
1118 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1119
1120error[E0433]: failed to resolve: `$crate` in paths can only be used in start position
1121 --> $DIR/use-path-segment-kw.rs:42:27
1122 |
1123LL | type A7 = $crate::$crate;
1124 | ^^^^^^ `$crate` in paths can only be used in start position
1125...
1126LL | macro_dollar_crate!();
1127 | --------------------- in this macro invocation
1128 |
1129 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1130
1131error[E0433]: failed to resolve: `crate` in paths can only be used in start position
1132 --> $DIR/use-path-segment-kw.rs:48:27
1133 |
1134LL | type A8 = $crate::crate;
1135 | ^^^^^ `crate` in paths can only be used in start position
1136...
1137LL | macro_dollar_crate!();
1138 | --------------------- in this macro invocation
1139 |
1140 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1141
1142error[E0433]: failed to resolve: `super` in paths can only be used in start position
1143 --> $DIR/use-path-segment-kw.rs:56:27
1144 |
1145LL | type A9 = $crate::super;
1146 | ^^^^^ `super` in paths can only be used in start position
1147...
1148LL | macro_dollar_crate!();
1149 | --------------------- in this macro invocation
1150 |
1151 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1152
1153error[E0433]: failed to resolve: `self` in paths can only be used in start position
1154 --> $DIR/use-path-segment-kw.rs:62:28
1155 |
1156LL | type A10 = $crate::self;
1157 | ^^^^ `self` in paths can only be used in start position
1158...
1159LL | macro_dollar_crate!();
1160 | --------------------- in this macro invocation
1161 |
1162 = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
1163
1164error[E0433]: failed to resolve: global paths cannot start with `crate`
1165 --> $DIR/use-path-segment-kw.rs:101:21
1166 |
1167LL | type B2 = ::crate;
1168 | ^^^^^ global paths cannot start with `crate`
1169
1170error[E0433]: failed to resolve: `crate` in paths can only be used in start position
1171 --> $DIR/use-path-segment-kw.rs:109:27
1172 |
1173LL | type B3 = foobar::crate;
1174 | ^^^^^ `crate` in paths can only be used in start position
1175
1176error[E0433]: failed to resolve: `crate` in paths can only be used in start position
1177 --> $DIR/use-path-segment-kw.rs:117:26
1178 |
1179LL | type B4 = crate::crate;
1180 | ^^^^^ `crate` in paths can only be used in start position
1181
1182error[E0433]: failed to resolve: `crate` in paths can only be used in start position
1183 --> $DIR/use-path-segment-kw.rs:125:26
1184 |
1185LL | type B5 = super::crate;
1186 | ^^^^^ `crate` in paths can only be used in start position
1187
1188error[E0433]: failed to resolve: `crate` in paths can only be used in start position
1189 --> $DIR/use-path-segment-kw.rs:133:25
1190 |
1191LL | type B6 = self::crate;
1192 | ^^^^^ `crate` in paths can only be used in start position
1193
1194error[E0433]: failed to resolve: global paths cannot start with `super`
1195 --> $DIR/use-path-segment-kw.rs:149:21
1196 |
1197LL | type C2 = ::super;
1198 | ^^^^^ global paths cannot start with `super`
1199
1200error[E0433]: failed to resolve: `super` in paths can only be used in start position
1201 --> $DIR/use-path-segment-kw.rs:155:27
1202 |
1203LL | type C3 = foobar::super;
1204 | ^^^^^ `super` in paths can only be used in start position
1205
1206error[E0433]: failed to resolve: `super` in paths can only be used in start position
1207 --> $DIR/use-path-segment-kw.rs:161:26
1208 |
1209LL | type C4 = crate::super;
1210 | ^^^^^ `super` in paths can only be used in start position
1211
1212error[E0433]: failed to resolve: global paths cannot start with `self`
1213 --> $DIR/use-path-segment-kw.rs:187:21
1214 |
1215LL | type D2 = ::self;
1216 | ^^^^ global paths cannot start with `self`
1217
1218error[E0433]: failed to resolve: `self` in paths can only be used in start position
1219 --> $DIR/use-path-segment-kw.rs:195:27
1220 |
1221LL | type D3 = foobar::self;
1222 | ^^^^ `self` in paths can only be used in start position
1223
1224error[E0433]: failed to resolve: `self` in paths can only be used in start position
1225 --> $DIR/use-path-segment-kw.rs:201:26
1226 |
1227LL | type D4 = crate::self;
1228 | ^^^^ `self` in paths can only be used in start position
1229
1230error[E0433]: failed to resolve: `self` in paths can only be used in start position
1231 --> $DIR/use-path-segment-kw.rs:210:26
1232 |
1233LL | type D5 = super::self;
1234 | ^^^^ `self` in paths can only be used in start position
1235
1236error[E0433]: failed to resolve: `self` in paths can only be used in start position
1237 --> $DIR/use-path-segment-kw.rs:218:25
1238 |
1239LL | type D6 = self::self;
1240 | ^^^^ `self` in paths can only be used in start position
1241
1242error: aborting due to 141 previous errors
1243
1244Some errors have detailed explanations: E0252, E0429, E0431, E0432, E0433, E0573.
1245For more information about an error, try `rustc --explain E0252`.