Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #98144

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e9d49b2
Fix suggestions for `&a: T` parameters
WaffleLapkin Jun 10, 2022
2411692
Make preconditions of `check_pat_ref` & `borrow_pat_suggestion` clearer
WaffleLapkin Jun 13, 2022
451e030
Improve suggestion wording
WaffleLapkin Jun 13, 2022
dc2977e
check for inferred params in a clearer way
WaffleLapkin Jun 13, 2022
33ccd76
Remove trailing whitespace
WaffleLapkin Jun 13, 2022
a752f82
Ignore impl items because they can be duplicated in case of generic impl
GuillaumeGomez Jun 13, 2022
99cd9ca
Add regression test for #97986
GuillaumeGomez Jun 13, 2022
8a8404b
Inline `const_eval_select`
tmiasko Jun 13, 2022
df9fea2
Fix expand/collapse on source viewer sidebar folders
GuillaumeGomez Jun 14, 2022
a70c14a
Add GUI test for sidebar items expand/collapse
GuillaumeGomez Jun 14, 2022
5028d20
Add regression test for #93775
JohnTitor Jun 15, 2022
9aa1ccd
Fix `cfg(not)` and `cfg(all)` causing Rustdoc stab to disappear
SpriteOvO Jun 14, 2022
713578b
Exclude cfg "doc" and "doctest" from feature `doc_auto_cfg`
SpriteOvO Jun 14, 2022
2a8abe6
Rollup merge of #97964 - WaffleLapkin:fix_borrow_par_suggestions, r=c…
GuillaumeGomez Jun 15, 2022
046ff35
Rollup merge of #98053 - GuillaumeGomez:fix-generic-impl-json-ice, r=…
GuillaumeGomez Jun 15, 2022
143fa5e
Rollup merge of #98059 - tmiasko:inline-const-eval-select, r=Amanieu
GuillaumeGomez Jun 15, 2022
ca3b4c6
Rollup merge of #98092 - GuillaumeGomez:fix-sidebar-items-expand-coll…
GuillaumeGomez Jun 15, 2022
bb3d1ad
Rollup merge of #98108 - SpriteOvO:doc_auto_cfg-feature-rmv-fix, r=no…
GuillaumeGomez Jun 15, 2022
0a29cad
Rollup merge of #98135 - JohnTitor:issue-93022-93775, r=compiler-errors
GuillaumeGomez Jun 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
59 changes: 31 additions & 28 deletions compiler/rustc_typeck/src/check/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,39 +649,41 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

