Skip to content

Commit 50b9553

Browse files
committed
Auto merge of #82996 - cuviper:beta-next, r=Mark-Simulacrum
[beta] backports This backports some beta-accepted PRs and one additional LLVM fix for s390x. - rustdoc: treat edition 2021 as unstable #82207 - Fix popping singleton paths in when generating E0433 #82259 - libtest: Fix unwrap panic on duplicate TestDesc #82274 - [intra-doc links] Don't check feature gates of items re-exported across crates #82295 - rustdoc: Remove duplicate "List of all items" #82484 - Substitute erased lifetimes on bad placeholder type #82494 - Revert LLVM D81803 because it broke Windows 7 #82605 - [SystemZ] Assign the full space for promoted and split outgoing args. rust-lang/llvm-project#95 r? `@Mark-Simulacrum`
2 parents 4d25f46 + ee71761 commit 50b9553

File tree

15 files changed

+94
-29
lines changed

15 files changed

+94
-29
lines changed

compiler/rustc_resolve/src/late.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
18011801
crate_lint: CrateLint,
18021802
) -> PartialRes {
18031803
tracing::debug!(
1804-
"smart_resolve_path_fragment(id={:?},qself={:?},path={:?}",
1804+
"smart_resolve_path_fragment(id={:?}, qself={:?}, path={:?})",
18051805
id,
18061806
qself,
18071807
path
@@ -1841,11 +1841,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
18411841

18421842
// Before we start looking for candidates, we have to get our hands
18431843
// on the type user is trying to perform invocation on; basically:
1844-
// we're transforming `HashMap::new` into just `HashMap`
1845-
let path = if let Some((_, path)) = path.split_last() {
1846-
path
1847-
} else {
1848-
return Some(parent_err);
1844+
// we're transforming `HashMap::new` into just `HashMap`.
1845+
let path = match path.split_last() {
1846+
Some((_, path)) if !path.is_empty() => path,
1847+
_ => return Some(parent_err),
18491848
};
18501849

18511850
let (mut err, candidates) =

compiler/rustc_session/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ pub fn parse_error_format(
12901290
error_format
12911291
}
12921292

1293-
fn parse_crate_edition(matches: &getopts::Matches) -> Edition {
1293+
pub fn parse_crate_edition(matches: &getopts::Matches) -> Edition {
12941294
let edition = match matches.opt_str("edition") {
12951295
Some(arg) => Edition::from_str(&arg).unwrap_or_else(|_| {
12961296
early_error(

compiler/rustc_typeck/src/collect.rs

+12
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,11 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
331331
span: Span,
332332
) -> &'tcx Const<'tcx> {
333333
bad_placeholder_type(self.tcx(), vec![span]).emit();
334+
// Typeck doesn't expect erased regions to be returned from `type_of`.
335+
let ty = self.tcx.fold_regions(ty, &mut false, |r, _| match r {
336+
ty::ReErased => self.tcx.lifetimes.re_static,
337+
_ => r,
338+
});
334339
self.tcx().const_error(ty)
335340
}
336341

@@ -1536,6 +1541,12 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
15361541
match get_infer_ret_ty(&sig.decl.output) {
15371542
Some(ty) => {
15381543
let fn_sig = tcx.typeck(def_id).liberated_fn_sigs()[hir_id];
1544+
// Typeck doesn't expect erased regions to be returned from `type_of`.
1545+
let fn_sig = tcx.fold_regions(fn_sig, &mut false, |r, _| match r {
1546+
ty::ReErased => tcx.lifetimes.re_static,
1547+
_ => r,
1548+
});
1549+
15391550
let mut visitor = PlaceholderHirTyCollector::default();
15401551
visitor.visit_ty(ty);
15411552
let mut diag = bad_placeholder_type(tcx, visitor.0);
@@ -1564,6 +1575,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
15641575
}
15651576
}
15661577
diag.emit();
1578+
15671579
ty::Binder::bind(fn_sig)
15681580
}
15691581
None => AstConv::ty_of_fn(

library/test/src/lib.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,13 @@ where
353353
}
354354

355355
let mut completed_test = res.unwrap();
356-
let running_test = running_tests.remove(&completed_test.desc).unwrap();
357-
if let Some(join_handle) = running_test.join_handle {
358-
if let Err(_) = join_handle.join() {
359-
if let TrOk = completed_test.result {
360-
completed_test.result =
361-
TrFailedMsg("panicked after reporting success".to_string());
356+
if let Some(running_test) = running_tests.remove(&completed_test.desc) {
357+
if let Some(join_handle) = running_test.join_handle {
358+
if let Err(_) = join_handle.join() {
359+
if let TrOk = completed_test.result {
360+
completed_test.result =
361+
TrFailedMsg("panicked after reporting success".to_string());
362+
}
362363
}
363364
}
364365
}

src/librustdoc/config.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_session::config::{CodegenOptions, DebuggingOptions, ErrorOutputType, E
1616
use rustc_session::getopts;
1717
use rustc_session::lint::Level;
1818
use rustc_session::search_paths::SearchPath;
19-
use rustc_span::edition::{Edition, DEFAULT_EDITION};
19+
use rustc_span::edition::Edition;
2020
use rustc_target::spec::TargetTriple;
2121

2222
use crate::core::new_handler;
@@ -469,17 +469,7 @@ impl Options {
469469
}
470470
}
471471

472-
let edition = if let Some(e) = matches.opt_str("edition") {
473-
match e.parse() {
474-
Ok(e) => e,
475-
Err(_) => {
476-
diag.struct_err("could not parse edition").emit();
477-
return Err(1);
478-
}
479-
}
480-
} else {
481-
DEFAULT_EDITION
482-
};
472+
let edition = config::parse_crate_edition(&matches);
483473

484474
let mut id_map = html::markdown::IdMap::new();
485475
id_map.populate(&html::render::INITIAL_IDS);

src/librustdoc/html/render/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,6 @@ impl AllTypes {
13441344
</a>\
13451345
</span>
13461346
</span>
1347-
<span class=\"in-band\">List of all items</span>\
13481347
</h1>",
13491348
);
13501349
// Note: print_entries does not escape the title, because we know the current set of titles

src/librustdoc/html/render/tests.rs

+11
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,14 @@ fn test_name_sorting() {
3838
sorted.sort_by(|&l, r| compare_names(l, r));
3939
assert_eq!(names, sorted);
4040
}
41+
42+
#[test]
43+
fn test_all_types_prints_header_once() {
44+
// Regression test for #82477
45+
let all_types = AllTypes::new();
46+
47+
let mut buffer = Buffer::new();
48+
all_types.print(&mut buffer);
49+
50+
assert_eq!(1, buffer.into_inner().matches("List of all items").count());
51+
}

src/librustdoc/passes/collect_intra_doc_links.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,10 @@ impl LinkCollector<'_, '_> {
12061206
// for discussion on the matter.
12071207
verify(kind, id)?;
12081208

1209+
// FIXME: it would be nice to check that the feature gate was enabled in the original crate, not just ignore it altogether.
1210+
// However I'm not sure how to check that across crates.
12091211
if prim == PrimitiveType::RawPointer
1212+
&& item.def_id.is_local()
12101213
&& !self.cx.tcx.features().intra_doc_pointers
12111214
{
12121215
let span = super::source_span_for_markdown_range(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![feature(intra_doc_pointers)]
2+
#![crate_name = "inner"]
3+
/// Link to [some pointer](*const::to_raw_parts)
4+
pub fn foo() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// aux-build:pointer-reexports-allowed.rs
2+
// check-pass
3+
extern crate inner;
4+
pub use inner::foo;

src/test/ui/resolve/issue-82156.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
super(); //~ ERROR failed to resolve: there are too many leading `super` keywords
3+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0433]: failed to resolve: there are too many leading `super` keywords
2+
--> $DIR/issue-82156.rs:2:5
3+
|
4+
LL | super();
5+
| ^^^^^ there are too many leading `super` keywords
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0433`.

src/test/ui/typeck/typeck_type_placeholder_item.rs

+12
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,15 @@ impl Qux for Struct {
208208
const D: _ = 42;
209209
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
210210
}
211+
212+
fn map<T>(_: fn() -> Option<&'static T>) -> Option<T> {
213+
None
214+
}
215+
216+
fn value() -> Option<&'static _> {
217+
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
218+
Option::<&'static u8>::None
219+
}
220+
221+
const _: Option<_> = map(value);
222+
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures

src/test/ui/typeck/typeck_type_placeholder_item.stderr

+20-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ LL | fn test11(x: &usize) -> &_ {
158158
| -^
159159
| ||
160160
| |not allowed in type signatures
161-
| help: replace with the correct return type: `&&usize`
161+
| help: replace with the correct return type: `&'static &'static usize`
162162

163163
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
164164
--> $DIR/typeck_type_placeholder_item.rs:52:52
@@ -410,6 +410,24 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa
410410
LL | type Y = impl Trait<_>;
411411
| ^ not allowed in type signatures
412412

413+
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
414+
--> $DIR/typeck_type_placeholder_item.rs:216:31
415+
|
416+
LL | fn value() -> Option<&'static _> {
417+
| ----------------^-
418+
| | |
419+
| | not allowed in type signatures
420+
| help: replace with the correct return type: `Option<&'static u8>`
421+
422+
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
423+
--> $DIR/typeck_type_placeholder_item.rs:221:10
424+
|
425+
LL | const _: Option<_> = map(value);
426+
| ^^^^^^^^^
427+
| |
428+
| not allowed in type signatures
429+
| help: replace `_` with the correct type: `Option<u8>`
430+
413431
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
414432
--> $DIR/typeck_type_placeholder_item.rs:140:31
415433
|
@@ -614,7 +632,7 @@ LL | const D: _ = 42;
614632
| not allowed in type signatures
615633
| help: replace `_` with the correct type: `i32`
616634

617-
error: aborting due to 67 previous errors
635+
error: aborting due to 69 previous errors
618636

619637
Some errors have detailed explanations: E0121, E0282, E0403.
620638
For more information about an error, try `rustc --explain E0121`.

0 commit comments

Comments
 (0)