diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 1a3d458c30067..2865ea8927336 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -223,7 +223,11 @@ fromRust(LLVMRustCodeModel Model) { case LLVMRustCodeModel::Large: return CodeModel::Large; case LLVMRustCodeModel::None: +#if LLVM_VERSION_LT(16, 0) return None; +#else + return std::nullopt; +#endif default: report_fatal_error("Bad CodeModel."); } diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 5831d4693f18b..279b699185421 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -322,7 +322,13 @@ extern "C" LLVMAttributeRef LLVMRustCreateUWTableAttr(LLVMContextRef C, bool Asy } extern "C" LLVMAttributeRef LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32_t ElementSizeArg) { - return wrap(Attribute::getWithAllocSizeArgs(*unwrap(C), ElementSizeArg, None)); + return wrap(Attribute::getWithAllocSizeArgs(*unwrap(C), ElementSizeArg, +#if LLVM_VERSION_LT(16, 0) + None +#else + std::nullopt +#endif + )); } #if LLVM_VERSION_GE(15, 0) @@ -717,7 +723,11 @@ static std::optional fromRust(LLVMRustChecksumKind Kind) { #endif switch (Kind) { case LLVMRustChecksumKind::None: +#if LLVM_VERSION_LT(16, 0) return None; +#else + return std::nullopt; +#endif case LLVMRustChecksumKind::MD5: return DIFile::ChecksumKind::CSK_MD5; case LLVMRustChecksumKind::SHA1: diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 8b4c4bb2675cb..29f9e82da75cc 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1337,24 +1337,16 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { debug!("EncodeContext::encode_info_for_trait_item({:?})", def_id); let tcx = self.tcx; - let ast_item = tcx.hir().expect_trait_item(def_id.expect_local()); - self.tables.impl_defaultness.set(def_id.index, ast_item.defaultness); + let impl_defaultness = tcx.impl_defaultness(def_id.expect_local()); + self.tables.impl_defaultness.set(def_id.index, impl_defaultness); let trait_item = tcx.associated_item(def_id); self.tables.assoc_container.set(def_id.index, trait_item.container); match trait_item.kind { ty::AssocKind::Const => {} ty::AssocKind::Fn => { - let hir::TraitItemKind::Fn(m_sig, m) = &ast_item.kind else { bug!() }; - match *m { - hir::TraitFn::Required(ref names) => { - record_array!(self.tables.fn_arg_names[def_id] <- *names) - } - hir::TraitFn::Provided(body) => { - record_array!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body)) - } - }; - self.tables.asyncness.set(def_id.index, m_sig.header.asyncness); + record_array!(self.tables.fn_arg_names[def_id] <- tcx.fn_arg_names(def_id)); + self.tables.asyncness.set(def_id.index, tcx.asyncness(def_id)); self.tables.constness.set(def_id.index, hir::Constness::NotConst); } ty::AssocKind::Type => { diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 7ebcda249e23a..beb9d55d45416 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -706,9 +706,9 @@ impl<'a> Parser<'a> { } match parse_item(self) { Ok(None) => { - let is_unnecessary_semicolon = !items.is_empty() + let mut is_unnecessary_semicolon = !items.is_empty() // When the close delim is `)` in a case like the following, `token.kind` is expected to be `token::CloseDelim(Delimiter::Parenthesis)`, - // but the actual `token.kind` is `token::CloseDelim(Delimiter::Bracket)`. + // but the actual `token.kind` is `token::CloseDelim(Delimiter::Brace)`. // This is because the `token.kind` of the close delim is treated as the same as // that of the open delim in `TokenTreesReader::parse_token_tree`, even if the delimiters of them are different. // Therefore, `token.kind` should not be compared here. @@ -727,7 +727,13 @@ impl<'a> Parser<'a> { .span_to_snippet(self.prev_token.span) .map_or(false, |snippet| snippet == "}") && self.token.kind == token::Semi; - let semicolon_span = self.token.span; + let mut semicolon_span = self.token.span; + if !is_unnecessary_semicolon { + // #105369, Detect spurious `;` before assoc fn body + is_unnecessary_semicolon = self.token == token::OpenDelim(Delimiter::Brace) + && self.prev_token.kind == token::Semi; + semicolon_span = self.prev_token.span; + } // We have to bail or we'll potentially never make progress. let non_item_span = self.token.span; let is_let = self.token.is_keyword(kw::Let); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index d0fe598ce086e..85d416c43f95a 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1710,7 +1710,8 @@ impl fmt::Display for Ident { } } -/// This is the most general way to print identifiers. +/// The most general type to print identifiers. +/// /// AST pretty-printer is used as a fallback for turning AST structures into token streams for /// proc macros. Additionally, proc macros may stringify their input and expect it survive the /// stringification (especially true for proc macro derives written between Rust 1.15 and 1.30). diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index dda7b2b2fa5b0..82449a36b1d54 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -597,6 +597,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // can get a better error message by performing HIR-based well-formedness checking. if let ObligationCauseCode::WellFormed(Some(wf_loc)) = root_obligation.cause.code().peel_derives() + && !obligation.predicate.has_non_region_infer() { if let Some(cause) = self .tcx diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 6eb7cbea6269d..183f9ab3b08f6 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -570,6 +570,13 @@ impl Error for JoinPathsError { /// /// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-getuserprofiledirectorya /// +/// # Deprecation +/// +/// This function is deprecated because the behaviour on Windows is not correct. +/// The 'HOME' environment variable is not standard on Windows, and may not produce +/// desired results; for instance, under Cygwin or Mingw it will return `/home/you` +/// when it should return `C:\Users\you`. +/// /// # Examples /// /// ``` @@ -582,7 +589,7 @@ impl Error for JoinPathsError { /// ``` #[deprecated( since = "1.29.0", - note = "This function's behavior is unexpected and probably not what you want. \ + note = "This function's behavior may be unexpected on Windows. \ Consider using a crate from crates.io instead." )] #[must_use] diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index 68b31a6ee083d..5878c58264ec3 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -343,6 +343,14 @@ fn test_ascii_with_prepending_hashtag() { #..#.#....#....#....#..#. #..#.#....#....#....#..#. #..#.####.####.####..##.. +", + ); + t( + r#"```markdown +# hello +```"#, + "
\
+# hello
 
", ); } diff --git a/src/test/ui/suggestions/issue-105226.rs b/src/test/ui/suggestions/issue-105226.rs new file mode 100644 index 0000000000000..f123dbf4cae0c --- /dev/null +++ b/src/test/ui/suggestions/issue-105226.rs @@ -0,0 +1,22 @@ +use std::fmt; + +struct S { +} + +impl S { + fn hello

(&self, val: &P) where P: fmt::Display; { + //~^ ERROR non-item in item list + //~| ERROR associated function in `impl` without body + println!("val: {}", val); + } +} + +impl S { + fn hello_empty

(&self, val: &P) where P: fmt::Display; + //~^ ERROR associated function in `impl` without body +} + +fn main() { + let s = S{}; + s.hello(&32); +} diff --git a/src/test/ui/suggestions/issue-105226.stderr b/src/test/ui/suggestions/issue-105226.stderr new file mode 100644 index 0000000000000..f16a809010390 --- /dev/null +++ b/src/test/ui/suggestions/issue-105226.stderr @@ -0,0 +1,31 @@ +error: non-item in item list + --> $DIR/issue-105226.rs:7:56 + | +LL | impl S { + | - item list starts here +LL | fn hello

(&self, val: &P) where P: fmt::Display; { + | - ^ non-item starts here + | | + | help: consider removing this semicolon +... +LL | } + | - item list ends here + +error: associated function in `impl` without body + --> $DIR/issue-105226.rs:7:5 + | +LL | fn hello

(&self, val: &P) where P: fmt::Display; { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: provide a definition for the function: `{ }` + +error: associated function in `impl` without body + --> $DIR/issue-105226.rs:15:5 + | +LL | fn hello_empty

(&self, val: &P) where P: fmt::Display; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: provide a definition for the function: `{ }` + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/wf/hir-wf-canonicalized.rs b/src/test/ui/wf/hir-wf-canonicalized.rs new file mode 100644 index 0000000000000..bdb84409d009d --- /dev/null +++ b/src/test/ui/wf/hir-wf-canonicalized.rs @@ -0,0 +1,18 @@ +// incremental + +trait Foo { + type V; +} + +trait Callback: Fn(&Bar<'_, T>, &T::V) {} + +struct Bar<'a, T> { + callback: Box>>>, + //~^ ERROR the trait bound `Bar<'a, T>: Foo` is not satisfied + //~| ERROR the trait bound `(dyn Callback, for<'b, 'c, 'd> Output = ()> + 'static): Foo` is not satisfied + //~| ERROR the size for values of type `(dyn Callback, for<'b, 'c, 'd> Output = ()> + 'static)` cannot be known at compilation time +} + +impl Bar<'_, Bar<'_, T>> {} + +fn main() {} diff --git a/src/test/ui/wf/hir-wf-canonicalized.stderr b/src/test/ui/wf/hir-wf-canonicalized.stderr new file mode 100644 index 0000000000000..9fd0f9c81ebd8 --- /dev/null +++ b/src/test/ui/wf/hir-wf-canonicalized.stderr @@ -0,0 +1,32 @@ +error[E0277]: the trait bound `Bar<'a, T>: Foo` is not satisfied + --> $DIR/hir-wf-canonicalized.rs:10:15 + | +LL | callback: Box>>>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bar<'a, T>` + +error[E0277]: the trait bound `(dyn Callback, for<'b, 'c, 'd> Output = ()> + 'static): Foo` is not satisfied + --> $DIR/hir-wf-canonicalized.rs:10:15 + | +LL | callback: Box>>>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback, for<'b, 'c, 'd> Output = ()> + 'static)` + +error[E0277]: the size for values of type `(dyn Callback, for<'b, 'c, 'd> Output = ()> + 'static)` cannot be known at compilation time + --> $DIR/hir-wf-canonicalized.rs:10:15 + | +LL | callback: Box>>>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Callback, for<'b, 'c, 'd> Output = ()> + 'static)` +note: required by a bound in `Bar` + --> $DIR/hir-wf-canonicalized.rs:9:16 + | +LL | struct Bar<'a, T> { + | ^ required by this bound in `Bar` +help: consider relaxing the implicit `Sized` restriction + | +LL | struct Bar<'a, T: ?Sized> { + | ++++++++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`.