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 8 pull requests #126345

Merged
merged 25 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
87ad80a
Add `target_env = "p1"` to the `wasm32-wasip1` target
alexcrichton Jun 1, 2024
5ecb034
Update test expectations
alexcrichton Jun 1, 2024
d313e7e
Fix testing examples in documentation
alexcrichton Jun 2, 2024
f88c647
rewrite `short-ice` in `rmake` format
Oneirical Jun 5, 2024
bbc5037
ensure the self-contained linker is only enabled on nightly/dev
lqd Jun 11, 2024
8a6bc13
Add set_backtrace_level helper function to run_make_support
Oneirical Jun 9, 2024
185a48d
Bump tracing-tree and allow rendering lines again
oli-obk Jun 11, 2024
3da9289
Avoid a bunch of booleans in favor of `Result<(), ErrorGuaranteed>` a…
oli-obk Jun 11, 2024
be464b8
Upgrade a span_delayed_bug into a span_bug, as we have no tests hitti…
oli-obk Jun 12, 2024
4a06a5b
Adjust LoongArch64 data layouts for LLVM update
zmodem Jun 12, 2024
4d72c42
Eagerly emit the diagnostic instead of leaving it to all callers
oli-obk Jun 12, 2024
9065889
Rename some functions
oli-obk Jun 12, 2024
6299071
Avoid a Ty::new_misc_error when an ErrorGuaranteed is available
oli-obk Jun 12, 2024
af10661
Detect pub structs never constructed even though they impl pub trait …
mu001999 Jun 12, 2024
39c3b86
Add a `ignore-tidy-todo` to ignore the tidy TODO comment check
tbu- Jun 11, 2024
4f5fb31
Add TODO comment to unsafe env modification
tbu- Jun 5, 2024
54429cf
Fix outdated predacates_of.rs comments
fee1-dead Jun 12, 2024
7133257
Rollup merge of #125869 - alexcrichton:add-p1-to-wasi-targets, r=wesl…
compiler-errors Jun 12, 2024
88984fe
Rollup merge of #126019 - tbu-:pr_unsafe_env_fixme, r=fee1-dead
compiler-errors Jun 12, 2024
d25227c
Rollup merge of #126036 - Oneirical:the-intelligent-intestor, r=jieyouxu
compiler-errors Jun 12, 2024
3065010
Rollup merge of #126276 - mu001999-contrib:dead/enhance, r=fee1-dead
compiler-errors Jun 12, 2024
49b28a4
Rollup merge of #126282 - lqd:contain-the-self-contained-linker, r=Ma…
compiler-errors Jun 12, 2024
7276f34
Rollup merge of #126317 - oli-obk:recursive_rpit4, r=compiler-errors
compiler-errors Jun 12, 2024
754b26d
Rollup merge of #126324 - zmodem:loongarch, r=nikic
compiler-errors Jun 12, 2024
0d1d6ba
Rollup merge of #126340 - fee1-dead-contrib:fix-predicates_of-comment…
compiler-errors Jun 12, 2024
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
8 changes: 8 additions & 0 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ pub unsafe fn create_module<'ll>(
}
}

if llvm_version < (19, 0, 0) {
if sess.target.arch == "loongarch64" {
// LLVM 19 updates the LoongArch64 data layout.
// See https://github.com/llvm/llvm-project/pull/93814
target_data_layout = target_data_layout.replace("-n32:64", "-n64");
}
}

// Ensure the data-layout values hardcoded remain the defaults.
{
let tm = crate::back::write::create_informational_target_machine(tcx.sess);
Expand Down
9 changes: 4 additions & 5 deletions compiler/rustc_hir_analysis/src/collect/predicates_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,11 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
predicates.insert((trait_ref.upcast(tcx), tcx.def_span(def_id)));
}

