From d6b06b8a327ff32d083bc0494cc3195d9f8082d2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 5 Mar 2021 08:43:25 -0800 Subject: [PATCH 01/10] std: Fix a bug on the wasm32-wasi target opening files This commit fixes an issue pointed out in #82758 where LTO changed the behavior of a program. It turns out that LTO was not at fault here, it simply uncovered an existing bug. The bindings to `__wasilibc_find_relpath` assumed that the relative portion of the path returned was always contained within thee input `buf` we passed in. This isn't actually the case, however, and sometimes the relative portion of the path may reference a sub-portion of the input string itself. The fix here is to use the relative path pointer coming out of `__wasilibc_find_relpath` as the source of truth. The `buf` used for local storage is discarded in this function and the relative path is copied out unconditionally. We might be able to get away with some `Cow`-like business or such to avoid the extra allocation, but for now this is probably the easiest patch to fix the original issue. --- library/std/src/sys/wasi/fs.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/std/src/sys/wasi/fs.rs b/library/std/src/sys/wasi/fs.rs index bcf7da46b4b07..63c22136273fb 100644 --- a/library/std/src/sys/wasi/fs.rs +++ b/library/std/src/sys/wasi/fs.rs @@ -650,13 +650,11 @@ fn open_parent(p: &Path) -> io::Result<(ManuallyDrop, PathBuf)> { ); return Err(io::Error::new(io::ErrorKind::Other, msg)); } - let len = CStr::from_ptr(buf.as_ptr().cast()).to_bytes().len(); - buf.set_len(len); - buf.shrink_to_fit(); + let relative = CStr::from_ptr(relative_path).to_bytes().to_vec(); return Ok(( ManuallyDrop::new(WasiFd::from_raw(fd as u32)), - PathBuf::from(OsString::from_vec(buf)), + PathBuf::from(OsString::from_vec(relative)), )); } } From 45229b0777e6791625392529c2c9d8eceac28dbd Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 5 Mar 2021 09:50:20 -0500 Subject: [PATCH 02/10] Rename `rustdoc` to `rustdoc::all` When rustdoc lints were changed to be tool lints, the `rustdoc` group was removed, leading to spurious warnings like ``` warning: unknown lint: `rustdoc` ``` The lint group still worked when rustdoc ran, since rustdoc added the group itself. This renames the group to `rustdoc::all` for consistency with `clippy::all` and the rest of the rustdoc lints. --- compiler/rustc_lint/src/lib.rs | 1 + src/librustdoc/lint.rs | 4 ++-- src/test/rustdoc-ui/check-fail.rs | 2 +- src/test/rustdoc-ui/check-fail.stderr | 12 +++++----- src/test/rustdoc-ui/check.rs | 2 +- src/test/rustdoc-ui/check.stderr | 16 ++++++------- src/test/rustdoc-ui/lint-group.rs | 2 +- src/test/rustdoc-ui/lint-group.stderr | 24 +++++++++---------- src/test/rustdoc-ui/unknown-renamed-lints.rs | 3 +++ .../rustdoc-ui/unknown-renamed-lints.stderr | 10 ++++++-- src/test/ui/lint/rustdoc-group.rs | 5 ++++ src/test/ui/lint/rustdoc-group.stderr | 10 ++++++++ 12 files changed, 58 insertions(+), 33 deletions(-) create mode 100644 src/test/ui/lint/rustdoc-group.rs create mode 100644 src/test/ui/lint/rustdoc-group.stderr diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 547779dd6856a..94ca0df818b9f 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -343,6 +343,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { "intra_doc_link_resolution_failure", "use `rustdoc::broken_intra_doc_links` instead", ); + store.register_removed("rustdoc", "use `rustdoc::all` instead"); store.register_removed("unknown_features", "replaced by an error"); store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate"); diff --git a/src/librustdoc/lint.rs b/src/librustdoc/lint.rs index e8806c1b6d787..754ec53b330f1 100644 --- a/src/librustdoc/lint.rs +++ b/src/librustdoc/lint.rs @@ -175,8 +175,8 @@ crate fn register_lints(_sess: &Session, lint_store: &mut LintStore) { lint_store.register_lints(&**RUSTDOC_LINTS); lint_store.register_group( true, - "rustdoc", - None, + "rustdoc::all", + Some("rustdoc"), RUSTDOC_LINTS.iter().map(|&lint| LintId::of(lint)).collect(), ); for lint in &*RUSTDOC_LINTS { diff --git a/src/test/rustdoc-ui/check-fail.rs b/src/test/rustdoc-ui/check-fail.rs index 291fc112c3407..2355d6a3d6cbc 100644 --- a/src/test/rustdoc-ui/check-fail.rs +++ b/src/test/rustdoc-ui/check-fail.rs @@ -1,7 +1,7 @@ // compile-flags: -Z unstable-options --check #![deny(missing_docs)] -#![deny(rustdoc)] +#![deny(rustdoc::all)] //! ```rust,testharness //~^ ERROR diff --git a/src/test/rustdoc-ui/check-fail.stderr b/src/test/rustdoc-ui/check-fail.stderr index 9f5ccbc6687c2..2758c5490a3d8 100644 --- a/src/test/rustdoc-ui/check-fail.stderr +++ b/src/test/rustdoc-ui/check-fail.stderr @@ -19,9 +19,9 @@ LL | pub fn foo() {} note: the lint level is defined here --> $DIR/check-fail.rs:4:9 | -LL | #![deny(rustdoc)] - | ^^^^^^^ - = note: `#[deny(rustdoc::missing_doc_code_examples)]` implied by `#[deny(rustdoc)]` +LL | #![deny(rustdoc::all)] + | ^^^^^^^^^^^^ + = note: `#[deny(rustdoc::missing_doc_code_examples)]` implied by `#[deny(rustdoc::all)]` error: unknown attribute `testharness`. Did you mean `test_harness`? --> $DIR/check-fail.rs:6:1 @@ -35,9 +35,9 @@ LL | | //! ``` note: the lint level is defined here --> $DIR/check-fail.rs:4:9 | -LL | #![deny(rustdoc)] - | ^^^^^^^ - = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(rustdoc)]` +LL | #![deny(rustdoc::all)] + | ^^^^^^^^^^^^ + = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(rustdoc::all)]` = help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function error: unknown attribute `testharness`. Did you mean `test_harness`? diff --git a/src/test/rustdoc-ui/check.rs b/src/test/rustdoc-ui/check.rs index 022c56214d451..65a56e03d9dfc 100644 --- a/src/test/rustdoc-ui/check.rs +++ b/src/test/rustdoc-ui/check.rs @@ -4,7 +4,7 @@ #![warn(missing_docs)] //~^ WARN //~^^ WARN -#![warn(rustdoc)] +#![warn(rustdoc::all)] pub fn foo() {} //~^ WARN diff --git a/src/test/rustdoc-ui/check.stderr b/src/test/rustdoc-ui/check.stderr index e6ba9df9b0555..2e1fc1eca4d6e 100644 --- a/src/test/rustdoc-ui/check.stderr +++ b/src/test/rustdoc-ui/check.stderr @@ -4,7 +4,7 @@ warning: missing documentation for the crate LL | / #![warn(missing_docs)] LL | | LL | | -LL | | #![warn(rustdoc)] +LL | | #![warn(rustdoc::all)] LL | | LL | | pub fn foo() {} | |_______________^ @@ -26,9 +26,9 @@ warning: no documentation found for this crate's top-level module note: the lint level is defined here --> $DIR/check.rs:7:9 | -LL | #![warn(rustdoc)] - | ^^^^^^^ - = note: `#[warn(rustdoc::missing_crate_level_docs)]` implied by `#[warn(rustdoc)]` +LL | #![warn(rustdoc::all)] + | ^^^^^^^^^^^^ + = note: `#[warn(rustdoc::missing_crate_level_docs)]` implied by `#[warn(rustdoc::all)]` = help: The following guide may be of use: https://doc.rust-lang.org/nightly/rustdoc/how-to-write-documentation.html @@ -38,7 +38,7 @@ warning: missing code example in this documentation LL | / #![warn(missing_docs)] LL | | LL | | -LL | | #![warn(rustdoc)] +LL | | #![warn(rustdoc::all)] LL | | LL | | pub fn foo() {} | |_______________^ @@ -46,9 +46,9 @@ LL | | pub fn foo() {} note: the lint level is defined here --> $DIR/check.rs:7:9 | -LL | #![warn(rustdoc)] - | ^^^^^^^ - = note: `#[warn(rustdoc::missing_doc_code_examples)]` implied by `#[warn(rustdoc)]` +LL | #![warn(rustdoc::all)] + | ^^^^^^^^^^^^ + = note: `#[warn(rustdoc::missing_doc_code_examples)]` implied by `#[warn(rustdoc::all)]` warning: missing code example in this documentation --> $DIR/check.rs:9:1 diff --git a/src/test/rustdoc-ui/lint-group.rs b/src/test/rustdoc-ui/lint-group.rs index 1446f7f1c1f31..61555a6e68617 100644 --- a/src/test/rustdoc-ui/lint-group.rs +++ b/src/test/rustdoc-ui/lint-group.rs @@ -4,7 +4,7 @@ //! println!("sup"); //! ``` -#![deny(rustdoc)] +#![deny(rustdoc::all)] /// what up, let's make an [error] /// diff --git a/src/test/rustdoc-ui/lint-group.stderr b/src/test/rustdoc-ui/lint-group.stderr index 6f8a20f7d53f0..cc6f03b03ff61 100644 --- a/src/test/rustdoc-ui/lint-group.stderr +++ b/src/test/rustdoc-ui/lint-group.stderr @@ -7,9 +7,9 @@ LL | /// wait, this doesn't have a doctest? note: the lint level is defined here --> $DIR/lint-group.rs:7:9 | -LL | #![deny(rustdoc)] - | ^^^^^^^ - = note: `#[deny(rustdoc::missing_doc_code_examples)]` implied by `#[deny(rustdoc)]` +LL | #![deny(rustdoc::all)] + | ^^^^^^^^^^^^ + = note: `#[deny(rustdoc::missing_doc_code_examples)]` implied by `#[deny(rustdoc::all)]` error: documentation test in private item --> $DIR/lint-group.rs:19:1 @@ -24,9 +24,9 @@ LL | | /// ``` note: the lint level is defined here --> $DIR/lint-group.rs:7:9 | -LL | #![deny(rustdoc)] - | ^^^^^^^ - = note: `#[deny(rustdoc::private_doc_tests)]` implied by `#[deny(rustdoc)]` +LL | #![deny(rustdoc::all)] + | ^^^^^^^^^^^^ + = note: `#[deny(rustdoc::private_doc_tests)]` implied by `#[deny(rustdoc::all)]` error: missing code example in this documentation --> $DIR/lint-group.rs:26:1 @@ -43,9 +43,9 @@ LL | /// what up, let's make an [error] note: the lint level is defined here --> $DIR/lint-group.rs:7:9 | -LL | #![deny(rustdoc)] - | ^^^^^^^ - = note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(rustdoc)]` +LL | #![deny(rustdoc::all)] + | ^^^^^^^^^^^^ + = note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(rustdoc::all)]` = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: unclosed HTML tag `unknown` @@ -57,9 +57,9 @@ LL | /// note: the lint level is defined here --> $DIR/lint-group.rs:7:9 | -LL | #![deny(rustdoc)] - | ^^^^^^^ - = note: `#[deny(rustdoc::invalid_html_tags)]` implied by `#[deny(rustdoc)]` +LL | #![deny(rustdoc::all)] + | ^^^^^^^^^^^^ + = note: `#[deny(rustdoc::invalid_html_tags)]` implied by `#[deny(rustdoc::all)]` error: aborting due to 5 previous errors diff --git a/src/test/rustdoc-ui/unknown-renamed-lints.rs b/src/test/rustdoc-ui/unknown-renamed-lints.rs index d2c78bc477410..9d20cb7d30d55 100644 --- a/src/test/rustdoc-ui/unknown-renamed-lints.rs +++ b/src/test/rustdoc-ui/unknown-renamed-lints.rs @@ -12,6 +12,9 @@ #![deny(non_autolinks)] //~^ ERROR renamed to `rustdoc::non_autolinks` +#![deny(rustdoc)] +//~^ ERROR removed: use `rustdoc::all` instead + // Explicitly don't try to handle this case, it was never valid #![deny(rustdoc::intra_doc_link_resolution_failure)] //~^ ERROR unknown lint diff --git a/src/test/rustdoc-ui/unknown-renamed-lints.stderr b/src/test/rustdoc-ui/unknown-renamed-lints.stderr index 0f31673fb47f2..2036335e85574 100644 --- a/src/test/rustdoc-ui/unknown-renamed-lints.stderr +++ b/src/test/rustdoc-ui/unknown-renamed-lints.stderr @@ -34,13 +34,19 @@ error: lint `non_autolinks` has been renamed to `rustdoc::non_autolinks` LL | #![deny(non_autolinks)] | ^^^^^^^^^^^^^ help: use the new name: `rustdoc::non_autolinks` +error: lint `rustdoc` has been removed: use `rustdoc::all` instead + --> $DIR/unknown-renamed-lints.rs:15:9 + | +LL | #![deny(rustdoc)] + | ^^^^^^^ + error: unknown lint: `rustdoc::intra_doc_link_resolution_failure` - --> $DIR/unknown-renamed-lints.rs:16:9 + --> $DIR/unknown-renamed-lints.rs:19:9 | LL | #![deny(rustdoc::intra_doc_link_resolution_failure)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Compilation failed, aborting rustdoc -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors diff --git a/src/test/ui/lint/rustdoc-group.rs b/src/test/ui/lint/rustdoc-group.rs new file mode 100644 index 0000000000000..130abe4253a13 --- /dev/null +++ b/src/test/ui/lint/rustdoc-group.rs @@ -0,0 +1,5 @@ +// check-pass +// compile-flags: --crate-type lib +#![deny(rustdoc)] +//~^ WARNING removed: use `rustdoc::all` +#![deny(rustdoc::all)] // has no effect when run with rustc directly diff --git a/src/test/ui/lint/rustdoc-group.stderr b/src/test/ui/lint/rustdoc-group.stderr new file mode 100644 index 0000000000000..fddc863ae1e99 --- /dev/null +++ b/src/test/ui/lint/rustdoc-group.stderr @@ -0,0 +1,10 @@ +warning: lint `rustdoc` has been removed: use `rustdoc::all` instead + --> $DIR/rustdoc-group.rs:3:9 + | +LL | #![deny(rustdoc)] + | ^^^^^^^ + | + = note: `#[warn(renamed_and_removed_lints)]` on by default + +warning: 1 warning emitted + From 2fd2796aae18a7e7a736346f344daa56fae37c41 Mon Sep 17 00:00:00 2001 From: csmoe Date: Fri, 5 Mar 2021 13:54:35 +0800 Subject: [PATCH 03/10] add ui testcase for issue 82772 --- compiler/rustc_typeck/src/check/pat.rs | 49 +++++++++++++++++++ .../ui/structs/struct-variant-privacy-xc.rs | 6 ++- .../structs/struct-variant-privacy-xc.stderr | 10 +++- src/test/ui/structs/struct-variant-privacy.rs | 6 ++- .../ui/structs/struct-variant-privacy.stderr | 10 +++- src/test/ui/typeck/issue-82772.rs | 13 +++++ src/test/ui/typeck/issue-82772.stderr | 15 ++++++ 7 files changed, 101 insertions(+), 8 deletions(-) create mode 100644 src/test/ui/typeck/issue-82772.rs create mode 100644 src/test/ui/typeck/issue-82772.stderr diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index f8ca916caf127..733f8e3dc9d8f 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -1176,6 +1176,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut no_field_errors = true; let mut inexistent_fields = vec![]; + let mut invisible_fields = vec![]; // Typecheck each field. for field in fields { let span = field.span; @@ -1191,6 +1192,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { field_map .get(&ident) .map(|(i, f)| { + if !f + .vis + .is_accessible_from(tcx.parent_module(pat.hir_id).to_def_id(), tcx) + { + invisible_fields.push(field.ident); + } self.write_field_index(field.hir_id, *i); self.tcx.check_stability(f.did, Some(pat.hir_id), span); self.field_ty(span, f, substs) @@ -1281,6 +1288,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.error_tuple_variant_index_shorthand(variant, pat, fields) { err.emit(); + } else if !invisible_fields.is_empty() { + let mut err = self.error_invisible_fields( + adt.variant_descr(), + &invisible_fields, + variant, + ); + err.emit(); } } } @@ -1359,6 +1373,41 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .emit(); } + fn error_invisible_fields( + &self, + kind_name: &str, + invisible_fields: &[Ident], + variant: &ty::VariantDef, + ) -> DiagnosticBuilder<'tcx> { + let spans = invisible_fields.iter().map(|ident| ident.span).collect::>(); + let (field_names, t) = if invisible_fields.len() == 1 { + (format!("a field named `{}`", invisible_fields[0]), "is") + } else { + ( + format!( + "fields named {}", + invisible_fields + .iter() + .map(|ident| format!("`{}`", ident)) + .collect::>() + .join(", ") + ), + "are", + ) + }; + let err = struct_span_err!( + self.tcx.sess, + spans, + E0603, + "cannot match on {} of {} `{}`, which {} not accessible in current scope", + field_names, + kind_name, + self.tcx.def_path_str(variant.def_id), + t + ); + err + } + fn error_inexistent_fields( &self, kind_name: &str, diff --git a/src/test/ui/structs/struct-variant-privacy-xc.rs b/src/test/ui/structs/struct-variant-privacy-xc.rs index 10e9639096f0f..bf765be75dd8c 100644 --- a/src/test/ui/structs/struct-variant-privacy-xc.rs +++ b/src/test/ui/structs/struct-variant-privacy-xc.rs @@ -1,9 +1,11 @@ // aux-build:struct_variant_privacy.rs extern crate struct_variant_privacy; -fn f(b: struct_variant_privacy::Bar) { //~ ERROR enum `Bar` is private +fn f(b: struct_variant_privacy::Bar) { + //~^ ERROR enum `Bar` is private match b { - struct_variant_privacy::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private + struct_variant_privacy::Bar::Baz { a: _a } => {} //~ ERROR cannot match on + //~^ ERROR enum `Bar` is private } } diff --git a/src/test/ui/structs/struct-variant-privacy-xc.stderr b/src/test/ui/structs/struct-variant-privacy-xc.stderr index 4e022cef1b2d3..03de40b488ca9 100644 --- a/src/test/ui/structs/struct-variant-privacy-xc.stderr +++ b/src/test/ui/structs/struct-variant-privacy-xc.stderr @@ -11,7 +11,7 @@ LL | enum Bar { | ^^^^^^^^ error[E0603]: enum `Bar` is private - --> $DIR/struct-variant-privacy-xc.rs:6:33 + --> $DIR/struct-variant-privacy-xc.rs:7:33 | LL | struct_variant_privacy::Bar::Baz { a: _a } => {} | ^^^ private enum @@ -22,6 +22,12 @@ note: the enum `Bar` is defined here LL | enum Bar { | ^^^^^^^^ -error: aborting due to 2 previous errors +error[E0603]: cannot match on a field named `a` of variant `struct_variant_privacy::Bar::Baz`, which is not accessible in current scope + --> $DIR/struct-variant-privacy-xc.rs:7:44 + | +LL | struct_variant_privacy::Bar::Baz { a: _a } => {} + | ^ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/structs/struct-variant-privacy.rs b/src/test/ui/structs/struct-variant-privacy.rs index 8355879e7d94d..7ce8ce9e290c8 100644 --- a/src/test/ui/structs/struct-variant-privacy.rs +++ b/src/test/ui/structs/struct-variant-privacy.rs @@ -1,12 +1,14 @@ mod foo { enum Bar { - Baz { a: isize } + Baz { a: isize }, } } -fn f(b: foo::Bar) { //~ ERROR enum `Bar` is private +fn f(b: foo::Bar) { + //~^ ERROR enum `Bar` is private match b { foo::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private + //~^ ERROR cannot match on } } diff --git a/src/test/ui/structs/struct-variant-privacy.stderr b/src/test/ui/structs/struct-variant-privacy.stderr index a6bc381ff6b38..a69a888553b7a 100644 --- a/src/test/ui/structs/struct-variant-privacy.stderr +++ b/src/test/ui/structs/struct-variant-privacy.stderr @@ -11,7 +11,7 @@ LL | enum Bar { | ^^^^^^^^ error[E0603]: enum `Bar` is private - --> $DIR/struct-variant-privacy.rs:9:14 + --> $DIR/struct-variant-privacy.rs:10:14 | LL | foo::Bar::Baz { a: _a } => {} | ^^^ private enum @@ -22,6 +22,12 @@ note: the enum `Bar` is defined here LL | enum Bar { | ^^^^^^^^ -error: aborting due to 2 previous errors +error[E0603]: cannot match on a field named `a` of variant `Bar::Baz`, which is not accessible in current scope + --> $DIR/struct-variant-privacy.rs:10:25 + | +LL | foo::Bar::Baz { a: _a } => {} + | ^ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/typeck/issue-82772.rs b/src/test/ui/typeck/issue-82772.rs new file mode 100644 index 0000000000000..62eb5f7a02147 --- /dev/null +++ b/src/test/ui/typeck/issue-82772.rs @@ -0,0 +1,13 @@ +// edition:2018 + +fn main() { + use a::LocalModPrivateStruct; + let Box { 1: _, .. }: Box<()>; //~ ERROR cannot match on + let LocalModPrivateStruct { 1: _, .. } = LocalModPrivateStruct::default(); + //~^ ERROR cannot match on +} + +mod a { + #[derive(Default)] + pub struct LocalModPrivateStruct(u8, u8); +} diff --git a/src/test/ui/typeck/issue-82772.stderr b/src/test/ui/typeck/issue-82772.stderr new file mode 100644 index 0000000000000..5bc6a5aa9e32f --- /dev/null +++ b/src/test/ui/typeck/issue-82772.stderr @@ -0,0 +1,15 @@ +error[E0603]: cannot match on a field named `1` of struct `Box`, which is not accessible in current scope + --> $DIR/issue-82772.rs:5:15 + | +LL | let Box { 1: _, .. }: Box<()>; + | ^ + +error[E0603]: cannot match on a field named `1` of struct `LocalModPrivateStruct`, which is not accessible in current scope + --> $DIR/issue-82772.rs:6:33 + | +LL | let LocalModPrivateStruct { 1: _, .. } = LocalModPrivateStruct::default(); + | ^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0603`. From 77fb6a0f32408925f212d1fb877e900f9736840d Mon Sep 17 00:00:00 2001 From: csmoe Date: Fri, 12 Mar 2021 01:49:27 +0800 Subject: [PATCH 04/10] fix: check before index into generated patterns --- .../src/thir/pattern/deconstruct_pat.rs | 4 +- compiler/rustc_typeck/src/check/pat.rs | 49 ------------------- .../ui/structs/struct-variant-privacy-xc.rs | 3 +- .../structs/struct-variant-privacy-xc.stderr | 8 +-- src/test/ui/structs/struct-variant-privacy.rs | 1 - .../ui/structs/struct-variant-privacy.stderr | 8 +-- src/test/ui/typeck/issue-82772.rs | 10 ++-- src/test/ui/typeck/issue-82772.stderr | 22 ++++++--- 8 files changed, 25 insertions(+), 80 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs index 3a67eeff92c31..8c740a7ec155a 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs @@ -1343,7 +1343,9 @@ impl<'p, 'tcx> Fields<'p, 'tcx> { match &mut fields { Fields::Vec(pats) => { for (i, pat) in new_pats { - pats[i] = pat + if let Some(p) = pats.get_mut(i) { + *p = pat; + } } } Fields::Filtered { fields, .. } => { diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index 733f8e3dc9d8f..f8ca916caf127 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -1176,7 +1176,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut no_field_errors = true; let mut inexistent_fields = vec![]; - let mut invisible_fields = vec![]; // Typecheck each field. for field in fields { let span = field.span; @@ -1192,12 +1191,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { field_map .get(&ident) .map(|(i, f)| { - if !f - .vis - .is_accessible_from(tcx.parent_module(pat.hir_id).to_def_id(), tcx) - { - invisible_fields.push(field.ident); - } self.write_field_index(field.hir_id, *i); self.tcx.check_stability(f.did, Some(pat.hir_id), span); self.field_ty(span, f, substs) @@ -1288,13 +1281,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.error_tuple_variant_index_shorthand(variant, pat, fields) { err.emit(); - } else if !invisible_fields.is_empty() { - let mut err = self.error_invisible_fields( - adt.variant_descr(), - &invisible_fields, - variant, - ); - err.emit(); } } } @@ -1373,41 +1359,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .emit(); } - fn error_invisible_fields( - &self, - kind_name: &str, - invisible_fields: &[Ident], - variant: &ty::VariantDef, - ) -> DiagnosticBuilder<'tcx> { - let spans = invisible_fields.iter().map(|ident| ident.span).collect::>(); - let (field_names, t) = if invisible_fields.len() == 1 { - (format!("a field named `{}`", invisible_fields[0]), "is") - } else { - ( - format!( - "fields named {}", - invisible_fields - .iter() - .map(|ident| format!("`{}`", ident)) - .collect::>() - .join(", ") - ), - "are", - ) - }; - let err = struct_span_err!( - self.tcx.sess, - spans, - E0603, - "cannot match on {} of {} `{}`, which {} not accessible in current scope", - field_names, - kind_name, - self.tcx.def_path_str(variant.def_id), - t - ); - err - } - fn error_inexistent_fields( &self, kind_name: &str, diff --git a/src/test/ui/structs/struct-variant-privacy-xc.rs b/src/test/ui/structs/struct-variant-privacy-xc.rs index bf765be75dd8c..763ab952738b7 100644 --- a/src/test/ui/structs/struct-variant-privacy-xc.rs +++ b/src/test/ui/structs/struct-variant-privacy-xc.rs @@ -4,8 +4,7 @@ extern crate struct_variant_privacy; fn f(b: struct_variant_privacy::Bar) { //~^ ERROR enum `Bar` is private match b { - struct_variant_privacy::Bar::Baz { a: _a } => {} //~ ERROR cannot match on - //~^ ERROR enum `Bar` is private + struct_variant_privacy::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private } } diff --git a/src/test/ui/structs/struct-variant-privacy-xc.stderr b/src/test/ui/structs/struct-variant-privacy-xc.stderr index 03de40b488ca9..1c1caaef8b79d 100644 --- a/src/test/ui/structs/struct-variant-privacy-xc.stderr +++ b/src/test/ui/structs/struct-variant-privacy-xc.stderr @@ -22,12 +22,6 @@ note: the enum `Bar` is defined here LL | enum Bar { | ^^^^^^^^ -error[E0603]: cannot match on a field named `a` of variant `struct_variant_privacy::Bar::Baz`, which is not accessible in current scope - --> $DIR/struct-variant-privacy-xc.rs:7:44 - | -LL | struct_variant_privacy::Bar::Baz { a: _a } => {} - | ^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/structs/struct-variant-privacy.rs b/src/test/ui/structs/struct-variant-privacy.rs index 7ce8ce9e290c8..fcdf9a22baf4b 100644 --- a/src/test/ui/structs/struct-variant-privacy.rs +++ b/src/test/ui/structs/struct-variant-privacy.rs @@ -8,7 +8,6 @@ fn f(b: foo::Bar) { //~^ ERROR enum `Bar` is private match b { foo::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private - //~^ ERROR cannot match on } } diff --git a/src/test/ui/structs/struct-variant-privacy.stderr b/src/test/ui/structs/struct-variant-privacy.stderr index a69a888553b7a..eafd26c716f11 100644 --- a/src/test/ui/structs/struct-variant-privacy.stderr +++ b/src/test/ui/structs/struct-variant-privacy.stderr @@ -22,12 +22,6 @@ note: the enum `Bar` is defined here LL | enum Bar { | ^^^^^^^^ -error[E0603]: cannot match on a field named `a` of variant `Bar::Baz`, which is not accessible in current scope - --> $DIR/struct-variant-privacy.rs:10:25 - | -LL | foo::Bar::Baz { a: _a } => {} - | ^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/typeck/issue-82772.rs b/src/test/ui/typeck/issue-82772.rs index 62eb5f7a02147..326273bfe9229 100644 --- a/src/test/ui/typeck/issue-82772.rs +++ b/src/test/ui/typeck/issue-82772.rs @@ -1,13 +1,13 @@ // edition:2018 fn main() { - use a::LocalModPrivateStruct; - let Box { 1: _, .. }: Box<()>; //~ ERROR cannot match on - let LocalModPrivateStruct { 1: _, .. } = LocalModPrivateStruct::default(); - //~^ ERROR cannot match on + use a::ModPrivateStruct; + let Box { 0: _, .. }: Box<()>; //~ ERROR field `0` of + let Box { 1: _, .. }: Box<()>; //~ ERROR field `1` of + let ModPrivateStruct { 1: _, .. } = ModPrivateStruct::default(); //~ ERROR field `1` of } mod a { #[derive(Default)] - pub struct LocalModPrivateStruct(u8, u8); + pub struct ModPrivateStruct(u8, u8); } diff --git a/src/test/ui/typeck/issue-82772.stderr b/src/test/ui/typeck/issue-82772.stderr index 5bc6a5aa9e32f..321143cb9683d 100644 --- a/src/test/ui/typeck/issue-82772.stderr +++ b/src/test/ui/typeck/issue-82772.stderr @@ -1,15 +1,21 @@ -error[E0603]: cannot match on a field named `1` of struct `Box`, which is not accessible in current scope +error[E0451]: field `0` of struct `Box` is private --> $DIR/issue-82772.rs:5:15 | +LL | let Box { 0: _, .. }: Box<()>; + | ^^^^ private field + +error[E0451]: field `1` of struct `Box` is private + --> $DIR/issue-82772.rs:6:15 + | LL | let Box { 1: _, .. }: Box<()>; - | ^ + | ^^^^ private field -error[E0603]: cannot match on a field named `1` of struct `LocalModPrivateStruct`, which is not accessible in current scope - --> $DIR/issue-82772.rs:6:33 +error[E0451]: field `1` of struct `ModPrivateStruct` is private + --> $DIR/issue-82772.rs:7:28 | -LL | let LocalModPrivateStruct { 1: _, .. } = LocalModPrivateStruct::default(); - | ^ +LL | let ModPrivateStruct { 1: _, .. } = ModPrivateStruct::default(); + | ^^^^ private field -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0603`. +For more information about this error, try `rustc --explain E0451`. From 56898ec6a7a9d3e221860c4c94f0e16c3a9d1c35 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 11 Mar 2021 21:13:42 +0100 Subject: [PATCH 05/10] Prevent JS error when there is no dependency or other crate documented --- src/librustdoc/html/static/main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index d5071cec0c83d..7827548aa1cce 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2955,7 +2955,11 @@ function defocusSearchBar() { enableSearchInput(); var crateSearchDropDown = document.getElementById("crate-search"); - crateSearchDropDown.addEventListener("focus", loadSearch); + // `crateSearchDropDown` can be null in case there is only crate because in that case, the + // crate filter dropdown is removed. + if (crateSearchDropDown) { + crateSearchDropDown.addEventListener("focus", loadSearch); + } var params = getQueryStringParams(); if (params.search !== undefined) { loadSearch(); From 1c9d56e9b4dbfd4cbb60b10920d4bef020755b11 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 12 Mar 2021 18:10:17 -0800 Subject: [PATCH 06/10] Update cargo --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 970bc67c37757..32da9eaa5de5b 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 970bc67c3775781b9708c8a36893576b9459c64a +Subproject commit 32da9eaa5de5be241cf8096ca6b749a157194f77 From bc8093ed551546730194a2b726dbd39466d199d0 Mon Sep 17 00:00:00 2001 From: hyd-dev Date: Sat, 13 Mar 2021 18:50:43 +0800 Subject: [PATCH 07/10] Fix panic message of `assert_failed_inner` --- library/core/src/panicking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 12acf5b4329db..3e3e96fcd7f78 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -154,7 +154,7 @@ fn assert_failed_inner( Some(args) => panic!( r#"assertion failed: `(left {} right)` left: `{:?}`, - right: `{:?}: {}`"#, + right: `{:?}`: {}"#, op, left, right, args ), None => panic!( From 7ecb5d86014f4da127c3d17c4b9fea3b344e7cde Mon Sep 17 00:00:00 2001 From: hyd-dev Date: Sat, 13 Mar 2021 19:14:57 +0800 Subject: [PATCH 08/10] Add regression tests --- src/test/ui/macros/assert-eq-macro-msg.rs | 9 +++++++++ src/test/ui/macros/assert-matches-macro-msg.rs | 11 +++++++++++ src/test/ui/macros/assert-ne-macro-msg.rs | 9 +++++++++ 3 files changed, 29 insertions(+) create mode 100644 src/test/ui/macros/assert-eq-macro-msg.rs create mode 100644 src/test/ui/macros/assert-matches-macro-msg.rs create mode 100644 src/test/ui/macros/assert-ne-macro-msg.rs diff --git a/src/test/ui/macros/assert-eq-macro-msg.rs b/src/test/ui/macros/assert-eq-macro-msg.rs new file mode 100644 index 0000000000000..accbd2d1e7f50 --- /dev/null +++ b/src/test/ui/macros/assert-eq-macro-msg.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:panicked at 'assertion failed: `(left == right)` +// error-pattern: left: `2` +// error-pattern:right: `3`: 1 + 1 definitely should be 3' +// ignore-emscripten no processes + +fn main() { + assert_eq!(1 + 1, 3, "1 + 1 definitely should be 3"); +} diff --git a/src/test/ui/macros/assert-matches-macro-msg.rs b/src/test/ui/macros/assert-matches-macro-msg.rs new file mode 100644 index 0000000000000..43be9532f5d1c --- /dev/null +++ b/src/test/ui/macros/assert-matches-macro-msg.rs @@ -0,0 +1,11 @@ +// run-fail +// error-pattern:panicked at 'assertion failed: `(left matches right)` +// error-pattern: left: `2` +// error-pattern:right: `3`: 1 + 1 definitely should be 3' +// ignore-emscripten no processes + +#![feature(assert_matches)] + +fn main() { + assert_matches!(1 + 1, 3, "1 + 1 definitely should be 3"); +} diff --git a/src/test/ui/macros/assert-ne-macro-msg.rs b/src/test/ui/macros/assert-ne-macro-msg.rs new file mode 100644 index 0000000000000..fc0472b99b428 --- /dev/null +++ b/src/test/ui/macros/assert-ne-macro-msg.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:panicked at 'assertion failed: `(left != right)` +// error-pattern: left: `2` +// error-pattern:right: `2`: 1 + 1 definitely should not be 2' +// ignore-emscripten no processes + +fn main() { + assert_ne!(1 + 1, 2, "1 + 1 definitely should not be 2"); +} From 06546d4b4071f48888a5bef476aa01a9d5e6c4e4 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Fri, 12 Mar 2021 17:53:02 -0500 Subject: [PATCH 09/10] Avoid sorting predicates by `DefId` Fixes issue #82920 Even if an item does not change between compilation sessions, it may end up with a different `DefId`, since inserting/deleting an item affects the `DefId`s of all subsequent items. Therefore, we use a `DefPathHash` in the incremental compilation system, which is stable in the face of changes to unrelated items. In particular, the query system will consider the inputs to a query to be unchanged if any `DefId`s in the inputs have their `DefPathHash`es unchanged. Queries are pure functions, so the query result should be unchanged if the query inputs are unchanged. Unfortunately, it's possible to inadvertantly make a query result incorrectly change across compilations, by relying on the specific value of a `DefId`. Specifically, if the query result is a slice that gets sorted by `DefId`, the precise order will depend on how the `DefId`s got assigned in a particular compilation session. If some definitions end up with different `DefId`s (but the same `DefPathHash`es) in a subsequent compilation session, we will end up re-computing a *different* value for the query, even though the query system expects the result to unchanged due to the unchanged inputs. It turns out that we have been sorting the predicates computed during `astconv` by their `DefId`. These predicates make their way into the `super_predicates_that_define_assoc_type`, which ends up getting used to compute the vtables of trait objects. This, re-ordering these predicates between compilation sessions can lead to undefined behavior at runtime - the query system will re-use code built with a *differently ordered* vtable, resulting in the wrong method being invoked at runtime. This PR avoids sorting by `DefId` in `astconv`, fixing the miscompilation. However, it's possible that other instances of this issue exist - they could also be easily introduced in the future. To fully fix this issue, we should 1. Turn on `-Z incremental-verify-ich` by default. This will cause the compiler to ICE whenver an 'unchanged' query result changes between compilation sessions, instead of causing a miscompilation. 2. Remove the `Ord` impls for `CrateNum` and `DefId`. This will make it difficult to introduce ICEs in the first place. --- compiler/rustc_typeck/src/astconv/mod.rs | 7 +++-- .../issue-82920-predicate-order-miscompile.rs | 31 +++++++++++++++++++ src/test/rustdoc/inline_cross/impl_trait.rs | 2 +- src/test/rustdoc/unit-return.rs | 4 +-- .../bad-bounds-on-assoc-in-trait.stderr | 29 ++++++++++------- ...rojection-from-multiple-supertraits.stderr | 20 ++++++------ .../defaults-unsound-62211-1.stderr | 28 ++++++++--------- .../defaults-unsound-62211-2.stderr | 28 ++++++++--------- src/test/ui/issues/issue-40827.stderr | 12 +++---- ...issing-trait-bounds-for-method-call.stderr | 4 +-- .../inductive-overflow/simultaneous.stderr | 2 +- 11 files changed, 102 insertions(+), 65 deletions(-) create mode 100644 src/test/incremental/issue-82920-predicate-order-miscompile.rs diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 947363fc3ed08..89501d9ce9725 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -942,7 +942,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let mut bounds = Bounds::default(); self.add_bounds(param_ty, ast_bounds, &mut bounds); - bounds.trait_bounds.sort_by_key(|(t, _, _)| t.def_id()); bounds.implicitly_sized = if let SizedByDefault::Yes = sized_by_default { if !self.is_unsized(ast_bounds, span) { Some(span) } else { None } @@ -1318,8 +1317,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // De-duplicate auto traits so that, e.g., `dyn Trait + Send + Send` is the same as // `dyn Trait + Send`. - auto_traits.sort_by_key(|i| i.trait_ref().def_id()); - auto_traits.dedup_by_key(|i| i.trait_ref().def_id()); + // We remove duplicates by inserting into a `FxHashSet` to avoid re-ordering + // the bounds + let mut duplicates = FxHashSet::default(); + auto_traits.retain(|i| duplicates.insert(i.trait_ref().def_id())); debug!("regular_traits: {:?}", regular_traits); debug!("auto_traits: {:?}", auto_traits); diff --git a/src/test/incremental/issue-82920-predicate-order-miscompile.rs b/src/test/incremental/issue-82920-predicate-order-miscompile.rs new file mode 100644 index 0000000000000..793af679c9fc5 --- /dev/null +++ b/src/test/incremental/issue-82920-predicate-order-miscompile.rs @@ -0,0 +1,31 @@ +// revisions: rpass1 rpass2 + +trait MyTrait: One + Two {} +impl One for T { + fn method_one(&self) -> usize { + 1 + } +} +impl Two for T { + fn method_two(&self) -> usize { + 2 + } +} +impl MyTrait for T {} + +fn main() { + let a: &dyn MyTrait = &true; + assert_eq!(a.method_one(), 1); + assert_eq!(a.method_two(), 2); +} + +// Re-order traits 'One' and 'Two' between compilation +// sessions + +#[cfg(rpass1)] +trait One { fn method_one(&self) -> usize; } + +trait Two { fn method_two(&self) -> usize; } + +#[cfg(rpass2)] +trait One { fn method_one(&self) -> usize; } diff --git a/src/test/rustdoc/inline_cross/impl_trait.rs b/src/test/rustdoc/inline_cross/impl_trait.rs index 0ab2fa99f877f..44e2c4d3fb253 100644 --- a/src/test/rustdoc/inline_cross/impl_trait.rs +++ b/src/test/rustdoc/inline_cross/impl_trait.rs @@ -18,7 +18,7 @@ pub use impl_trait_aux::func2; // @has impl_trait/fn.func3.html // @has - '//pre[@class="rust fn"]' "func3(" -// @has - '//pre[@class="rust fn"]' "_x: impl Clone + Iterator>)" +// @has - '//pre[@class="rust fn"]' "_x: impl Iterator> + Clone)" // @!has - '//pre[@class="rust fn"]' 'where' pub use impl_trait_aux::func3; diff --git a/src/test/rustdoc/unit-return.rs b/src/test/rustdoc/unit-return.rs index b1f251dae6eed..ae3a6031519fb 100644 --- a/src/test/rustdoc/unit-return.rs +++ b/src/test/rustdoc/unit-return.rs @@ -10,8 +10,8 @@ pub fn f0(f: F) {} // @has 'foo/fn.f1.html' '//*[@class="rust fn"]' 'F: FnMut(u16) + Clone' pub fn f1 () + Clone>(f: F) {} -// @has 'foo/fn.f2.html' '//*[@class="rust fn"]' 'F: Clone + FnMut(u32)' +// @has 'foo/fn.f2.html' '//*[@class="rust fn"]' 'F: FnMut(u32) + Clone' pub use unit_return::f2; -// @has 'foo/fn.f3.html' '//*[@class="rust fn"]' 'F: Clone + FnMut(u64)' +// @has 'foo/fn.f3.html' '//*[@class="rust fn"]' 'F: FnMut(u64) + Clone' pub use unit_return::f3; diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr index 1c493581bc953..a5ebb80c83620 100644 --- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr +++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr @@ -1,15 +1,3 @@ -error[E0277]: `<::C as Iterator>::Item` is not an iterator - --> $DIR/bad-bounds-on-assoc-in-trait.rs:27:5 - | -LL | type C: Clone + Iterator Lam<&'a u8, App: Debug>> + Sync>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `<::C as Iterator>::Item` is not an iterator - | - = help: the trait `Iterator` is not implemented for `<::C as Iterator>::Item` -help: consider further restricting the associated type - | -LL | trait Case1 where <::C as Iterator>::Item: Iterator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0277]: `<::C as Iterator>::Item` cannot be sent between threads safely --> $DIR/bad-bounds-on-assoc-in-trait.rs:27:36 | @@ -27,6 +15,23 @@ help: consider further restricting the associated type LL | trait Case1 where <::C as Iterator>::Item: Send { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0277]: `<::C as Iterator>::Item` is not an iterator + --> $DIR/bad-bounds-on-assoc-in-trait.rs:27:43 + | +LL | type C: Clone + Iterator Lam<&'a u8, App: Debug>> + Sync>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `<::C as Iterator>::Item` is not an iterator + | + ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | +LL | pub trait Iterator { + | ------------------ required by this bound in `Iterator` + | + = help: the trait `Iterator` is not implemented for `<::C as Iterator>::Item` +help: consider further restricting the associated type + | +LL | trait Case1 where <::C as Iterator>::Item: Iterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0277]: `<::C as Iterator>::Item` cannot be shared between threads safely --> $DIR/bad-bounds-on-assoc-in-trait.rs:27:93 | diff --git a/src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr b/src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr index b6a88179c1f63..cd7c0dc4a44d0 100644 --- a/src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr +++ b/src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr @@ -20,12 +20,12 @@ LL | fn dent(c: C, color: C::Color) { | help: use fully qualified syntax to disambiguate | -LL | fn dent(c: C, color: ::Color) { - | ^^^^^^^^^^^^^^^^^ -help: use fully qualified syntax to disambiguate - | LL | fn dent(c: C, color: ::Color) { | ^^^^^^^^^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | fn dent(c: C, color: ::Color) { + | ^^^^^^^^^^^^^^^^^ error[E0222]: ambiguous associated type `Color` in bounds of `BoxCar` --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:37 @@ -42,8 +42,8 @@ LL | fn dent_object(c: dyn BoxCar) { = help: consider introducing a new type parameter `T` and adding `where` constraints: where T: BoxCar, - T: Box::Color = COLOR, - T: Vehicle::Color = COLOR + T: Vehicle::Color = COLOR, + T: Box::Color = COLOR error[E0191]: the value of the associated types `Color` (from trait `Box`), `Color` (from trait `Vehicle`) must be specified --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:30 @@ -73,12 +73,12 @@ LL | fn paint(c: C, d: C::Color) { | help: use fully qualified syntax to disambiguate | -LL | fn paint(c: C, d: ::Color) { - | ^^^^^^^^^^^^^^^^^ -help: use fully qualified syntax to disambiguate - | LL | fn paint(c: C, d: ::Color) { | ^^^^^^^^^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | fn paint(c: C, d: ::Color) { + | ^^^^^^^^^^^^^^^^^ error[E0191]: the value of the associated types `Color` (from trait `Box`), `Color` (from trait `Vehicle`) must be specified --> $DIR/associated-type-projection-from-multiple-supertraits.rs:32:32 diff --git a/src/test/ui/associated-types/defaults-unsound-62211-1.stderr b/src/test/ui/associated-types/defaults-unsound-62211-1.stderr index 8e446cf051f47..bcdb50aa312cb 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-1.stderr +++ b/src/test/ui/associated-types/defaults-unsound-62211-1.stderr @@ -13,20 +13,6 @@ help: consider further restricting `Self` LL | trait UncheckedCopy: Sized + std::fmt::Display { | ^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `Self: Deref` is not satisfied - --> $DIR/defaults-unsound-62211-1.rs:20:5 - | -LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; - | ^^^^^^^^^^^^^^^^^^^^-------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | required by this bound in `UncheckedCopy::Output` - | the trait `Deref` is not implemented for `Self` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + Deref { - | ^^^^^^^ - error[E0277]: cannot add-assign `&'static str` to `Self` --> $DIR/defaults-unsound-62211-1.rs:20:5 | @@ -41,6 +27,20 @@ help: consider further restricting `Self` LL | trait UncheckedCopy: Sized + AddAssign<&'static str> { | ^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0277]: the trait bound `Self: Deref` is not satisfied + --> $DIR/defaults-unsound-62211-1.rs:20:5 + | +LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; + | ^^^^^^^^^^^^^^^^^^^^-------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | required by this bound in `UncheckedCopy::Output` + | the trait `Deref` is not implemented for `Self` + | +help: consider further restricting `Self` + | +LL | trait UncheckedCopy: Sized + Deref { + | ^^^^^^^ + error[E0277]: the trait bound `Self: Copy` is not satisfied --> $DIR/defaults-unsound-62211-1.rs:20:5 | diff --git a/src/test/ui/associated-types/defaults-unsound-62211-2.stderr b/src/test/ui/associated-types/defaults-unsound-62211-2.stderr index 93f4f497b38a2..fa5cf9196edbd 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-2.stderr +++ b/src/test/ui/associated-types/defaults-unsound-62211-2.stderr @@ -13,20 +13,6 @@ help: consider further restricting `Self` LL | trait UncheckedCopy: Sized + std::fmt::Display { | ^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `Self: Deref` is not satisfied - --> $DIR/defaults-unsound-62211-2.rs:20:5 - | -LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; - | ^^^^^^^^^^^^^^^^^^^^-------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | required by this bound in `UncheckedCopy::Output` - | the trait `Deref` is not implemented for `Self` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + Deref { - | ^^^^^^^ - error[E0277]: cannot add-assign `&'static str` to `Self` --> $DIR/defaults-unsound-62211-2.rs:20:5 | @@ -41,6 +27,20 @@ help: consider further restricting `Self` LL | trait UncheckedCopy: Sized + AddAssign<&'static str> { | ^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0277]: the trait bound `Self: Deref` is not satisfied + --> $DIR/defaults-unsound-62211-2.rs:20:5 + | +LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; + | ^^^^^^^^^^^^^^^^^^^^-------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | required by this bound in `UncheckedCopy::Output` + | the trait `Deref` is not implemented for `Self` + | +help: consider further restricting `Self` + | +LL | trait UncheckedCopy: Sized + Deref { + | ^^^^^^^ + error[E0277]: the trait bound `Self: Copy` is not satisfied --> $DIR/defaults-unsound-62211-2.rs:20:5 | diff --git a/src/test/ui/issues/issue-40827.stderr b/src/test/ui/issues/issue-40827.stderr index 5ea795d139715..95cacbc32ab69 100644 --- a/src/test/ui/issues/issue-40827.stderr +++ b/src/test/ui/issues/issue-40827.stderr @@ -1,27 +1,27 @@ -error[E0277]: `Rc` cannot be sent between threads safely +error[E0277]: `Rc` cannot be shared between threads safely --> $DIR/issue-40827.rs:14:5 | LL | fn f(_: T) {} | ---- required by this bound in `f` ... LL | f(Foo(Arc::new(Bar::B(None)))); - | ^ `Rc` cannot be sent between threads safely + | ^ `Rc` cannot be shared between threads safely | - = help: within `Bar`, the trait `Send` is not implemented for `Rc` + = help: within `Bar`, the trait `Sync` is not implemented for `Rc` = note: required because it appears within the type `Bar` = note: required because of the requirements on the impl of `Send` for `Arc` = note: required because it appears within the type `Foo` -error[E0277]: `Rc` cannot be shared between threads safely +error[E0277]: `Rc` cannot be sent between threads safely --> $DIR/issue-40827.rs:14:5 | LL | fn f(_: T) {} | ---- required by this bound in `f` ... LL | f(Foo(Arc::new(Bar::B(None)))); - | ^ `Rc` cannot be shared between threads safely + | ^ `Rc` cannot be sent between threads safely | - = help: within `Bar`, the trait `Sync` is not implemented for `Rc` + = help: within `Bar`, the trait `Send` is not implemented for `Rc` = note: required because it appears within the type `Bar` = note: required because of the requirements on the impl of `Send` for `Arc` = note: required because it appears within the type `Foo` diff --git a/src/test/ui/suggestions/missing-trait-bounds-for-method-call.stderr b/src/test/ui/suggestions/missing-trait-bounds-for-method-call.stderr index c7376b0007f97..0a64a0d7d5ebc 100644 --- a/src/test/ui/suggestions/missing-trait-bounds-for-method-call.stderr +++ b/src/test/ui/suggestions/missing-trait-bounds-for-method-call.stderr @@ -8,10 +8,10 @@ LL | self.foo(); | ^^^ method cannot be called on `&Foo` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: - `T: Bar` - which is required by `Foo: Bar` `T: Default` which is required by `Foo: Bar` + `T: Bar` + which is required by `Foo: Bar` help: consider restricting the type parameters to satisfy the trait bounds | LL | struct Foo where T: Bar, T: Default { diff --git a/src/test/ui/traits/inductive-overflow/simultaneous.stderr b/src/test/ui/traits/inductive-overflow/simultaneous.stderr index 484ac8511790f..88e0631eeb27a 100644 --- a/src/test/ui/traits/inductive-overflow/simultaneous.stderr +++ b/src/test/ui/traits/inductive-overflow/simultaneous.stderr @@ -1,4 +1,4 @@ -error[E0275]: overflow evaluating the requirement `{integer}: Tweedledum` +error[E0275]: overflow evaluating the requirement `{integer}: Tweedledee` --> $DIR/simultaneous.rs:18:5 | LL | fn is_ee(t: T) { From 48a3bcd860f995f7fb476b9bb4ec6b67abc7a049 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 13 Mar 2021 21:21:03 +0100 Subject: [PATCH 10/10] crates.js should use root_path and not static_root_path --- src/librustdoc/html/layout.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index ab65c71d7d1af..a717b30456692 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -58,7 +58,7 @@ crate fn render( {style_files}\ \ \ - \ + \ \ {css_extension}\ {favicon}\