fn borrow_pat_suggestion(
&self,
err: &mut Diagnostic,
pat: &Pat<'_>,
inner: &Pat<'_>,
expected: Ty<'tcx>,
) {
// Precondition: pat is a Ref(_) pattern
fn borrow_pat_suggestion(&self, err: &mut Diagnostic, pat: &Pat<'_>) {
let tcx = self.tcx;
if let PatKind::Binding(..) = inner.kind {
if let PatKind::Ref(inner, mutbl) = pat.kind
&& let PatKind::Binding(_, _, binding, ..) = inner.kind {
let binding_parent_id = tcx.hir().get_parent_node(pat.hir_id);
let binding_parent = tcx.hir().get(binding_parent_id);
debug!("inner {:?} pat {:?} parent {:?}", inner, pat, binding_parent);
debug!(?inner, ?pat, ?binding_parent);

let mutability = match mutbl {
ast::Mutability::Mut => "mut",
ast::Mutability::Not => "",
};

match binding_parent {
hir::Node::Param(hir::Param { span, .. })
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(inner.span) =>
{
err.span_suggestion(
*span,
&format!("did you mean `{snippet}`"),
format!(" &{expected}"),
Applicability::MachineApplicable,
// Check that there is explicit type (ie this is not a closure param with inferred type)
// so we don't suggest moving something to the type that does not exist
hir::Node::Param(hir::Param { ty_span, .. }) if binding.span != *ty_span => {
err.multipart_suggestion_verbose(
format!("to take parameter `{binding}` by reference, move `&{mutability}` to the type"),
vec![
(pat.span.until(inner.span), "".to_owned()),
(ty_span.shrink_to_lo(), format!("&{}", mutbl.prefix_str())),
],
Applicability::MachineApplicable
);
}
hir::Node::Arm(_) | hir::Node::Pat(_) => {
hir::Node::Param(_) | hir::Node::Arm(_) | hir::Node::Pat(_) => {
// rely on match ergonomics or it might be nested `&&pat`
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(inner.span) {
err.span_suggestion(
pat.span,
"you can probably remove the explicit borrow",
snippet,
Applicability::MaybeIncorrect,
);
}
err.span_suggestion_verbose(
pat.span.until(inner.span),
format!("consider removing `&{mutability}` from the pattern"),
"",
Applicability::MaybeIncorrect,
);
}
_ => {} // don't provide suggestions in other cases #55175
}
Expand Down Expand Up @@ -1836,6 +1838,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
box_ty
}

// Precondition: Pat is Ref(inner)
fn check_pat_ref(
&self,
pat: &'tcx Pat<'tcx>,
Expand All @@ -1853,7 +1856,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

// Take region, inner-type from expected type if we can,
// to avoid creating needless variables. This also helps with
// the bad interactions of the given hack detailed in (note_1).
// the bad interactions of the given hack detailed in (note_1).
debug!("check_pat_ref: expected={:?}", expected);
match *expected.kind() {
ty::Ref(_, r_ty, r_mutbl) if r_mutbl == mutbl => (expected, r_ty),
Expand All @@ -1869,7 +1872,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Look for a case like `fn foo(&foo: u32)` and suggest
// `fn foo(foo: &u32)`
if let Some(mut err) = err {
self.borrow_pat_suggestion(&mut err, pat, inner, expected);
self.borrow_pat_suggestion(&mut err, pat);
err.emit();
}
(rptr_ty, inner_ty)
Expand Down
1 change: 1 addition & 0 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2363,6 +2363,7 @@ pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
#[lang = "const_eval_select"]
#[rustc_do_not_const_check]
#[inline]
pub const unsafe fn const_eval_select<ARG, F, G, RET>(
arg: ARG,
_called_in_const: F,
Expand Down
14 changes: 9 additions & 5 deletions src/librustdoc/clean/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,20 @@ impl Cfg {
}),
},
MetaItemKind::List(ref items) => {
let orig_len = items.len();
let sub_cfgs =
items.iter().filter_map(|i| Cfg::parse_nested(i, exclude).transpose());
let ret = match name {
sym::all => sub_cfgs.fold(Ok(Cfg::True), |x, y| Ok(x? & y?)),
sym::any => sub_cfgs.fold(Ok(Cfg::False), |x, y| Ok(x? | y?)),
sym::not => {
let mut sub_cfgs = sub_cfgs.collect::<Vec<_>>();
if sub_cfgs.len() == 1 {
Ok(!sub_cfgs.pop().unwrap()?)
if orig_len == 1 {
let mut sub_cfgs = sub_cfgs.collect::<Vec<_>>();
if sub_cfgs.len() == 1 {
Ok(!sub_cfgs.pop().unwrap()?)
} else {
return Ok(None);
}
} else {
Err(InvalidCfgError { msg: "expected 1 cfg-pattern", span: cfg.span })
}
Expand Down Expand Up @@ -304,8 +309,7 @@ impl ops::BitAnd for Cfg {
impl ops::BitOrAssign for Cfg {
fn bitor_assign(&mut self, other: Cfg) {
match (self, other) {
(&mut Cfg::True, _) | (_, Cfg::False) => {}
(s, Cfg::True) => *s = Cfg::True,
(Cfg::True, _) | (_, Cfg::False) | (_, Cfg::True) => {}
(s @ &mut Cfg::False, b) => *s = b,
(&mut Cfg::Any(ref mut a), Cfg::Any(ref mut b)) => {
for c in b.drain(..) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/cfg/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ fn test_cfg_or() {

x = word_cfg("test");
x |= Cfg::True;
assert_eq!(x, Cfg::True);
assert_eq!(x, word_cfg("test"));

x = word_cfg("test2");
x |= Cfg::False;
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/static/js/source-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) {
fullPath += elem["name"] + "/";

name.onclick = () => {
if (hasClass(this, "expand")) {
removeClass(this, "expand");
if (hasClass(name, "expand")) {
removeClass(name, "expand");
} else {
addClass(this, "expand");
addClass(name, "expand");
}
};
name.innerText = elem["name"];
Expand Down
53 changes: 43 additions & 10 deletions src/librustdoc/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,44 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
let name = item.name;
let item_id = item.item_id;
if let Some(mut new_item) = self.convert_item(item) {
if let types::ItemEnum::Trait(ref mut t) = new_item.inner {
t.implementations = self.get_trait_implementors(item_id.expect_def_id())
} else if let types::ItemEnum::Struct(ref mut s) = new_item.inner {
s.impls = self.get_impls(item_id.expect_def_id())
} else if let types::ItemEnum::Enum(ref mut e) = new_item.inner {
e.impls = self.get_impls(item_id.expect_def_id())
} else if let types::ItemEnum::Union(ref mut u) = new_item.inner {
u.impls = self.get_impls(item_id.expect_def_id())
}
let can_be_ignored = match new_item.inner {
types::ItemEnum::Trait(ref mut t) => {
t.implementations = self.get_trait_implementors(item_id.expect_def_id());
false
}
types::ItemEnum::Struct(ref mut s) => {
s.impls = self.get_impls(item_id.expect_def_id());
false
}
types::ItemEnum::Enum(ref mut e) => {
e.impls = self.get_impls(item_id.expect_def_id());
false
}
types::ItemEnum::Union(ref mut u) => {
u.impls = self.get_impls(item_id.expect_def_id());
false
}

types::ItemEnum::Method(_)
| types::ItemEnum::AssocConst { .. }
| types::ItemEnum::AssocType { .. } => true,
types::ItemEnum::Module(_)
| types::ItemEnum::ExternCrate { .. }
| types::ItemEnum::Import(_)
| types::ItemEnum::StructField(_)
| types::ItemEnum::Variant(_)
| types::ItemEnum::Function(_)
| types::ItemEnum::TraitAlias(_)
| types::ItemEnum::Impl(_)
| types::ItemEnum::Typedef(_)
| types::ItemEnum::OpaqueTy(_)
| types::ItemEnum::Constant(_)
| types::ItemEnum::Static(_)
| types::ItemEnum::ForeignType
| types::ItemEnum::Macro(_)
| types::ItemEnum::ProcMacro(_)
| types::ItemEnum::PrimitiveType(_) => false,
};
let removed = self
.index
.borrow_mut()
Expand All @@ -199,7 +228,11 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
// to make sure the items are unique. The main place this happens is when an item, is
// reexported in more than one place. See `rustdoc-json/reexport/in_root_and_mod`
if let Some(old_item) = removed {
assert_eq!(old_item, new_item);
// In case of generic implementations (like `impl<T> Trait for T {}`), all the
// inner items will be duplicated so we can ignore if they are slightly different.
if !can_be_ignored {
assert_eq!(old_item, new_item);
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
})
.collect::<Vec<_>>()
})
.chain([Cfg::Cfg(sym::test, None)].into_iter())
.chain(
[Cfg::Cfg(sym::test, None), Cfg::Cfg(sym::doc, None), Cfg::Cfg(sym::doctest, None)]
.into_iter(),
)
.collect();

self.cx.cache.exact_paths = self.exact_paths;
Expand Down
25 changes: 24 additions & 1 deletion src/test/rustdoc-gui/source-code-page.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Checks that the interactions with the source code pages are workined as expected.
// Checks that the interactions with the source code pages are working as expected.
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
// Check that we can click on the line number.
click: ".line-numbers > span:nth-child(4)" // This is the span for line 4.
Expand Down Expand Up @@ -27,3 +27,26 @@ assert-position: ("//*[@id='1']", {"x": 104, "y": 103})
// We click on the left of the "1" span but still in the "line-number" `<pre>`.
click: (103, 103)
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)

// Checking the source code sidebar.

// First we "open" it.
click: "#sidebar-toggle"
assert: ".sidebar.expanded"

// We check that the first entry of the sidebar is collapsed (which, for whatever reason,
// is number 2 and not 1...).
assert-attribute: ("#source-sidebar .name:nth-child(2)", {"class": "name"})
assert-text: ("#source-sidebar .name:nth-child(2)", "implementors")
// We also check its children are hidden too.
assert-css: ("#source-sidebar .name:nth-child(2) + .children", {"display": "none"})
// We now click on it.
click: "#source-sidebar .name:nth-child(2)"
assert-attribute: ("#source-sidebar .name:nth-child(2)", {"class": "name expand"})
// Checking that its children are displayed as well.
assert-css: ("#source-sidebar .name:nth-child(2) + .children", {"display": "block"})

// And now we collapse it again.
click: "#source-sidebar .name:nth-child(2)"
assert-attribute: ("#source-sidebar .name:nth-child(2)", {"class": "name"})
assert-css: ("#source-sidebar .name:nth-child(2) + .children", {"display": "none"})
24 changes: 24 additions & 0 deletions src/test/rustdoc-json/generic_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Regression test for <https://github.com/rust-lang/rust/issues/97986>.

// @has generic_impl.json
// @has - "$.index[*][?(@.name=='f')]"
// @has - "$.index[*][?(@.name=='AssocTy')]"
// @has - "$.index[*][?(@.name=='AssocConst')]"

pub mod m {
pub struct S;
}

pub trait F {
type AssocTy;
const AssocConst: usize;
fn f() -> m::S;
}

impl<T> F for T {
type AssocTy = u32;
const AssocConst: usize = 0;
fn f() -> m::S {
m::S
}
}
31 changes: 26 additions & 5 deletions src/test/rustdoc/doc-auto-cfg.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
#![feature(doc_auto_cfg)]

#![crate_name = "foo"]

// @has foo/fn.foo.html
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'non-doctest'
#[cfg(not(doctest))]
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'non-meowmeow'
#[cfg(not(meowmeow))]
pub fn foo() {}

// @has foo/fn.bar.html
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'test'
#[cfg(any(test, doc))]
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doctest'
#[cfg(any(meowmeow, test, doc, doctest))]
pub fn bar() {}

// @has foo/fn.appear_1.html
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'non-test'
#[cfg(any(meowmeow, doc, not(test)))]
pub fn appear_1() {} // issue #98065

// @has foo/fn.appear_2.html
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'test'
#[cfg(any(meowmeow, doc, all(test)))]
pub fn appear_2() {} // issue #98065

// @has foo/fn.appear_3.html
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
#[cfg(any(meowmeow, doc, all()))]
pub fn appear_3() {} // issue #98065
29 changes: 29 additions & 0 deletions src/test/ui/associated-consts/issue-93775.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// build-pass
// ignore-tidy-linelength

// Regression for #93775, needs build-pass to test it.

#![recursion_limit = "1000"]

use std::marker::PhantomData;

struct Z;
struct S<T>(PhantomData<T>);

type Nested = S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;

trait AsNum {
const NUM: u32;
}

impl AsNum for Z {
const NUM: u32 = 0;
}

impl<T: AsNum> AsNum for S<T> {
const NUM: u32 = T::NUM + 1;
}

fn main() {
let _ = Nested::NUM;
}
12 changes: 10 additions & 2 deletions src/test/ui/destructure-trait-ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ LL | let &&x = &1isize as &dyn T;
| ^^ ----------------- this expression has type `&dyn T`
| |
| expected trait object `dyn T`, found reference
| help: you can probably remove the explicit borrow: `x`
|
= note: expected trait object `dyn T`
found reference `&_`
help: consider removing `&` from the pattern
|
LL - let &&x = &1isize as &dyn T;
LL + let &x = &1isize as &dyn T;
|

error[E0308]: mismatched types
--> $DIR/destructure-trait-ref.rs:36:11
Expand All @@ -35,10 +39,14 @@ LL | let &&&x = &(&1isize as &dyn T);
| ^^ -------------------- this expression has type `&&dyn T`
| |
| expected trait object `dyn T`, found reference
| help: you can probably remove the explicit borrow: `x`
|
= note: expected trait object `dyn T`
found reference `&_`
help: consider removing `&` from the pattern
|
LL - let &&&x = &(&1isize as &dyn T);
LL + let &&x = &(&1isize as &dyn T);
|

error[E0308]: mismatched types
--> $DIR/destructure-trait-ref.rs:40:13
Expand Down