// Collect the predicates that were written inline by the user on each
// type parameter (e.g., `<T: Foo>`). Also add `ConstArgHasType` predicates
// for each const parameter.
// Add implicit predicates that should be treated as if the user has written them,
// including the implicit `T: Sized` for all generic parameters, and `ConstArgHasType`
// for const params.
for param in hir_generics.params {
match param.kind {
// We already dealt with early bound lifetimes above.
GenericParamKind::Lifetime { .. } => (),
GenericParamKind::Type { .. } => {
let param_ty = icx.lowerer().lower_ty_param(param.hir_id);
Expand Down Expand Up @@ -204,7 +203,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
}

trace!(?predicates);
// Add in the bounds that appear in the where-clause.
// Add inline `<T: Foo>` bounds and bounds in the where clause.
for predicate in hir_generics.predicates {
match predicate {
hir::WherePredicate::BoundPredicate(bound_pred) => {
Expand Down
11 changes: 4 additions & 7 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1342,14 +1342,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Ok(method)
}
Err(error) => {
if segment.ident.name != kw::Empty {
if let Some(err) =
self.report_method_error(expr.hir_id, rcvr_t, error, expected, false)
{
err.emit();
}
if segment.ident.name == kw::Empty {
span_bug!(rcvr.span, "empty method name")
} else {
Err(self.report_method_error(expr.hir_id, rcvr_t, error, expected, false))
}
Err(())
}
};

Expand Down
10 changes: 4 additions & 6 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
})
}

pub(crate) fn err_args(&self, len: usize) -> Vec<Ty<'tcx>> {
let ty_error = Ty::new_misc_error(self.tcx);
pub(crate) fn err_args(&self, len: usize, guar: ErrorGuaranteed) -> Vec<Ty<'tcx>> {
let ty_error = Ty::new_error(self.tcx, guar);
vec![ty_error; len]
}

Expand Down Expand Up @@ -846,15 +846,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

if item_name.name != kw::Empty {
if let Some(e) = self.report_method_error(
self.report_method_error(
hir_id,
ty.normalized,
error,
Expectation::NoExpectation,
trait_missing_method && span.edition().at_least_rust_2021(), // emits missing method for trait only after edition 2021
) {
e.emit();
}
);
}

result
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self,
sp: Span,
expr: &'tcx hir::Expr<'tcx>,
method: Result<MethodCallee<'tcx>, ()>,
method: Result<MethodCallee<'tcx>, ErrorGuaranteed>,
args_no_rcvr: &'tcx [hir::Expr<'tcx>],
tuple_arguments: TupleArgumentsFlag,
expected: Expectation<'tcx>,
) -> Ty<'tcx> {
let has_error = match method {
Ok(method) => method.args.references_error() || method.sig.references_error(),
Err(_) => true,
Ok(method) => method.args.error_reported().and(method.sig.error_reported()),
Err(guar) => Err(guar),
};
if has_error {
let err_inputs = self.err_args(args_no_rcvr.len());
if let Err(guar) = has_error {
let err_inputs = self.err_args(args_no_rcvr.len(), guar);

let err_inputs = match tuple_arguments {
DontTupleArguments => err_inputs,
Expand All @@ -140,7 +140,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
tuple_arguments,
method.ok().map(|method| method.def_id),
);
return Ty::new_misc_error(self.tcx);
return Ty::new_error(self.tcx, guar);
}

let method = method.unwrap();
Expand Down Expand Up @@ -237,15 +237,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => {
// Otherwise, there's a mismatch, so clear out what we're expecting, and set
// our input types to err_args so we don't blow up the error messages
struct_span_code_err!(
let guar = struct_span_code_err!(
tcx.dcx(),
call_span,
E0059,
"cannot use call notation; the first type parameter \
for the function trait is neither a tuple nor unit"
)
.emit();
(self.err_args(provided_args.len()), None)
(self.err_args(provided_args.len(), guar), None)
}
}
} else {
Expand Down
52 changes: 26 additions & 26 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use rustc_middle::ty::IsSuggestable;
use rustc_middle::ty::{self, GenericArgKind, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::def_id::DefIdSet;
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::{edit_distance, ExpnKind, FileName, MacroKind, Span};
use rustc_span::{edit_distance, ErrorGuaranteed, ExpnKind, FileName, MacroKind, Span};
use rustc_span::{Symbol, DUMMY_SP};
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::error_reporting::on_unimplemented::OnUnimplementedNote;
Expand Down Expand Up @@ -192,7 +192,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
error: MethodError<'tcx>,
expected: Expectation<'tcx>,
trait_missing_method: bool,
) -> Option<Diag<'_>> {
) -> ErrorGuaranteed {
let (span, sugg_span, source, item_name, args) = match self.tcx.hir_node(call_id) {
hir::Node::Expr(&hir::Expr {
kind: hir::ExprKind::MethodCall(segment, rcvr, args, _),
Expand Down Expand Up @@ -226,8 +226,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};

// Avoid suggestions when we don't know what's going on.
if rcvr_ty.references_error() {
return None;
if let Err(guar) = rcvr_ty.error_reported() {
return guar;
}

match error {
Expand Down Expand Up @@ -265,7 +265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&mut sources,
Some(sugg_span),
);
err.emit();
return err.emit();
}

MethodError::PrivateMatch(kind, def_id, out_of_scope_traits) => {
Expand All @@ -286,7 +286,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.unwrap_or_else(|| self.tcx.def_span(def_id));
err.span_label(sp, format!("private {kind} defined here"));
self.suggest_valid_traits(&mut err, item_name, out_of_scope_traits, true);
err.emit();
return err.emit();
}

MethodError::IllegalSizedBound { candidates, needs_mut, bound_span, self_expr } => {
Expand Down Expand Up @@ -343,12 +343,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
}
err.emit();
return err.emit();
}

MethodError::BadReturnType => bug!("no return type expectations but got BadReturnType"),
}
None
}

