Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to Rust 1.71.1 #369

Merged
merged 4 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ src = "src"
title = "PL/Rust Guide"

[preprocessor.variables.variables]
toolchain_ver = "1.70.0"
toolchain_ver = "1.71.1"
2 changes: 1 addition & 1 deletion doc/src/install-plrust-on-debian-ubuntu.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Where:
Example:

```
plrust-trusted-1.2.3_1.70.0-debian-pg15-amd64.deb
plrust-trusted-1.2.3_1.71.1-debian-pg15-amd64.deb
```

## Preparing the environment
Expand Down
2 changes: 1 addition & 1 deletion plrust/build
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fi
git pull
git submodule update --init --recursive
else
git clone https://github.com/tcdi/postgrestd.git --branch "rust-1.70.0" --recurse-submodules
git clone https://github.com/tcdi/postgrestd.git --branch "rust-1.71.1" --recurse-submodules
cd ./postgrestd
fi
rm -f rust-toolchain.toml
Expand Down
4 changes: 2 additions & 2 deletions plrustc/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ fi
export RUSTC_BOOTSTRAP=1

version=$($RUSTC --version | cut -d ' ' -f 2)
if [ "$version" != "1.70.0" ]; then
echo "rustc ('$RUSTC') is not version 1.70.0" >&2
if [ "$version" != "1.71.1" ]; then
echo "rustc ('$RUSTC') is not version 1.71.1" >&2
exit 1
fi

Expand Down
67 changes: 5 additions & 62 deletions plrustc/plrustc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ extern crate rustc_middle;
extern crate rustc_session;
extern crate rustc_span;

use once_cell::sync::Lazy;
use rustc_driver::Callbacks;
use rustc_interface::interface;
use rustc_session::config::ErrorOutputType;
Expand All @@ -24,8 +23,6 @@ use std::path::Path;
const PLRUSTC_USER_CRATE_NAME: &str = "PLRUSTC_USER_CRATE_NAME";
const PLRUSTC_USER_CRATE_ALLOWED_SOURCE_PATHS: &str = "PLRUSTC_USER_CRATE_ALLOWED_SOURCE_PATHS";

const PLRUSTC_VERSION: &str = env!("CARGO_PKG_VERSION");

mod lints;

struct PlrustcCallbacks {
Expand All @@ -51,62 +48,8 @@ impl Callbacks for PlrustcCallbacks {
}
}

