Skip to content

Commit ee6533d

Browse files
committed
Auto merge of rust-lang#105579 - matthiaskrgr:rollup-vw5dlqc, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#101648 (Better documentation for env::home_dir()'s broken behaviour) - rust-lang#105283 (Don't call `diagnostic_hir_wf_check` query if we have infer variables) - rust-lang#105369 (Detect spurious ; before assoc fn body) - rust-lang#105472 (Make encode_info_for_trait_item use queries instead of accessing the HIR) - rust-lang#105521 (separate heading from body) - rust-lang#105555 (llvm-wrapper: adapt for LLVM API changes) - rust-lang#105560 (Extend rustdoc hashtag prepended line test) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents bdb07a8 + 427ea68 commit ee6533d

File tree

12 files changed

+150
-18
lines changed

12 files changed

+150
-18
lines changed

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,11 @@ fromRust(LLVMRustCodeModel Model) {
223223
case LLVMRustCodeModel::Large:
224224
return CodeModel::Large;
225225
case LLVMRustCodeModel::None:
226+
#if LLVM_VERSION_LT(16, 0)
226227
return None;
228+
#else
229+
return std::nullopt;
230+
#endif
227231
default:
228232
report_fatal_error("Bad CodeModel.");
229233
}

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,13 @@ extern "C" LLVMAttributeRef LLVMRustCreateUWTableAttr(LLVMContextRef C, bool Asy
322322
}
323323

324324
extern "C" LLVMAttributeRef LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32_t ElementSizeArg) {
325-
return wrap(Attribute::getWithAllocSizeArgs(*unwrap(C), ElementSizeArg, None));
325+
return wrap(Attribute::getWithAllocSizeArgs(*unwrap(C), ElementSizeArg,
326+
#if LLVM_VERSION_LT(16, 0)
327+
None
328+
#else
329+
std::nullopt
330+
#endif
331+
));
326332
}
327333