fn suggest_missing_writer(&self, rcvr_ty: Ty<'tcx>, rcvr_expr: &hir::Expr<'tcx>) -> Diag<'_> {
Expand Down Expand Up @@ -564,7 +563,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

pub fn report_no_match_method_error(
fn report_no_match_method_error(
&self,
mut span: Span,
rcvr_ty: Ty<'tcx>,
Expand All @@ -576,7 +575,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
no_match_data: &mut NoMatchData<'tcx>,
expected: Expectation<'tcx>,
trait_missing_method: bool,
) -> Option<Diag<'_>> {
) -> ErrorGuaranteed {
let mode = no_match_data.mode;
let tcx = self.tcx;
let rcvr_ty = self.resolve_vars_if_possible(rcvr_ty);
Expand Down Expand Up @@ -608,14 +607,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

// We could pass the file for long types into these two, but it isn't strictly necessary
// given how targeted they are.
if self.suggest_wrapping_range_with_parens(
if let Err(guar) = self.report_failed_method_call_on_range_end(
tcx,
rcvr_ty,
source,
span,
item_name,
&short_ty_str,
) || self.suggest_constraining_numerical_ty(
) {
return guar;
}
if let Err(guar) = self.report_failed_method_call_on_numerical_infer_var(
tcx,
rcvr_ty,
source,
Expand All @@ -624,7 +626,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
item_name,
&short_ty_str,
) {
return None;
return guar;
}
span = item_name.span;

Expand Down Expand Up @@ -881,7 +883,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
vec![(span.shrink_to_lo(), format!("into_iter()."))],
Applicability::MaybeIncorrect,
);
return Some(err);
return err.emit();
} else if !unsatisfied_predicates.is_empty() && matches!(rcvr_ty.kind(), ty::Param(_)) {
// We special case the situation where we are looking for `_` in
// `<TypeParam as _>::method` because otherwise the machinery will look for blanket
Expand Down Expand Up @@ -1606,7 +1608,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

self.note_derefed_ty_has_method(&mut err, source, rcvr_ty, item_name, expected);
Some(err)
err.emit()
}

/// If an appropriate error source is not found, check method chain for possible candidates
Expand Down Expand Up @@ -2251,15 +2253,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

