Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ce6adcc
Prevent stable `libtest` from supporting `-Zunstable-options`
thomcc Mar 12, 2023
9afffc5
Remove box expressions from HIR
clubby789 Mar 14, 2023
fb916a0
Fix riscv64 fuchsia LLVM target name
taiki-e Mar 15, 2023
86a5e36
Fix linker detection for clang with prefix
taiki-e Mar 15, 2023
26c4c1e
Rename impl_trait_in_trait_parent to impl_trait_in_trait_parent_fn
spastorino Mar 10, 2023
39ffe96
Properly implement generics_of for traits
spastorino Mar 14, 2023
39d19ca
Make impl_trait_in_trait_container consider newly generated RPITITs
spastorino Mar 13, 2023
d9ac2be
Handle proc-macro spans pointing at attribute in suggestions
estebank Mar 10, 2023
00a2616
Fix range_minus_one and range_plus_one clippy lints
estebank Mar 14, 2023
f219ab5
Tweak E0412 label for proc-macros
estebank Mar 14, 2023
d692d37
Do not suggest binding from outside of a macro in macro
estebank Mar 14, 2023
b54ba21
Avoid incorrect argument suggestions in macros
estebank Mar 15, 2023
8a47602
Tweak `alloc_error_handler` desugaring
estebank Mar 15, 2023
d7c0bcd
Rename and document span marking method
estebank Mar 15, 2023
0172d15
Fix #90557
estebank Mar 15, 2023
019556d
Small cleanup
estebank Mar 15, 2023
0b9b7dd
inherit_overflow: adapt pattern to also work with v0 mangling
durin42 Mar 15, 2023
e41491f
ImplTraitPlaceholder -> is_impl_trait_in_trait
spastorino Mar 14, 2023
11f1810
Feed is_type_alias_impl_trait for RPITITs on the trait side
spastorino Mar 13, 2023
c5c4340
Add revisions to fixed tests in -Zlower-impl-trait-in-trait-to-assoc-ty
spastorino Mar 14, 2023
738ea1b
Change text -> rust highlighting in sanitizer.md
tgross35 Mar 10, 2023
0949da8
Install projection from RPITIT to default trait method opaque correctly
compiler-errors Mar 15, 2023
ff7c3b8
Don't install default opaque projection predicates in RPITIT associat…
compiler-errors Mar 16, 2023
8d922eb
Fix on_unimplemented_note for RPITITs
compiler-errors Mar 16, 2023
a8839c3
Use sort_by_key instead of sort_by
est31 Mar 16, 2023
11a80a0
Rollup merge of #108958 - clubby789:unbox-the-hir, r=compiler-errors
matthiaskrgr Mar 16, 2023
e505cdc
Rollup merge of #108997 - tgross35:patch-1, r=JohnTitor
matthiaskrgr Mar 16, 2023
3182334
Rollup merge of #109044 - thomcc:disallow-unstable-libtest, r=jyn514
matthiaskrgr Mar 16, 2023
1d17b6a
Rollup merge of #109082 - estebank:macro-spans, r=oli-obk
matthiaskrgr Mar 16, 2023
0148cc4
Rollup merge of #109155 - taiki-e:riscv64-fuchsia-fix-llvm-target, r=…
matthiaskrgr Mar 16, 2023
4612076
Rollup merge of #109156 - taiki-e:linker-detection, r=petrochenkov
matthiaskrgr Mar 16, 2023
4f4a3f0
Rollup merge of #109181 - durin42:v0-mangle-inherit_overflow, r=Nilst…
matthiaskrgr Mar 16, 2023
e9f4cae
Rollup merge of #109198 - compiler-errors:new-rpitit-default-body, r=…
matthiaskrgr Mar 16, 2023
686e832
Rollup merge of #109215 - est31:sort_by_key, r=Nilstrieb
matthiaskrgr Mar 16, 2023
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
Prev Previous commit
Next Next commit
Rename and document span marking method
  • Loading branch information
