Skip to content

Commit 99e3aef

Browse files
committed
Auto merge of rust-lang#85518 - GuillaumeGomez:rollup-mq4ohfy, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - rust-lang#85275 (Move `std::memchr` to `sys_common`) - rust-lang#85326 (bootstrap: ensure host std when cross-compiling tools, fixes rust-lang#85320) - rust-lang#85375 (Fix missing lifetimes diagnostics after rust-lang#83759) - rust-lang#85507 (Extend escape key check) - rust-lang#85509 (Prevent tab title to "null" if the URL is a search one) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9a3214e + 247e2e2 commit 99e3aef

File tree

15 files changed

+70
-50
lines changed

15 files changed

+70
-50
lines changed

compiler/rustc_typeck/src/structured_errors/wrong_number_of_generic_args.rs

+16-37
Original file line numberDiff line numberDiff line change
@@ -509,44 +509,23 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
509509
}
510510

511511
AngleBrackets::Available => {
512-
// angle brackets exist, so we insert missing arguments after the existing args
513-
514-
assert!(!self.gen_args.args.is_empty());
515-
516-
if self.num_provided_lifetime_args() > 0 {
517-
let last_lt_arg_span = self.gen_args.args
518-
[self.num_provided_lifetime_args() - 1]
519-
.span()
520-
.shrink_to_hi();
521-
let source_map = self.tcx.sess.source_map();
522-
523-
if let Ok(last_gen_arg) = source_map.span_to_snippet(last_lt_arg_span) {
524-
let sugg = format!("{}, {}", last_gen_arg, suggested_args);
525-
526-
err.span_suggestion_verbose(
527-
last_lt_arg_span,
528-
&msg,
529-
sugg,
530-
Applicability::HasPlaceholders,
531-
);
532-
}
512+
let (sugg_span, is_first) = if self.num_provided_lifetime_args() == 0 {
513+
(self.gen_args.span().unwrap().shrink_to_lo(), true)
533514
} else {
534-
// Non-lifetime arguments included in `gen_args` -> insert missing lifetimes before
535-
// existing arguments
536-
let first_arg_span = self.gen_args.args[0].span().shrink_to_lo();
537-
let source_map = self.tcx.sess.source_map();
538-
539-
if let Ok(first_gen_arg) = source_map.span_to_snippet(first_arg_span) {
540-
let sugg = format!("{}, {}", suggested_args, first_gen_arg);
541-
542-
err.span_suggestion_verbose(
543-
first_arg_span,
544-
&msg,
545-
sugg,
546-
Applicability::HasPlaceholders,
547-
);
548-
}
549-
}
515+
let last_lt = &self.gen_args.args[self.num_provided_lifetime_args() - 1];
516+
(last_lt.span().shrink_to_hi(), false)
517+
};
518+
let has_non_lt_args = self.num_provided_type_or_const_args() != 0;
519+
let has_bindings = !self.gen_args.bindings.is_empty();
520+
521+
let sugg_prefix = if is_first { "" } else { ", " };
522+
let sugg_suffix =
523+
if is_first && (has_non_lt_args || has_bindings) { ", " } else { "" };
524+
525+
let sugg = format!("{}{}{}", sugg_prefix, suggested_args, sugg_suffix);
526+
debug!("sugg: {:?}", sugg);
527+
528+
err.span_suggestion_verbose(sugg_span, &msg, sugg, Applicability::HasPlaceholders);
550529
}
551530
AngleBrackets::Implied => {
552531
// We never encounter missing lifetimes in situations in which lifetimes are elided

library/std/src/ffi/c_str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::error::Error;
1010
use crate::fmt::{self, Write};
1111
use crate::io;
1212
use crate::mem;
13-
use crate::memchr;
1413
use crate::num::NonZeroU8;
1514
use crate::ops;
1615
use crate::os::raw::c_char;
@@ -20,6 +19,7 @@ use crate::slice;
2019
use crate::str::{self, Utf8Error};
2120
use crate::sync::Arc;
2221
use crate::sys;
22+
use crate::sys_common::memchr;
2323

2424
/// A type representing an owned, C-compatible, nul-terminated string with no nul bytes in the
2525
/// middle.

library/std/src/io/buffered/linewritershim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::io::{self, BufWriter, IoSlice, Write};
2-
use crate::memchr;
2+
use crate::sys_common::memchr;
33

44
/// Private helper struct for implementing the line-buffered writing logic.
55
/// This shim temporarily wraps a BufWriter, and uses its internals to

library/std/src/io/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,12 @@ mod tests;
253253

254254
use crate::cmp;
255255
use crate::fmt;
256-
use crate::memchr;
257256
use crate::ops::{Deref, DerefMut};
258257
use crate::ptr;
259258
use crate::slice;
260259
use crate::str;
261260
use crate::sys;
261+
use crate::sys_common::memchr;
262262

263263
#[stable(feature = "rust1", since = "1.0.0")]
264264
pub use self::buffered::IntoInnerError;

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ mod sys;
530530
pub mod alloc;
531531

532532
// Private support modules
533-
mod memchr;
534533
mod panicking;
535534

536535
// The runtime entry point and a few unstable public functions used by the

library/std/src/sys/hermit/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ use crate::ffi::{CStr, OsStr, OsString};
44
use crate::fmt;
55
use crate::io;
66
use crate::marker::PhantomData;
7-
use crate::memchr;
87
use crate::path::{self, PathBuf};
98
use crate::str;
109
use crate::sync::Mutex;
1110
use crate::sys::hermit::abi;
11+
use crate::sys::memchr;
1212
use crate::sys::unsupported;
1313
use crate::sys_common::os_str_bytes::*;
1414
use crate::vec;

library/std/src/sys/unix/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ use crate::fmt;
1313
use crate::io;
1414
use crate::iter;
1515
use crate::mem;
16-
use crate::memchr;
1716
use crate::path::{self, PathBuf};
1817
use crate::ptr;
1918
use crate::slice;
2019
use crate::str;
2120
use crate::sys::cvt;
2221
use crate::sys::fd;
22+
use crate::sys::memchr;
2323
use crate::sys::rwlock::{RWLockReadGuard, StaticRWLock};
2424
use crate::sys_common::mutex::{StaticMutex, StaticMutexGuard};
2525
use crate::vec;

library/std/src/memchr.rs library/std/src/sys_common/memchr.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Original implementation taken from rust-memchr.
22
// Copyright 2015 Andrew Gallant, bluss and Nicolas Koch
33

4+
use crate::sys::memchr as sys;
5+
46
#[cfg(test)]
57
mod tests;
68

@@ -25,7 +27,7 @@ mod tests;
2527
/// ```
2628
#[inline]
2729
pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
28-
crate::sys::memchr::memchr(needle, haystack)
30+
sys::memchr(needle, haystack)
2931
}
3032

