Skip to content

Commit 003b6f2

Browse files
committed
Auto merge of rust-lang#108037 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] backport * Do not eagerly recover for bad impl Trait types in macros rust-lang#107813 * Fix infinite loop in rustdoc get_all_import_attributes function rust-lang#107357 * Bring tests back into rustc source tarball rust-lang#107239 r? `@Mark-Simulacrum`
2 parents a6d8057 + 993482a commit 003b6f2

File tree

6 files changed

+57
-4
lines changed

6 files changed

+57
-4
lines changed

compiler/rustc_parse/src/parser/ty.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,9 @@ impl<'a> Parser<'a> {
733733
// `where`, so stop if it's it.
734734
// We also continue if we find types (not traits), again for error recovery.
735735
while self.can_begin_bound()
736-
|| self.token.can_begin_type()
737-
|| (self.token.is_reserved_ident() && !self.token.is_keyword(kw::Where))
736+
|| (self.may_recover()
737+
&& (self.token.can_begin_type()
738+
|| (self.token.is_reserved_ident() && !self.token.is_keyword(kw::Where))))
738739
{
739740
if self.token.is_keyword(kw::Dyn) {
740741
// Account for `&dyn Trait + dyn Other`.

src/bootstrap/dist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ impl Step for PlainSourceTarball {
952952
"Cargo.toml",
953953
"Cargo.lock",
954954
];
955-
let src_dirs = ["src", "compiler", "library"];
955+
let src_dirs = ["src", "compiler", "library", "tests"];
956956

957957
copy_src_dirs(builder, &builder.src, &src_dirs, &[], &plain_dst_src);
958958

src/librustdoc/clean/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2111,10 +2111,12 @@ fn get_all_import_attributes<'hir>(
21112111
) {
21122112
let hir_map = tcx.hir();
21132113
let mut visitor = OneLevelVisitor::new(hir_map, target_hir_id);
2114+
let mut visited = FxHashSet::default();
21142115
// If the item is an import and has at least a path with two parts, we go into it.
21152116
while let hir::ItemKind::Use(path, _) = item.kind &&
21162117
path.segments.len() > 1 &&
2117-
let hir::def::Res::Def(_, def_id) = path.segments[path.segments.len() - 2].res
2118+
let hir::def::Res::Def(_, def_id) = path.segments[path.segments.len() - 2].res &&
2119+
visited.insert(def_id)
21182120
{
21192121
if let Some(hir::Node::Item(parent_item)) = hir_map.get_if_local(def_id) {
21202122
// We add the attributes from this import into the list.

tests/rustdoc/issue-107350.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This is a regression test for <https://github.com./rust-lang/rust/issues/107350>.
2+
// It shouldn't loop indefinitely.
3+
4+
#![crate_name = "foo"]
5+
6+
// @has 'foo/oops/enum.OhNo.html'
7+
8+
pub mod oops {
9+
pub use crate::oops::OhNo;
10+
11+
mod inner {
12+
pub enum OhNo {
13+
Item = 1,
14+
}
15+
}
16+
17+
pub use self::inner::*;
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// check-pass
2+
3+
// edition:2021
4+
// for the `impl` + keyword test
5+
6+
macro_rules! impl_primitive {
7+
($ty:ty) => {
8+
compile_error!("whoops");
9+
};
10+
(impl async) => {};
11+
}
12+
13+
impl_primitive!(impl async);
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// check-pass
2+
3+
macro_rules! impl_primitive {
4+
($ty:ty) => { impl_primitive!(impl $ty); };
5+
(impl $ty:ty) => { fn a(_: $ty) {} }
6+
}
7+
8+
impl_primitive! { u8 }
9+
10+
macro_rules! test {
11+
($ty:ty) => { compile_error!("oh no"); };
12+
(impl &) => {};
13+
}
14+
15+
test!(impl &);
16+
17+
fn main() {}

0 commit comments

Comments
 (0)