diff --git a/compiler/rustc_codegen_gcc/src/asm.rs b/compiler/rustc_codegen_gcc/src/asm.rs index 2e8cd934eb298..20d91b80e8c52 100644 --- a/compiler/rustc_codegen_gcc/src/asm.rs +++ b/compiler/rustc_codegen_gcc/src/asm.rs @@ -592,7 +592,7 @@ fn reg_to_gcc(reg: InlineAsmRegOrRegClass) -> ConstraintOrRegister { InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => unimplemented!(), InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => unimplemented!(), InlineAsmRegClass::X86( - X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg, + X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg | X86InlineAsmRegClass::tmm_reg, ) => unreachable!("clobber-only"), InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => { bug!("GCC backend does not support SPIR-V") @@ -656,6 +656,7 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg) => unimplemented!(), InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => cx.type_i16(), InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => cx.type_i16(), + InlineAsmRegClass::X86(X86InlineAsmRegClass::tmm_reg) => unimplemented!(), InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => cx.type_i32(), InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => { bug!("LLVM backend does not support SPIR-V") @@ -787,7 +788,7 @@ fn modifier_to_gcc(arch: InlineAsmArch, reg: InlineAsmRegClass, modifier: Option }, InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => None, InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => None, - InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg) => { + InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg | X86InlineAsmRegClass::tmm_reg) => { unreachable!("clobber-only") } InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => unimplemented!(), diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index e994001f96fd9..a53946995ee1c 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -604,7 +604,8 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) -> InlineAsmRegClass::X86( X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg - | X86InlineAsmRegClass::kreg0, + | X86InlineAsmRegClass::kreg0 + | X86InlineAsmRegClass::tmm_reg, ) => unreachable!("clobber-only"), InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => "r", InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::reg) => "r", @@ -692,7 +693,8 @@ fn modifier_to_llvm( InlineAsmRegClass::X86( X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg - | X86InlineAsmRegClass::kreg0, + | X86InlineAsmRegClass::kreg0 + | X86InlineAsmRegClass::tmm_reg, ) => { unreachable!("clobber-only") } @@ -766,7 +768,8 @@ fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &' InlineAsmRegClass::X86( X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg - | X86InlineAsmRegClass::kreg0, + | X86InlineAsmRegClass::kreg0 + | X86InlineAsmRegClass::tmm_reg, ) => { unreachable!("clobber-only") } diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 2dab9ff89868f..8770ed956e61f 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -412,22 +412,27 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' self.path, err_ub!(AlignmentCheckFailed { required, has }) => { - "an unaligned {} (required {} byte alignment but found {})", - kind, + "an unaligned {kind} (required {} byte alignment but found {})", required.bytes(), has.bytes() }, err_ub!(DanglingIntPointer(0, _)) => - { "a null {}", kind }, + { "a null {kind}" }, err_ub!(DanglingIntPointer(i, _)) => - { "a dangling {} (address 0x{:x} is unallocated)", kind, i }, + { "a dangling {kind} (address 0x{i:x} is unallocated)" }, err_ub!(PointerOutOfBounds { .. }) => - { "a dangling {} (going beyond the bounds of its allocation)", kind }, + { "a dangling {kind} (going beyond the bounds of its allocation)" }, // This cannot happen during const-eval (because interning already detects // dangling pointers), but it can happen in Miri. err_ub!(PointerUseAfterFree(..)) => - { "a dangling {} (use-after-free)", kind }, + { "a dangling {kind} (use-after-free)" }, ); + // Do not allow pointers to uninhabited types. + if place.layout.abi.is_uninhabited() { + throw_validation_failure!(self.path, + { "a {kind} pointing to uninhabited type {}", place.layout.ty } + ) + } // Recursive checking if let Some(ref mut ref_tracking) = self.ref_tracking { // Proceed recursively even for ZST, no reason to skip them! diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 4d3c730dc9089..e6c7b4064fb09 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -775,7 +775,14 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> { } // Corner case: if the variant is reachable, but its // enum is not, make the enum reachable as well. - self.update(item.def_id, variant_level); + self.reach(item.def_id, variant_level).ty(); + } + if let Some(hir_id) = variant.data.ctor_hir_id() { + let ctor_def_id = self.tcx.hir().local_def_id(hir_id); + let ctor_level = self.get(ctor_def_id); + if ctor_level.is_some() { + self.reach(item.def_id, ctor_level).ty(); + } } } } @@ -803,6 +810,13 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> { } } } + if let Some(hir_id) = struct_def.ctor_hir_id() { + let ctor_def_id = self.tcx.hir().local_def_id(hir_id); + let ctor_level = self.get(ctor_def_id); + if ctor_level.is_some() { + self.reach(item.def_id, ctor_level).ty(); + } + } } } diff --git a/compiler/rustc_resolve/src/check_unused.rs b/compiler/rustc_resolve/src/check_unused.rs index 6503b97a1d31f..ec3b14ace4df2 100644 --- a/compiler/rustc_resolve/src/check_unused.rs +++ b/compiler/rustc_resolve/src/check_unused.rs @@ -315,21 +315,28 @@ impl Resolver<'_> { "remove the unused import" }; - let parent_module = visitor.r.get_nearest_non_block_module( - visitor.r.local_def_id(unused.use_tree_id).to_def_id(), - ); - let test_module_span = match module_to_string(parent_module) { - Some(module) - if module == "test" - || module == "tests" - || module.starts_with("test_") - || module.starts_with("tests_") - || module.ends_with("_test") - || module.ends_with("_tests") => - { - Some(parent_module.span) + // If we are in the `--test` mode, suppress a help that adds the `#[cfg(test)]` + // attribute; however, if not, suggest adding the attribute. There is no way to + // retrieve attributes here because we do not have a `TyCtxt` yet. + let test_module_span = if visitor.r.session.opts.test { + None + } else { + let parent_module = visitor.r.get_nearest_non_block_module( + visitor.r.local_def_id(unused.use_tree_id).to_def_id(), + ); + match module_to_string(parent_module) { + Some(module) + if module == "test" + || module == "tests" + || module.starts_with("test_") + || module.starts_with("tests_") + || module.ends_with("_test") + || module.ends_with("_tests") => + { + Some(parent_module.span) + } + _ => None, } - _ => None, }; visitor.r.lint_buffer.buffer_lint_with_diagnostic( diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 2cc6eb0358567..5c9c16350e469 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1408,6 +1408,7 @@ symbols! { thread_local_macro, thumb2, thumb_mode: "thumb-mode", + tmm_reg, todo_macro, tool_attributes, tool_lints, diff --git a/compiler/rustc_target/src/asm/mod.rs b/compiler/rustc_target/src/asm/mod.rs index 6bc807c7c4421..df8ccc42a77a3 100644 --- a/compiler/rustc_target/src/asm/mod.rs +++ b/compiler/rustc_target/src/asm/mod.rs @@ -912,6 +912,7 @@ impl InlineAsmClobberAbi { mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7, st0, st1, st2, st3, st4, st5, st6, st7, + tmm0, tmm1, tmm2, tmm3, tmm4, tmm5, tmm6, tmm7, } }, InlineAsmClobberAbi::X86_64Win => clobbered_regs! { @@ -931,6 +932,7 @@ impl InlineAsmClobberAbi { mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7, st0, st1, st2, st3, st4, st5, st6, st7, + tmm0, tmm1, tmm2, tmm3, tmm4, tmm5, tmm6, tmm7, } }, InlineAsmClobberAbi::AArch64 => clobbered_regs! { diff --git a/compiler/rustc_target/src/asm/x86.rs b/compiler/rustc_target/src/asm/x86.rs index 854674c7f2fa7..e35035fd25af6 100644 --- a/compiler/rustc_target/src/asm/x86.rs +++ b/compiler/rustc_target/src/asm/x86.rs @@ -17,6 +17,7 @@ def_reg_class! { kreg0, mmx_reg, x87_reg, + tmm_reg, } } @@ -41,6 +42,7 @@ impl X86InlineAsmRegClass { Self::xmm_reg | Self::ymm_reg | Self::zmm_reg => &['x', 'y', 'z'], Self::kreg | Self::kreg0 => &[], Self::mmx_reg | Self::x87_reg => &[], + Self::tmm_reg => &[], } } @@ -80,6 +82,7 @@ impl X86InlineAsmRegClass { }, Self::kreg | Self::kreg0 => None, Self::mmx_reg | Self::x87_reg => None, + Self::tmm_reg => None, } } @@ -98,6 +101,7 @@ impl X86InlineAsmRegClass { Self::zmm_reg => Some(('z', "zmm0")), Self::kreg | Self::kreg0 => None, Self::mmx_reg | Self::x87_reg => None, + Self::tmm_reg => None, } } @@ -135,6 +139,7 @@ impl X86InlineAsmRegClass { }, Self::kreg0 => &[], Self::mmx_reg | Self::x87_reg => &[], + Self::tmm_reg => &[], } } } @@ -320,6 +325,14 @@ def_regs! { st5: x87_reg = ["st(5)"], st6: x87_reg = ["st(6)"], st7: x87_reg = ["st(7)"], + tmm0: tmm_reg = ["tmm0"] % x86_64_only, + tmm1: tmm_reg = ["tmm1"] % x86_64_only, + tmm2: tmm_reg = ["tmm2"] % x86_64_only, + tmm3: tmm_reg = ["tmm3"] % x86_64_only, + tmm4: tmm_reg = ["tmm4"] % x86_64_only, + tmm5: tmm_reg = ["tmm5"] % x86_64_only, + tmm6: tmm_reg = ["tmm6"] % x86_64_only, + tmm7: tmm_reg = ["tmm7"] % x86_64_only, #error = ["bp", "bpl", "ebp", "rbp"] => "the frame pointer cannot be used as an operand for inline asm", #error = ["sp", "spl", "esp", "rsp"] => diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version index f514a2f0bd053..f76f9131742ee 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version +++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version @@ -1 +1 @@ -0.9.1 \ No newline at end of file +0.9.2 \ No newline at end of file diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 21efd040663b8..0495cd97dc229 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -12,7 +12,6 @@ askama = { version = "0.11", default-features = false, features = ["config"] } atty = "0.2" pulldown-cmark = { version = "0.9", default-features = false } minifier = "0.0.43" -rayon = "1.5.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" smallvec = "1.6.1" @@ -29,6 +28,9 @@ version = "0.3.3" default-features = false features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] +[target.'cfg(windows)'.dependencies] +rayon = "1.5.1" + [dev-dependencies] expect-test = "1.0" diff --git a/src/librustdoc/docfs.rs b/src/librustdoc/docfs.rs index d59273db08b4f..8dd8eb23df270 100644 --- a/src/librustdoc/docfs.rs +++ b/src/librustdoc/docfs.rs @@ -54,7 +54,8 @@ impl DocFS { where E: PathError, { - if !self.sync_only && cfg!(windows) { + #[cfg(windows)] + if !self.sync_only { // A possible future enhancement after more detailed profiling would // be to create the file sync so errors are reported eagerly. let sender = self.errors.clone().expect("can't write after closing"); @@ -68,6 +69,10 @@ impl DocFS { } else { fs::write(&path, contents).map_err(|e| E::new(e, path))?; } + + #[cfg(not(windows))] + fs::write(&path, contents).map_err(|e| E::new(e, path))?; + Ok(()) } } diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 38e67c233d698..4eb8029ee2db6 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -897,7 +897,7 @@ table, margin-left: 0.25em; padding-left: 0.3125em; padding-right: 23px; - border: 0; + border: 1px solid; border-radius: 4px; outline: none; cursor: pointer; @@ -2010,7 +2010,6 @@ details.rustdoc-toggle[open] > summary.hideme::after { #crate-search { border-radius: 4px; - border: 0; } .docblock { diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css index ea0cb5e072696..d32bb4cf22d6e 100644 --- a/src/librustdoc/html/static/css/themes/ayu.css +++ b/src/librustdoc/html/static/css/themes/ayu.css @@ -236,8 +236,8 @@ details.undocumented > summary::before { #crate-search, .search-input { background-color: #141920; - border-color: #424c57; - color: #c5c5c5; + /* Without the `!important`, the border-color is ignored for ``... */ + border-color: #f0f0f0 !important; } .search-input { diff --git a/src/librustdoc/html/static/css/themes/light.css b/src/librustdoc/html/static/css/themes/light.css index d36a088d38e3f..7d4acc6c61181 100644 --- a/src/librustdoc/html/static/css/themes/light.css +++ b/src/librustdoc/html/static/css/themes/light.css @@ -209,9 +209,9 @@ details.undocumented > summary::before { } #crate-search, .search-input { - color: #555; background-color: white; - border-color: #e0e0e0; + /* Without the `!important`, the border-color is ignored for `"). +assert-text: ("#search-settings", "Results for test in All", STARTS_WITH) + +// Checking the display of the crate filter. +// We start with the light theme. +local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} +reload: + +timeout: 2000 +wait-for: "#crate-search" +assert-css: ("#crate-search", { + "border": "1px solid rgb(224, 224, 224)", + "color": "rgb(0, 0, 0)", + "background-color": "rgb(255, 255, 255)", +}) + +// We now check the dark theme. +click: "#settings-menu" +wait-for: "#settings" +click: "#theme-dark" +wait-for-css: ("#crate-search", { + "border": "1px solid rgb(240, 240, 240)", + "color": "rgb(17, 17, 17)", + "background-color": "rgb(240, 240, 240)", +}) + +// And finally we check the ayu theme. +click: "#theme-ayu" +wait-for-css: ("#crate-search", { + "border": "1px solid rgb(66, 76, 87)", + "color": "rgb(197, 197, 197)", + "background-color": "rgb(20, 25, 32)", +}) diff --git a/src/test/rustdoc-json/fn_pointer/generics.rs b/src/test/rustdoc-json/fn_pointer/generics.rs new file mode 100644 index 0000000000000..646f720e66396 --- /dev/null +++ b/src/test/rustdoc-json/fn_pointer/generics.rs @@ -0,0 +1,14 @@ +// ignore-tidy-linelength + +#![feature(no_core)] +#![no_core] + +// @count generics.json "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[*]" 1 +// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][0]" '"val"' +// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][1].kind" '"borrowed_ref"' +// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][1].inner.lifetime" \"\'c\" +// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.output" '{ "kind": "primitive", "inner": "i32" }' +// @count - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[*]" 1 +// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[0].name" \"\'c\" +// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +pub type WithHigherRankTraitBounds = for<'c> fn(val: &'c i32) -> i32; diff --git a/src/test/rustdoc-json/fns/generic_args.rs b/src/test/rustdoc-json/fns/generic_args.rs index 3b03724b040ae..69150443c29dc 100644 --- a/src/test/rustdoc-json/fns/generic_args.rs +++ b/src/test/rustdoc-json/fns/generic_args.rs @@ -6,6 +6,9 @@ // @set foo = generic_args.json "$.index[*][?(@.name=='Foo')].id" pub trait Foo {} +// @set generic_foo = generic_args.json "$.index[*][?(@.name=='GenericFoo')].id" +pub trait GenericFoo<'a> {} + // @is - "$.index[*][?(@.name=='generics')].inner.generics.where_predicates" "[]" // @count - "$.index[*][?(@.name=='generics')].inner.generics.params[*]" 1 // @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].name" '"F"' @@ -29,19 +32,40 @@ pub fn generics(f: F) {} // @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.inner.id" $foo pub fn impl_trait(f: impl Foo) {} -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.params[*]" 1 +// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.params[*]" 3 // @is - "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].name" '"F"' // @is - "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].kind" '{"type": {"bounds": [], "default": null, "synthetic": false}}' -// @count - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[*]" 1 +// @count - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[*]" 3 // @is - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][0]" '"f"' // @is - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].kind" '"generic"' // @is - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].inner" '"F"' -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[*]" 1 +// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[*]" 3 + // @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.type" '{"inner": "F", "kind": "generic"}' // @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[*]" 1 // @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[0].trait_bound.trait.inner.id" $foo -pub fn where_clase(f: F) + +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.type" '{"inner": "G", "kind": "generic"}' +// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[*]" 1 +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.trait.inner.id" $generic_foo +// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[*]" 1 +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].name" \"\'a\" +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.generic_params" "[]" + +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.kind" '"borrowed_ref"' +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.lifetime" \"\'b\" +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.type" '{"inner": "H", "kind": "generic"}' +// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[*]" 1 +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.trait.inner.id" $foo +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.generic_params" "[]" +// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[*]" 1 +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].name" \"\'b\" +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +pub fn where_clase(f: F, g: G, h: H) where F: Foo, + G: for<'a> GenericFoo<'a>, + for<'b> &'b H: Foo, { } diff --git a/src/test/ui/consts/const-eval/ub-uninhabit.32bit.stderr b/src/test/ui/consts/const-eval/ub-uninhabit.32bit.stderr index 350bd941939b1..7873b3463c117 100644 --- a/src/test/ui/consts/const-eval/ub-uninhabit.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-uninhabit.32bit.stderr @@ -11,7 +11,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-uninhabit.rs:18:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .: encountered a value of uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a reference pointing to uninhabited type Bar | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr b/src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr index 13a4fde0830e4..473497501113c 100644 --- a/src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr @@ -11,7 +11,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-uninhabit.rs:18:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .: encountered a value of uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a reference pointing to uninhabited type Bar | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { diff --git a/src/test/ui/consts/validate_never_arrays.32bit.stderr b/src/test/ui/consts/validate_never_arrays.32bit.stderr index e2f5175bf0ac9..6280a7478e70c 100644 --- a/src/test/ui/consts/validate_never_arrays.32bit.stderr +++ b/src/test/ui/consts/validate_never_arrays.32bit.stderr @@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/validate_never_arrays.rs:4:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a reference pointing to uninhabited type [!; 1] | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/src/test/ui/consts/validate_never_arrays.64bit.stderr b/src/test/ui/consts/validate_never_arrays.64bit.stderr index c145eddef575b..c5a71e5be51b6 100644 --- a/src/test/ui/consts/validate_never_arrays.64bit.stderr +++ b/src/test/ui/consts/validate_never_arrays.64bit.stderr @@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/validate_never_arrays.rs:4:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a reference pointing to uninhabited type [!; 1] | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { diff --git a/src/test/ui/imports/unused-imports-in-test-mode.rs b/src/test/ui/imports/unused-imports-in-test-mode.rs new file mode 100644 index 0000000000000..ed0bb65b3aa91 --- /dev/null +++ b/src/test/ui/imports/unused-imports-in-test-mode.rs @@ -0,0 +1,84 @@ +// compile-flags: --test + +#![deny(unused_imports)] + +use std::io::BufRead; //~ ERROR unused import: `std::io::BufRead` + +fn a() {} +fn b() {} + +mod test { + use super::a; //~ ERROR unused import: `super::a` + + fn foo() { + use crate::b; //~ ERROR unused import: `crate::b` + } +} + +mod tests { + use super::a; //~ ERROR unused import: `super::a` + + fn foo() { + use crate::b; //~ ERROR unused import: `crate::b` + } +} + +mod test_a { + use super::a; //~ ERROR unused import: `super::a` + + fn foo() { + use crate::b; //~ ERROR unused import: `crate::b` + } +} + +mod a_test { + use super::a; //~ ERROR unused import: `super::a` + + fn foo() { + use crate::b; //~ ERROR unused import: `crate::b` + } +} + +mod tests_a { + use super::a; //~ ERROR unused import: `super::a` + + fn foo() { + use crate::b; //~ ERROR unused import: `crate::b` + } +} + +mod a_tests { + use super::a; //~ ERROR unused import: `super::a` + + fn foo() { + use crate::b; //~ ERROR unused import: `crate::b` + } +} + +mod fastest_search { + use super::a; //~ ERROR unused import: `super::a` + + fn foo() { + use crate::b; //~ ERROR unused import: `crate::b` + } +} + +#[cfg(test)] +mod test_has_attr { + use super::a; //~ ERROR unused import: `super::a` + + fn foo() { + use crate::b; //~ ERROR unused import: `crate::b` + } +} + +mod test_has_no_attr { + #[cfg(test)] + use super::a; //~ ERROR unused import: `super::a` + + fn foo() { + use crate::b; //~ ERROR unused import: `crate::b` + } +} + +fn main() {} diff --git a/src/test/ui/imports/unused-imports-in-test-mode.stderr b/src/test/ui/imports/unused-imports-in-test-mode.stderr new file mode 100644 index 0000000000000..1847abd64b4f2 --- /dev/null +++ b/src/test/ui/imports/unused-imports-in-test-mode.stderr @@ -0,0 +1,122 @@ +error: unused import: `std::io::BufRead` + --> $DIR/unused-imports-in-test-mode.rs:5:5 + | +LL | use std::io::BufRead; + | ^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/unused-imports-in-test-mode.rs:3:9 + | +LL | #![deny(unused_imports)] + | ^^^^^^^^^^^^^^ + +error: unused import: `super::a` + --> $DIR/unused-imports-in-test-mode.rs:11:9 + | +LL | use super::a; + | ^^^^^^^^ + +error: unused import: `crate::b` + --> $DIR/unused-imports-in-test-mode.rs:14:13 + | +LL | use crate::b; + | ^^^^^^^^ + +error: unused import: `super::a` + --> $DIR/unused-imports-in-test-mode.rs:19:9 + | +LL | use super::a; + | ^^^^^^^^ + +error: unused import: `crate::b` + --> $DIR/unused-imports-in-test-mode.rs:22:13 + | +LL | use crate::b; + | ^^^^^^^^ + +error: unused import: `super::a` + --> $DIR/unused-imports-in-test-mode.rs:27:9 + | +LL | use super::a; + | ^^^^^^^^ + +error: unused import: `crate::b` + --> $DIR/unused-imports-in-test-mode.rs:30:13 + | +LL | use crate::b; + | ^^^^^^^^ + +error: unused import: `super::a` + --> $DIR/unused-imports-in-test-mode.rs:35:9 + | +LL | use super::a; + | ^^^^^^^^ + +error: unused import: `crate::b` + --> $DIR/unused-imports-in-test-mode.rs:38:13 + | +LL | use crate::b; + | ^^^^^^^^ + +error: unused import: `super::a` + --> $DIR/unused-imports-in-test-mode.rs:43:9 + | +LL | use super::a; + | ^^^^^^^^ + +error: unused import: `crate::b` + --> $DIR/unused-imports-in-test-mode.rs:46:13 + | +LL | use crate::b; + | ^^^^^^^^ + +error: unused import: `super::a` + --> $DIR/unused-imports-in-test-mode.rs:51:9 + | +LL | use super::a; + | ^^^^^^^^ + +error: unused import: `crate::b` + --> $DIR/unused-imports-in-test-mode.rs:54:13 + | +LL | use crate::b; + | ^^^^^^^^ + +error: unused import: `super::a` + --> $DIR/unused-imports-in-test-mode.rs:59:9 + | +LL | use super::a; + | ^^^^^^^^ + +error: unused import: `crate::b` + --> $DIR/unused-imports-in-test-mode.rs:62:13 + | +LL | use crate::b; + | ^^^^^^^^ + +error: unused import: `super::a` + --> $DIR/unused-imports-in-test-mode.rs:68:9 + | +LL | use super::a; + | ^^^^^^^^ + +error: unused import: `crate::b` + --> $DIR/unused-imports-in-test-mode.rs:71:13 + | +LL | use crate::b; + | ^^^^^^^^ + +error: unused import: `super::a` + --> $DIR/unused-imports-in-test-mode.rs:77:9 + | +LL | use super::a; + | ^^^^^^^^ + +error: unused import: `crate::b` + --> $DIR/unused-imports-in-test-mode.rs:80:13 + | +LL | use crate::b; + | ^^^^^^^^ + +error: aborting due to 19 previous errors + diff --git a/src/test/ui/privacy/auxiliary/ctor_aux.rs b/src/test/ui/privacy/auxiliary/ctor_aux.rs new file mode 100644 index 0000000000000..9c99cca9ae6ed --- /dev/null +++ b/src/test/ui/privacy/auxiliary/ctor_aux.rs @@ -0,0 +1,25 @@ +// edition:2021 +//! Missing docs lint warns about undocumented exported items. +//! Use the lint to additionally verify that items are reachable +//! but not exported. +#![allow(non_camel_case_types)] +#![deny(missing_docs)] + +mod hidden { + pub struct s; + pub enum e { x, y, z } + pub use e::*; + impl s { + pub fn f(&self) {} + } + impl e { + pub fn g(&self) {} + } +} +// Hide all type definitions while reexporting their constructors: +mod e {} +mod x {} +mod y {} +mod z {} +mod s {} +pub use hidden::*; diff --git a/src/test/ui/privacy/ctor.rs b/src/test/ui/privacy/ctor.rs new file mode 100644 index 0000000000000..0ec15d68ed39e --- /dev/null +++ b/src/test/ui/privacy/ctor.rs @@ -0,0 +1,16 @@ +// Verify that a type is considered reachable when its constructor is +// reachable. The auxiliary library is constructed so that all types are +// shadowed and cannot be named directly, while their constructors are +// reexported. Regression test for issue #96934. +// +// aux-build:ctor_aux.rs +// edition:2021 +// build-pass + +extern crate ctor_aux; + +fn main() { + ctor_aux::s.f(); + ctor_aux::x.g(); + ctor_aux::y.g(); +}