3133
/// A safe interface to `memrchr`.
@@ -45,5 +47,5 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
4547
/// ```
4648
#[inline]
4749
pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> {
48-
crate::sys::memchr::memrchr(needle, haystack)
50+
sys::memrchr(needle, haystack)
4951
}
File renamed without changes.

library/std/src/sys_common/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub mod bytestring;
2525
pub mod condvar;
2626
pub mod fs;
2727
pub mod io;
28+
pub mod memchr;
2829
pub mod mutex;
2930
// `doc` is required because `sys/mod.rs` imports `unix/ext/mod.rs` on Windows
3031
// when generating documentation.

src/bootstrap/tool.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ impl Step for ToolBuild {
5252
let is_optional_tool = self.is_optional_tool;
5353

5454
match self.mode {
55-
Mode::ToolRustc => builder.ensure(compile::Rustc { compiler, target }),
55+
Mode::ToolRustc => {
56+
builder.ensure(compile::Std { compiler, target: compiler.host });
57+
builder.ensure(compile::Rustc { compiler, target });
58+
}
5659
Mode::ToolStd => builder.ensure(compile::Std { compiler, target }),
5760
Mode::ToolBootstrap => {} // uses downloaded stage0 compiler libs
5861
_ => panic!("unexpected Mode for tool build"),

src/librustdoc/html/static/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function hideThemeButtonState() {
161161
outputElement: function() {
162162
return document.getElementById("search");
163163
},
164-
title: null,
164+
title: document.title,
165165
titleBeforeSearch: document.title,
166166
timeout: null,
167167
// On the search screen, so you remain on the last tab you opened.

src/test/rustdoc-gui/escape-key.goml

+10-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ assert: ("#help", "class", "hidden")
2222
assert: ("#search", "class", "content")
2323
assert: ("#main", "class", "content hidden")
2424

25-
// FIXME: Once https://github.com/rust-lang/rust/pull/84462 is merged, add check to ensure
26-
// that Escape hides the search results when a result is focused.
27-
// press-key: "ArrowDown"
25+
// Check that Escape hides the search results when a search result is focused.
26+
focus: ".search-input"
27+
assert: ".search-input:focus"
28+
press-key: "ArrowDown"
29+
assert-false: ".search-input:focus"
30+
assert: "#results a:focus"
31+
press-key: "Escape"
32+
assert: ("#help", "class", "hidden")
33+
assert: ("#search", "class", "content hidden")
34+
assert: ("#main", "class", "content")
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![allow(incomplete_features)]
2+
#![feature(generic_associated_types)]
3+
use std::ops::Deref;
4+
trait Foo {
5+
type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
6+
//~^ ERROR this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
7+
//~| HELP add missing
8+
}
9+
10+
fn main() {}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
2+
--> $DIR/issue-85347.rs:5:42
3+
|
4+
LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
5+
| ^^^ expected 1 lifetime argument
6+
|
7+
note: associated type defined here, with 1 lifetime parameter: `'a`
8+
--> $DIR/issue-85347.rs:5:10
9+
|
10+
LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
11+
| ^^^ --
12+
help: add missing lifetime argument
13+
|
14+
LL | type Bar<'a>: Deref<Target = <Self>::Bar<'a, Target = Self>>;
15+
| ^^^
16+
17+
error: aborting due to previous error
18+
19+
For more information about this error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)