estebank committed Mar 15, 2023
commit d7c0bcd197536598fa5e469f8308de16dfd28f13
6 changes: 4 additions & 2 deletions compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
segment_ident_span.find_ancestor_inside(path_span).unwrap_or(path_span)
} else if generic_args.is_empty() {
// If there are brackets, but not generic arguments, then use the opening bracket
self.tcx.adjust_span(generic_args.span).with_hi(generic_args.span.lo() + BytePos(1))
self.tcx
.mark_span_for_resize(generic_args.span)
.with_hi(generic_args.span.lo() + BytePos(1))
} else {
// Else use an empty span right after the opening bracket.
self.tcx
.adjust_span(generic_args.span)
.mark_span_for_resize(generic_args.span)
.with_lo(generic_args.span.lo() + BytePos(1))
.shrink_to_lo()
};
Expand Down
12 changes: 9 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2073,12 +2073,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
Ok(string) => {
if string.starts_with("async ") {
let pos = args_span.lo() + BytePos(6);
(self.infcx.tcx.adjust_span(args_span).with_lo(pos).with_hi(pos), "move ")
(
self.infcx.tcx.mark_span_for_resize(args_span).with_lo(pos).with_hi(pos),
"move ",
)
} else if string.starts_with("async|") {
let pos = args_span.lo() + BytePos(5);
(self.infcx.tcx.adjust_span(args_span).with_lo(pos).with_hi(pos), " move")
(
self.infcx.tcx.mark_span_for_resize(args_span).with_lo(pos).with_hi(pos),
" move",
)
} else {
(self.infcx.tcx.adjust_span(args_span).shrink_to_lo(), "move ")
(self.infcx.tcx.mark_span_for_resize(args_span).shrink_to_lo(), "move ")
}
}
Err(_) => (args_span, "move |<args>| <body>"),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/move_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,15 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
match self.infcx.tcx.sess.source_map().span_to_snippet(span) {
Ok(snippet) if snippet.starts_with('*') => {
err.span_suggestion_verbose(
self.infcx.tcx.adjust_span(span).with_hi(span.lo() + BytePos(1)),
self.infcx.tcx.mark_span_for_resize(span).with_hi(span.lo() + BytePos(1)),
"consider removing the dereference here",
String::new(),
Applicability::MaybeIncorrect,
);
}
_ => {
err.span_suggestion_verbose(
self.infcx.tcx.adjust_span(span).shrink_to_lo(),
self.infcx.tcx.mark_span_for_resize(span).shrink_to_lo(),
"consider borrowing here",
'&',
Applicability::MaybeIncorrect,
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_const_eval/src/transform/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,15 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
{
let rhs_pos =
span.lo() + BytePos::from_usize(eq_idx + 2 + rhs_idx);
let rhs_span =
tcx.adjust_span(span).with_lo(rhs_pos).with_hi(rhs_pos);
let rhs_span = tcx
.mark_span_for_resize(span)
.with_lo(rhs_pos)
.with_hi(rhs_pos);
err.multipart_suggestion(
"consider dereferencing here",
vec![
(
tcx.adjust_span(span).shrink_to_lo(),
tcx.mark_span_for_resize(span).shrink_to_lo(),
deref.clone(),
),
(rhs_span, deref),
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,8 @@ fn compare_number_of_method_arguments<'tcx>(
if pos == 0 {
arg.span
} else {
tcx.adjust_span(arg.span).with_lo(trait_m_sig.decl.inputs[0].span.lo())
tcx.mark_span_for_resize(arg.span)
.with_lo(trait_m_sig.decl.inputs[0].span.lo())
}
})
})
Expand All @@ -1367,7 +1368,7 @@ fn compare_number_of_method_arguments<'tcx>(
if pos == 0 {
arg.span
} else {
tcx.adjust_span(arg.span).with_lo(impl_m_sig.decl.inputs[0].span.lo())
tcx.mark_span_for_resize(arg.span).with_lo(impl_m_sig.decl.inputs[0].span.lo())
}
})
.unwrap_or_else(|| tcx.def_span(impl_m.def_id));
Expand Down Expand Up @@ -1464,8 +1465,9 @@ fn compare_synthetic_generics<'tcx>(

