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

Rollup of 10 pull requests #104607

Merged
merged 32 commits into from
Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c5ad97d
Use IsTerminal in rustc_errors
joshtriplett Oct 16, 2022
34f61dd
Use IsTerminal in rustc_driver
joshtriplett Oct 16, 2022
d60ba29
Use IsTerminal in rustc_log
joshtriplett Oct 16, 2022
e3d44dd
Use IsTerminal in librustdoc
joshtriplett Oct 16, 2022
7c60236
Fix build of thumbv7a-pc-windows-msvc
arlosi Nov 4, 2022
654a4e8
check if current stage is target build stage r=ozkanonur
onur-ozkan Nov 12, 2022
80d5359
normalize source paths from sysroot in compiletest
pietroalbini Nov 4, 2022
470423c
normalize download-rustc's prefix when running compiletests
pietroalbini Nov 16, 2022
867582e
detect () to avoid redundant <> suggestion for type
Nov 16, 2022
b8a5b02
Don't focus on notable trait parent when hiding it
GuillaumeGomez Nov 18, 2022
d49c10a
Make "long type" printing type aware
estebank Nov 16, 2022
787e633
On overflow errors, do not print out long types
estebank Nov 17, 2022
4ed1376
On E0275 do not print out the full type in the msg
estebank Nov 17, 2022
3debf50
Only use `...` instead of `_` for type elision
estebank Nov 17, 2022
bcb2655
review comment
estebank Nov 17, 2022
35f8962
Update cargo
weihanglo Nov 18, 2022
59c856c
Fix invalid focus when blurring notable traits popover
GuillaumeGomez Nov 18, 2022
c4165f3
drive-by: Add is_async fn to hir::IsAsync
compiler-errors Nov 19, 2022
9a9d0f4
Improve spans for RPITIT object-safety errors
compiler-errors Nov 19, 2022
87f81b0
Extend GUI test to check notable traits blur behaviour
GuillaumeGomez Nov 18, 2022
5ed8dca
Update browser-ui-test version to 0.13.2
GuillaumeGomez Nov 18, 2022
afab05b
Migrate top buttons style to CSS variables
GuillaumeGomez Nov 19, 2022
52cc0d5
Rollup merge of #103117 - joshtriplett:use-is-terminal, r=eholk
matthiaskrgr Nov 19, 2022
4451e28
Rollup merge of #103969 - ferrocene:pa-download-rustc-ui-tests, r=jyn514
matthiaskrgr Nov 19, 2022
747f29f
Rollup merge of #103989 - arlosi:arm32-panic, r=Amanieu
matthiaskrgr Nov 19, 2022
d6298d3
Rollup merge of #104076 - ozkanonur:fix-ci-rustc-sysroot, r=jyn514
matthiaskrgr Nov 19, 2022
06707c0
Rollup merge of #104469 - estebank:long-types, r=oli-obk
matthiaskrgr Nov 19, 2022
e86f184
Rollup merge of #104497 - lyming2007:issue-104379-fix, r=fee1-dead
matthiaskrgr Nov 19, 2022
e2dcc28
Rollup merge of #104577 - GuillaumeGomez:remove-focus-on-blur, r=notr…
matthiaskrgr Nov 19, 2022
c916a8d
Rollup merge of #104587 - weihanglo:update-cargo, r=weihanglo
matthiaskrgr Nov 19, 2022
c571b2a
Rollup merge of #104593 - compiler-errors:rpitit-object-safety-spans,…
matthiaskrgr Nov 19, 2022
f69f4cb
Rollup merge of #104604 - GuillaumeGomez:migrate-top-button-to-css-va…
matthiaskrgr Nov 19, 2022
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
21 changes: 14 additions & 7 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ dependencies = [
"glob",
"hex 0.4.2",
"home",
"http-auth",
"humantime 2.0.1",
"ignore",
"im-rc",
Expand Down Expand Up @@ -349,11 +350,11 @@ dependencies = [

[[package]]
name = "cargo-credential"
version = "0.1.0"
version = "0.2.0"

[[package]]
name = "cargo-credential-1password"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"cargo-credential",
"serde",
Expand All @@ -362,15 +363,15 @@ dependencies = [

[[package]]
name = "cargo-credential-macos-keychain"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"cargo-credential",
"security-framework",
]

[[package]]
name = "cargo-credential-wincred"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"cargo-credential",
"winapi",
Expand Down Expand Up @@ -1692,6 +1693,15 @@ dependencies = [
"syn",
]

[[package]]
name = "http-auth"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0b40b39d66c28829a0cf4d09f7e139ff8201f7500a5083732848ed3b4b4d850"
dependencies = [
"memchr",
]

[[package]]
name = "humantime"
version = "1.3.0"
Expand Down Expand Up @@ -3535,7 +3545,6 @@ name = "rustc_errors"
version = "0.0.0"
dependencies = [
"annotate-snippets",
"atty",
"rustc_ast",
"rustc_ast_pretty",
"rustc_data_structures",
Expand Down Expand Up @@ -3834,7 +3843,6 @@ dependencies = [
name = "rustc_log"
version = "0.0.0"
dependencies = [
"atty",
"rustc_span",
"tracing",
"tracing-subscriber",
Expand Down Expand Up @@ -4389,7 +4397,6 @@ version = "0.0.0"
dependencies = [
"arrayvec",
"askama",
"atty",
"expect-test",
"itertools",
"minifier",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<'mir, 'tcx> ConstCx<'mir, 'tcx> {
}

fn is_async(&self) -> bool {
self.tcx.asyncness(self.def_id()) == hir::IsAsync::Async
self.tcx.asyncness(self.def_id()).is_async()
}
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//! This API is completely unstable and subject to change.

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(is_terminal)]
#![feature(once_cell)]
#![feature(decl_macro)]
#![recursion_limit = "256"]
Expand All @@ -27,7 +28,6 @@ use rustc_feature::find_gated_cfg;
use rustc_interface::util::{self, collect_crate_types, get_codegen_backend};
use rustc_interface::{interface, Queries};
use rustc_lint::LintStore;
use rustc_log::stdout_isatty;
use rustc_metadata::locator;
use rustc_save_analysis as save;
use rustc_save_analysis::DumpHandler;
Expand All @@ -48,7 +48,7 @@ use std::default::Default;
use std::env;
use std::ffi::OsString;
use std::fs;
use std::io::{self, Read, Write};
use std::io::{self, IsTerminal, Read, Write};
use std::panic::{self, catch_unwind};
use std::path::PathBuf;
use std::process::{self, Command, Stdio};
Expand Down Expand Up @@ -515,7 +515,7 @@ fn handle_explain(registry: Registry, code: &str, output: ErrorOutputType) {
}
text.push('\n');
}
if stdout_isatty() {
if io::stdout().is_terminal() {
show_content_with_pager(&text);
} else {
print!("{}", text);
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ rustc_target = { path = "../rustc_target" }
rustc_hir = { path = "../rustc_hir" }
rustc_lint_defs = { path = "../rustc_lint_defs" }
unicode-width = "0.1.4"
atty = "0.2"
termcolor = "1.0"
annotate-snippets = "0.9"
termize = "0.1.1"
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use rustc_error_messages::FluentArgs;
use rustc_span::hygiene::{ExpnKind, MacroKind};
use std::borrow::Cow;
use std::cmp::{max, min, Reverse};
use std::io;
use std::io::prelude::*;
use std::io::{self, IsTerminal};
use std::iter;
use std::path::Path;
use termcolor::{Ansi, BufferWriter, ColorChoice, ColorSpec, StandardStream};
Expand Down Expand Up @@ -619,14 +619,14 @@ impl ColorConfig {
fn to_color_choice(self) -> ColorChoice {
match self {
ColorConfig::Always => {
if atty::is(atty::Stream::Stderr) {
if io::stderr().is_terminal() {
ColorChoice::Always
} else {
ColorChoice::AlwaysAnsi
}
}
ColorConfig::Never => ColorChoice::Never,
ColorConfig::Auto if atty::is(atty::Stream::Stderr) => ColorChoice::Auto,
ColorConfig::Auto if io::stderr().is_terminal() => ColorChoice::Auto,
ColorConfig::Auto => ColorChoice::Never,
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(drain_filter)]
#![feature(if_let_guard)]
#![feature(is_terminal)]
#![feature(adt_const_params)]
#![feature(let_chains)]
#![feature(never_type)]
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2720,6 +2720,12 @@ pub enum IsAsync {
NotAsync,
}

impl IsAsync {
pub fn is_async(self) -> bool {
self == IsAsync::Async
}
}

#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Encodable, Decodable, HashStable_Generic)]
pub enum Defaultness {
Default { has_value: bool },
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_hir_analysis/src/check/compare_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,7 @@ fn report_trait_method_mismatch<'tcx>(
// Suggestion to change output type. We do not suggest in `async` functions
// to avoid complex logic or incorrect output.
match tcx.hir().expect_impl_item(impl_m.def_id.expect_local()).kind {
ImplItemKind::Fn(ref sig, _)
if sig.header.asyncness == hir::IsAsync::NotAsync =>
{
ImplItemKind::Fn(ref sig, _) if !sig.header.asyncness.is_async() => {
let msg = "change the output type to match the trait";
let ap = Applicability::MachineApplicable;
match sig.decl.output {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1918,12 +1918,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
| ty::Str
| ty::Projection(_)
| ty::Param(_) => format!("{deref_ty}"),
// we need to test something like <&[_]>::len
// we need to test something like <&[_]>::len or <(&[u32])>::len
// and Vec::function();
// <&[_]>::len doesn't need an extra "<>" between
// <&[_]>::len or <&[u32]>::len doesn't need an extra "<>" between
// but for Adt type like Vec::function()
// we would suggest <[_]>::function();
_ if self.tcx.sess.source_map().span_wrapped_by_angle_bracket(ty.span) => format!("{deref_ty}"),
_ if self.tcx.sess.source_map().span_wrapped_by_angle_or_parentheses(ty.span) => format!("{deref_ty}"),
_ => format!("<{deref_ty}>"),
};
err.span_suggestion_verbose(
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ version = "0.0.0"
edition = "2021"

[dependencies]
atty = "0.2"
tracing = "0.1.28"
tracing-subscriber = { version = "0.3.3", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
tracing-tree = "0.2.0"
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@

#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
#![feature(is_terminal)]

use std::env::{self, VarError};
use std::fmt::{self, Display};
use std::io;
use std::io::{self, IsTerminal};
use tracing_subscriber::filter::{Directive, EnvFilter, LevelFilter};
use tracing_subscriber::layer::SubscriberExt;

Expand Down Expand Up @@ -93,11 +94,11 @@ pub fn init_env_logger(env: &str) -> Result<(), Error> {
}

pub fn stdout_isatty() -> bool {
atty::is(atty::Stream::Stdout)
io::stdout().is_terminal()
}

pub fn stderr_isatty() -> bool {
atty::is(atty::Stream::Stderr)
io::stderr().is_terminal()
}

#[derive(Debug)]
Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_middle/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,10 +924,13 @@ impl ObjectSafetyViolation {
}
ObjectSafetyViolation::Method(
name,
MethodViolationCode::ReferencesImplTraitInTrait,
MethodViolationCode::ReferencesImplTraitInTrait(_),
_,
) => format!("method `{}` references an `impl Trait` type in its return type", name)
.into(),
ObjectSafetyViolation::Method(name, MethodViolationCode::AsyncFn, _) => {
format!("method `{}` is `async`", name).into()
}
ObjectSafetyViolation::Method(
name,
MethodViolationCode::WhereClauseReferencesSelf,
Expand Down Expand Up @@ -1035,7 +1038,10 @@ pub enum MethodViolationCode {
ReferencesSelfOutput,

/// e.g., `fn foo(&self) -> impl Sized`
ReferencesImplTraitInTrait,
ReferencesImplTraitInTrait(Span),

/// e.g., `async fn foo(&self)`
AsyncFn,

/// e.g., `fn foo(&self) where Self: Clone`
WhereClauseReferencesSelf,
Expand Down
37 changes: 37 additions & 0 deletions compiler/rustc_middle/src/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ use rustc_span::{BytePos, Span};
use rustc_target::spec::abi;

use std::borrow::Cow;
use std::collections::hash_map::DefaultHasher;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::path::PathBuf;

use super::print::PrettyPrinter;

#[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable, TypeVisitable, Lift)]
pub struct ExpectedFound<T> {
Expand Down Expand Up @@ -985,6 +990,38 @@ fn foo(&self) -> Self::T { String::new() }
false
}

pub fn short_ty_string(self, ty: Ty<'tcx>) -> (String, Option<PathBuf>) {
let length_limit = 50;
let type_limit = 4;
let regular = FmtPrinter::new(self, hir::def::Namespace::TypeNS)
.pretty_print_type(ty)
.expect("could not write to `String`")
.into_buffer();
if regular.len() <= length_limit {
return (regular, None);
}
let short = FmtPrinter::new_with_limit(
self,
hir::def::Namespace::TypeNS,
rustc_session::Limit(type_limit),
)
.pretty_print_type(ty)
.expect("could not write to `String`")
.into_buffer();
if regular == short {
return (regular, None);
}
// Multiple types might be shortened in a single error, ensure we create a file for each.
let mut s = DefaultHasher::new();
ty.hash(&mut s);
let hash = s.finish();
let path = self.output_filenames(()).temp_path_ext(&format!("long-type-{hash}.txt"), None);
match std::fs::write(&path, &regular) {
Ok(_) => (short, Some(path)),
Err(_) => (regular, None),
}
}

fn format_generic_args(self, args: &[ty::GenericArg<'tcx>]) -> String {
FmtPrinter::new(self, hir::def::Namespace::TypeNS)
.path_generic_args(Ok, args)
Expand Down
57 changes: 37 additions & 20 deletions compiler/rustc_middle/src/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,28 +276,45 @@ impl<'tcx> InstanceDef<'tcx> {
}
}

impl<'tcx> fmt::Display for Instance<'tcx> {
fn fmt_instance(
f: &mut fmt::Formatter<'_>,
instance: &Instance<'_>,
type_length: rustc_session::Limit,
) -> fmt::Result {
ty::tls::with(|tcx| {
let substs = tcx.lift(instance.substs).expect("could not lift for printing");

let s = FmtPrinter::new_with_limit(tcx, Namespace::ValueNS, type_length)
.print_def_path(instance.def_id(), substs)?
.into_buffer();
f.write_str(&s)
})?;

match instance.def {
InstanceDef::Item(_) => Ok(()),
InstanceDef::VTableShim(_) => write!(f, " - shim(vtable)"),
InstanceDef::ReifyShim(_) => write!(f, " - shim(reify)"),
InstanceDef::Intrinsic(_) => write!(f, " - intrinsic"),
InstanceDef::Virtual(_, num) => write!(f, " - virtual#{}", num),
InstanceDef::FnPtrShim(_, ty) => write!(f, " - shim({})", ty),
InstanceDef::ClosureOnceShim { .. } => write!(f, " - shim"),
InstanceDef::DropGlue(_, None) => write!(f, " - shim(None)"),
InstanceDef::DropGlue(_, Some(ty)) => write!(f, " - shim(Some({}))", ty),
InstanceDef::CloneShim(_, ty) => write!(f, " - shim({})", ty),
}
}

pub struct ShortInstance<'a, 'tcx>(pub &'a Instance<'tcx>, pub usize);

impl<'a, 'tcx> fmt::Display for ShortInstance<'a, 'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
ty::tls::with(|tcx| {
let substs = tcx.lift(self.substs).expect("could not lift for printing");
let s = FmtPrinter::new(tcx, Namespace::ValueNS)
.print_def_path(self.def_id(), substs)?
.into_buffer();
f.write_str(&s)
})?;
fmt_instance(f, self.0, rustc_session::Limit(self.1))
}
}

match self.def {
InstanceDef::Item(_) => Ok(()),
InstanceDef::VTableShim(_) => write!(f, " - shim(vtable)"),
InstanceDef::ReifyShim(_) => write!(f, " - shim(reify)"),
InstanceDef::Intrinsic(_) => write!(f, " - intrinsic"),
InstanceDef::Virtual(_, num) => write!(f, " - virtual#{}", num),
InstanceDef::FnPtrShim(_, ty) => write!(f, " - shim({})", ty),
InstanceDef::ClosureOnceShim { .. } => write!(f, " - shim"),
InstanceDef::DropGlue(_, None) => write!(f, " - shim(None)"),
InstanceDef::DropGlue(_, Some(ty)) => write!(f, " - shim(Some({}))", ty),
InstanceDef::CloneShim(_, ty) => write!(f, " - shim({})", ty),
}
impl<'tcx> fmt::Display for Instance<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
ty::tls::with(|tcx| fmt_instance(f, self, tcx.type_length_limit()))
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub use self::context::{
GeneratorInteriorTypeCause, GlobalCtxt, Lift, OnDiskCache, TyCtxt, TypeckResults, UserType,
UserTypeAnnotationIndex,
};
pub use self::instance::{Instance, InstanceDef};
pub use self::instance::{Instance, InstanceDef, ShortInstance};
pub use self::list::List;
pub use self::parameterized::ParameterizedOverTcx;
pub use self::rvalue_scopes::RvalueScopes;
Expand Down
Loading