From 28b6d2c28259769c31649f6b8c8497576adc6a76 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 18 Mar 2022 11:24:52 +0100 Subject: [PATCH 1/2] Fix incorrect auto trait displayed in rustdoc --- compiler/rustc_trait_selection/src/traits/select/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index a1a8497859d..c3c5ae92039 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1270,7 +1270,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // the master cache. Since coherence executes pretty quickly, // it's not worth going to more trouble to increase the // hit-rate, I don't think. - if self.intercrate { + if self.intercrate || self.allow_negative_impls { return false; } @@ -1287,7 +1287,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // mode, so don't do any caching. In particular, we might // re-use the same `InferCtxt` with both an intercrate // and non-intercrate `SelectionContext` - if self.intercrate { + if self.intercrate || self.allow_negative_impls { return None; } let tcx = self.tcx(); From 7c53ae09a85b79b3e20a85771a68e8e63aec265c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 18 Mar 2022 11:27:18 +0100 Subject: [PATCH 2/2] Add test to ensure auto-traits are respecting constraints --- src/test/rustdoc/auto-trait-not-send.rs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/test/rustdoc/auto-trait-not-send.rs diff --git a/src/test/rustdoc/auto-trait-not-send.rs b/src/test/rustdoc/auto-trait-not-send.rs new file mode 100644 index 00000000000..7bd4f6dbd8c --- /dev/null +++ b/src/test/rustdoc/auto-trait-not-send.rs @@ -0,0 +1,8 @@ +#![crate_name = "foo"] + +// @has 'foo/struct.Foo.html' +// @has - '//*[@id="impl-Send"]' 'impl !Send for Foo' +// @has - '//*[@id="impl-Sync"]' 'impl !Sync for Foo' +pub struct Foo(*const i8); +pub trait Whatever: Send {} +impl Whatever for T {}