diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index b2d38a00f0b5f..ba6b9ef078467 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -11,6 +11,7 @@ #![allow(internal_features)] #![feature(decl_macro)] #![feature(let_chains)] +#![feature(panic_backtrace_config)] #![feature(panic_update_hook)] #![feature(result_flattening)] @@ -1317,8 +1318,8 @@ pub fn install_ice_hook( // by the user. Compiler developers and other rustc users can // opt in to less-verbose backtraces by manually setting "RUST_BACKTRACE" // (e.g. `RUST_BACKTRACE=1`) - if std::env::var_os("RUST_BACKTRACE").is_none() { - std::env::set_var("RUST_BACKTRACE", "full"); + if env::var_os("RUST_BACKTRACE").is_none() { + panic::set_backtrace_style(panic::BacktraceStyle::Full); } let using_internal_features = Arc::new(std::sync::atomic::AtomicBool::default()); diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 5c6e7b7bd50f0..f55ec1588f91d 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2044,7 +2044,6 @@ pub trait Seek { /// # Example /// /// ```no_run - /// #![feature(seek_seek_relative)] /// use std::{ /// io::{self, Seek}, /// fs::File, @@ -2059,7 +2058,7 @@ pub trait Seek { /// ``` /// /// [`BufReader`]: crate::io::BufReader - #[unstable(feature = "seek_seek_relative", issue = "117374")] + #[stable(feature = "seek_seek_relative", since = "CURRENT_RUSTC_VERSION")] fn seek_relative(&mut self, offset: i64) -> Result<()> { self.seek(SeekFrom::Current(offset))?; Ok(()) diff --git a/src/doc/style-guide/src/editions.md b/src/doc/style-guide/src/editions.md index b9a89c20cee40..9d593f8081025 100644 --- a/src/doc/style-guide/src/editions.md +++ b/src/doc/style-guide/src/editions.md @@ -43,6 +43,7 @@ include: - Miscellaneous `rustfmt` bugfixes. - Use version-sort (sort `x8`, `x16`, `x32`, `x64`, `x128` in that order). - Change "ASCIIbetical" sort to Unicode-aware "non-lowercase before lowercase". +- Format single associated type `where` clauses on the same line if they fit. ## Rust 2015/2018/2021 style edition diff --git a/src/doc/style-guide/src/items.md b/src/doc/style-guide/src/items.md index 0066a4bacb956..c0628691b7734 100644 --- a/src/doc/style-guide/src/items.md +++ b/src/doc/style-guide/src/items.md @@ -295,8 +295,18 @@ Prefer to use single-letter names for generic parameters. These rules apply for `where` clauses on any item. -If immediately following a closing bracket of any kind, write the keyword -`where` on the same line, with a space before it. +If a where clause is short, and appears on a short one-line function +declaration with no body or on a short type with no `=`, format it on +the same line as the declaration: + +```rust +fn new(&self) -> Self where Self: Sized; + +type Item<'a>: SomeTrait where Self: 'a; +``` + +Otherwise, if immediately following a closing bracket of any kind, write the +keyword `where` on the same line, with a space before it. Otherwise, put `where` on a new line at the same indentation level. Put each component of a `where` clause on its own line, block-indented. Use a trailing @@ -347,7 +357,7 @@ where ``` If a `where` clause is very short, prefer using an inline bound on the type -parameter. +parameter if possible. If a component of a `where` clause does not fit and contains `+`, break it before each `+` and block-indent the continuation lines. Put each bound on its @@ -421,9 +431,21 @@ Format associated types like type aliases. Where an associated type has a bound, put a space after the colon but not before: ```rust -pub type Foo: Bar; +type Foo: Bar; ``` +If an associated type is short, has no `=`, and has a `where` clause with only +one entry, format the entire type declaration including the `where` clause on +the same line if it fits: + +```rust +type Item<'a> where Self: 'a; +type Item<'a>: PartialEq + Send where Self: 'a; +``` + +If the associated type has a `=`, or if the `where` clause contains multiple +entries, format it across multiple lines as with a type alias. + ## extern items When writing extern items (such as `extern "C" fn`), always specify the ABI. diff --git a/src/tools/run-make-support/src/rustdoc.rs b/src/tools/run-make-support/src/rustdoc.rs index 75ca1fc29747f..c4f4e9f9bd23b 100644 --- a/src/tools/run-make-support/src/rustdoc.rs +++ b/src/tools/run-make-support/src/rustdoc.rs @@ -123,6 +123,12 @@ impl Rustdoc { self } + /// Specify the target triple, or a path to a custom target json spec file. + pub fn target(&mut self, target: &str) -> &mut Self { + self.cmd.arg(format!("--target={target}")); + self + } + /// Specify the crate type. pub fn crate_type(&mut self, crate_type: &str) -> &mut Self { self.cmd.arg("--crate-type"); @@ -137,6 +143,14 @@ impl Rustdoc { self } + /// Add a directory to the library search path. It corresponds to the `-L` + /// rustdoc option. + pub fn library_search_path>(&mut self, path: P) -> &mut Self { + self.cmd.arg("-L"); + self.cmd.arg(path.as_ref()); + self + } + #[track_caller] pub fn run_fail_assert_exit_code(&mut self, code: i32) -> Output { let caller_location = std::panic::Location::caller(); diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 02a94457385e4..18a7cb168b3b4 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -248,7 +248,6 @@ run-make/rustdoc-scrape-examples-multiple/Makefile run-make/rustdoc-scrape-examples-remap/Makefile run-make/rustdoc-scrape-examples-test/Makefile run-make/rustdoc-scrape-examples-whitespace/Makefile -run-make/rustdoc-target-spec-json-path/Makefile run-make/rustdoc-themes/Makefile run-make/rustdoc-verify-output-files/Makefile run-make/rustdoc-with-out-dir-option/Makefile diff --git a/tests/run-make/rustdoc-target-spec-json-path/Makefile b/tests/run-make/rustdoc-target-spec-json-path/Makefile deleted file mode 100644 index 6d0bc4186f229..0000000000000 --- a/tests/run-make/rustdoc-target-spec-json-path/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../tools.mk - -# Test that rustdoc will properly canonicalize the target spec json path just like rustc - -OUTPUT_DIR := "$(TMPDIR)/rustdoc-target-spec-json-path" - -all: - $(RUSTC) --crate-type lib dummy_core.rs --target target.json - $(RUSTDOC) -o $(OUTPUT_DIR) -L $(TMPDIR) my_crate.rs --target target.json diff --git a/tests/run-make/rustdoc-target-spec-json-path/rmake.rs b/tests/run-make/rustdoc-target-spec-json-path/rmake.rs new file mode 100644 index 0000000000000..66530a4f08ee9 --- /dev/null +++ b/tests/run-make/rustdoc-target-spec-json-path/rmake.rs @@ -0,0 +1,14 @@ +// Test that rustdoc will properly canonicalize the target spec json path just like rustc. + +use run_make_support::{rustc, rustdoc, tmp_dir}; + +fn main() { + let out_dir = tmp_dir().join("rustdoc-target-spec-json-path"); + rustc().crate_type("lib").input("dummy_core.rs").target("target.json").run(); + rustdoc() + .input("my_crate.rs") + .output(out_dir) + .library_search_path(tmp_dir()) + .target("target.json") + .run(); +} diff --git a/triagebot.toml b/triagebot.toml index 3d22da56f7c75..ddab670178646 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -419,7 +419,7 @@ message_on_add = """\ - Priority? - Regression? - Notify people/groups? -- Needs `I-nominated`? +- Needs `I-{team}-nominated`? """ message_on_remove = "Issue #{number}'s prioritization request has been removed." message_on_close = "Issue #{number} has been closed while requested for prioritization."