// in case there are no generics, take the spot between the function name
// and the opening paren of the argument list
let new_generics_span =
tcx.adjust_span(tcx.def_ident_span(impl_def_id)?).shrink_to_hi();
let new_generics_span = tcx
.mark_span_for_resize(tcx.def_ident_span(impl_def_id)?)
.shrink_to_hi();
// in case there are generics, just replace them
let generics_span =
impl_m.generics.span.substitute_dummy(new_generics_span);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ fn missing_items_err(
let hi = full_impl_span.hi() - BytePos(1);
// Point at the place right before the closing brace of the relevant `impl` to suggest
// adding the associated item at the end of its body.
let sugg_sp = tcx.adjust_span(full_impl_span).with_lo(hi).with_hi(hi);
let sugg_sp = tcx.mark_span_for_resize(full_impl_span).with_lo(hi).with_hi(hi);
// Obtain the level of indentation ending in `sugg_sp`.
let padding =
tcx.sess.source_map().indentation_before(sugg_sp).unwrap_or_else(|| String::new());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,13 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {

AngleBrackets::Available => {
let (sugg_span, is_first) = if self.num_provided_lifetime_args() == 0 {
(self.tcx.adjust_span(self.gen_args.span().unwrap()).shrink_to_lo(), true)
(
self.tcx.mark_span_for_resize(self.gen_args.span().unwrap()).shrink_to_lo(),
true,
)
} else {
let last_lt = &self.gen_args.args[self.num_provided_lifetime_args() - 1];
(self.tcx.adjust_span(last_lt.span()).shrink_to_hi(), false)
(self.tcx.mark_span_for_resize(last_lt.span()).shrink_to_hi(), false)
};
let has_non_lt_args = self.num_provided_type_or_const_args() != 0;
let has_bindings = !self.gen_args.bindings.is_empty();
Expand Down Expand Up @@ -658,14 +661,15 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
);
}
AngleBrackets::Available => {
let gen_args_span = self.tcx.adjust_span(self.gen_args.span().unwrap());
let gen_args_span = self.tcx.mark_span_for_resize(self.gen_args.span().unwrap());
let sugg_offset =
self.get_lifetime_args_offset() + self.num_provided_type_or_const_args();

let (sugg_span, is_first) = if sugg_offset == 0 {
(self.tcx.adjust_span(gen_args_span).shrink_to_lo(), true)
(self.tcx.mark_span_for_resize(gen_args_span).shrink_to_lo(), true)
} else {
let arg_span = self.tcx.adjust_span(self.gen_args.args[sugg_offset - 1].span());
let arg_span =
self.tcx.mark_span_for_resize(self.gen_args.args[sugg_offset - 1].span());
// If we came here then inferred lifetime's spans can only point
// to either the opening bracket or to the space right after.
// Both of these spans have an `hi` lower than or equal to the span
Expand Down Expand Up @@ -770,7 +774,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
let sugg = vec![
(self.path_segment.ident.span, format!("{}::{}", snippet, self.path_segment.ident)),
(self.tcx.adjust_span(span).with_lo(self.path_segment.ident.span.hi()), "".to_owned())
(self.tcx.mark_span_for_resize(span).with_lo(self.path_segment.ident.span.hi()), "".to_owned())
];

err.multipart_suggestion(
Expand Down Expand Up @@ -954,7 +958,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
} else if remove_entire_generics {
let span = self
.tcx
.adjust_span(self.path_segment.args.unwrap().span_ext().unwrap())
.mark_span_for_resize(self.path_segment.args.unwrap().span_ext().unwrap())
.with_lo(self.path_segment.ident.span.hi());

let msg = format!(
Expand Down
51 changes: 27 additions & 24 deletions compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
),
match &args[..] {
[] => (
self.tcx.adjust_span(base.span).shrink_to_hi().with_hi(deref.span.hi()),
self.tcx
.mark_span_for_resize(base.span)
.shrink_to_hi()
.with_hi(deref.span.hi()),
")".to_string(),
),
[first, ..] => (base.span.between(first.span), ", ".to_string()),
Expand Down Expand Up @@ -750,8 +753,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
"use `?` to coerce and return an appropriate `Err`, and wrap the resulting value \
in `Ok` so the expression remains of type `Result`",
vec![
(self.tcx.adjust_span(expr.span).shrink_to_lo(), "Ok(".to_string()),
(self.tcx.adjust_span(expr.span).shrink_to_hi(), "?)".to_string()),
(self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), "Ok(".to_string()),
(self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), "?)".to_string()),
],
Applicability::MaybeIncorrect,
);
Expand Down Expand Up @@ -822,20 +825,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else {
return false;
};
if let Some(indent) = self
.tcx
.sess
.source_map()
.indentation_before(self.tcx.adjust_span(span).shrink_to_lo())
{
if let Some(indent) = self.tcx.sess.source_map().indentation_before(
self.tcx.mark_span_for_resize(span).shrink_to_lo(),
) {
// Add a semicolon, except after `}`.
let semicolon =
match self.tcx.sess.source_map().span_to_snippet(span) {
Ok(s) if s.ends_with('}') => "",
_ => ";",
};
err.span_suggestions(
self.tcx.adjust_span(span).shrink_to_hi(),
self.tcx.mark_span_for_resize(span).shrink_to_hi(),
"try adding an expression at the end of the block",
return_suggestions
.into_iter()
Expand Down Expand Up @@ -914,10 +914,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

vec![
(
self.tcx.adjust_span(expr.span).shrink_to_lo(),
self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(),
format!("{prefix}{variant}{open}"),
),
(self.tcx.adjust_span(expr.span).shrink_to_hi(), close.to_owned()),
(self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), close.to_owned()),
]
};

Expand Down Expand Up @@ -1001,8 +1001,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.multipart_suggestion(
format!("consider calling `{s}::new`"),
vec![
(self.tcx.adjust_span(expr.span).shrink_to_lo(), format!("{path}::new(")),
(self.tcx.adjust_span(expr.span).shrink_to_hi(), format!("){unwrap}")),
(self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), format!("{path}::new(")),
(self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), format!("){unwrap}")),
],
Applicability::MaybeIncorrect,
);
Expand Down Expand Up @@ -1256,7 +1256,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&& replace_prefix(&src, "\"", "b\"").is_some()
{
return Some((
self.tcx.adjust_span(sp).shrink_to_lo(),
self.tcx.mark_span_for_resize(sp).shrink_to_lo(),
"consider adding a leading `b`".to_string(),
"b".to_string(),
Applicability::MachineApplicable,
Expand Down Expand Up @@ -1453,7 +1453,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ if sp == expr.span => {
if let Some(mut steps) = self.deref_steps(checked_ty, expected) {
let mut expr = expr.peel_blocks();
let mut prefix_span = self.tcx.adjust_span(expr.span).shrink_to_lo();
let mut prefix_span = self.tcx.mark_span_for_resize(expr.span).shrink_to_lo();
let mut remove = String::new();

// Try peeling off any existing `&` and `&mut` to reach our target type
Expand Down Expand Up @@ -1524,7 +1524,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return None;
} else if let Some(expr) = self.maybe_get_block_expr(expr) {
// prefix should be empty here..
(self.tcx.adjust_span(expr.span).shrink_to_lo(), "*".to_string())
(self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), "*".to_string())
} else {
(prefix_span, format!("{}{}", prefix, "*".repeat(steps)))
};
Expand Down Expand Up @@ -1582,7 +1582,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if field.is_shorthand {
// This is a field literal
sugg.push((
self.tcx.adjust_span(field.ident.span).shrink_to_lo(),
self.tcx.mark_span_for_resize(field.ident.span).shrink_to_lo(),
format!("{}: ", field.ident),
));
} else {
Expand Down Expand Up @@ -1640,20 +1640,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);

let close_paren = if expr.precedence().order() < PREC_POSTFIX {
sugg.push((self.tcx.adjust_span(expr.span).shrink_to_lo(), "(".to_string()));
sugg.push((self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), "(".to_string()));
")"
} else {
""
};

let mut cast_suggestion = sugg.clone();
cast_suggestion.push((
self.tcx.adjust_span(expr.span).shrink_to_hi(),
self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(),
format!("{close_paren} as {expected_ty}"),
));
let mut into_suggestion = sugg.clone();
into_suggestion.push((
self.tcx.adjust_span(expr.span).shrink_to_hi(),
self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(),
format!("{close_paren}.into()"),
));
let mut suffix_suggestion = sugg.clone();
Expand Down Expand Up @@ -1710,17 +1710,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
let suggestion = vec![
(
self.tcx.adjust_span(lhs_expr.span).shrink_to_lo(),
self.tcx.mark_span_for_resize(lhs_expr.span).shrink_to_lo(),
format!("{checked_ty}::from("),
),
(self.tcx.adjust_span(lhs_expr.span).shrink_to_hi(), ")".to_string()),
(
self.tcx.mark_span_for_resize(lhs_expr.span).shrink_to_hi(),
")".to_string(),
),
];
(msg, suggestion)
} else {
let msg = format!("{msg} and panic if the converted value doesn't fit");
let mut suggestion = sugg.clone();
suggestion.push((
self.tcx.adjust_span(expr.span).shrink_to_hi(),
self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(),
format!("{close_paren}.try_into().unwrap()"),
));
(msg, suggestion)
Expand Down
Loading