Skip to content

Commit ee6eaab

Browse files
committed
Auto merge of rust-lang#96931 - JohnTitor:rollup-3um8o4j, r=JohnTitor
Rollup of 7 pull requests Successful merges: - rust-lang#96543 (Remove hacks in `make_token_stream`.) - rust-lang#96887 (rustdoc: correct path to type alias methods) - rust-lang#96896 (Add regression test for rust-lang#68408) - rust-lang#96900 (Fix js error) - rust-lang#96903 (Use lifetimes on type-alias-impl-trait used in function signatures to infer output type lifetimes) - rust-lang#96916 (simplify length count) - rust-lang#96925 (Fix issue rust-lang#95151) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents b862b43 + 514b585 commit ee6eaab

File tree

15 files changed

+92
-58
lines changed

15 files changed

+92
-58
lines changed

compiler/rustc_middle/src/ty/fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
13491349
// ignore the inputs to a projection, as they may not appear
13501350
// in the normalized form
13511351
if self.just_constrained {
1352-
if let ty::Projection(..) | ty::Opaque(..) = t.kind() {
1352+
if let ty::Projection(..) = t.kind() {
13531353
return ControlFlow::CONTINUE;
13541354
}
13551355
}

compiler/rustc_mir_transform/src/coverage/spans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
485485
}) {
486486
let merged_prefix_len = self.curr_original_span.lo() - self.curr().span.lo();
487487
let after_macro_bang =
488-
merged_prefix_len + BytePos(visible_macro.as_str().bytes().count() as u32 + 1);
488+
merged_prefix_len + BytePos(visible_macro.as_str().len() as u32 + 1);
489489
let mut macro_name_cov = self.curr().clone();
490490
self.curr_mut().span =
491491
self.curr().span.with_lo(self.curr().span.lo() + after_macro_bang);

compiler/rustc_parse/src/parser/attr_wrapper.rs

-38
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,6 @@ impl<'a> Parser<'a> {
388388
/// Converts a flattened iterator of tokens (including open and close delimiter tokens)
389389
/// into a `TokenStream`, creating a `TokenTree::Delimited` for each matching pair
390390
/// of open and close delims.
391-
// FIXME(#67062): Currently, we don't parse `Invisible`-delimited groups correctly,
392-
// which can cause us to end up with mismatched `Invisible` delimiters in our
393-
// captured tokens. This function contains several hacks to work around this -
394-
// essentially, we throw away mismatched `Invisible` delimiters when we encounter them.
395-
// Once we properly parse `Invisible` delimiters, they can be captured just like any
396-
// other tokens, and these hacks can be removed.
397391
fn make_token_stream(
398392
mut iter: impl Iterator<Item = (FlatToken, Spacing)>,
399393
break_last_token: bool,
@@ -412,35 +406,10 @@ fn make_token_stream(
412406
stack.push(FrameData { open_delim_sp: Some((delim, span)), inner: vec![] });
413407
}
414408
FlatToken::Token(Token { kind: TokenKind::CloseDelim(delim), span }) => {
415-
// HACK: If we encounter a mismatched `Invisible` delimiter at the top
416-
// level, just ignore it.
417-
if matches!(delim, Delimiter::Invisible)
418-
&& (stack.len() == 1
419-
|| !matches!(
420-
stack.last_mut().unwrap().open_delim_sp.unwrap().0,
421-
Delimiter::Invisible
422-
))
423-
{
424-
token_and_spacing = iter.next();
425-
continue;
426-
}
427409
let frame_data = stack
428410
.pop()
429411
.unwrap_or_else(|| panic!("Token stack was empty for token: {:?}", token));
430412

431-
// HACK: If our current frame has a mismatched opening `Invisible` delimiter,
432-
// merge our current frame with the one above it. That is, transform
433-
// `[ { < first second } third ]` into `[ { first second } third ]`
434-
if !matches!(delim, Delimiter::Invisible)
435-
&& matches!(frame_data.open_delim_sp.unwrap().0, Delimiter::Invisible)
436-
{
437-
stack.last_mut().unwrap().inner.extend(frame_data.inner);
438-
// Process our closing delimiter again, this time at the previous
439-
// frame in the stack
440-
token_and_spacing = Some((token, spacing));
441-
continue;
442-
}
443-
444413
let (open_delim, open_sp) = frame_data.open_delim_sp.unwrap();
445414
assert_eq!(
446415
open_delim, delim,
@@ -472,13 +441,6 @@ fn make_token_stream(
472441
}
473442
token_and_spacing = iter.next();
474443
}
475-
// HACK: If we don't have a closing `Invisible` delimiter for our last
476-
// frame, merge the frame with the top-level frame. That is,
477-
// turn `< first second` into `first second`
478-
if stack.len() == 2 && stack[1].open_delim_sp.unwrap().0 == Delimiter::Invisible {
479-
let temp_buf = stack.pop().unwrap();
480-
stack.last_mut().unwrap().inner.extend(temp_buf.inner);
481-
}
482444
let mut final_buf = stack.pop().expect("Missing final buf!");
483445
if break_last_token {
484446
let (last_token, spacing) = final_buf.inner.pop().unwrap();

compiler/rustc_parse/src/parser/diagnostics.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2109,8 +2109,7 @@ impl<'a> Parser<'a> {
21092109
brace_depth -= 1;
21102110
continue;
21112111
}
2112-
} else if self.token == token::Eof || self.eat(&token::CloseDelim(Delimiter::Invisible))
2113-
{
2112+
} else if self.token == token::Eof {
21142113
return;
21152114
} else {
21162115
self.bump();

src/librustdoc/formats/cache.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
288288
// for where the type was defined. On the other
289289
// hand, `paths` always has the right
290290
// information if present.
291-
Some(&(
292-
ref fqp,
293-
ItemType::Trait
294-
| ItemType::Struct
295-
| ItemType::Union
296-
| ItemType::Enum,
297-
)) => Some(&fqp[..fqp.len() - 1]),
298-
Some(..) => Some(&*self.cache.stack),
291+
Some(&(ref fqp, _)) => Some(&fqp[..fqp.len() - 1]),
299292
None => None,
300293
};
301294
((Some(*last), path), true)

src/librustdoc/html/static/css/rustdoc.css

-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ li {
331331
nav.sub {
332332
position: relative;
333333
font-size: 1rem;
334-
text-transform: uppercase;
335334
}
336335

337336
.sub-container {

src/librustdoc/html/static/js/source-script.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// From rust:
2-
/* global search, sourcesIndex */
2+
/* global sourcesIndex */
33

44
// Local js definitions:
55
/* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, browserSupportsHistoryApi */
@@ -69,7 +69,6 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) {
6969
files.appendChild(file);
7070
}
7171
}
72-
search.fullPath = fullPath;
7372
children.appendChild(files);
7473
parent.appendChild(name);
7574
parent.appendChild(children);

src/test/rustdoc-gui/sidebar-source-code-display.goml

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ assert-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1})
1515
assert-css: (".sidebar > *:not(#sidebar-toggle)", {"visibility": "hidden", "opacity": 0})
1616
// Let's expand the sidebar now.
1717
click: "#sidebar-toggle"
18-
// Because of the transition CSS, better wait a second before checking.
18+
// Because of the transition CSS, we check by using `wait-for-css` instead of `assert-css`.
1919
wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1})
20-
assert-css: (".sidebar > *:not(#sidebar-toggle)", {"visibility": "visible", "opacity": 1})