328334
#if LLVM_VERSION_GE(15, 0)
@@ -717,7 +723,11 @@ static std::optional<DIFile::ChecksumKind> fromRust(LLVMRustChecksumKind Kind) {
717723
#endif
718724
switch (Kind) {
719725
case LLVMRustChecksumKind::None:
726+
#if LLVM_VERSION_LT(16, 0)
720727
return None;
728+
#else
729+
return std::nullopt;
730+
#endif
721731
case LLVMRustChecksumKind::MD5:
722732
return DIFile::ChecksumKind::CSK_MD5;
723733
case LLVMRustChecksumKind::SHA1:

compiler/rustc_metadata/src/rmeta/encoder.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -1337,24 +1337,16 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13371337
debug!("EncodeContext::encode_info_for_trait_item({:?})", def_id);
13381338
let tcx = self.tcx;
13391339

1340-
let ast_item = tcx.hir().expect_trait_item(def_id.expect_local());
1341-
self.tables.impl_defaultness.set(def_id.index, ast_item.defaultness);
1340+
let impl_defaultness = tcx.impl_defaultness(def_id.expect_local());
1341+
self.tables.impl_defaultness.set(def_id.index, impl_defaultness);
13421342
let trait_item = tcx.associated_item(def_id);
13431343
self.tables.assoc_container.set(def_id.index, trait_item.container);
13441344

13451345
match trait_item.kind {
13461346
ty::AssocKind::Const => {}
13471347
ty::AssocKind::Fn => {
1348-
let hir::TraitItemKind::Fn(m_sig, m) = &ast_item.kind else { bug!() };
1349-
match *m {
1350-
hir::TraitFn::Required(ref names) => {
1351-
record_array!(self.tables.fn_arg_names[def_id] <- *names)
1352-
}
1353-
hir::TraitFn::Provided(body) => {
1354-
record_array!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body))
1355-
}
1356-
};
1357-
self.tables.asyncness.set(def_id.index, m_sig.header.asyncness);
1348+
record_array!(self.tables.fn_arg_names[def_id] <- tcx.fn_arg_names(def_id));
1349+
self.tables.asyncness.set(def_id.index, tcx.asyncness(def_id));
13581350
self.tables.constness.set(def_id.index, hir::Constness::NotConst);
13591351
}
13601352
ty::AssocKind::Type => {

compiler/rustc_parse/src/parser/item.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,9 @@ impl<'a> Parser<'a> {
706706
}
707707
match parse_item(self) {
708708
Ok(None) => {
709-
let is_unnecessary_semicolon = !items.is_empty()
709+
let mut is_unnecessary_semicolon = !items.is_empty()
710710
// When the close delim is `)` in a case like the following, `token.kind` is expected to be `token::CloseDelim(Delimiter::Parenthesis)`,
711-
// but the actual `token.kind` is `token::CloseDelim(Delimiter::Bracket)`.
711+
// but the actual `token.kind` is `token::CloseDelim(Delimiter::Brace)`.
712712
// This is because the `token.kind` of the close delim is treated as the same as
713713
// that of the open delim in `TokenTreesReader::parse_token_tree`, even if the delimiters of them are different.
714714
// Therefore, `token.kind` should not be compared here.
@@ -727,7 +727,13 @@ impl<'a> Parser<'a> {
727727
.span_to_snippet(self.prev_token.span)
728728
.map_or(false, |snippet| snippet == "}")
729729
&& self.token.kind == token::Semi;
730-
let semicolon_span = self.token.span;
730+
let mut semicolon_span = self.token.span;
731+
if !is_unnecessary_semicolon {
732+
// #105369, Detect spurious `;` before assoc fn body
733+
is_unnecessary_semicolon = self.token == token::OpenDelim(Delimiter::Brace)
734+
&& self.prev_token.kind == token::Semi;
735+
semicolon_span = self.prev_token.span;
736+
}
731737
// We have to bail or we'll potentially never make progress.
732738
let non_item_span = self.token.span;
733739
let is_let = self.token.is_keyword(kw::Let);

compiler/rustc_span/src/symbol.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,8 @@ impl fmt::Display for Ident {
17101710
}
17111711
}
17121712

1713-
/// This is the most general way to print identifiers.
1713+
/// The most general type to print identifiers.
1714+
///
17141715
/// AST pretty-printer is used as a fallback for turning AST structures into token streams for
17151716
/// proc macros. Additionally, proc macros may stringify their input and expect it survive the
17161717
/// stringification (especially true for proc macro derives written between Rust 1.15 and 1.30).

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
597597
// can get a better error message by performing HIR-based well-formedness checking.
598598
if let ObligationCauseCode::WellFormed(Some(wf_loc)) =
599599
root_obligation.cause.code().peel_derives()
600+
&& !obligation.predicate.has_non_region_infer()
600601
{
601602
if let Some(cause) = self
602603
.tcx

library/std/src/env.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,13 @@ impl Error for JoinPathsError {
570570
///
571571
/// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-getuserprofiledirectorya
572572
///
573+
/// # Deprecation
574+
///
575+
/// This function is deprecated because the behaviour on Windows is not correct.
576+
/// The 'HOME' environment variable is not standard on Windows, and may not produce
577+
/// desired results; for instance, under Cygwin or Mingw it will return `/home/you`
578+
/// when it should return `C:\Users\you`.
579+
///
573580
/// # Examples
574581
///
575582
/// ```
@@ -582,7 +589,7 @@ impl Error for JoinPathsError {
582589
/// ```
583590
#[deprecated(
584591
since = "1.29.0",
585-
note = "This function's behavior is unexpected and probably not what you want. \
592+
note = "This function's behavior may be unexpected on Windows. \
586593
Consider using a crate from crates.io instead."
587594
)]
588595
#[must_use]

src/librustdoc/html/markdown/tests.rs

+8
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,14 @@ fn test_ascii_with_prepending_hashtag() {
343343
#..#.#....#....#....#..#.
344344
#..#.#....#....#....#..#.
345345
#..#.####.####.####..##..
346+
</code></pre></div>",
347+
);
348+
t(
349+
r#"```markdown
350+
# hello
351+
```"#,
352+
"<div class=\"example-wrap\"><pre class=\"language-markdown\"><code>\
353+
# hello
346354
</code></pre></div>",
347355
);
348356
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use std::fmt;
2+
3+
struct S {
4+
}
5+
6+
impl S {
7+
fn hello<P>(&self, val: &P) where P: fmt::Display; {
8+
//~^ ERROR non-item in item list
9+
//~| ERROR associated function in `impl` without body
10+
println!("val: {}", val);
11+
}
12+
}
13+
14+
impl S {
15+
fn hello_empty<P>(&self, val: &P) where P: fmt::Display;
16+
//~^ ERROR associated function in `impl` without body
17+
}
18+
19+
fn main() {
20+
let s = S{};
21+
s.hello(&32);
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error: non-item in item list
2+
--> $DIR/issue-105226.rs:7:56
3+
|
4+
LL | impl S {
5+
| - item list starts here
6+
LL | fn hello<P>(&self, val: &P) where P: fmt::Display; {
7+
| - ^ non-item starts here
8+
| |
9+
| help: consider removing this semicolon
10+
...
11+
LL | }
12+
| - item list ends here
13+
14+
error: associated function in `impl` without body
15+
--> $DIR/issue-105226.rs:7:5
16+
|
17+
LL | fn hello<P>(&self, val: &P) where P: fmt::Display; {
18+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
19+
| |
20+
| help: provide a definition for the function: `{ <body> }`
21+
22+
error: associated function in `impl` without body
23+
--> $DIR/issue-105226.rs:15:5
24+
|
25+
LL | fn hello_empty<P>(&self, val: &P) where P: fmt::Display;
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
27+
| |
28+
| help: provide a definition for the function: `{ <body> }`
29+
30+
error: aborting due to 3 previous errors
31+
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// incremental
2+
3+
trait Foo {
4+
type V;
5+
}
6+
7+
trait Callback<T: Foo>: Fn(&Bar<'_, T>, &T::V) {}
8+
9+
struct Bar<'a, T> {
10+
callback: Box<dyn Callback<dyn Callback<Bar<'a, T>>>>,
11+
//~^ ERROR the trait bound `Bar<'a, T>: Foo` is not satisfied
12+
//~| ERROR the trait bound `(dyn Callback<Bar<'a, T>, for<'b, 'c, 'd> Output = ()> + 'static): Foo` is not satisfied
13+
//~| ERROR the size for values of type `(dyn Callback<Bar<'a, T>, for<'b, 'c, 'd> Output = ()> + 'static)` cannot be known at compilation time
14+
}
15+
16+
impl<T: Foo> Bar<'_, Bar<'_, T>> {}
17+
18+
fn main() {}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
error[E0277]: the trait bound `Bar<'a, T>: Foo` is not satisfied
2+
--> $DIR/hir-wf-canonicalized.rs:10:15
3+
|
4+
LL | callback: Box<dyn Callback<dyn Callback<Bar<'a, T>>>>,
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bar<'a, T>`
6+
7+
error[E0277]: the trait bound `(dyn Callback<Bar<'a, T>, for<'b, 'c, 'd> Output = ()> + 'static): Foo` is not satisfied
8+
--> $DIR/hir-wf-canonicalized.rs:10:15
9+
|
10+
LL | callback: Box<dyn Callback<dyn Callback<Bar<'a, T>>>>,
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback<Bar<'a, T>, for<'b, 'c, 'd> Output = ()> + 'static)`
12+
13+
error[E0277]: the size for values of type `(dyn Callback<Bar<'a, T>, for<'b, 'c, 'd> Output = ()> + 'static)` cannot be known at compilation time
14+
--> $DIR/hir-wf-canonicalized.rs:10:15
15+
|
16+
LL | callback: Box<dyn Callback<dyn Callback<Bar<'a, T>>>>,
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
18+
|
19+
= help: the trait `Sized` is not implemented for `(dyn Callback<Bar<'a, T>, for<'b, 'c, 'd> Output = ()> + 'static)`
20+
note: required by a bound in `Bar`
21+
--> $DIR/hir-wf-canonicalized.rs:9:16
22+
|
23+
LL | struct Bar<'a, T> {
24+
| ^ required by this bound in `Bar`
25+
help: consider relaxing the implicit `Sized` restriction
26+
|
27+
LL | struct Bar<'a, T: ?Sized> {
28+
| ++++++++
29+
30+
error: aborting due to 3 previous errors
31+
32+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)