Skip to content

Commit e2b0339

Browse files
committed
fix: Rename Origin::new to Origin::path
This is to align with `Snippet::source`
1 parent 6129319 commit e2b0339

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/renderer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ impl Renderer {
484484
}
485485

486486
if let Some(path) = &cause.path {
487-
let mut origin = Origin::new(path.as_ref());
487+
let mut origin = Origin::path(path.as_ref());
488488
origin.primary = true;
489489

490490
let source_map = SourceMap::new(&cause.source, cause.line_start);
@@ -719,7 +719,7 @@ impl Renderer {
719719
is_cont: bool,
720720
) {
721721
if let Some(path) = &snippet.path {
722-
let mut origin = Origin::new(path.as_ref());
722+
let mut origin = Origin::path(path.as_ref());
723723
// print out the span location and spacer before we print the annotated source
724724
// to do this, we need to know if this span will be primary
725725
let is_primary = primary_path == Some(&origin.path);

src/snippet.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ impl<'a> Patch<'a> {
411411
/// let input = &[
412412
/// Group::with_title(Level::ERROR.title("mismatched types").id("E0308"))
413413
/// .element(
414-
/// Origin::new("$DIR/mismatched-types.rs")
414+
/// Origin::path("$DIR/mismatched-types.rs")
415415
/// )
416416
/// ];
417417
/// ```
@@ -431,7 +431,7 @@ impl<'a> Origin<'a> {
431431
/// not allowed to be passed to this function.
432432
///
433433
/// </div>
434-
pub fn new(path: impl Into<Cow<'a, str>>) -> Self {
434+
pub fn path(path: impl Into<Cow<'a, str>>) -> Self {
435435
Self {
436436
path: path.into(),
437437
line: None,
@@ -467,7 +467,7 @@ impl<'a> Origin<'a> {
467467

468468
impl<'a> From<Cow<'a, str>> for Origin<'a> {
469469
fn from(origin: Cow<'a, str>) -> Self {
470-
Self::new(origin)
470+
Self::path(origin)
471471
}
472472
}
473473

tests/color/multiline_removal_suggestion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn main() {}
8888
),
8989
Group::with_title(Level::NOTE.title("required by a bound in `flatten`"))
9090
.element(
91-
Origin::new("/rustc/FAKE_PREFIX/library/core/src/iter/traits/iterator.rs")
91+
Origin::path("/rustc/FAKE_PREFIX/library/core/src/iter/traits/iterator.rs")
9292
.line(1556)
9393
.char_column(4),
9494
),

tests/rustc_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1743,7 +1743,7 @@ fn main() {
17431743
Level::NOTE
17441744
.title("for a trait to be dyn compatible it needs to allow building a vtable\nfor more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>"))
17451745
.element(
1746-
Origin::new("$SRC_DIR/core/src/cmp.rs")
1746+
Origin::path("$SRC_DIR/core/src/cmp.rs")
17471747
.line(334)
17481748
.char_column(14)
17491749
.primary(true)

0 commit comments

Comments
 (0)