src/test/rustdoc-js-std/asrawfd.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// ignore-order
2+
3+
const QUERY = 'RawFd::as_raw_fd';
4+
5+
const EXPECTED = {
6+
'others': [
7+
// Reproduction test for https://github.com/rust-lang/rust/issues/78724
8+
// Validate that type alias methods get the correct path.
9+
{ 'path': 'std::os::unix::io::AsRawFd', 'name': 'as_raw_fd' },
10+
{ 'path': 'std::os::wasi::io::AsRawFd', 'name': 'as_raw_fd' },
11+
{ 'path': 'std::os::linux::process::PidFd', 'name': 'as_raw_fd' },
12+
{ 'path': 'std::os::unix::io::RawFd', 'name': 'as_raw_fd' },
13+
],
14+
};
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const QUERY = 'MyForeignType::my_method';
2+
3+
const EXPECTED = {
4+
'others': [
5+
// Test case for https://github.com/rust-lang/rust/pull/96887#pullrequestreview-967154358
6+
// Validates that the parent path for a foreign type method is correct.
7+
{ 'path': 'foreign_type_path::aaaaaaa::MyForeignType', 'name': 'my_method' },
8+
],
9+
};
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(extern_types)]
2+
3+
pub mod aaaaaaa {
4+
5+
extern {
6+
pub type MyForeignType;
7+
}
8+
9+
impl MyForeignType {
10+
pub fn my_method() {}
11+
}
12+
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// check-pass
2+
3+
// Make sure we don't have any false positives here.
4+
5+
#![deny(dead_code)]
6+
7+
enum X {
8+
A { _a: () },
9+
B { _b: () },
10+
}
11+
impl X {
12+
fn a() -> X {
13+
X::A { _a: () }
14+
}
15+
fn b() -> Self {
16+
Self::B { _b: () }
17+
}
18+
}
19+
20+
fn main() {
21+
let (_, _) = (X::a(), X::b());
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
3+
// See https://github.com/rust-lang/rust/issues/95151
4+
#[track_caller]
5+
macro_rules! _foo {
6+
() => {};
7+
}
8+
9+
fn main() {
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// check-pass
2+
3+
#![feature(type_alias_impl_trait)]
4+
5+
mod foo {
6+
type Ty<'a> = impl Sized;
7+
fn defining(s: &str) -> Ty<'_> { s }
8+
fn execute(ty: Ty<'_>) -> &str { todo!() }
9+
}
10+
11+
mod bar {
12+
type Ty<'a> = impl FnOnce() -> &'a str;
13+
fn defining(s: &str) -> Ty<'_> { move || s }
14+
fn execute(ty: Ty<'_>) -> &str { ty() }
15+
}
16+
17+
fn main() {}

src/tools/rustfmt/src/parse/macros/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
7979
for &keyword in RUST_KW.iter() {
8080
if parser.token.is_keyword(keyword)
8181
&& parser.look_ahead(1, |t| {
82-
t.kind == TokenKind::Eof
83-
|| t.kind == TokenKind::Comma
84-
|| t.kind == TokenKind::CloseDelim(Delimiter::Invisible)
82+
t.kind == TokenKind::Eof || t.kind == TokenKind::Comma
8583
})
8684
{
8785
parser.bump();

0 commit comments

Comments
 (0)