Skip to content

Rollup of 8 pull requests #112801

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

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fe4aec1
Simplify `Span::source_callee` impl
WaffleLapkin Jun 16, 2023
c4c428b
Use BorrowFlag instead of explicit isize
Danvil Jun 18, 2023
09707ee
Same for BorrowRef
Danvil Jun 18, 2023
94f7a79
[doc] poll_fn: explain how to pin captured state safely
danielhenrymantilla Apr 5, 2023
8fa9003
Add translatable diagnostic for changing import binding
NotStirred Jun 18, 2023
50c971a
Add translatable diagnostic for invalid imports
NotStirred Jun 18, 2023
355a689
Add translatable diagnostic for cannot find in this scope
NotStirred Jun 18, 2023
4b5a5a4
Add translatable diagnostic for various strings in resolve::unresolve…
NotStirred Jun 18, 2023
c07b50a
Fix tidy
NotStirred Jun 18, 2023
493b18b
Continue folding in query normalizer on weak aliases
compiler-errors Jun 18, 2023
d43683f
Treat TAIT equation as always ambiguous in coherence
compiler-errors Jun 18, 2023
29c74d5
Don't ICE on bound var in reject_fn_ptr_impls
compiler-errors Jun 19, 2023
b374b20
Fix linker failures when #[global_allocator] is used in a dependency
bjorn3 Jun 19, 2023
db61375
Reformatting
NotStirred Jun 19, 2023
2027e98
Remove unreachable and untested suggestion for invalid span enum deri…
NotStirred Jun 19, 2023
78367a8
Rollup merge of #109970 - danielhenrymantilla:add-poll-fn-pin-clarifi…
matthiaskrgr Jun 19, 2023
70ff8c2
Rollup merge of #112705 - WaffleLapkin:simplify_source_callee_impl, r…
matthiaskrgr Jun 19, 2023
33beedb
Rollup merge of #112757 - Danvil:patch-1, r=Mark-Simulacrum
matthiaskrgr Jun 19, 2023
e6ccb11
Rollup merge of #112768 - NotStirred:translatable_diag/resolve1, r=Wa…
matthiaskrgr Jun 19, 2023
c8bc2a9
Rollup merge of #112777 - compiler-errors:normalize-weak-more, r=oli-obk
matthiaskrgr Jun 19, 2023
9c99aec
Rollup merge of #112780 - compiler-errors:tait-is-ambig, r=lcnr
matthiaskrgr Jun 19, 2023
249bd4b
Rollup merge of #112783 - compiler-errors:nlb-fnptr-reject-ice, r=fee…
matthiaskrgr Jun 19, 2023
1b7f451
Rollup merge of #112794 - bjorn3:fix_lib_global_alloc, r=oli-obk
matthiaskrgr Jun 19, 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
Next Next commit
Simplify Span::source_callee impl
  • Loading branch information
WaffleLapkin committed Jun 16, 2023
commit fe4aec1c4da0e92dbb727ebe5a2ee8951a6a45d9
17 changes: 10 additions & 7 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ use rustc_data_structures::sync::{Lock, Lrc};

use std::borrow::Cow;
use std::cmp::{self, Ordering};
use std::fmt;
use std::hash::Hash;
use std::ops::{Add, Range, Sub};
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::{fmt, iter};

use md5::Digest;
use md5::Md5;
Expand Down Expand Up @@ -733,12 +733,15 @@ impl Span {
/// else returns the `ExpnData` for the macro definition
/// corresponding to the source callsite.
pub fn source_callee(self) -> Option<ExpnData> {
fn source_callee(expn_data: ExpnData) -> ExpnData {
let next_expn_data = expn_data.call_site.ctxt().outer_expn_data();
if !next_expn_data.is_root() { source_callee(next_expn_data) } else { expn_data }
}
let expn_data = self.ctxt().outer_expn_data();
if !expn_data.is_root() { Some(source_callee(expn_data)) } else { None }

// Create an iterator of call site expansions
iter::successors(Some(expn_data), |expn_data| {
Some(expn_data.call_site.ctxt().outer_expn_data())
})
// Find the last expansion which is not root
.take_while(|expn_data| !expn_data.is_root())
.last()
}

/// Checks if a span is "internal" to a macro in which `#[unstable]`
Expand Down Expand Up @@ -777,7 +780,7 @@ impl Span {

pub fn macro_backtrace(mut self) -> impl Iterator<Item = ExpnData> {
let mut prev_span = DUMMY_SP;
std::iter::from_fn(move || {
iter::from_fn(move || {
loop {
let expn_data = self.ctxt().outer_expn_data();
if expn_data.is_root() {
Expand Down