/// Suggest possible range with adding parentheses, for example:
/// when encountering `0..1.map(|i| i + 1)` suggest `(0..1).map(|i| i + 1)`.
fn suggest_wrapping_range_with_parens(
fn report_failed_method_call_on_range_end(
&self,
tcx: TyCtxt<'tcx>,
actual: Ty<'tcx>,
source: SelfSource<'tcx>,
span: Span,
item_name: Ident,
ty_str: &str,
) -> bool {
) -> Result<(), ErrorGuaranteed> {
if let SelfSource::MethodCall(expr) = source {
for (_, parent) in tcx.hir().parent_iter(expr.hir_id).take(5) {
if let Node::Expr(parent_expr) = parent {
Expand Down Expand Up @@ -2316,7 +2318,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
if pick.is_ok() {
let range_span = parent_expr.span.with_hi(expr.span.hi());
tcx.dcx().emit_err(errors::MissingParenthesesInRange {
return Err(tcx.dcx().emit_err(errors::MissingParenthesesInRange {
span,
ty_str: ty_str.to_string(),
method_name: item_name.as_str().to_string(),
Expand All @@ -2325,16 +2327,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
left: range_span.shrink_to_lo(),
right: range_span.shrink_to_hi(),
}),
});
return true;
}));
}
}
}
}
false
Ok(())
}

fn suggest_constraining_numerical_ty(
fn report_failed_method_call_on_numerical_infer_var(
&self,
tcx: TyCtxt<'tcx>,
actual: Ty<'tcx>,
Expand All @@ -2343,7 +2344,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
item_kind: &str,
item_name: Ident,
ty_str: &str,
) -> bool {
) -> Result<(), ErrorGuaranteed> {
let found_candidate = all_traits(self.tcx)
.into_iter()
.any(|info| self.associated_value(info.def_id, item_name).is_some());
Expand Down Expand Up @@ -2447,10 +2448,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
_ => {}
}
err.emit();
return true;
return Err(err.emit());
}
false
Ok(())
}

/// For code `rect::area(...)`,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
tracing = "0.1.28"
tracing-core = "=0.1.30" # FIXME(Nilstrieb) tracing has a deadlock: https://github.com/tokio-rs/tracing/issues/2635
tracing-subscriber = { version = "0.3.3", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
tracing-tree = "0.3.0"
tracing-tree = "0.3.1"
# tidy-alphabetical-end

[dev-dependencies]
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct LoggerConfig {
pub verbose_thread_ids: Result<String, VarError>,
pub backtrace: Result<String, VarError>,
pub wraptree: Result<String, VarError>,
pub lines: Result<String, VarError>,
}

impl LoggerConfig {
Expand All @@ -69,6 +70,7 @@ impl LoggerConfig {
verbose_thread_ids: env::var(format!("{env}_THREAD_IDS")),
backtrace: env::var(format!("{env}_BACKTRACE")),
wraptree: env::var(format!("{env}_WRAPTREE")),
lines: env::var(format!("{env}_LINES")),
}
}
}
Expand Down Expand Up @@ -101,13 +103,19 @@ pub fn init_logger(cfg: LoggerConfig) -> Result<(), Error> {
Err(_) => false,
};

let lines = match cfg.lines {
Ok(v) => &v == "1",
Err(_) => false,
};

let mut layer = tracing_tree::HierarchicalLayer::default()
.with_writer(io::stderr)
.with_ansi(color_logs)
.with_targets(true)
.with_verbose_exit(verbose_entry_exit)
.with_verbose_entry(verbose_entry_exit)
.with_indent_amount(2)
.with_indent_lines(lines)
.with_thread_ids(verbose_thread_ids)
.with_thread_names(verbose_thread_ids);

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_mir_build/src/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
if !span.at_least_rust_2024()
&& self.tcx.has_attr(id, sym::rustc_deprecated_safe_2024) =>
{
let sm = self.tcx.sess.source_map();
self.tcx.emit_node_span_lint(
DEPRECATED_SAFE,
self.hir_context,
Expand All @@ -105,6 +106,8 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
span,
function: with_no_trimmed_paths!(self.tcx.def_path_str(id)),
sub: CallToDeprecatedSafeFnRequiresUnsafeSub {
indent: sm.indentation_before(span).unwrap_or_default(),
start_of_line: sm.span_extend_to_line(span).shrink_to_lo(),
left: span.shrink_to_lo(),
right: span.shrink_to_hi(),
},
Expand Down
Loading
Loading