// TODO: eventually we can replace this with:
// rustc_driver::install_ice_hook("https://github.com/tcdi/plrust/issues/new", |_| ());
fn install_ice_hook() {
fn report_plrustc_ice(info: &std::panic::PanicInfo<'_>, bug_report_url: &str) {
// Invoke the default panic handler to print the message and (possibly) a back trace
(*PANIC_HOOK)(info);
// Separate output with an empty line
eprintln!();

let fallback_bundle = rustc_errors::fallback_fluent_bundle(
rustc_driver::DEFAULT_LOCALE_RESOURCES.into(),
false,
);
let emitter = Box::new(rustc_errors::emitter::EmitterWriter::stderr(
rustc_errors::ColorConfig::Auto,
None,
None,
fallback_bundle,
false,
false,
None,
false,
false,
rustc_errors::TerminalUrl::No,
));
let handler = rustc_errors::Handler::with_emitter(true, None, emitter);

// Don't need to print anything extra for ExplicitBug
if !info.payload().is::<rustc_errors::ExplicitBug>() {
let mut d = rustc_errors::Diagnostic::new(rustc_errors::Level::Bug, "unexpected panic");
handler.emit_diagnostic(&mut d);
}
handler.note_without_error("`plrustc` unexpectedly panicked. This is probably a bug.");
handler.note_without_error(&format!("Please file a bug report at <{bug_report_url}>"));
handler.note_without_error(&format!("plrustc version: {PLRUSTC_VERSION}"));

// If backtraces are enabled, also print the query stack
let backtrace = std::env::var_os("RUST_BACKTRACE").map_or(false, |x| &x != "0");

let num_frames = if backtrace { None } else { Some(2) };

interface::try_print_query_stack(&handler, num_frames);
}

type PanicCallback = Box<dyn Fn(&std::panic::PanicInfo<'_>) + Sync + Send + 'static>;
static PANIC_HOOK: Lazy<PanicCallback> = Lazy::new(|| {
let hook = std::panic::take_hook();
let bug_report_url = "https://github.com/tcdi/plrust/issues/new";
std::panic::set_hook(Box::new(|info| report_plrustc_ice(info, bug_report_url)));
hook
});
Lazy::force(&PANIC_HOOK);
}

fn main() {
install_ice_hook();
rustc_driver::install_ice_hook("https://github.com/tcdi/plrust/issues/new", |_| ());
rustc_driver::init_rustc_env_logger();
std::process::exit(rustc_driver::catch_with_exit_code(move || {
let args = rustc_driver::args::arg_expand_all(&std::env::args().collect::<Vec<_>>());
Expand Down Expand Up @@ -177,7 +120,7 @@ impl PlrustcConfig {
let Some(allowed) = self.plrust_user_crate_allowed_source_paths.as_deref() else {
early_error(
ErrorOutputType::default(),
&format!(
format!(
"if `{PLRUSTC_USER_CRATE_NAME}` is provided, \
then `{PLRUSTC_USER_CRATE_ALLOWED_SOURCE_PATHS}` should also be provided",
),
Expand All @@ -189,22 +132,22 @@ impl PlrustcConfig {
if !path.is_absolute() {
early_error(
ErrorOutputType::default(),
&format!("`{PLRUSTC_USER_CRATE_ALLOWED_SOURCE_PATHS}` contains relative path: {allowed:?}"),
format!("`{PLRUSTC_USER_CRATE_ALLOWED_SOURCE_PATHS}` contains relative path: {allowed:?}"),
);
}
let path = path.canonicalize().ok()?;
let Some(pathstr) = path.to_str() else {
early_error(
ErrorOutputType::default(),
&format!("`{PLRUSTC_USER_CRATE_ALLOWED_SOURCE_PATHS}` contains non-UTF-8 path: {allowed:?}"),
format!("`{PLRUSTC_USER_CRATE_ALLOWED_SOURCE_PATHS}` contains non-UTF-8 path: {allowed:?}"),
);
};
Some(pathstr.to_owned())
}).collect::<Vec<String>>();
if allowed_source_dirs.is_empty() {
early_error(
ErrorOutputType::default(),
&format!(
format!(
"`{PLRUSTC_USER_CRATE_ALLOWED_SOURCE_PATHS}` was provided but contained no paths \
which exist: {allowed:?}",
),
Expand Down
1 change: 1 addition & 0 deletions plrustc/plrustc/uitests/ice_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// normalize-stderr-test: "plrustc version: .*" -> "plrustc version: <version here>"
// normalize-stderr-test: "force_ice.rs:\d*:\d*" -> "force_ice.rs"
// normalize-stderr-test: "(?ms)query stack during panic:\n.*end of query stack\n" -> ""
// normalize-stderr-test: "note: rustc .*? running on .*" -> "note: rustc <version here> running on <target here>"
#![crate_type = "lib"]
// The comments above are to clean up file/line/version numbers, backtrace info,
// etc. We want to avoid ice_hook.stderr changing more than is needed.
Expand Down
11 changes: 6 additions & 5 deletions plrustc/plrustc/uitests/ice_hook.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
thread 'rustc' panicked at 'Here is your ICE', plrustc/src/lints/force_ice.rs
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic
error: the compiler unexpectedly panicked. this is a bug.

note: `plrustc` unexpectedly panicked. This is probably a bug.
note: we would appreciate a bug report: https://github.com/tcdi/plrust/issues/new

note: Please file a bug report at <https://github.com/tcdi/plrust/issues/new>
note: rustc <version here> running on <target here>

note: plrustc version: <version here>
note: compiler flags: -C prefer-dynamic -Z ui-testing

thread panicked while panicking. aborting.
query stack during panic:
thread panicked while processing panic. aborting.
5 changes: 2 additions & 3 deletions plrustc/plrustc/uitests/tuple_struct_self_pat_box.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
error: `Self` pattern on tuple struct used to access private field
error[E0603]: tuple struct constructor `std::boxed::Box` is private
--> $DIR/tuple_struct_self_pat_box.rs:10:13
|
LL | let Self(ptr, _) = self;
| ^^^^^^^^^^^^
|
= note: `-F plrust-tuple-struct-self-pattern` implied by `-F plrust-lints`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0603`.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
error: `Self` pattern on tuple struct used to access private field
error[E0603]: tuple struct constructor `my::Foo` is private
--> $DIR/tuple_struct_self_pat_local_priv.rs:8:13
|
LL | let Self(s) = self;
| ^^^^^^^
|
= note: `-F plrust-tuple-struct-self-pattern` implied by `-F plrust-lints`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0603`.
2 changes: 1 addition & 1 deletion plrustc/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.70.0"
channel = "1.71.1"
components = [ "rustfmt", "rust-src", "rustc-dev", "cargo", "llvm-tools" ]
targets = [ ]
profile = "minimal"
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.70.0"
channel = "1.71.1"
components = [ "rustfmt", "rust-src", "rustc-dev", "llvm-tools" ]
targets = [ ]
profile = "minimal"